1 | /* $Id: VMMDevState.h 58164 2015-10-09 19:48:10Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VMMDev - Guest <-> VMM/Host communication device, internal header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2015 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 ___VMMDev_VMMDevState_h
|
---|
19 | #define ___VMMDev_VMMDevState_h
|
---|
20 |
|
---|
21 | #include <VBox/VMMDev.h>
|
---|
22 | #include <VBox/vmm/pdmdev.h>
|
---|
23 | #include <VBox/vmm/pdmifs.h>
|
---|
24 | #ifndef VBOX_WITHOUT_TESTING_FEATURES
|
---|
25 | # include <iprt/test.h>
|
---|
26 | #endif
|
---|
27 |
|
---|
28 | #define VMMDEV_WITH_ALT_TIMESYNC
|
---|
29 |
|
---|
30 | typedef struct DISPLAYCHANGEINFO
|
---|
31 | {
|
---|
32 | uint32_t xres;
|
---|
33 | uint32_t yres;
|
---|
34 | uint32_t bpp;
|
---|
35 | uint32_t display;
|
---|
36 | int32_t xOrigin;
|
---|
37 | int32_t yOrigin;
|
---|
38 | bool fEnabled;
|
---|
39 | bool fChangeOrigin;
|
---|
40 | } DISPLAYCHANGEINFO;
|
---|
41 |
|
---|
42 | typedef struct DISPLAYCHANGEREQUEST
|
---|
43 | {
|
---|
44 | bool fPending;
|
---|
45 | bool afAlignment[3];
|
---|
46 | DISPLAYCHANGEINFO displayChangeRequest;
|
---|
47 | DISPLAYCHANGEINFO lastReadDisplayChangeRequest;
|
---|
48 | } DISPLAYCHANGEREQUEST;
|
---|
49 |
|
---|
50 | typedef struct DISPLAYCHANGEDATA
|
---|
51 | {
|
---|
52 | /* Which monitor is being reported to the guest. */
|
---|
53 | int iCurrentMonitor;
|
---|
54 |
|
---|
55 | /** true if the guest responded to VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST at least once */
|
---|
56 | bool fGuestSentChangeEventAck;
|
---|
57 | bool afAlignment[3];
|
---|
58 |
|
---|
59 | DISPLAYCHANGEREQUEST aRequests[64]; /// @todo maxMonitors
|
---|
60 | } DISPLAYCHANGEDATA;
|
---|
61 |
|
---|
62 |
|
---|
63 | /**
|
---|
64 | * Credentials for automatic guest logon and host configured logon (?).
|
---|
65 | *
|
---|
66 | * This is not stored in the same block as the instance data in order to make it
|
---|
67 | * harder to access.
|
---|
68 | */
|
---|
69 | typedef struct VMMDEVCREDS
|
---|
70 | {
|
---|
71 | /** credentials for guest logon purposes */
|
---|
72 | struct
|
---|
73 | {
|
---|
74 | char szUserName[VMMDEV_CREDENTIALS_SZ_SIZE];
|
---|
75 | char szPassword[VMMDEV_CREDENTIALS_SZ_SIZE];
|
---|
76 | char szDomain[VMMDEV_CREDENTIALS_SZ_SIZE];
|
---|
77 | bool fAllowInteractiveLogon;
|
---|
78 | } Logon;
|
---|
79 |
|
---|
80 | /** credentials for verification by guest */
|
---|
81 | struct
|
---|
82 | {
|
---|
83 | char szUserName[VMMDEV_CREDENTIALS_SZ_SIZE];
|
---|
84 | char szPassword[VMMDEV_CREDENTIALS_SZ_SIZE];
|
---|
85 | char szDomain[VMMDEV_CREDENTIALS_SZ_SIZE];
|
---|
86 | } Judge;
|
---|
87 | } VMMDEVCREDS;
|
---|
88 |
|
---|
89 |
|
---|
90 | /**
|
---|
91 | * Facility status entry.
|
---|
92 | */
|
---|
93 | typedef struct VMMDEVFACILITYSTATUSENTRY
|
---|
94 | {
|
---|
95 | /** The facility (may contain values other than the defined ones). */
|
---|
96 | VBoxGuestFacilityType enmFacility;
|
---|
97 | /** The status (may contain values other than the defined ones). */
|
---|
98 | VBoxGuestFacilityStatus enmStatus;
|
---|
99 | /** Whether this entry is fixed and cannot be reused when inactive. */
|
---|
100 | bool fFixed;
|
---|
101 | /** Explicit alignment padding / reserved for future use. MBZ. */
|
---|
102 | bool afPadding[3];
|
---|
103 | /** The facility flags (yet to be defined). */
|
---|
104 | uint32_t fFlags;
|
---|
105 | /** Last update timestamp. */
|
---|
106 | RTTIMESPEC TimeSpecTS;
|
---|
107 | } VMMDEVFACILITYSTATUSENTRY;
|
---|
108 | /** Pointer to a facility status entry. */
|
---|
109 | typedef VMMDEVFACILITYSTATUSENTRY *PVMMDEVFACILITYSTATUSENTRY;
|
---|
110 |
|
---|
111 |
|
---|
112 | /** device structure containing all state information */
|
---|
113 | typedef struct VMMDevState
|
---|
114 | {
|
---|
115 | /** The PCI device structure. */
|
---|
116 | PCIDevice PciDev;
|
---|
117 | /** The critical section for this device.
|
---|
118 | * @remarks We use this rather than the default one, it's simpler with all
|
---|
119 | * the driver interfaces where we have to waste time digging out the
|
---|
120 | * PDMDEVINS structure. */
|
---|
121 | PDMCRITSECT CritSect;
|
---|
122 |
|
---|
123 | /** hypervisor address space size */
|
---|
124 | uint32_t hypervisorSize;
|
---|
125 |
|
---|
126 | /** mouse capabilities of host and guest */
|
---|
127 | uint32_t mouseCapabilities;
|
---|
128 | /** absolute mouse position in pixels */
|
---|
129 | int32_t mouseXAbs;
|
---|
130 | int32_t mouseYAbs;
|
---|
131 | /** Does the guest currently want the host pointer to be shown? */
|
---|
132 | uint32_t fHostCursorRequested;
|
---|
133 |
|
---|
134 | /** Alignment padding. */
|
---|
135 | uint32_t u32Alignment0;
|
---|
136 |
|
---|
137 | /** Pointer to device instance. */
|
---|
138 | PPDMDEVINSR3 pDevIns;
|
---|
139 | /** LUN\#0 + Status: VMMDev port base interface. */
|
---|
140 | PDMIBASE IBase;
|
---|
141 | /** LUN\#0: VMMDev port interface. */
|
---|
142 | PDMIVMMDEVPORT IPort;
|
---|
143 | #ifdef VBOX_WITH_HGCM
|
---|
144 | /** LUN\#0: HGCM port interface. */
|
---|
145 | PDMIHGCMPORT IHGCMPort;
|
---|
146 | #endif
|
---|
147 | /** Pointer to base interface of the driver. */
|
---|
148 | R3PTRTYPE(PPDMIBASE) pDrvBase;
|
---|
149 | /** VMMDev connector interface */
|
---|
150 | R3PTRTYPE(PPDMIVMMDEVCONNECTOR) pDrv;
|
---|
151 | #ifdef VBOX_WITH_HGCM
|
---|
152 | /** HGCM connector interface */
|
---|
153 | R3PTRTYPE(PPDMIHGCMCONNECTOR) pHGCMDrv;
|
---|
154 | #endif
|
---|
155 | /** Alignment padding. */
|
---|
156 | RTR3PTR PtrR3Alignment1;
|
---|
157 | /** message buffer for backdoor logging. */
|
---|
158 | char szMsg[512];
|
---|
159 | /** message buffer index. */
|
---|
160 | uint32_t iMsg;
|
---|
161 | /** Alignment padding. */
|
---|
162 | uint32_t u32Alignment2;
|
---|
163 |
|
---|
164 | /** IRQ number assigned to the device */
|
---|
165 | uint32_t irq;
|
---|
166 | /** Current host side event flags */
|
---|
167 | uint32_t u32HostEventFlags;
|
---|
168 | /** Mask of events guest is interested in.
|
---|
169 | * @note The HGCM events are enabled automatically by the VMMDev device when
|
---|
170 | * guest issues HGCM commands. */
|
---|
171 | uint32_t u32GuestFilterMask;
|
---|
172 | /** Delayed mask of guest events */
|
---|
173 | uint32_t u32NewGuestFilterMask;
|
---|
174 | /** Flag whether u32NewGuestFilterMask is valid */
|
---|
175 | bool fNewGuestFilterMask;
|
---|
176 | /** Alignment padding. */
|
---|
177 | bool afAlignment3[3];
|
---|
178 |
|
---|
179 | /** GC physical address of VMMDev RAM area */
|
---|
180 | RTGCPHYS32 GCPhysVMMDevRAM;
|
---|
181 | /** R3 pointer to VMMDev RAM area */
|
---|
182 | R3PTRTYPE(VMMDevMemory *) pVMMDevRAMR3;
|
---|
183 |
|
---|
184 | /** R3 pointer to VMMDev Heap RAM area
|
---|
185 | */
|
---|
186 | R3PTRTYPE(VMMDevMemory *) pVMMDevHeapR3;
|
---|
187 | /** GC physical address of VMMDev Heap RAM area */
|
---|
188 | RTGCPHYS32 GCPhysVMMDevHeap;
|
---|
189 |
|
---|
190 | /** Information reported by guest via VMMDevReportGuestInfo generic request.
|
---|
191 | * Until this information is reported the VMMDev refuses any other requests.
|
---|
192 | */
|
---|
193 | VBoxGuestInfo guestInfo;
|
---|
194 | /** Information report \#2, chewed a litte. */
|
---|
195 | struct
|
---|
196 | {
|
---|
197 | uint32_t uFullVersion; /**< non-zero if info is present. */
|
---|
198 | uint32_t uRevision;
|
---|
199 | uint32_t fFeatures;
|
---|
200 | char szName[128];
|
---|
201 | } guestInfo2;
|
---|
202 |
|
---|
203 | /** Array of guest facility statuses. */
|
---|
204 | VMMDEVFACILITYSTATUSENTRY aFacilityStatuses[32];
|
---|
205 | /** The number of valid entries in the facility status array. */
|
---|
206 | uint32_t cFacilityStatuses;
|
---|
207 |
|
---|
208 | /** Information reported by guest via VMMDevReportGuestCapabilities. */
|
---|
209 | uint32_t guestCaps;
|
---|
210 |
|
---|
211 | /** "Additions are Ok" indicator, set to true after processing VMMDevReportGuestInfo,
|
---|
212 | * if additions version is compatible. This flag is here to avoid repeated comparing
|
---|
213 | * of the version in guestInfo.
|
---|
214 | */
|
---|
215 | uint32_t fu32AdditionsOk;
|
---|
216 |
|
---|
217 | /** Video acceleration status set by guest. */
|
---|
218 | uint32_t u32VideoAccelEnabled;
|
---|
219 |
|
---|
220 | DISPLAYCHANGEDATA displayChangeData;
|
---|
221 |
|
---|
222 | /** Pointer to the credentials. */
|
---|
223 | R3PTRTYPE(VMMDEVCREDS *) pCredentials;
|
---|
224 |
|
---|
225 | bool afAlignment4[HC_ARCH_BITS == 32 ? 3 : 7];
|
---|
226 |
|
---|
227 | /* memory balloon change request */
|
---|
228 | uint32_t cMbMemoryBalloon;
|
---|
229 | /** The last balloon size queried by the guest additions. */
|
---|
230 | uint32_t cMbMemoryBalloonLast;
|
---|
231 |
|
---|
232 | /* guest ram size */
|
---|
233 | uint64_t cbGuestRAM;
|
---|
234 |
|
---|
235 | /* unique session id; the id will be different after each start, reset or restore of the VM. */
|
---|
236 | uint64_t idSession;
|
---|
237 |
|
---|
238 | /* statistics interval change request */
|
---|
239 | uint32_t u32StatIntervalSize, u32LastStatIntervalSize;
|
---|
240 |
|
---|
241 | /* seamless mode change request */
|
---|
242 | bool fLastSeamlessEnabled, fSeamlessEnabled;
|
---|
243 | bool afAlignment5[1];
|
---|
244 |
|
---|
245 | bool fVRDPEnabled;
|
---|
246 | uint32_t uVRDPExperienceLevel;
|
---|
247 |
|
---|
248 | #ifdef VMMDEV_WITH_ALT_TIMESYNC
|
---|
249 | uint64_t hostTime;
|
---|
250 | bool fTimesyncBackdoorLo;
|
---|
251 | bool afAlignment6[3];
|
---|
252 | #endif
|
---|
253 | /** Set if GetHostTime should fail.
|
---|
254 | * Loaded from the GetHostTimeDisabled configuration value. */
|
---|
255 | bool fGetHostTimeDisabled;
|
---|
256 |
|
---|
257 | /** Set if backdoor logging should be disabled (output will be ignored then) */
|
---|
258 | bool fBackdoorLogDisabled;
|
---|
259 |
|
---|
260 | /** Don't clear credentials */
|
---|
261 | bool fKeepCredentials;
|
---|
262 |
|
---|
263 | /** Heap enabled. */
|
---|
264 | bool fHeapEnabled;
|
---|
265 |
|
---|
266 | /** Guest Core Dumping enabled. */
|
---|
267 | bool fGuestCoreDumpEnabled;
|
---|
268 |
|
---|
269 | /** Guest Core Dump location. */
|
---|
270 | char szGuestCoreDumpDir[RTPATH_MAX];
|
---|
271 |
|
---|
272 | /** Number of additional cores to keep around. */
|
---|
273 | uint32_t cGuestCoreDumps;
|
---|
274 |
|
---|
275 | bool afAlignment7[1];
|
---|
276 |
|
---|
277 | #ifdef VBOX_WITH_HGCM
|
---|
278 | /** List of pending HGCM requests, used for saving the HGCM state. */
|
---|
279 | R3PTRTYPE(PVBOXHGCMCMD) pHGCMCmdList;
|
---|
280 | /** Critical section to protect the list. */
|
---|
281 | RTCRITSECT critsectHGCMCmdList;
|
---|
282 | /** Whether the HGCM events are already automatically enabled. */
|
---|
283 | uint32_t u32HGCMEnabled;
|
---|
284 | /** Alignment padding. */
|
---|
285 | uint32_t u32Alignment7;
|
---|
286 | #endif /* VBOX_WITH_HGCM */
|
---|
287 |
|
---|
288 | /** Status LUN: Shared folders LED */
|
---|
289 | struct
|
---|
290 | {
|
---|
291 | /** The LED. */
|
---|
292 | PDMLED Led;
|
---|
293 | /** The LED ports. */
|
---|
294 | PDMILEDPORTS ILeds;
|
---|
295 | /** Partner of ILeds. */
|
---|
296 | R3PTRTYPE(PPDMILEDCONNECTORS) pLedsConnector;
|
---|
297 | } SharedFolders;
|
---|
298 |
|
---|
299 | /** FLag whether CPU hotplug events are monitored */
|
---|
300 | bool fCpuHotPlugEventsEnabled;
|
---|
301 | /** Alignment padding. */
|
---|
302 | bool afPadding8[3];
|
---|
303 | /** CPU hotplug event */
|
---|
304 | VMMDevCpuEventType enmCpuHotPlugEvent;
|
---|
305 | /** Core id of the CPU to change */
|
---|
306 | uint32_t idCpuCore;
|
---|
307 | /** Package id of the CPU to change */
|
---|
308 | uint32_t idCpuPackage;
|
---|
309 |
|
---|
310 | uint32_t StatMemBalloonChunks;
|
---|
311 |
|
---|
312 | /** Set if RC/R0 is enabled. */
|
---|
313 | bool fRZEnabled;
|
---|
314 | /** Set if testing is enabled. */
|
---|
315 | bool fTestingEnabled;
|
---|
316 | /** Set if testing the MMIO testing range is enabled. */
|
---|
317 | bool fTestingMMIO;
|
---|
318 | /** Alignment padding. */
|
---|
319 | bool afPadding9[HC_ARCH_BITS == 32 ? 1 : 5];
|
---|
320 | #ifndef VBOX_WITHOUT_TESTING_FEATURES
|
---|
321 | /** The high timestamp value. */
|
---|
322 | uint32_t u32TestingHighTimestamp;
|
---|
323 | /** The current testing command (VMMDEV_TESTING_CMD_XXX). */
|
---|
324 | uint32_t u32TestingCmd;
|
---|
325 | /** The testing data offset (command specific). */
|
---|
326 | uint32_t offTestingData;
|
---|
327 | /** For buffering the what comes in over the testing data port. */
|
---|
328 | union
|
---|
329 | {
|
---|
330 | char padding[1024];
|
---|
331 |
|
---|
332 | /** VMMDEV_TESTING_CMD_INIT, VMMDEV_TESTING_CMD_SUB_NEW,
|
---|
333 | * VMMDEV_TESTING_CMD_FAILED. */
|
---|
334 | struct
|
---|
335 | {
|
---|
336 | char sz[1024];
|
---|
337 | } String, Init, SubNew, Failed;
|
---|
338 |
|
---|
339 | /** VMMDEV_TESTING_CMD_TERM, VMMDEV_TESTING_CMD_SUB_DONE. */
|
---|
340 | struct
|
---|
341 | {
|
---|
342 | uint32_t c;
|
---|
343 | } Error, Term, SubDone;
|
---|
344 |
|
---|
345 | /** VMMDEV_TESTING_CMD_VALUE. */
|
---|
346 | struct
|
---|
347 | {
|
---|
348 | RTUINT64U u64Value;
|
---|
349 | uint32_t u32Unit;
|
---|
350 | char szName[1024 - 8 - 4];
|
---|
351 | } Value;
|
---|
352 | } TestingData;
|
---|
353 | /** The XML output file name (can be a named pipe, doesn't matter to us). */
|
---|
354 | R3PTRTYPE(char *) pszTestingXmlOutput;
|
---|
355 | /** Testing instance for dealing with the output. */
|
---|
356 | RTTEST hTestingTest;
|
---|
357 | #endif /* !VBOX_WITHOUT_TESTING_FEATURES */
|
---|
358 |
|
---|
359 | /** @name Heartbeat
|
---|
360 | * @{ */
|
---|
361 | /** Timestamp of the last heartbeat from guest in nanosec. */
|
---|
362 | uint64_t volatile nsLastHeartbeatTS;
|
---|
363 | /** Indicates whether we missed HB from guest on last check. */
|
---|
364 | bool volatile fFlatlined;
|
---|
365 | /** Indicates whether heartbeat check is active. */
|
---|
366 | bool volatile fHeartbeatActive;
|
---|
367 | /** Alignment padding. */
|
---|
368 | bool afAlignment8[6];
|
---|
369 | /** Guest heartbeat interval in nanoseconds.
|
---|
370 | * This is the interval the guest is told to produce heartbeats at. */
|
---|
371 | uint64_t cNsHeartbeatInterval;
|
---|
372 | /** The amount of time without a heartbeat (nanoseconds) before we
|
---|
373 | * conclude the guest is doing a Dixie Flatline (Neuromancer) impression. */
|
---|
374 | uint64_t cNsHeartbeatTimeout;
|
---|
375 | /** Timer for signalling a flatlined guest. */
|
---|
376 | PTMTIMERR3 pFlatlinedTimer;
|
---|
377 | /** @} */
|
---|
378 | } VMMDevState;
|
---|
379 | typedef VMMDevState VMMDEV;
|
---|
380 | /** Pointer to the VMM device state. */
|
---|
381 | typedef VMMDEV *PVMMDEV;
|
---|
382 | AssertCompileMemberAlignment(VMMDEV, CritSect, 8);
|
---|
383 | AssertCompileMemberAlignment(VMMDEV, cbGuestRAM, 8);
|
---|
384 | AssertCompileMemberAlignment(VMMDEV, enmCpuHotPlugEvent, 4);
|
---|
385 | AssertCompileMemberAlignment(VMMDEV, aFacilityStatuses, 8);
|
---|
386 | #ifndef VBOX_WITHOUT_TESTING_FEATURES
|
---|
387 | AssertCompileMemberAlignment(VMMDEV, TestingData.Value.u64Value, 8);
|
---|
388 | #endif
|
---|
389 |
|
---|
390 |
|
---|
391 | void VMMDevNotifyGuest(VMMDEV *pVMMDevState, uint32_t u32EventMask);
|
---|
392 | void VMMDevCtlSetGuestFilterMask(VMMDEV *pVMMDevState, uint32_t u32OrMask, uint32_t u32NotMask);
|
---|
393 |
|
---|
394 | #endif /* !___VMMDev_VMMDevState_h */
|
---|
395 |
|
---|