VirtualBox

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

Last change on this file since 76882 was 76565, checked in by vboxsync, 6 years ago

Devices: Use VBOX_INCLUDED_SRC_ as header guard prefix with scm.

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