VirtualBox

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

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

VMMDev: cleanups. bugref:9218

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.7 KB
Line 
1/* $Id: VMMDevState.h 81569 2019-10-29 11:26:34Z 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 /** mouse capabilities of host and guest */
130 uint32_t fMouseCapabilities;
131 /** @name Absolute mouse position in pixels
132 * @{ */
133 int32_t xMouseAbs;
134 int32_t yMouseAbs;
135 /** @} */
136 /** Does the guest currently want the host pointer to be shown? */
137 uint32_t fHostCursorRequested;
138
139 /** Pointer to device instance - R3 poitner. */
140 PPDMDEVINSR3 pDevInsR3;
141 /** Pointer to device instance - R0 pointer. */
142 PPDMDEVINSR0 pDevInsR0;
143
144 /** LUN\#0 + Status: VMMDev port base interface. */
145 PDMIBASE IBase;
146 /** LUN\#0: VMMDev port interface. */
147 PDMIVMMDEVPORT IPort;
148#ifdef VBOX_WITH_HGCM
149 /** LUN\#0: HGCM port interface. */
150 PDMIHGCMPORT IHGCMPort;
151//# if HC_ARCH_BITS == 32
152// RTR3PTR R3PtrAlignment1;
153//# endif
154#endif
155 /** Pointer to base interface of the driver. */
156 R3PTRTYPE(PPDMIBASE) pDrvBase;
157 /** VMMDev connector interface */
158 R3PTRTYPE(PPDMIVMMDEVCONNECTOR) pDrv;
159#ifdef VBOX_WITH_HGCM
160 /** HGCM connector interface */
161 R3PTRTYPE(PPDMIHGCMCONNECTOR) pHGCMDrv;
162#endif
163 /** message buffer for backdoor logging. */
164 char szMsg[512];
165 /** message buffer index. */
166 uint32_t offMsg;
167 /** Alignment padding. */
168 uint32_t u32Alignment2;
169
170 /** Statistics counter for slow IRQ ACK. */
171 STAMCOUNTER StatSlowIrqAck;
172 /** Statistics counter for fast IRQ ACK - R3. */
173 STAMCOUNTER StatFastIrqAckR3;
174 /** Statistics counter for fast IRQ ACK - R0 / RC. */
175 STAMCOUNTER StatFastIrqAckRZ;
176 /** Current host side event flags - VMMDEV_EVENT_XXX. */
177 uint32_t fHostEventFlags;
178 /** Mask of events guest is interested in - VMMDEV_EVENT_XXX.
179 * @note The HGCM events are enabled automatically by the VMMDev device when
180 * guest issues HGCM commands. */
181 uint32_t fGuestFilterMask;
182 /** Delayed mask of guest events - VMMDEV_EVENT_XXX. */
183 uint32_t fNewGuestFilterMask;
184 /** Flag whether fNewGuestFilterMask is valid */
185 bool fNewGuestFilterMaskValid;
186 /** Alignment padding. */
187 bool afAlignment3[7];
188
189 /** GC physical address of VMMDev RAM area */
190 RTGCPHYS32 GCPhysVMMDevRAM;
191 /** R3 pointer to VMMDev RAM area */
192 R3PTRTYPE(VMMDevMemory *) pVMMDevRAMR3;
193 /** R0 pointer to VMMDev RAM area - first page only, could be NULL! */
194 R0PTRTYPE(VMMDevMemory *) pVMMDevRAMR0;
195#ifdef VBOX_WITH_RAW_MODE_KEEP
196 /** R0 pointer to VMMDev RAM area - first page only, could be NULL! */
197 RCPTRTYPE(VMMDevMemory *) pVMMDevRAMRC;
198 RTRCPTR RCPtrAlignment3b;
199#endif
200
201 /** R3 pointer to VMMDev Heap RAM area. */
202 R3PTRTYPE(VMMDevMemory *) pVMMDevHeapR3;
203 /** GC physical address of VMMDev Heap RAM area */
204 RTGCPHYS32 GCPhysVMMDevHeap;
205
206 /** Information reported by guest via VMMDevReportGuestInfo generic request.
207 * Until this information is reported the VMMDev refuses any other requests.
208 */
209 VBoxGuestInfo guestInfo;
210 /** Information report \#2, chewed a little. */
211 struct
212 {
213 uint32_t uFullVersion; /**< non-zero if info is present. */
214 uint32_t uRevision;
215 uint32_t fFeatures;
216 char szName[128];
217 } guestInfo2;
218
219 /** Array of guest facility statuses. */
220 VMMDEVFACILITYSTATUSENTRY aFacilityStatuses[32];
221 /** The number of valid entries in the facility status array. */
222 uint32_t cFacilityStatuses;
223
224 /** Information reported by guest via VMMDevReportGuestCapabilities - VMMDEV_GUEST_SUPPORTS_XXX. */
225 uint32_t fGuestCaps;
226
227 /** "Additions are Ok" indicator, set to true after processing VMMDevReportGuestInfo,
228 * if additions version is compatible. This flag is here to avoid repeated comparing
229 * of the version in guestInfo.
230 */
231 uint32_t fu32AdditionsOk;
232
233 /** Video acceleration status set by guest. */
234 uint32_t u32VideoAccelEnabled;
235
236 DISPLAYCHANGEDATA displayChangeData;
237
238 /** Pointer to the credentials. */
239 R3PTRTYPE(VMMDEVCREDS *) pCredentials;
240
241#if HC_ARCH_BITS == 32
242 uint32_t uAlignment4;
243#endif
244
245 /** memory balloon change request */
246 uint32_t cMbMemoryBalloon;
247 /** The last balloon size queried by the guest additions. */
248 uint32_t cMbMemoryBalloonLast;
249
250 /** guest ram size */
251 uint64_t cbGuestRAM;
252
253 /** unique session id; the id will be different after each start, reset or restore of the VM. */
254 uint64_t idSession;
255
256 /** Statistics interval in seconds. */
257 uint32_t cSecsStatInterval;
258 /** The statistics interval last returned to the guest. */
259 uint32_t cSecsLastStatInterval;
260
261 /** Whether seamless is enabled or not. */
262 bool fSeamlessEnabled;
263 /** The last fSeamlessEnabled state returned to the guest. */
264 bool fLastSeamlessEnabled;
265 bool afAlignment5[1];
266
267 bool fVRDPEnabled;
268 uint32_t uVRDPExperienceLevel;
269
270#ifdef VMMDEV_WITH_ALT_TIMESYNC
271 uint64_t msLatchedHostTime;
272 bool fTimesyncBackdoorLo;
273 bool afAlignment6[2];
274#else
275 bool afAlignment6[1+2];
276#endif
277
278 /** Set if GetHostTime should fail.
279 * Loaded from the GetHostTimeDisabled configuration value. */
280 bool fGetHostTimeDisabled;
281 /** Set if backdoor logging should be disabled (output will be ignored then) */
282 bool fBackdoorLogDisabled;
283 /** Don't clear credentials */
284 bool fKeepCredentials;
285 /** Heap enabled. */
286 bool fHeapEnabled;
287
288 /** Guest Core Dumping enabled. */
289 bool fGuestCoreDumpEnabled;
290 /** Guest Core Dump location. */
291 char szGuestCoreDumpDir[RTPATH_MAX];
292 /** Number of additional cores to keep around. */
293 uint32_t cGuestCoreDumps;
294
295#ifdef VBOX_WITH_HGCM
296 /** List of pending HGCM requests (VBOXHGCMCMD). */
297 RTLISTANCHORR3 listHGCMCmd;
298 /** Critical section to protect the list. */
299 RTCRITSECT critsectHGCMCmdList;
300 /** Whether the HGCM events are already automatically enabled. */
301 uint32_t u32HGCMEnabled;
302 /** Saved state version of restored commands. */
303 uint32_t u32SSMVersion;
304 RTMEMCACHE hHgcmCmdCache;
305 STAMPROFILE StatHgcmCmdArrival;
306 STAMPROFILE StatHgcmCmdCompletion;
307 STAMPROFILE StatHgcmCmdTotal;
308 STAMCOUNTER StatHgcmLargeCmdAllocs;
309 STAMCOUNTER StatHgcmFailedPageListLocking;
310#endif /* VBOX_WITH_HGCM */
311 STAMCOUNTER StatReqBufAllocs;
312
313 /** Per CPU request 4K sized buffers, allocated as needed. */
314 R3PTRTYPE(VMMDevRequestHeader *) apReqBufs[VMM_MAX_CPU_COUNT];
315
316 /** Status LUN: Shared folders LED */
317 struct
318 {
319 /** The LED. */
320 PDMLED Led;
321 /** The LED ports. */
322 PDMILEDPORTS ILeds;
323 /** Partner of ILeds. */
324 R3PTRTYPE(PPDMILEDCONNECTORS) pLedsConnector;
325 } SharedFolders;
326
327 /** FLag whether CPU hotplug events are monitored */
328 bool fCpuHotPlugEventsEnabled;
329 /** Alignment padding. */
330 bool afPadding8[3];
331 /** CPU hotplug event */
332 VMMDevCpuEventType enmCpuHotPlugEvent;
333 /** Core id of the CPU to change */
334 uint32_t idCpuCore;
335 /** Package id of the CPU to change */
336 uint32_t idCpuPackage;
337
338 uint32_t StatMemBalloonChunks;
339
340 /** Set if RC/R0 is enabled. */
341 bool fRZEnabled;
342 /** Set if testing is enabled. */
343 bool fTestingEnabled;
344 /** Set if testing the MMIO testing range is enabled. */
345 bool fTestingMMIO;
346 /** Alignment padding. */
347 bool afPadding9[HC_ARCH_BITS == 32 ? 1 : 5];
348#ifndef VBOX_WITHOUT_TESTING_FEATURES
349 /** The high timestamp value. */
350 uint32_t u32TestingHighTimestamp;
351 /** The current testing command (VMMDEV_TESTING_CMD_XXX). */
352 uint32_t u32TestingCmd;
353 /** The testing data offset (command specific). */
354 uint32_t offTestingData;
355 /** For buffering the what comes in over the testing data port. */
356 union
357 {
358 char padding[1024];
359
360 /** VMMDEV_TESTING_CMD_INIT, VMMDEV_TESTING_CMD_SUB_NEW,
361 * VMMDEV_TESTING_CMD_FAILED. */
362 struct
363 {
364 char sz[1024];
365 } String, Init, SubNew, Failed;
366
367 /** VMMDEV_TESTING_CMD_TERM, VMMDEV_TESTING_CMD_SUB_DONE. */
368 struct
369 {
370 uint32_t c;
371 } Error, Term, SubDone;
372
373 /** VMMDEV_TESTING_CMD_VALUE. */
374 struct
375 {
376 RTUINT64U u64Value;
377 uint32_t u32Unit;
378 char szName[1024 - 8 - 4];
379 } Value;
380
381 /** The read back register (VMMDEV_TESTING_MMIO_OFF_READBACK,
382 * VMMDEV_TESTING_MMIO_OFF_READBACK_R3). */
383 uint8_t abReadBack[VMMDEV_TESTING_READBACK_SIZE];
384 } TestingData;
385 /** The XML output file name (can be a named pipe, doesn't matter to us). */
386 R3PTRTYPE(char *) pszTestingXmlOutput;
387 /** Testing instance for dealing with the output. */
388 RTTEST hTestingTest;
389#endif /* !VBOX_WITHOUT_TESTING_FEATURES */
390
391 /** @name Heartbeat
392 * @{ */
393 /** Timestamp of the last heartbeat from guest in nanosec. */
394 uint64_t volatile nsLastHeartbeatTS;
395 /** Indicates whether we missed HB from guest on last check. */
396 bool volatile fFlatlined;
397 /** Indicates whether heartbeat check is active. */
398 bool volatile fHeartbeatActive;
399 /** Alignment padding. */
400 bool afAlignment8[6];
401 /** Guest heartbeat interval in nanoseconds.
402 * This is the interval the guest is told to produce heartbeats at. */
403 uint64_t cNsHeartbeatInterval;
404 /** The amount of time without a heartbeat (nanoseconds) before we
405 * conclude the guest is doing a Dixie Flatline (Neuromancer) impression. */
406 uint64_t cNsHeartbeatTimeout;
407 /** Timer for signalling a flatlined guest. */
408 PTMTIMERR3 pFlatlinedTimer;
409 /** @} */
410} VMMDevState;
411typedef VMMDevState VMMDEV;
412/** Pointer to the VMM device state. */
413typedef VMMDEV *PVMMDEV;
414AssertCompileMemberAlignment(VMMDEV, CritSect, 8);
415AssertCompileMemberAlignment(VMMDEV, StatSlowIrqAck, 8);
416AssertCompileMemberAlignment(VMMDEV, cbGuestRAM, 8);
417AssertCompileMemberAlignment(VMMDEV, enmCpuHotPlugEvent, 4);
418AssertCompileMemberAlignment(VMMDEV, aFacilityStatuses, 8);
419#ifndef VBOX_WITHOUT_TESTING_FEATURES
420AssertCompileMemberAlignment(VMMDEV, TestingData.Value.u64Value, 8);
421#endif
422
423
424void VMMDevNotifyGuest(VMMDEV *pVMMDevState, uint32_t u32EventMask);
425void VMMDevCtlSetGuestFilterMask(VMMDEV *pVMMDevState, uint32_t u32OrMask, uint32_t u32NotMask);
426
427
428/** The saved state version. */
429#define VMMDEV_SAVED_STATE_VERSION VMMDEV_SAVED_STATE_VERSION_HGCM_PARAMS
430/** Updated HGCM commands. */
431#define VMMDEV_SAVED_STATE_VERSION_HGCM_PARAMS 17
432/** The saved state version with heartbeat state. */
433#define VMMDEV_SAVED_STATE_VERSION_HEARTBEAT 16
434/** The saved state version without heartbeat state. */
435#define VMMDEV_SAVED_STATE_VERSION_NO_HEARTBEAT 15
436/** The saved state version which is missing the guest facility statuses. */
437#define VMMDEV_SAVED_STATE_VERSION_MISSING_FACILITY_STATUSES 14
438/** The saved state version which is missing the guestInfo2 bits. */
439#define VMMDEV_SAVED_STATE_VERSION_MISSING_GUEST_INFO_2 13
440/** The saved state version used by VirtualBox 3.0.
441 * This doesn't have the config part. */
442#define VMMDEV_SAVED_STATE_VERSION_VBOX_30 11
443
444#endif /* !VBOX_INCLUDED_SRC_VMMDev_VMMDevState_h */
445
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