VirtualBox

source: vbox/trunk/src/VBox/Devices/VMMDev/VMMDevState.h@ 81031

Last change on this file since 81031 was 81031, checked in by vboxsync, 5 years ago

PDM,Devices: Moving the PDMPCIDEV structures into the PDMDEVINS allocation. Preps for extending the config space to 4KB. bugref:9218

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.1 KB
Line 
1/* $Id: VMMDevState.h 81031 2019-09-26 19:26:33Z vboxsync $ */
2/** @file
3 * VMMDev - Guest <-> VMM/Host communication device, internal header.
4 */
5
6/*
7 * Copyright (C) 2006-2019 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef VBOX_INCLUDED_SRC_VMMDev_VMMDevState_h
19#define VBOX_INCLUDED_SRC_VMMDev_VMMDevState_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <VBoxVideo.h> /* For VBVA definitions. */
25#include <VBox/VMMDev.h>
26#include <VBox/vmm/pdmdev.h>
27#include <VBox/vmm/pdmifs.h>
28#ifndef VBOX_WITHOUT_TESTING_FEATURES
29# include <iprt/test.h>
30# include <VBox/VMMDevTesting.h>
31#endif
32
33#include <iprt/list.h>
34#include <iprt/memcache.h>
35
36
37#define VMMDEV_WITH_ALT_TIMESYNC
38
39/** Request locking structure (HGCM optimization). */
40typedef struct VMMDEVREQLOCK
41{
42 void *pvReq;
43 PGMPAGEMAPLOCK Lock;
44} VMMDEVREQLOCK;
45/** Pointer to a request lock structure. */
46typedef VMMDEVREQLOCK *PVMMDEVREQLOCK;
47
48typedef struct DISPLAYCHANGEREQUEST
49{
50 bool fPending;
51 bool afAlignment[3];
52 VMMDevDisplayDef displayChangeRequest;
53 VMMDevDisplayDef lastReadDisplayChangeRequest;
54} DISPLAYCHANGEREQUEST;
55
56typedef struct DISPLAYCHANGEDATA
57{
58 /* Which monitor is being reported to the guest. */
59 int32_t iCurrentMonitor;
60
61 /** true if the guest responded to VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST at least once */
62 bool fGuestSentChangeEventAck;
63 bool afAlignment[3];
64
65 DISPLAYCHANGEREQUEST aRequests[VBOX_VIDEO_MAX_SCREENS];
66} DISPLAYCHANGEDATA;
67
68
69/**
70 * Credentials for automatic guest logon and host configured logon (?).
71 *
72 * This is not stored in the same block as the instance data in order to make it
73 * harder to access.
74 */
75typedef struct VMMDEVCREDS
76{
77 /** credentials for guest logon purposes */
78 struct
79 {
80 char szUserName[VMMDEV_CREDENTIALS_SZ_SIZE];
81 char szPassword[VMMDEV_CREDENTIALS_SZ_SIZE];
82 char szDomain[VMMDEV_CREDENTIALS_SZ_SIZE];
83 bool fAllowInteractiveLogon;
84 } Logon;
85
86 /** credentials for verification by guest */
87 struct
88 {
89 char szUserName[VMMDEV_CREDENTIALS_SZ_SIZE];
90 char szPassword[VMMDEV_CREDENTIALS_SZ_SIZE];
91 char szDomain[VMMDEV_CREDENTIALS_SZ_SIZE];
92 } Judge;
93} VMMDEVCREDS;
94
95
96/**
97 * Facility status entry.
98 */
99typedef struct VMMDEVFACILITYSTATUSENTRY
100{
101 /** The facility (may contain values other than the defined ones). */
102 VBoxGuestFacilityType enmFacility;
103 /** The status (may contain values other than the defined ones). */
104 VBoxGuestFacilityStatus enmStatus;
105 /** Whether this entry is fixed and cannot be reused when inactive. */
106 bool fFixed;
107 /** Explicit alignment padding / reserved for future use. MBZ. */
108 bool afPadding[3];
109 /** The facility flags (yet to be defined). */
110 uint32_t fFlags;
111 /** Last update timestamp. */
112 RTTIMESPEC TimeSpecTS;
113} VMMDEVFACILITYSTATUSENTRY;
114/** Pointer to a facility status entry. */
115typedef VMMDEVFACILITYSTATUSENTRY *PVMMDEVFACILITYSTATUSENTRY;
116
117
118/**
119 * State structure for the VMM device.
120 */
121typedef struct VMMDevState
122{
123 /** The critical section for this device.
124 * @remarks We use this rather than the default one, it's simpler with all
125 * the driver interfaces where we have to waste time digging out the
126 * PDMDEVINS structure. */
127 PDMCRITSECT CritSect;
128
129 /** hypervisor address space size */
130 uint32_t hypervisorSize;
131
132 /** mouse capabilities of host and guest */
133 uint32_t mouseCapabilities;
134 /** absolute mouse position in pixels */
135 int32_t mouseXAbs;
136 int32_t mouseYAbs;
137 /** Does the guest currently want the host pointer to be shown? */
138 uint32_t fHostCursorRequested;
139
140#ifdef VBOX_WITH_RAW_MODE_KEEP
141 /** Pointer to device instance - RC pointer. */
142 PPDMDEVINSRC pDevInsRC;
143#else
144 uint32_t u32Alignment0;
145#endif
146 /** Pointer to device instance - R3 poitner. */
147 PPDMDEVINSR3 pDevInsR3;
148 /** Pointer to device instance - R0 pointer. */
149 PPDMDEVINSR0 pDevInsR0;
150
151 /** LUN\#0 + Status: VMMDev port base interface. */
152 PDMIBASE IBase;
153 /** LUN\#0: VMMDev port interface. */
154 PDMIVMMDEVPORT IPort;
155#ifdef VBOX_WITH_HGCM
156 /** LUN\#0: HGCM port interface. */
157 PDMIHGCMPORT IHGCMPort;
158//# if HC_ARCH_BITS == 32
159// RTR3PTR R3PtrAlignment1;
160//# endif
161#endif
162 /** Pointer to base interface of the driver. */
163 R3PTRTYPE(PPDMIBASE) pDrvBase;
164 /** VMMDev connector interface */
165 R3PTRTYPE(PPDMIVMMDEVCONNECTOR) pDrv;
166#ifdef VBOX_WITH_HGCM
167 /** HGCM connector interface */
168 R3PTRTYPE(PPDMIHGCMCONNECTOR) pHGCMDrv;
169#endif
170 /** message buffer for backdoor logging. */
171 char szMsg[512];
172 /** message buffer index. */
173 uint32_t iMsg;
174 /** Alignment padding. */
175 uint32_t u32Alignment2;
176
177 /** Statistics counter for slow IRQ ACK. */
178 STAMCOUNTER StatSlowIrqAck;
179 /** Statistics counter for fast IRQ ACK - R3. */
180 STAMCOUNTER StatFastIrqAckR3;
181 /** Statistics counter for fast IRQ ACK - R0 / RC. */
182 STAMCOUNTER StatFastIrqAckRZ;
183 /** IRQ number assigned to the device */
184 uint32_t irq;
185 /** Current host side event flags */
186 uint32_t u32HostEventFlags;
187 /** Mask of events guest is interested in.
188 * @note The HGCM events are enabled automatically by the VMMDev device when
189 * guest issues HGCM commands. */
190 uint32_t u32GuestFilterMask;
191 /** Delayed mask of guest events */
192 uint32_t u32NewGuestFilterMask;
193 /** Flag whether u32NewGuestFilterMask is valid */
194 bool fNewGuestFilterMask;
195 /** Alignment padding. */
196 bool afAlignment3[3];
197
198 /** GC physical address of VMMDev RAM area */
199 RTGCPHYS32 GCPhysVMMDevRAM;
200 /** R3 pointer to VMMDev RAM area */
201 R3PTRTYPE(VMMDevMemory *) pVMMDevRAMR3;
202 /** R0 pointer to VMMDev RAM area - first page only, could be NULL! */
203 R0PTRTYPE(VMMDevMemory *) pVMMDevRAMR0;
204#ifdef VBOX_WITH_RAW_MODE_KEEP
205 /** R0 pointer to VMMDev RAM area - first page only, could be NULL! */
206 RCPTRTYPE(VMMDevMemory *) pVMMDevRAMRC;
207 RTRCPTR RCPtrAlignment3b;
208#endif
209
210 /** R3 pointer to VMMDev Heap RAM area. */
211 R3PTRTYPE(VMMDevMemory *) pVMMDevHeapR3;
212 /** GC physical address of VMMDev Heap RAM area */
213 RTGCPHYS32 GCPhysVMMDevHeap;
214
215 /** Information reported by guest via VMMDevReportGuestInfo generic request.
216 * Until this information is reported the VMMDev refuses any other requests.
217 */
218 VBoxGuestInfo guestInfo;
219 /** Information report \#2, chewed a little. */
220 struct
221 {
222 uint32_t uFullVersion; /**< non-zero if info is present. */
223 uint32_t uRevision;
224 uint32_t fFeatures;
225 char szName[128];
226 } guestInfo2;
227
228 /** Array of guest facility statuses. */
229 VMMDEVFACILITYSTATUSENTRY aFacilityStatuses[32];
230 /** The number of valid entries in the facility status array. */
231 uint32_t cFacilityStatuses;
232
233 /** Information reported by guest via VMMDevReportGuestCapabilities. */
234 uint32_t guestCaps;
235
236 /** "Additions are Ok" indicator, set to true after processing VMMDevReportGuestInfo,
237 * if additions version is compatible. This flag is here to avoid repeated comparing
238 * of the version in guestInfo.
239 */
240 uint32_t fu32AdditionsOk;
241
242 /** Video acceleration status set by guest. */
243 uint32_t u32VideoAccelEnabled;
244
245 DISPLAYCHANGEDATA displayChangeData;
246
247 /** Pointer to the credentials. */
248 R3PTRTYPE(VMMDEVCREDS *) pCredentials;
249
250#if HC_ARCH_BITS == 32
251 uint32_t uAlignment4;
252#endif
253
254 /* memory balloon change request */
255 uint32_t cMbMemoryBalloon;
256 /** The last balloon size queried by the guest additions. */
257 uint32_t cMbMemoryBalloonLast;
258
259 /* guest ram size */
260 uint64_t cbGuestRAM;
261
262 /* unique session id; the id will be different after each start, reset or restore of the VM. */
263 uint64_t idSession;
264
265 /* statistics interval change request */
266 uint32_t u32StatIntervalSize, u32LastStatIntervalSize;
267
268 /* seamless mode change request */
269 bool fLastSeamlessEnabled, fSeamlessEnabled;
270 bool afAlignment5[1];
271
272 bool fVRDPEnabled;
273 uint32_t uVRDPExperienceLevel;
274
275#ifdef VMMDEV_WITH_ALT_TIMESYNC
276 uint64_t hostTime;
277 bool fTimesyncBackdoorLo;
278 bool afAlignment6[2];
279#else
280 bool afAlignment6[1+2];
281#endif
282 /** Set if GetHostTime should fail.
283 * Loaded from the GetHostTimeDisabled configuration value. */
284 bool fGetHostTimeDisabled;
285
286 /** Set if backdoor logging should be disabled (output will be ignored then) */
287 bool fBackdoorLogDisabled;
288
289 /** Don't clear credentials */
290 bool fKeepCredentials;
291
292 /** Heap enabled. */
293 bool fHeapEnabled;
294
295 /** Guest Core Dumping enabled. */
296 bool fGuestCoreDumpEnabled;
297
298 /** Guest Core Dump location. */
299 char szGuestCoreDumpDir[RTPATH_MAX];
300
301 /** Number of additional cores to keep around. */
302 uint32_t cGuestCoreDumps;
303
304#ifdef VBOX_WITH_HGCM
305 /** List of pending HGCM requests (VBOXHGCMCMD). */
306 RTLISTANCHORR3 listHGCMCmd;
307 /** Critical section to protect the list. */
308 RTCRITSECT critsectHGCMCmdList;
309 /** Whether the HGCM events are already automatically enabled. */
310 uint32_t u32HGCMEnabled;
311 /** Saved state version of restored commands. */
312 uint32_t u32SSMVersion;
313 RTMEMCACHE hHgcmCmdCache;
314 STAMPROFILE StatHgcmCmdArrival;
315 STAMPROFILE StatHgcmCmdCompletion;
316 STAMPROFILE StatHgcmCmdTotal;
317 STAMCOUNTER StatHgcmLargeCmdAllocs;
318 STAMCOUNTER StatHgcmFailedPageListLocking;
319#endif /* VBOX_WITH_HGCM */
320 STAMCOUNTER StatReqBufAllocs;
321
322 /** Per CPU request 4K sized buffers, allocated as needed. */
323 R3PTRTYPE(VMMDevRequestHeader *) apReqBufs[VMM_MAX_CPU_COUNT];
324
325 /** Status LUN: Shared folders LED */
326 struct
327 {
328 /** The LED. */
329 PDMLED Led;
330 /** The LED ports. */
331 PDMILEDPORTS ILeds;
332 /** Partner of ILeds. */
333 R3PTRTYPE(PPDMILEDCONNECTORS) pLedsConnector;
334 } SharedFolders;
335
336 /** FLag whether CPU hotplug events are monitored */
337 bool fCpuHotPlugEventsEnabled;
338 /** Alignment padding. */
339 bool afPadding8[3];
340 /** CPU hotplug event */
341 VMMDevCpuEventType enmCpuHotPlugEvent;
342 /** Core id of the CPU to change */
343 uint32_t idCpuCore;
344 /** Package id of the CPU to change */
345 uint32_t idCpuPackage;
346
347 uint32_t StatMemBalloonChunks;
348
349 /** Set if RC/R0 is enabled. */
350 bool fRZEnabled;
351 /** Set if testing is enabled. */
352 bool fTestingEnabled;
353 /** Set if testing the MMIO testing range is enabled. */
354 bool fTestingMMIO;
355 /** Alignment padding. */
356 bool afPadding9[HC_ARCH_BITS == 32 ? 1 : 5];
357#ifndef VBOX_WITHOUT_TESTING_FEATURES
358 /** The high timestamp value. */
359 uint32_t u32TestingHighTimestamp;
360 /** The current testing command (VMMDEV_TESTING_CMD_XXX). */
361 uint32_t u32TestingCmd;
362 /** The testing data offset (command specific). */
363 uint32_t offTestingData;
364 /** For buffering the what comes in over the testing data port. */
365 union
366 {
367 char padding[1024];
368
369 /** VMMDEV_TESTING_CMD_INIT, VMMDEV_TESTING_CMD_SUB_NEW,
370 * VMMDEV_TESTING_CMD_FAILED. */
371 struct
372 {
373 char sz[1024];
374 } String, Init, SubNew, Failed;
375
376 /** VMMDEV_TESTING_CMD_TERM, VMMDEV_TESTING_CMD_SUB_DONE. */
377 struct
378 {
379 uint32_t c;
380 } Error, Term, SubDone;
381
382 /** VMMDEV_TESTING_CMD_VALUE. */
383 struct
384 {
385 RTUINT64U u64Value;
386 uint32_t u32Unit;
387 char szName[1024 - 8 - 4];
388 } Value;
389
390 /** The read back register (VMMDEV_TESTING_MMIO_OFF_READBACK,
391 * VMMDEV_TESTING_MMIO_OFF_READBACK_R3). */
392 uint8_t abReadBack[VMMDEV_TESTING_READBACK_SIZE];
393 } TestingData;
394 /** The XML output file name (can be a named pipe, doesn't matter to us). */
395 R3PTRTYPE(char *) pszTestingXmlOutput;
396 /** Testing instance for dealing with the output. */
397 RTTEST hTestingTest;
398#endif /* !VBOX_WITHOUT_TESTING_FEATURES */
399
400 /** @name Heartbeat
401 * @{ */
402 /** Timestamp of the last heartbeat from guest in nanosec. */
403 uint64_t volatile nsLastHeartbeatTS;
404 /** Indicates whether we missed HB from guest on last check. */
405 bool volatile fFlatlined;
406 /** Indicates whether heartbeat check is active. */
407 bool volatile fHeartbeatActive;
408 /** Alignment padding. */
409 bool afAlignment8[6];
410 /** Guest heartbeat interval in nanoseconds.
411 * This is the interval the guest is told to produce heartbeats at. */
412 uint64_t cNsHeartbeatInterval;
413 /** The amount of time without a heartbeat (nanoseconds) before we
414 * conclude the guest is doing a Dixie Flatline (Neuromancer) impression. */
415 uint64_t cNsHeartbeatTimeout;
416 /** Timer for signalling a flatlined guest. */
417 PTMTIMERR3 pFlatlinedTimer;
418 /** @} */
419} VMMDevState;
420typedef VMMDevState VMMDEV;
421/** Pointer to the VMM device state. */
422typedef VMMDEV *PVMMDEV;
423AssertCompileMemberAlignment(VMMDEV, CritSect, 8);
424AssertCompileMemberAlignment(VMMDEV, StatSlowIrqAck, 8);
425AssertCompileMemberAlignment(VMMDEV, cbGuestRAM, 8);
426AssertCompileMemberAlignment(VMMDEV, enmCpuHotPlugEvent, 4);
427AssertCompileMemberAlignment(VMMDEV, aFacilityStatuses, 8);
428#ifndef VBOX_WITHOUT_TESTING_FEATURES
429AssertCompileMemberAlignment(VMMDEV, TestingData.Value.u64Value, 8);
430#endif
431
432
433void VMMDevNotifyGuest(VMMDEV *pVMMDevState, uint32_t u32EventMask);
434void VMMDevCtlSetGuestFilterMask(VMMDEV *pVMMDevState, uint32_t u32OrMask, uint32_t u32NotMask);
435
436
437/** The saved state version. */
438#define VMMDEV_SAVED_STATE_VERSION VMMDEV_SAVED_STATE_VERSION_HGCM_PARAMS
439/** Updated HGCM commands. */
440#define VMMDEV_SAVED_STATE_VERSION_HGCM_PARAMS 17
441/** The saved state version with heartbeat state. */
442#define VMMDEV_SAVED_STATE_VERSION_HEARTBEAT 16
443/** The saved state version without heartbeat state. */
444#define VMMDEV_SAVED_STATE_VERSION_NO_HEARTBEAT 15
445/** The saved state version which is missing the guest facility statuses. */
446#define VMMDEV_SAVED_STATE_VERSION_MISSING_FACILITY_STATUSES 14
447/** The saved state version which is missing the guestInfo2 bits. */
448#define VMMDEV_SAVED_STATE_VERSION_MISSING_GUEST_INFO_2 13
449/** The saved state version used by VirtualBox 3.0.
450 * This doesn't have the config part. */
451#define VMMDEV_SAVED_STATE_VERSION_VBOX_30 11
452
453#endif /* !VBOX_INCLUDED_SRC_VMMDev_VMMDevState_h */
454
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette