1 | /* $Id: VMMDevState.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VMMDev - Guest <-> VMM/Host communication device, internal header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2024 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef VBOX_INCLUDED_SRC_VMMDev_VMMDevState_h
|
---|
29 | #define VBOX_INCLUDED_SRC_VMMDev_VMMDevState_h
|
---|
30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
31 | # pragma once
|
---|
32 | #endif
|
---|
33 |
|
---|
34 | #include <VBoxVideo.h> /* For VBVA definitions. */
|
---|
35 | #include <VBox/VMMDev.h>
|
---|
36 | #include <VBox/vmm/pdmdev.h>
|
---|
37 | #include <VBox/vmm/pdmifs.h>
|
---|
38 | #ifndef VBOX_WITHOUT_TESTING_FEATURES
|
---|
39 | # include <VBox/vmm/pdmthread.h>
|
---|
40 | # include <iprt/test.h>
|
---|
41 | # include <VBox/VMMDevTesting.h>
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | #include <iprt/list.h>
|
---|
45 | #include <iprt/memcache.h>
|
---|
46 |
|
---|
47 |
|
---|
48 | #define VMMDEV_WITH_ALT_TIMESYNC
|
---|
49 |
|
---|
50 | /** Request locking structure (HGCM optimization). */
|
---|
51 | typedef struct VMMDEVREQLOCK
|
---|
52 | {
|
---|
53 | void *pvReq;
|
---|
54 | PGMPAGEMAPLOCK Lock;
|
---|
55 | } VMMDEVREQLOCK;
|
---|
56 | /** Pointer to a request lock structure. */
|
---|
57 | typedef VMMDEVREQLOCK *PVMMDEVREQLOCK;
|
---|
58 |
|
---|
59 | typedef struct DISPLAYCHANGEREQUEST
|
---|
60 | {
|
---|
61 | bool fPending;
|
---|
62 | bool afAlignment[3];
|
---|
63 | VMMDevDisplayDef displayChangeRequest;
|
---|
64 | VMMDevDisplayDef lastReadDisplayChangeRequest;
|
---|
65 | } DISPLAYCHANGEREQUEST;
|
---|
66 |
|
---|
67 | typedef struct DISPLAYCHANGEDATA
|
---|
68 | {
|
---|
69 | /* Which monitor is being reported to the guest. */
|
---|
70 | int32_t iCurrentMonitor;
|
---|
71 |
|
---|
72 | /** true if the guest responded to VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST at least once */
|
---|
73 | bool fGuestSentChangeEventAck;
|
---|
74 | bool afAlignment[3];
|
---|
75 |
|
---|
76 | DISPLAYCHANGEREQUEST aRequests[VBOX_VIDEO_MAX_SCREENS];
|
---|
77 | } DISPLAYCHANGEDATA;
|
---|
78 |
|
---|
79 |
|
---|
80 | /**
|
---|
81 | * Credentials for automatic guest logon and host configured logon (?).
|
---|
82 | *
|
---|
83 | * This is not stored in the same block as the instance data in order to make it
|
---|
84 | * harder to access.
|
---|
85 | */
|
---|
86 | typedef struct VMMDEVCREDS
|
---|
87 | {
|
---|
88 | /** credentials for guest logon purposes */
|
---|
89 | struct
|
---|
90 | {
|
---|
91 | char szUserName[VMMDEV_CREDENTIALS_SZ_SIZE];
|
---|
92 | char szPassword[VMMDEV_CREDENTIALS_SZ_SIZE];
|
---|
93 | char szDomain[VMMDEV_CREDENTIALS_SZ_SIZE];
|
---|
94 | bool fAllowInteractiveLogon;
|
---|
95 | } Logon;
|
---|
96 |
|
---|
97 | /** credentials for verification by guest */
|
---|
98 | struct
|
---|
99 | {
|
---|
100 | char szUserName[VMMDEV_CREDENTIALS_SZ_SIZE];
|
---|
101 | char szPassword[VMMDEV_CREDENTIALS_SZ_SIZE];
|
---|
102 | char szDomain[VMMDEV_CREDENTIALS_SZ_SIZE];
|
---|
103 | } Judge;
|
---|
104 | } VMMDEVCREDS;
|
---|
105 |
|
---|
106 |
|
---|
107 | /**
|
---|
108 | * Facility status entry.
|
---|
109 | */
|
---|
110 | typedef struct VMMDEVFACILITYSTATUSENTRY
|
---|
111 | {
|
---|
112 | /** The facility (may contain values other than the defined ones). */
|
---|
113 | VBoxGuestFacilityType enmFacility;
|
---|
114 | /** The status (may contain values other than the defined ones). */
|
---|
115 | VBoxGuestFacilityStatus enmStatus;
|
---|
116 | /** Whether this entry is fixed and cannot be reused when inactive. */
|
---|
117 | bool fFixed;
|
---|
118 | /** Explicit alignment padding / reserved for future use. MBZ. */
|
---|
119 | bool afPadding[3];
|
---|
120 | /** The facility flags (yet to be defined). */
|
---|
121 | uint32_t fFlags;
|
---|
122 | /** Last update timestamp. */
|
---|
123 | RTTIMESPEC TimeSpecTS;
|
---|
124 | } VMMDEVFACILITYSTATUSENTRY;
|
---|
125 | /** Pointer to a facility status entry. */
|
---|
126 | typedef VMMDEVFACILITYSTATUSENTRY *PVMMDEVFACILITYSTATUSENTRY;
|
---|
127 |
|
---|
128 |
|
---|
129 | /**
|
---|
130 | * State structure for the VMM device.
|
---|
131 | */
|
---|
132 | typedef struct VMMDEV
|
---|
133 | {
|
---|
134 | /** The critical section for this device.
|
---|
135 | * @remarks We use this rather than the default one, it's simpler with all
|
---|
136 | * the driver interfaces where we have to waste time digging out the
|
---|
137 | * PDMDEVINS structure. */
|
---|
138 | PDMCRITSECT CritSect;
|
---|
139 | #if !defined(VBOX_WITHOUT_TESTING_FEATURES) || defined(DOXYGEN_RUNNING)
|
---|
140 | /** Read write critical section of lock testing.
|
---|
141 | * @remarks At the beginning to satisfy 64 byte alignment requirement. */
|
---|
142 | PDMCRITSECTRW CritSectRw;
|
---|
143 | #endif
|
---|
144 |
|
---|
145 | /** mouse capabilities of host and guest */
|
---|
146 | uint32_t fMouseCapabilities;
|
---|
147 | /** @name Absolute mouse position in pixels, relative wheel movement and buttons state.
|
---|
148 | * @{ */
|
---|
149 | int32_t xMouseAbs;
|
---|
150 | int32_t yMouseAbs;
|
---|
151 | int32_t dzMouse;
|
---|
152 | int32_t dwMouse;
|
---|
153 | uint32_t fMouseButtons;
|
---|
154 | /** @} */
|
---|
155 | /** Does the guest currently want the host pointer to be shown? */
|
---|
156 | uint32_t fHostCursorRequested;
|
---|
157 |
|
---|
158 | /** message buffer for backdoor logging. */
|
---|
159 | char szMsg[512];
|
---|
160 | /** message buffer index. */
|
---|
161 | uint32_t offMsg;
|
---|
162 | /** Alignment padding. */
|
---|
163 | uint32_t u32Alignment2;
|
---|
164 |
|
---|
165 | /** Statistics counter for slow IRQ ACK. */
|
---|
166 | STAMCOUNTER StatSlowIrqAck;
|
---|
167 | /** Statistics counter for fast IRQ ACK - R3. */
|
---|
168 | STAMCOUNTER StatFastIrqAckR3;
|
---|
169 | /** Statistics counter for fast IRQ ACK - R0 / RC. */
|
---|
170 | STAMCOUNTER StatFastIrqAckRZ;
|
---|
171 | /** Current host side event flags - VMMDEV_EVENT_XXX. */
|
---|
172 | uint32_t fHostEventFlags;
|
---|
173 | /** Mask of events guest is interested in - VMMDEV_EVENT_XXX.
|
---|
174 | * @note The HGCM events are enabled automatically by the VMMDev device when
|
---|
175 | * guest issues HGCM commands. */
|
---|
176 | uint32_t fGuestFilterMask;
|
---|
177 | /** Delayed mask of guest events - VMMDEV_EVENT_XXX. */
|
---|
178 | uint32_t fNewGuestFilterMask;
|
---|
179 | /** Flag whether fNewGuestFilterMask is valid */
|
---|
180 | bool fNewGuestFilterMaskValid;
|
---|
181 | /** Alignment padding. */
|
---|
182 | bool afAlignment3[3];
|
---|
183 |
|
---|
184 | /** Information reported by guest via VMMDevReportGuestInfo generic request.
|
---|
185 | * Until this information is reported the VMMDev refuses any other requests.
|
---|
186 | */
|
---|
187 | VBoxGuestInfo guestInfo;
|
---|
188 | /** Information report \#2, chewed a little. */
|
---|
189 | struct
|
---|
190 | {
|
---|
191 | uint32_t uFullVersion; /**< non-zero if info is present. */
|
---|
192 | uint32_t uRevision;
|
---|
193 | uint32_t fFeatures;
|
---|
194 | char szName[128];
|
---|
195 | } guestInfo2;
|
---|
196 |
|
---|
197 | /** Array of guest facility statuses. */
|
---|
198 | VMMDEVFACILITYSTATUSENTRY aFacilityStatuses[32];
|
---|
199 | /** The number of valid entries in the facility status array. */
|
---|
200 | uint32_t cFacilityStatuses;
|
---|
201 |
|
---|
202 | /** Information reported by guest via VMMDevReportGuestCapabilities - VMMDEV_GUEST_SUPPORTS_XXX. */
|
---|
203 | uint32_t fGuestCaps;
|
---|
204 |
|
---|
205 | /** "Additions are Ok" indicator, set to true after processing VMMDevReportGuestInfo,
|
---|
206 | * if additions version is compatible. This flag is here to avoid repeated comparing
|
---|
207 | * of the version in guestInfo.
|
---|
208 | */
|
---|
209 | uint32_t fu32AdditionsOk;
|
---|
210 |
|
---|
211 | /** Video acceleration status set by guest. */
|
---|
212 | uint32_t u32VideoAccelEnabled;
|
---|
213 |
|
---|
214 | DISPLAYCHANGEDATA displayChangeData;
|
---|
215 |
|
---|
216 | /** memory balloon change request */
|
---|
217 | uint32_t cMbMemoryBalloon;
|
---|
218 | /** The last balloon size queried by the guest additions. */
|
---|
219 | uint32_t cMbMemoryBalloonLast;
|
---|
220 |
|
---|
221 | /** guest ram size */
|
---|
222 | uint64_t cbGuestRAM;
|
---|
223 |
|
---|
224 | /** unique session id; the id will be different after each start, reset or restore of the VM. */
|
---|
225 | uint64_t idSession;
|
---|
226 |
|
---|
227 | /** Statistics interval in seconds. */
|
---|
228 | uint32_t cSecsStatInterval;
|
---|
229 | /** The statistics interval last returned to the guest. */
|
---|
230 | uint32_t cSecsLastStatInterval;
|
---|
231 |
|
---|
232 | /** Whether seamless is enabled or not. */
|
---|
233 | bool fSeamlessEnabled;
|
---|
234 | /** The last fSeamlessEnabled state returned to the guest. */
|
---|
235 | bool fLastSeamlessEnabled;
|
---|
236 | bool afAlignment5[1];
|
---|
237 |
|
---|
238 | bool fVRDPEnabled;
|
---|
239 | uint32_t uVRDPExperienceLevel;
|
---|
240 |
|
---|
241 | #ifdef VMMDEV_WITH_ALT_TIMESYNC
|
---|
242 | uint64_t msLatchedHostTime;
|
---|
243 | bool fTimesyncBackdoorLo;
|
---|
244 | bool afAlignment6[1];
|
---|
245 | #else
|
---|
246 | bool afAlignment6[2];
|
---|
247 | #endif
|
---|
248 |
|
---|
249 | /** Set if guest should be allowed to trigger state save and power off. */
|
---|
250 | bool fAllowGuestToSaveState;
|
---|
251 | /** Set if GetHostTime should fail.
|
---|
252 | * Loaded from the GetHostTimeDisabled configuration value. */
|
---|
253 | bool fGetHostTimeDisabled;
|
---|
254 | /** Set if backdoor logging should be disabled (output will be ignored then) */
|
---|
255 | bool fBackdoorLogDisabled;
|
---|
256 | /** Don't clear credentials */
|
---|
257 | bool fKeepCredentials;
|
---|
258 | /** Heap enabled. */
|
---|
259 | bool fHeapEnabled;
|
---|
260 |
|
---|
261 | /** Guest Core Dumping enabled. */
|
---|
262 | bool fGuestCoreDumpEnabled;
|
---|
263 | /** Guest Core Dump location. */
|
---|
264 | char szGuestCoreDumpDir[RTPATH_MAX];
|
---|
265 | /** Number of additional cores to keep around. */
|
---|
266 | uint32_t cGuestCoreDumps;
|
---|
267 |
|
---|
268 | /** FLag whether CPU hotplug events are monitored */
|
---|
269 | bool fCpuHotPlugEventsEnabled;
|
---|
270 | /** Flag whether the VMM device is offering the request ports
|
---|
271 | * over MMIO as well (mainly for ARM at the moment). */
|
---|
272 | bool fMmioReq;
|
---|
273 | /** Alignment padding. */
|
---|
274 | bool afPadding8[2];
|
---|
275 | /** CPU hotplug event */
|
---|
276 | VMMDevCpuEventType enmCpuHotPlugEvent;
|
---|
277 | /** Core id of the CPU to change */
|
---|
278 | uint32_t idCpuCore;
|
---|
279 | /** Package id of the CPU to change */
|
---|
280 | uint32_t idCpuPackage;
|
---|
281 |
|
---|
282 | uint32_t StatMemBalloonChunks;
|
---|
283 |
|
---|
284 | /** @name Heartbeat
|
---|
285 | * @{ */
|
---|
286 | /** Timestamp of the last heartbeat from guest in nanosec. */
|
---|
287 | uint64_t volatile nsLastHeartbeatTS;
|
---|
288 | /** Indicates whether we missed HB from guest on last check. */
|
---|
289 | bool volatile fFlatlined;
|
---|
290 | /** Indicates whether heartbeat check is active. */
|
---|
291 | bool volatile fHeartbeatActive;
|
---|
292 | /** Alignment padding. */
|
---|
293 | bool afAlignment8[6];
|
---|
294 | /** Guest heartbeat interval in nanoseconds.
|
---|
295 | * This is the interval the guest is told to produce heartbeats at. */
|
---|
296 | uint64_t cNsHeartbeatInterval;
|
---|
297 | /** The amount of time without a heartbeat (nanoseconds) before we
|
---|
298 | * conclude the guest is doing a Dixie Flatline (Neuromancer) impression. */
|
---|
299 | uint64_t cNsHeartbeatTimeout;
|
---|
300 | /** Timer for signalling a flatlined guest. */
|
---|
301 | TMTIMERHANDLE hFlatlinedTimer;
|
---|
302 | /** @} */
|
---|
303 |
|
---|
304 | /** @name Testing
|
---|
305 | * @{ */
|
---|
306 | /** Set if testing is enabled. */
|
---|
307 | bool fTestingEnabled;
|
---|
308 | /** Set if testing the MMIO testing range is enabled. */
|
---|
309 | bool fTestingMMIO;
|
---|
310 | #if defined(VBOX_WITHOUT_TESTING_FEATURES) && !defined(DOXYGEN_RUNNING)
|
---|
311 | /** Alignment padding. */
|
---|
312 | bool afPadding9[2];
|
---|
313 | #else
|
---|
314 | /** The amount of readable testing data (for query response). */
|
---|
315 | uint16_t cbReadableTestingData;
|
---|
316 | /** The high timestamp value. */
|
---|
317 | uint32_t u32TestingHighTimestamp;
|
---|
318 | /** The current testing command (VMMDEV_TESTING_CMD_XXX). */
|
---|
319 | uint32_t u32TestingCmd;
|
---|
320 | /** The testing data offset (command specific). */
|
---|
321 | uint32_t offTestingData;
|
---|
322 | /** For buffering the what comes in over the testing data port. */
|
---|
323 | union
|
---|
324 | {
|
---|
325 | /** Plain byte view. */
|
---|
326 | uint8_t ab[1024];
|
---|
327 |
|
---|
328 | /** VMMDEV_TESTING_CMD_INIT, VMMDEV_TESTING_CMD_SUB_NEW,
|
---|
329 | * VMMDEV_TESTING_CMD_FAILED. */
|
---|
330 | struct
|
---|
331 | {
|
---|
332 | char sz[1024];
|
---|
333 | } String, Init, SubNew, Failed;
|
---|
334 |
|
---|
335 | /** VMMDEV_TESTING_CMD_TERM, VMMDEV_TESTING_CMD_SUB_DONE. */
|
---|
336 | struct
|
---|
337 | {
|
---|
338 | uint32_t c;
|
---|
339 | } Error, Term, SubDone;
|
---|
340 |
|
---|
341 | /** VMMDEV_TESTING_CMD_VALUE. */
|
---|
342 | struct
|
---|
343 | {
|
---|
344 | RTUINT64U u64Value;
|
---|
345 | uint32_t u32Unit;
|
---|
346 | char szName[1024 - 8 - 4];
|
---|
347 | } Value;
|
---|
348 |
|
---|
349 | /** A 8-bit VMMDEV_TESTING_QUERY_CFG response. */
|
---|
350 | uint8_t b;
|
---|
351 | /** A 16-bit VMMDEV_TESTING_QUERY_CFG response. */
|
---|
352 | uint16_t u16;
|
---|
353 | /** A 32-bit VMMDEV_TESTING_QUERY_CFG response. */
|
---|
354 | uint32_t u32;
|
---|
355 |
|
---|
356 | /** The read back register (VMMDEV_TESTING_MMIO_OFF_READBACK,
|
---|
357 | * VMMDEV_TESTING_MMIO_OFF_READBACK_R3). */
|
---|
358 | uint8_t abReadBack[VMMDEV_TESTING_READBACK_SIZE];
|
---|
359 | } TestingData;
|
---|
360 | /** The locking testing control dword. */
|
---|
361 | union
|
---|
362 | {
|
---|
363 | /** Plain view. */
|
---|
364 | uint64_t u64;
|
---|
365 | /** Plain 32-bit view. */
|
---|
366 | uint32_t au32[2];
|
---|
367 | struct
|
---|
368 | {
|
---|
369 | /** bits 15:0: Number of microseconds to hold the lock. */
|
---|
370 | uint32_t cUsHold : 16;
|
---|
371 | /** bits 31:16: Number of microseconds to wait before retaking the lock again. */
|
---|
372 | uint32_t cUsBetween : 16;
|
---|
373 | /** bits 51:32: Kilo (1024) ticks the EMT should hold the lock for. */
|
---|
374 | uint32_t cKiloTicksEmtHold : 20;
|
---|
375 | /** bits 57:52: Reserved MBZ. */
|
---|
376 | uint32_t uReserved : 6;
|
---|
377 | /** bit 58: Thread takes lock in shared mode when set, exclusive when clear. */
|
---|
378 | uint32_t fThreadShared : 1;
|
---|
379 | /** bit 59: EMT takes lock in shared mode when set, exclusive when clear. */
|
---|
380 | uint32_t fEmtShared : 1;
|
---|
381 | /** bit 60: Use read/write critical section instead of regular. */
|
---|
382 | uint32_t fReadWriteSection : 1;
|
---|
383 | /** bit 61: EMT passes VINF_SUCCESS as rcBusy if set. */
|
---|
384 | uint32_t fMustSucceed : 1;
|
---|
385 | /** bit 62: Thread pokes EMTs before releasing it when set. */
|
---|
386 | uint32_t fPokeBeforeRelease : 1;
|
---|
387 | /** bit 63: Enabled/disabled. */
|
---|
388 | uint32_t fEnabled : 1;
|
---|
389 | } s;
|
---|
390 | } TestingLockControl;
|
---|
391 | /** Event semaphore that the locking thread blocks. */
|
---|
392 | SUPSEMEVENT hTestingLockEvt;
|
---|
393 | # if HC_ARCH_BITS == 32
|
---|
394 | uint32_t uPadding10;
|
---|
395 | # endif
|
---|
396 | /** Handle for the I/O ports used by the testing component. */
|
---|
397 | IOMIOPORTHANDLE hIoPortTesting;
|
---|
398 | /** Handle for the MMIO region used by the testing component. */
|
---|
399 | IOMMMIOHANDLE hMmioTesting;
|
---|
400 | /** User defined configuration dwords. */
|
---|
401 | uint32_t au32TestingCfgDwords[10];
|
---|
402 | /** VMMDEV_TESTING_CFG_THRESHOLD_NATIVE_RECOMPILER value. */
|
---|
403 | uint16_t cTestingThresholdNativeRecompiler;
|
---|
404 | uint16_t au16Padding[3];
|
---|
405 | #endif /* !VBOX_WITHOUT_TESTING_FEATURES || DOXYGEN_RUNNING */
|
---|
406 | /** @} */
|
---|
407 |
|
---|
408 | /** Handle for the backdoor logging I/O port. */
|
---|
409 | IOMIOPORTHANDLE hIoPortBackdoorLog;
|
---|
410 | /** Handle for the alternative timesync I/O port. */
|
---|
411 | IOMIOPORTHANDLE hIoPortAltTimesync;
|
---|
412 | /** Handle for the VMM request I/O port (PCI region \#0). */
|
---|
413 | IOMIOPORTHANDLE hIoPortReq;
|
---|
414 | /** Handle for the fast VMM request I/O port (PCI region \#0). */
|
---|
415 | IOMIOPORTHANDLE hIoPortFast;
|
---|
416 | /** Handle for the VMM request MMIO region (PCI region \#3). */
|
---|
417 | IOMMMIOHANDLE hMmioReq;
|
---|
418 | /** Handle for the VMMDev RAM (PCI region \#1). */
|
---|
419 | PGMMMIO2HANDLE hMmio2VMMDevRAM;
|
---|
420 | /** Handle for the VMMDev Heap (PCI region \#2). */
|
---|
421 | PGMMMIO2HANDLE hMmio2Heap;
|
---|
422 | } VMMDEV;
|
---|
423 | /** Pointer to the shared VMM device state. */
|
---|
424 | typedef VMMDEV *PVMMDEV;
|
---|
425 | AssertCompileMemberAlignment(VMMDEV, CritSect, 8);
|
---|
426 | AssertCompileMemberAlignment(VMMDEV, StatSlowIrqAck, 8);
|
---|
427 | AssertCompileMemberAlignment(VMMDEV, cbGuestRAM, 8);
|
---|
428 | AssertCompileMemberAlignment(VMMDEV, enmCpuHotPlugEvent, 4);
|
---|
429 | AssertCompileMemberAlignment(VMMDEV, aFacilityStatuses, 8);
|
---|
430 | #ifndef VBOX_WITHOUT_TESTING_FEATURES
|
---|
431 | AssertCompileMemberAlignment(VMMDEV, TestingData.Value.u64Value, 8);
|
---|
432 | AssertCompileMemberAlignment(VMMDEV, CritSectRw, 64);
|
---|
433 | #endif
|
---|
434 |
|
---|
435 |
|
---|
436 | /** @name VMMDev/HGCM accounting categories (indexes into VMMDEVR3::aHgcmAcc)
|
---|
437 | * @{ */
|
---|
438 | /** Legacy, VMMDEV_REQUESTOR_USR_NOT_GIVEN, VMMDEV_REQUESTOR_USR_DRV,
|
---|
439 | * VMMDEV_REQUESTOR_USR_DRV_OTHER. */
|
---|
440 | #define VMMDEV_HGCM_CATEGORY_KERNEL 0
|
---|
441 | /** VMMDEV_REQUESTOR_USR_ROOT, VMMDEV_REQUESTOR_USR_SYSTEM */
|
---|
442 | #define VMMDEV_HGCM_CATEGORY_ROOT 1
|
---|
443 | /** VMMDEV_REQUESTOR_USR_RESERVED1, VMMDEV_REQUESTOR_USR_USER,
|
---|
444 | * VMMDEV_REQUESTOR_USR_GUEST */
|
---|
445 | #define VMMDEV_HGCM_CATEGORY_USER 2
|
---|
446 | /** Array size. */
|
---|
447 | #define VMMDEV_HGCM_CATEGORY_MAX 3
|
---|
448 | /** @} */
|
---|
449 |
|
---|
450 | /**
|
---|
451 | * State structure for the VMM device, ring-3 edition.
|
---|
452 | */
|
---|
453 | typedef struct VMMDEVR3
|
---|
454 | {
|
---|
455 | /** LUN\#0 + Status: VMMDev port base interface. */
|
---|
456 | PDMIBASE IBase;
|
---|
457 | /** LUN\#0: VMMDev port interface. */
|
---|
458 | PDMIVMMDEVPORT IPort;
|
---|
459 | #ifdef VBOX_WITH_HGCM
|
---|
460 | /** LUN\#0: HGCM port interface. */
|
---|
461 | PDMIHGCMPORT IHGCMPort;
|
---|
462 | /** HGCM connector interface */
|
---|
463 | R3PTRTYPE(PPDMIHGCMCONNECTOR) pHGCMDrv;
|
---|
464 | #endif
|
---|
465 | /** Pointer to base interface of the driver. */
|
---|
466 | R3PTRTYPE(PPDMIBASE) pDrvBase;
|
---|
467 | /** VMMDev connector interface */
|
---|
468 | R3PTRTYPE(PPDMIVMMDEVCONNECTOR) pDrv;
|
---|
469 | /** Pointer to the device instance.
|
---|
470 | * @note Only for interface methods to get their bearings. */
|
---|
471 | PPDMDEVINSR3 pDevIns;
|
---|
472 |
|
---|
473 | /** R3 pointer to VMMDev RAM area */
|
---|
474 | R3PTRTYPE(VMMDevMemory *) pVMMDevRAMR3;
|
---|
475 |
|
---|
476 | /** R3 pointer to VMMDev Heap RAM area. */
|
---|
477 | R3PTRTYPE(VMMDevMemory *) pVMMDevHeapR3;
|
---|
478 |
|
---|
479 | /** Pointer to the credentials. */
|
---|
480 | R3PTRTYPE(VMMDEVCREDS *) pCredentials;
|
---|
481 | /** Set if pCredentials is using the RTMemSafer allocator, clear if heap. */
|
---|
482 | bool fSaferCredentials;
|
---|
483 | bool afAlignment[7];
|
---|
484 |
|
---|
485 | #ifdef VBOX_WITH_HGCM
|
---|
486 | /** Critical section to protect the list. */
|
---|
487 | RTCRITSECT critsectHGCMCmdList;
|
---|
488 | /** List of pending HGCM requests (VBOXHGCMCMD). */
|
---|
489 | RTLISTANCHORR3 listHGCMCmd;
|
---|
490 | /** Whether the HGCM events are already automatically enabled. */
|
---|
491 | uint32_t u32HGCMEnabled;
|
---|
492 | /** Saved state version of restored commands. */
|
---|
493 | uint32_t uSavedStateVersion;
|
---|
494 | RTMEMCACHE hHgcmCmdCache;
|
---|
495 | /** Accounting by for each requestor VMMDEV_REQUESTOR_USR_XXX group.
|
---|
496 | * Legacy requests ends up with VMMDEV_REQUESTOR_USR_NOT_GIVEN */
|
---|
497 | struct
|
---|
498 | {
|
---|
499 | /** The configured heap budget. */
|
---|
500 | uint64_t cbHeapBudgetConfig;
|
---|
501 | /** The currently available heap budget. */
|
---|
502 | uint64_t cbHeapBudget;
|
---|
503 | /** Message stats. */
|
---|
504 | STAMPROFILE StateMsgHeapUsage;
|
---|
505 | /** Budget overruns. */
|
---|
506 | STAMCOUNTER StatBudgetOverruns;
|
---|
507 | } aHgcmAcc[VMMDEV_HGCM_CATEGORY_MAX];
|
---|
508 | STAMPROFILE StatHgcmCmdArrival;
|
---|
509 | STAMPROFILE StatHgcmCmdCompletion;
|
---|
510 | STAMPROFILE StatHgcmCmdTotal;
|
---|
511 | STAMCOUNTER StatHgcmLargeCmdAllocs;
|
---|
512 | STAMCOUNTER StatHgcmFailedPageListLocking;
|
---|
513 | #endif /* VBOX_WITH_HGCM */
|
---|
514 | STAMCOUNTER StatReqBufAllocs;
|
---|
515 | /** Per CPU request 4K sized buffers, allocated as needed. */
|
---|
516 | R3PTRTYPE(VMMDevRequestHeader *) apReqBufs[VMM_MAX_CPU_COUNT];
|
---|
517 |
|
---|
518 | /** Status LUN: Shared folders LED */
|
---|
519 | struct
|
---|
520 | {
|
---|
521 | /** The LED. */
|
---|
522 | PDMLED Led;
|
---|
523 | /** The LED ports. */
|
---|
524 | PDMILEDPORTS ILeds;
|
---|
525 | /** Partner of ILeds. */
|
---|
526 | R3PTRTYPE(PPDMILEDCONNECTORS) pLedsConnector;
|
---|
527 | } SharedFolders;
|
---|
528 |
|
---|
529 | #ifndef VBOX_WITHOUT_TESTING_FEATURES
|
---|
530 | /** The XML output file name (can be a named pipe, doesn't matter to us). */
|
---|
531 | R3PTRTYPE(char *) pszTestingXmlOutput;
|
---|
532 | /** Testing instance for dealing with the output. */
|
---|
533 | RTTEST hTestingTest;
|
---|
534 | /** The locking test thread (). */
|
---|
535 | PPDMTHREAD pTestingLockThread;
|
---|
536 | #endif
|
---|
537 | } VMMDEVR3;
|
---|
538 | /** Pointer to the ring-3 VMM device state. */
|
---|
539 | typedef VMMDEVR3 *PVMMDEVR3;
|
---|
540 |
|
---|
541 |
|
---|
542 | /**
|
---|
543 | * State structure for the VMM device, ring-0 edition.
|
---|
544 | */
|
---|
545 | typedef struct VMMDEVR0
|
---|
546 | {
|
---|
547 | /** R0 pointer to VMMDev RAM area - first page only, could be NULL! */
|
---|
548 | R0PTRTYPE(VMMDevMemory *) pVMMDevRAMR0;
|
---|
549 | } VMMDEVR0;
|
---|
550 | /** Pointer to the ring-0 VMM device state. */
|
---|
551 | typedef VMMDEVR0 *PVMMDEVR0;
|
---|
552 |
|
---|
553 |
|
---|
554 | /**
|
---|
555 | * State structure for the VMM device, raw-mode edition.
|
---|
556 | */
|
---|
557 | typedef struct VMMDEVRC
|
---|
558 | {
|
---|
559 | /** R0 pointer to VMMDev RAM area - first page only, could be NULL! */
|
---|
560 | RCPTRTYPE(VMMDevMemory *) pVMMDevRAMRC;
|
---|
561 | } VMMDEVRC;
|
---|
562 | /** Pointer to the raw-mode VMM device state. */
|
---|
563 | typedef VMMDEVRC *PVMMDEVRC;
|
---|
564 |
|
---|
565 |
|
---|
566 | /** @typedef VMMDEVCC
|
---|
567 | * The VMMDEV device data for the current context. */
|
---|
568 | typedef CTX_SUFF(VMMDEV) VMMDEVCC;
|
---|
569 | /** @typedef PVMMDEVCC
|
---|
570 | * Pointer to the VMMDEV device for the current context. */
|
---|
571 | typedef CTX_SUFF(PVMMDEV) PVMMDEVCC;
|
---|
572 |
|
---|
573 |
|
---|
574 | void VMMDevNotifyGuest(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, uint32_t fAddEvents);
|
---|
575 | void VMMDevCtlSetGuestFilterMask(PPDMDEVINS pDevIns, PVMMDEV pThis, PVMMDEVCC pThisCC, uint32_t fOrMask, uint32_t fNotMask);
|
---|
576 |
|
---|
577 |
|
---|
578 | /** The saved state version. */
|
---|
579 | #define VMMDEV_SAVED_STATE_VERSION VMMDEV_SAVED_STATE_VERSION_MMIO_ACCESS
|
---|
580 | /** Added support to optionally use MMIO instead of PIO for passing requests to the host (mainly for ARM). */
|
---|
581 | #define VMMDEV_SAVED_STATE_VERSION_MMIO_ACCESS 20
|
---|
582 | /** The saved state version with VMMDev mouse buttons state and wheel movement data. */
|
---|
583 | #define VMMDEV_SAVED_STATE_VERSION_VMM_MOUSE_EXTENDED_DATA 19
|
---|
584 | /** The saved state version with display change data state. */
|
---|
585 | #define VMMDEV_SAVED_STATE_VERSION_DISPLAY_CHANGE_DATA 18
|
---|
586 | /** Updated HGCM commands. */
|
---|
587 | #define VMMDEV_SAVED_STATE_VERSION_HGCM_PARAMS 17
|
---|
588 | /** The saved state version with heartbeat state. */
|
---|
589 | #define VMMDEV_SAVED_STATE_VERSION_HEARTBEAT 16
|
---|
590 | /** The saved state version without heartbeat state. */
|
---|
591 | #define VMMDEV_SAVED_STATE_VERSION_NO_HEARTBEAT 15
|
---|
592 | /** The saved state version which is missing the guest facility statuses. */
|
---|
593 | #define VMMDEV_SAVED_STATE_VERSION_MISSING_FACILITY_STATUSES 14
|
---|
594 | /** The saved state version which is missing the guestInfo2 bits. */
|
---|
595 | #define VMMDEV_SAVED_STATE_VERSION_MISSING_GUEST_INFO_2 13
|
---|
596 | /** The saved state version used by VirtualBox 3.0.
|
---|
597 | * This doesn't have the config part. */
|
---|
598 | #define VMMDEV_SAVED_STATE_VERSION_VBOX_30 11
|
---|
599 |
|
---|
600 | #endif /* !VBOX_INCLUDED_SRC_VMMDev_VMMDevState_h */
|
---|
601 |
|
---|