1 | /* $Id: VMMDev.cpp 73698 2018-08-15 17:12:09Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VMMDev - Guest <-> VMM/Host communication device.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2017 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 | /** @page pg_vmmdev The VMM Device.
|
---|
19 | *
|
---|
20 | * The VMM device is a custom hardware device emulation for communicating with
|
---|
21 | * the guest additions.
|
---|
22 | *
|
---|
23 | * Whenever host wants to inform guest about something an IRQ notification will
|
---|
24 | * be raised.
|
---|
25 | *
|
---|
26 | * VMMDev PDM interface will contain the guest notification method.
|
---|
27 | *
|
---|
28 | * There is a 32 bit event mask which will be read by guest on an interrupt. A
|
---|
29 | * non zero bit in the mask means that the specific event occurred and requires
|
---|
30 | * processing on guest side.
|
---|
31 | *
|
---|
32 | * After reading the event mask guest must issue a generic request
|
---|
33 | * AcknowlegdeEvents.
|
---|
34 | *
|
---|
35 | * IRQ line is set to 1 (request) if there are unprocessed events, that is the
|
---|
36 | * event mask is not zero.
|
---|
37 | *
|
---|
38 | * After receiving an interrupt and checking event mask, the guest must process
|
---|
39 | * events using the event specific mechanism.
|
---|
40 | *
|
---|
41 | * That is if mouse capabilities were changed, guest will use
|
---|
42 | * VMMDev_GetMouseStatus generic request.
|
---|
43 | *
|
---|
44 | * Event mask is only a set of flags indicating that guest must proceed with a
|
---|
45 | * procedure.
|
---|
46 | *
|
---|
47 | * Unsupported events are therefore ignored. The guest additions must inform
|
---|
48 | * host which events they want to receive, to avoid unnecessary IRQ processing.
|
---|
49 | * By default no events are signalled to guest.
|
---|
50 | *
|
---|
51 | * This seems to be fast method. It requires only one context switch for an
|
---|
52 | * event processing.
|
---|
53 | *
|
---|
54 | *
|
---|
55 | * @section sec_vmmdev_heartbeat Heartbeat
|
---|
56 | *
|
---|
57 | * The heartbeat is a feature to monitor whether the guest OS is hung or not.
|
---|
58 | *
|
---|
59 | * The main kernel component of the guest additions, VBoxGuest, sets up a timer
|
---|
60 | * at a frequency returned by VMMDevReq_HeartbeatConfigure
|
---|
61 | * (VMMDevReqHeartbeat::cNsInterval, VMMDEV::cNsHeartbeatInterval) and performs
|
---|
62 | * a VMMDevReq_GuestHeartbeat request every time the timer ticks.
|
---|
63 | *
|
---|
64 | * The host side (VMMDev) arms a timer with a more distant deadline
|
---|
65 | * (VMMDEV::cNsHeartbeatTimeout), twice cNsHeartbeatInterval by default. Each
|
---|
66 | * time a VMMDevReq_GuestHeartbeat request comes in, the timer is rearmed with
|
---|
67 | * the same relative deadline. So, as long as VMMDevReq_GuestHeartbeat comes
|
---|
68 | * when they should, the host timer will never fire.
|
---|
69 | *
|
---|
70 | * When the timer fires, we consider the guest as hung / flatlined / dead.
|
---|
71 | * Currently we only LogRel that, but it's easy to extend this with an event in
|
---|
72 | * Main API.
|
---|
73 | *
|
---|
74 | * Should the guest reawaken at some later point, we LogRel that event and
|
---|
75 | * continue as normal. Again something which would merit an API event.
|
---|
76 | *
|
---|
77 | */
|
---|
78 |
|
---|
79 |
|
---|
80 | /*********************************************************************************************************************************
|
---|
81 | * Header Files *
|
---|
82 | *********************************************************************************************************************************/
|
---|
83 | /* Enable dev_vmm Log3 statements to get IRQ-related logging. */
|
---|
84 | #define LOG_GROUP LOG_GROUP_DEV_VMM
|
---|
85 | #include <VBox/AssertGuest.h>
|
---|
86 | #include <VBox/VMMDev.h>
|
---|
87 | #include <VBox/vmm/dbgf.h>
|
---|
88 | #include <VBox/vmm/mm.h>
|
---|
89 | #include <VBox/log.h>
|
---|
90 | #include <VBox/param.h>
|
---|
91 | #include <iprt/path.h>
|
---|
92 | #include <iprt/dir.h>
|
---|
93 | #include <iprt/file.h>
|
---|
94 | #include <VBox/vmm/pgm.h>
|
---|
95 | #include <VBox/err.h>
|
---|
96 | #include <VBox/vmm/vm.h> /* for VM_IS_EMT */
|
---|
97 | #include <VBox/dbg.h>
|
---|
98 | #include <VBox/version.h>
|
---|
99 |
|
---|
100 | #include <iprt/asm.h>
|
---|
101 | #include <iprt/asm-amd64-x86.h>
|
---|
102 | #include <iprt/assert.h>
|
---|
103 | #include <iprt/buildconfig.h>
|
---|
104 | #include <iprt/string.h>
|
---|
105 | #include <iprt/time.h>
|
---|
106 | #ifndef IN_RC
|
---|
107 | # include <iprt/mem.h>
|
---|
108 | #endif
|
---|
109 | #ifdef IN_RING3
|
---|
110 | # include <iprt/uuid.h>
|
---|
111 | #endif
|
---|
112 |
|
---|
113 | #include "VMMDevState.h"
|
---|
114 | #ifdef VBOX_WITH_HGCM
|
---|
115 | # include "VMMDevHGCM.h"
|
---|
116 | #endif
|
---|
117 | #ifndef VBOX_WITHOUT_TESTING_FEATURES
|
---|
118 | # include "VMMDevTesting.h"
|
---|
119 | #endif
|
---|
120 |
|
---|
121 |
|
---|
122 | /*********************************************************************************************************************************
|
---|
123 | * Defined Constants And Macros *
|
---|
124 | *********************************************************************************************************************************/
|
---|
125 | #define VMMDEV_INTERFACE_VERSION_IS_1_03(s) \
|
---|
126 | ( RT_HIWORD((s)->guestInfo.interfaceVersion) == 1 \
|
---|
127 | && RT_LOWORD((s)->guestInfo.interfaceVersion) == 3 )
|
---|
128 |
|
---|
129 | #define VMMDEV_INTERFACE_VERSION_IS_OK(additionsVersion) \
|
---|
130 | ( RT_HIWORD(additionsVersion) == RT_HIWORD(VMMDEV_VERSION) \
|
---|
131 | && RT_LOWORD(additionsVersion) <= RT_LOWORD(VMMDEV_VERSION) )
|
---|
132 |
|
---|
133 | #define VMMDEV_INTERFACE_VERSION_IS_OLD(additionsVersion) \
|
---|
134 | ( (RT_HIWORD(additionsVersion) < RT_HIWORD(VMMDEV_VERSION) \
|
---|
135 | || ( RT_HIWORD(additionsVersion) == RT_HIWORD(VMMDEV_VERSION) \
|
---|
136 | && RT_LOWORD(additionsVersion) <= RT_LOWORD(VMMDEV_VERSION) ) )
|
---|
137 |
|
---|
138 | #define VMMDEV_INTERFACE_VERSION_IS_TOO_OLD(additionsVersion) \
|
---|
139 | ( RT_HIWORD(additionsVersion) < RT_HIWORD(VMMDEV_VERSION) )
|
---|
140 |
|
---|
141 | #define VMMDEV_INTERFACE_VERSION_IS_NEW(additionsVersion) \
|
---|
142 | ( RT_HIWORD(additionsVersion) > RT_HIWORD(VMMDEV_VERSION) \
|
---|
143 | || ( RT_HIWORD(additionsVersion) == RT_HIWORD(VMMDEV_VERSION) \
|
---|
144 | && RT_LOWORD(additionsVersion) > RT_LOWORD(VMMDEV_VERSION) ) )
|
---|
145 |
|
---|
146 | /** Default interval in nanoseconds between guest heartbeats.
|
---|
147 | * Used when no HeartbeatInterval is set in CFGM and for setting
|
---|
148 | * HB check timer if the guest's heartbeat frequency is less than 1Hz. */
|
---|
149 | #define VMMDEV_HEARTBEAT_DEFAULT_INTERVAL (2U*RT_NS_1SEC_64)
|
---|
150 |
|
---|
151 |
|
---|
152 | #ifndef VBOX_DEVICE_STRUCT_TESTCASE
|
---|
153 |
|
---|
154 | /* -=-=-=-=- Misc Helpers -=-=-=-=- */
|
---|
155 |
|
---|
156 | /**
|
---|
157 | * Log information about the Guest Additions.
|
---|
158 | *
|
---|
159 | * @param pGuestInfo The information we've got from the Guest Additions driver.
|
---|
160 | */
|
---|
161 | static void vmmdevLogGuestOsInfo(VBoxGuestInfo *pGuestInfo)
|
---|
162 | {
|
---|
163 | const char *pszOs;
|
---|
164 | switch (pGuestInfo->osType & ~VBOXOSTYPE_x64)
|
---|
165 | {
|
---|
166 | case VBOXOSTYPE_DOS: pszOs = "DOS"; break;
|
---|
167 | case VBOXOSTYPE_Win31: pszOs = "Windows 3.1"; break;
|
---|
168 | case VBOXOSTYPE_Win9x: pszOs = "Windows 9x"; break;
|
---|
169 | case VBOXOSTYPE_Win95: pszOs = "Windows 95"; break;
|
---|
170 | case VBOXOSTYPE_Win98: pszOs = "Windows 98"; break;
|
---|
171 | case VBOXOSTYPE_WinMe: pszOs = "Windows Me"; break;
|
---|
172 | case VBOXOSTYPE_WinNT: pszOs = "Windows NT"; break;
|
---|
173 | case VBOXOSTYPE_WinNT3x: pszOs = "Windows NT 3.x"; break;
|
---|
174 | case VBOXOSTYPE_WinNT4: pszOs = "Windows NT4"; break;
|
---|
175 | case VBOXOSTYPE_Win2k: pszOs = "Windows 2k"; break;
|
---|
176 | case VBOXOSTYPE_WinXP: pszOs = "Windows XP"; break;
|
---|
177 | case VBOXOSTYPE_Win2k3: pszOs = "Windows 2k3"; break;
|
---|
178 | case VBOXOSTYPE_WinVista: pszOs = "Windows Vista"; break;
|
---|
179 | case VBOXOSTYPE_Win2k8: pszOs = "Windows 2k8"; break;
|
---|
180 | case VBOXOSTYPE_Win7: pszOs = "Windows 7"; break;
|
---|
181 | case VBOXOSTYPE_Win8: pszOs = "Windows 8"; break;
|
---|
182 | case VBOXOSTYPE_Win2k12_x64 & ~VBOXOSTYPE_x64: pszOs = "Windows 2k12"; break;
|
---|
183 | case VBOXOSTYPE_Win81: pszOs = "Windows 8.1"; break;
|
---|
184 | case VBOXOSTYPE_Win10: pszOs = "Windows 10"; break;
|
---|
185 | case VBOXOSTYPE_Win2k16_x64 & ~VBOXOSTYPE_x64: pszOs = "Windows 2k16"; break;
|
---|
186 | case VBOXOSTYPE_OS2: pszOs = "OS/2"; break;
|
---|
187 | case VBOXOSTYPE_OS2Warp3: pszOs = "OS/2 Warp 3"; break;
|
---|
188 | case VBOXOSTYPE_OS2Warp4: pszOs = "OS/2 Warp 4"; break;
|
---|
189 | case VBOXOSTYPE_OS2Warp45: pszOs = "OS/2 Warp 4.5"; break;
|
---|
190 | case VBOXOSTYPE_ECS: pszOs = "OS/2 ECS"; break;
|
---|
191 | case VBOXOSTYPE_OS21x: pszOs = "OS/2 2.1x"; break;
|
---|
192 | case VBOXOSTYPE_Linux: pszOs = "Linux"; break;
|
---|
193 | case VBOXOSTYPE_Linux22: pszOs = "Linux 2.2"; break;
|
---|
194 | case VBOXOSTYPE_Linux24: pszOs = "Linux 2.4"; break;
|
---|
195 | case VBOXOSTYPE_Linux26: pszOs = "Linux >= 2.6"; break;
|
---|
196 | case VBOXOSTYPE_ArchLinux: pszOs = "ArchLinux"; break;
|
---|
197 | case VBOXOSTYPE_Debian: pszOs = "Debian"; break;
|
---|
198 | case VBOXOSTYPE_OpenSUSE: pszOs = "openSUSE"; break;
|
---|
199 | case VBOXOSTYPE_FedoraCore: pszOs = "Fedora"; break;
|
---|
200 | case VBOXOSTYPE_Gentoo: pszOs = "Gentoo"; break;
|
---|
201 | case VBOXOSTYPE_Mandriva: pszOs = "Mandriva"; break;
|
---|
202 | case VBOXOSTYPE_RedHat: pszOs = "RedHat"; break;
|
---|
203 | case VBOXOSTYPE_Turbolinux: pszOs = "TurboLinux"; break;
|
---|
204 | case VBOXOSTYPE_Ubuntu: pszOs = "Ubuntu"; break;
|
---|
205 | case VBOXOSTYPE_Xandros: pszOs = "Xandros"; break;
|
---|
206 | case VBOXOSTYPE_Oracle: pszOs = "Oracle Linux"; break;
|
---|
207 | case VBOXOSTYPE_FreeBSD: pszOs = "FreeBSD"; break;
|
---|
208 | case VBOXOSTYPE_OpenBSD: pszOs = "OpenBSD"; break;
|
---|
209 | case VBOXOSTYPE_NetBSD: pszOs = "NetBSD"; break;
|
---|
210 | case VBOXOSTYPE_Netware: pszOs = "Netware"; break;
|
---|
211 | case VBOXOSTYPE_Solaris: pszOs = "Solaris"; break;
|
---|
212 | case VBOXOSTYPE_OpenSolaris: pszOs = "OpenSolaris"; break;
|
---|
213 | case VBOXOSTYPE_Solaris11_x64 & ~VBOXOSTYPE_x64: pszOs = "Solaris 11"; break;
|
---|
214 | case VBOXOSTYPE_MacOS: pszOs = "Mac OS X"; break;
|
---|
215 | case VBOXOSTYPE_MacOS106: pszOs = "Mac OS X 10.6"; break;
|
---|
216 | case VBOXOSTYPE_MacOS107_x64 & ~VBOXOSTYPE_x64: pszOs = "Mac OS X 10.7"; break;
|
---|
217 | case VBOXOSTYPE_MacOS108_x64 & ~VBOXOSTYPE_x64: pszOs = "Mac OS X 10.8"; break;
|
---|
218 | case VBOXOSTYPE_MacOS109_x64 & ~VBOXOSTYPE_x64: pszOs = "Mac OS X 10.9"; break;
|
---|
219 | case VBOXOSTYPE_MacOS1010_x64 & ~VBOXOSTYPE_x64: pszOs = "Mac OS X 10.10"; break;
|
---|
220 | case VBOXOSTYPE_MacOS1011_x64 & ~VBOXOSTYPE_x64: pszOs = "Mac OS X 10.11"; break;
|
---|
221 | case VBOXOSTYPE_MacOS1012_x64 & ~VBOXOSTYPE_x64: pszOs = "macOS 10.12"; break;
|
---|
222 | case VBOXOSTYPE_MacOS1013_x64 & ~VBOXOSTYPE_x64: pszOs = "macOS 10.13"; break;
|
---|
223 | case VBOXOSTYPE_Haiku: pszOs = "Haiku"; break;
|
---|
224 | default: pszOs = "unknown"; break;
|
---|
225 | }
|
---|
226 | LogRel(("VMMDev: Guest Additions information report: Interface = 0x%08X osType = 0x%08X (%s, %u-bit)\n",
|
---|
227 | pGuestInfo->interfaceVersion, pGuestInfo->osType, pszOs,
|
---|
228 | pGuestInfo->osType & VBOXOSTYPE_x64 ? 64 : 32));
|
---|
229 | }
|
---|
230 |
|
---|
231 | /**
|
---|
232 | * Sets the IRQ (raise it or lower it) for 1.03 additions.
|
---|
233 | *
|
---|
234 | * @param pThis The VMMDev state.
|
---|
235 | * @thread Any.
|
---|
236 | * @remarks Must be called owning the critical section.
|
---|
237 | */
|
---|
238 | static void vmmdevSetIRQ_Legacy(PVMMDEV pThis)
|
---|
239 | {
|
---|
240 | if (pThis->fu32AdditionsOk)
|
---|
241 | {
|
---|
242 | /* Filter unsupported events */
|
---|
243 | uint32_t fEvents = pThis->u32HostEventFlags & pThis->pVMMDevRAMR3->V.V1_03.u32GuestEventMask;
|
---|
244 |
|
---|
245 | Log(("vmmdevSetIRQ: fEvents=%#010x, u32HostEventFlags=%#010x, u32GuestEventMask=%#010x.\n",
|
---|
246 | fEvents, pThis->u32HostEventFlags, pThis->pVMMDevRAMR3->V.V1_03.u32GuestEventMask));
|
---|
247 |
|
---|
248 | /* Move event flags to VMMDev RAM */
|
---|
249 | pThis->pVMMDevRAMR3->V.V1_03.u32HostEvents = fEvents;
|
---|
250 |
|
---|
251 | uint32_t uIRQLevel = 0;
|
---|
252 | if (fEvents)
|
---|
253 | {
|
---|
254 | /* Clear host flags which will be delivered to guest. */
|
---|
255 | pThis->u32HostEventFlags &= ~fEvents;
|
---|
256 | Log(("vmmdevSetIRQ: u32HostEventFlags=%#010x\n", pThis->u32HostEventFlags));
|
---|
257 | uIRQLevel = 1;
|
---|
258 | }
|
---|
259 |
|
---|
260 | /* Set IRQ level for pin 0 (see NoWait comment in vmmdevMaybeSetIRQ). */
|
---|
261 | /** @todo make IRQ pin configurable, at least a symbolic constant */
|
---|
262 | PDMDevHlpPCISetIrqNoWait(pThis->pDevIns, 0, uIRQLevel);
|
---|
263 | Log(("vmmdevSetIRQ: IRQ set %d\n", uIRQLevel));
|
---|
264 | }
|
---|
265 | else
|
---|
266 | Log(("vmmdevSetIRQ: IRQ is not generated, guest has not yet reported to us.\n"));
|
---|
267 | }
|
---|
268 |
|
---|
269 | /**
|
---|
270 | * Sets the IRQ if there are events to be delivered.
|
---|
271 | *
|
---|
272 | * @param pThis The VMMDev state.
|
---|
273 | * @thread Any.
|
---|
274 | * @remarks Must be called owning the critical section.
|
---|
275 | */
|
---|
276 | static void vmmdevMaybeSetIRQ(PVMMDEV pThis)
|
---|
277 | {
|
---|
278 | Log3(("vmmdevMaybeSetIRQ: u32HostEventFlags=%#010x, u32GuestFilterMask=%#010x.\n",
|
---|
279 | pThis->u32HostEventFlags, pThis->u32GuestFilterMask));
|
---|
280 |
|
---|
281 | if (pThis->u32HostEventFlags & pThis->u32GuestFilterMask)
|
---|
282 | {
|
---|
283 | /*
|
---|
284 | * Note! No need to wait for the IRQs to be set (if we're not luck
|
---|
285 | * with the locks, etc). It is a notification about something,
|
---|
286 | * which has already happened.
|
---|
287 | */
|
---|
288 | pThis->pVMMDevRAMR3->V.V1_04.fHaveEvents = true;
|
---|
289 | PDMDevHlpPCISetIrqNoWait(pThis->pDevIns, 0, 1);
|
---|
290 | Log3(("vmmdevMaybeSetIRQ: IRQ set.\n"));
|
---|
291 | }
|
---|
292 | }
|
---|
293 |
|
---|
294 | /**
|
---|
295 | * Notifies the guest about new events (@a fAddEvents).
|
---|
296 | *
|
---|
297 | * @param pThis The VMMDev state.
|
---|
298 | * @param fAddEvents New events to add.
|
---|
299 | * @thread Any.
|
---|
300 | * @remarks Must be called owning the critical section.
|
---|
301 | */
|
---|
302 | static void vmmdevNotifyGuestWorker(PVMMDEV pThis, uint32_t fAddEvents)
|
---|
303 | {
|
---|
304 | Log3(("vmmdevNotifyGuestWorker: fAddEvents=%#010x.\n", fAddEvents));
|
---|
305 | Assert(PDMCritSectIsOwner(&pThis->CritSect));
|
---|
306 |
|
---|
307 | if (!VMMDEV_INTERFACE_VERSION_IS_1_03(pThis))
|
---|
308 | {
|
---|
309 | Log3(("vmmdevNotifyGuestWorker: New additions detected.\n"));
|
---|
310 |
|
---|
311 | if (pThis->fu32AdditionsOk)
|
---|
312 | {
|
---|
313 | const bool fHadEvents = (pThis->u32HostEventFlags & pThis->u32GuestFilterMask) != 0;
|
---|
314 |
|
---|
315 | Log3(("vmmdevNotifyGuestWorker: fHadEvents=%d, u32HostEventFlags=%#010x, u32GuestFilterMask=%#010x.\n",
|
---|
316 | fHadEvents, pThis->u32HostEventFlags, pThis->u32GuestFilterMask));
|
---|
317 |
|
---|
318 | pThis->u32HostEventFlags |= fAddEvents;
|
---|
319 |
|
---|
320 | if (!fHadEvents)
|
---|
321 | vmmdevMaybeSetIRQ(pThis);
|
---|
322 | }
|
---|
323 | else
|
---|
324 | {
|
---|
325 | pThis->u32HostEventFlags |= fAddEvents;
|
---|
326 | Log(("vmmdevNotifyGuestWorker: IRQ is not generated, guest has not yet reported to us.\n"));
|
---|
327 | }
|
---|
328 | }
|
---|
329 | else
|
---|
330 | {
|
---|
331 | Log3(("vmmdevNotifyGuestWorker: Old additions detected.\n"));
|
---|
332 |
|
---|
333 | pThis->u32HostEventFlags |= fAddEvents;
|
---|
334 | vmmdevSetIRQ_Legacy(pThis);
|
---|
335 | }
|
---|
336 | }
|
---|
337 |
|
---|
338 |
|
---|
339 |
|
---|
340 | /* -=-=-=-=- Interfaces shared with VMMDevHGCM.cpp -=-=-=-=- */
|
---|
341 |
|
---|
342 | /**
|
---|
343 | * Notifies the guest about new events (@a fAddEvents).
|
---|
344 | *
|
---|
345 | * This is used by VMMDev.cpp as well as VMMDevHGCM.cpp.
|
---|
346 | *
|
---|
347 | * @param pThis The VMMDev state.
|
---|
348 | * @param fAddEvents New events to add.
|
---|
349 | * @thread Any.
|
---|
350 | */
|
---|
351 | void VMMDevNotifyGuest(PVMMDEV pThis, uint32_t fAddEvents)
|
---|
352 | {
|
---|
353 | Log3(("VMMDevNotifyGuest: fAddEvents=%#010x\n", fAddEvents));
|
---|
354 |
|
---|
355 | /*
|
---|
356 | * Only notify the VM when it's running.
|
---|
357 | */
|
---|
358 | VMSTATE enmVMState = PDMDevHlpVMState(pThis->pDevIns);
|
---|
359 | /** @todo r=bird: Shouldn't there be more states here? Wouldn't we drop
|
---|
360 | * notifications now when we're in the process of suspending or
|
---|
361 | * similar? */
|
---|
362 | if ( enmVMState == VMSTATE_RUNNING
|
---|
363 | || enmVMState == VMSTATE_RUNNING_LS)
|
---|
364 | {
|
---|
365 | PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
|
---|
366 | vmmdevNotifyGuestWorker(pThis, fAddEvents);
|
---|
367 | PDMCritSectLeave(&pThis->CritSect);
|
---|
368 | }
|
---|
369 | }
|
---|
370 |
|
---|
371 | /**
|
---|
372 | * Code shared by VMMDevReq_CtlGuestFilterMask and HGCM for controlling the
|
---|
373 | * events the guest are interested in.
|
---|
374 | *
|
---|
375 | * @param pThis The VMMDev state.
|
---|
376 | * @param fOrMask Events to add (VMMDEV_EVENT_XXX). Pass 0 for no
|
---|
377 | * change.
|
---|
378 | * @param fNotMask Events to remove (VMMDEV_EVENT_XXX). Pass 0 for no
|
---|
379 | * change.
|
---|
380 | *
|
---|
381 | * @remarks When HGCM will automatically enable VMMDEV_EVENT_HGCM when the guest
|
---|
382 | * starts submitting HGCM requests. Otherwise, the events are
|
---|
383 | * controlled by the guest.
|
---|
384 | */
|
---|
385 | void VMMDevCtlSetGuestFilterMask(PVMMDEV pThis, uint32_t fOrMask, uint32_t fNotMask)
|
---|
386 | {
|
---|
387 | PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
|
---|
388 |
|
---|
389 | const bool fHadEvents = (pThis->u32HostEventFlags & pThis->u32GuestFilterMask) != 0;
|
---|
390 |
|
---|
391 | Log(("VMMDevCtlSetGuestFilterMask: fOrMask=%#010x, u32NotMask=%#010x, fHadEvents=%d.\n", fOrMask, fNotMask, fHadEvents));
|
---|
392 | if (fHadEvents)
|
---|
393 | {
|
---|
394 | if (!pThis->fNewGuestFilterMask)
|
---|
395 | pThis->u32NewGuestFilterMask = pThis->u32GuestFilterMask;
|
---|
396 |
|
---|
397 | pThis->u32NewGuestFilterMask |= fOrMask;
|
---|
398 | pThis->u32NewGuestFilterMask &= ~fNotMask;
|
---|
399 | pThis->fNewGuestFilterMask = true;
|
---|
400 | }
|
---|
401 | else
|
---|
402 | {
|
---|
403 | pThis->u32GuestFilterMask |= fOrMask;
|
---|
404 | pThis->u32GuestFilterMask &= ~fNotMask;
|
---|
405 | vmmdevMaybeSetIRQ(pThis);
|
---|
406 | }
|
---|
407 |
|
---|
408 | PDMCritSectLeave(&pThis->CritSect);
|
---|
409 | }
|
---|
410 |
|
---|
411 |
|
---|
412 |
|
---|
413 | /* -=-=-=-=- Request processing functions. -=-=-=-=- */
|
---|
414 |
|
---|
415 | /**
|
---|
416 | * Handles VMMDevReq_ReportGuestInfo.
|
---|
417 | *
|
---|
418 | * @returns VBox status code that the guest should see.
|
---|
419 | * @param pThis The VMMDev instance data.
|
---|
420 | * @param pRequestHeader The header of the request to handle.
|
---|
421 | */
|
---|
422 | static int vmmdevReqHandler_ReportGuestInfo(PVMMDEV pThis, VMMDevRequestHeader *pRequestHeader)
|
---|
423 | {
|
---|
424 | AssertMsgReturn(pRequestHeader->size == sizeof(VMMDevReportGuestInfo), ("%u\n", pRequestHeader->size), VERR_INVALID_PARAMETER);
|
---|
425 | VBoxGuestInfo const *pInfo = &((VMMDevReportGuestInfo *)pRequestHeader)->guestInfo;
|
---|
426 |
|
---|
427 | if (memcmp(&pThis->guestInfo, pInfo, sizeof(*pInfo)) != 0)
|
---|
428 | {
|
---|
429 | /* Make a copy of supplied information. */
|
---|
430 | pThis->guestInfo = *pInfo;
|
---|
431 |
|
---|
432 | /* Check additions interface version. */
|
---|
433 | pThis->fu32AdditionsOk = VMMDEV_INTERFACE_VERSION_IS_OK(pThis->guestInfo.interfaceVersion);
|
---|
434 |
|
---|
435 | vmmdevLogGuestOsInfo(&pThis->guestInfo);
|
---|
436 |
|
---|
437 | if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestInfo)
|
---|
438 | pThis->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);
|
---|
439 | }
|
---|
440 |
|
---|
441 | if (!pThis->fu32AdditionsOk)
|
---|
442 | return VERR_VERSION_MISMATCH;
|
---|
443 |
|
---|
444 | /* Clear our IRQ in case it was high for whatever reason. */
|
---|
445 | PDMDevHlpPCISetIrqNoWait(pThis->pDevIns, 0, 0);
|
---|
446 |
|
---|
447 | return VINF_SUCCESS;
|
---|
448 | }
|
---|
449 |
|
---|
450 |
|
---|
451 | /**
|
---|
452 | * Handles VMMDevReq_GuestHeartbeat.
|
---|
453 | *
|
---|
454 | * @returns VBox status code that the guest should see.
|
---|
455 | * @param pThis The VMMDev instance data.
|
---|
456 | */
|
---|
457 | static int vmmDevReqHandler_GuestHeartbeat(PVMMDEV pThis)
|
---|
458 | {
|
---|
459 | int rc;
|
---|
460 | if (pThis->fHeartbeatActive)
|
---|
461 | {
|
---|
462 | uint64_t const nsNowTS = TMTimerGetNano(pThis->pFlatlinedTimer);
|
---|
463 | if (!pThis->fFlatlined)
|
---|
464 | { /* likely */ }
|
---|
465 | else
|
---|
466 | {
|
---|
467 | LogRel(("VMMDev: GuestHeartBeat: Guest is alive (gone %'llu ns)\n", nsNowTS - pThis->nsLastHeartbeatTS));
|
---|
468 | ASMAtomicWriteBool(&pThis->fFlatlined, false);
|
---|
469 | }
|
---|
470 | ASMAtomicWriteU64(&pThis->nsLastHeartbeatTS, nsNowTS);
|
---|
471 |
|
---|
472 | /* Postpone (or restart if we missed a beat) the timeout timer. */
|
---|
473 | rc = TMTimerSetNano(pThis->pFlatlinedTimer, pThis->cNsHeartbeatTimeout);
|
---|
474 | }
|
---|
475 | else
|
---|
476 | rc = VINF_SUCCESS;
|
---|
477 | return rc;
|
---|
478 | }
|
---|
479 |
|
---|
480 |
|
---|
481 | /**
|
---|
482 | * Timer that fires when where have been no heartbeats for a given time.
|
---|
483 | *
|
---|
484 | * @remarks Does not take the VMMDev critsect.
|
---|
485 | */
|
---|
486 | static DECLCALLBACK(void) vmmDevHeartbeatFlatlinedTimer(PPDMDEVINS pDevIns, PTMTIMER pTimer, void *pvUser)
|
---|
487 | {
|
---|
488 | RT_NOREF1(pDevIns);
|
---|
489 | PVMMDEV pThis = (PVMMDEV)pvUser;
|
---|
490 | if (pThis->fHeartbeatActive)
|
---|
491 | {
|
---|
492 | uint64_t cNsElapsed = TMTimerGetNano(pTimer) - pThis->nsLastHeartbeatTS;
|
---|
493 | if ( !pThis->fFlatlined
|
---|
494 | && cNsElapsed >= pThis->cNsHeartbeatInterval)
|
---|
495 | {
|
---|
496 | LogRel(("VMMDev: vmmDevHeartbeatFlatlinedTimer: Guest seems to be unresponsive. Last heartbeat received %RU64 seconds ago\n",
|
---|
497 | cNsElapsed / RT_NS_1SEC));
|
---|
498 | ASMAtomicWriteBool(&pThis->fFlatlined, true);
|
---|
499 | }
|
---|
500 | }
|
---|
501 | }
|
---|
502 |
|
---|
503 |
|
---|
504 | /**
|
---|
505 | * Handles VMMDevReq_HeartbeatConfigure.
|
---|
506 | *
|
---|
507 | * @returns VBox status code that the guest should see.
|
---|
508 | * @param pThis The VMMDev instance data.
|
---|
509 | * @param pReqHdr The header of the request to handle.
|
---|
510 | */
|
---|
511 | static int vmmDevReqHandler_HeartbeatConfigure(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
512 | {
|
---|
513 | AssertMsgReturn(pReqHdr->size == sizeof(VMMDevReqHeartbeat), ("%u\n", pReqHdr->size), VERR_INVALID_PARAMETER);
|
---|
514 | VMMDevReqHeartbeat *pReq = (VMMDevReqHeartbeat *)pReqHdr;
|
---|
515 | int rc;
|
---|
516 |
|
---|
517 | pReq->cNsInterval = pThis->cNsHeartbeatInterval;
|
---|
518 |
|
---|
519 | if (pReq->fEnabled != pThis->fHeartbeatActive)
|
---|
520 | {
|
---|
521 | ASMAtomicWriteBool(&pThis->fHeartbeatActive, pReq->fEnabled);
|
---|
522 | if (pReq->fEnabled)
|
---|
523 | {
|
---|
524 | /*
|
---|
525 | * Activate the heartbeat monitor.
|
---|
526 | */
|
---|
527 | pThis->nsLastHeartbeatTS = TMTimerGetNano(pThis->pFlatlinedTimer);
|
---|
528 | rc = TMTimerSetNano(pThis->pFlatlinedTimer, pThis->cNsHeartbeatTimeout);
|
---|
529 | if (RT_SUCCESS(rc))
|
---|
530 | LogRel(("VMMDev: Heartbeat flatline timer set to trigger after %'RU64 ns\n", pThis->cNsHeartbeatTimeout));
|
---|
531 | else
|
---|
532 | LogRel(("VMMDev: Error starting flatline timer (heartbeat): %Rrc\n", rc));
|
---|
533 | }
|
---|
534 | else
|
---|
535 | {
|
---|
536 | /*
|
---|
537 | * Deactivate the heartbeat monitor.
|
---|
538 | */
|
---|
539 | rc = TMTimerStop(pThis->pFlatlinedTimer);
|
---|
540 | LogRel(("VMMDev: Heartbeat checking timer has been stopped (rc=%Rrc)\n", rc));
|
---|
541 | }
|
---|
542 | }
|
---|
543 | else
|
---|
544 | {
|
---|
545 | LogRel(("VMMDev: vmmDevReqHandler_HeartbeatConfigure: No change (fHeartbeatActive=%RTbool)\n", pThis->fHeartbeatActive));
|
---|
546 | rc = VINF_SUCCESS;
|
---|
547 | }
|
---|
548 |
|
---|
549 | return rc;
|
---|
550 | }
|
---|
551 |
|
---|
552 |
|
---|
553 | /**
|
---|
554 | * Handles VMMDevReq_NtBugCheck.
|
---|
555 | *
|
---|
556 | * @returns VBox status code that the guest should see.
|
---|
557 | * @param pThis The VMMDev instance data.
|
---|
558 | * @param pReqHdr The header of the request to handle.
|
---|
559 | */
|
---|
560 | static int vmmDevReqHandler_NtBugCheck(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
561 | {
|
---|
562 | if (pReqHdr->size == sizeof(VMMDevReqNtBugCheck))
|
---|
563 | {
|
---|
564 | VMMDevReqNtBugCheck const *pReq = (VMMDevReqNtBugCheck const *)pReqHdr;
|
---|
565 | DBGFR3ReportBugCheck(PDMDevHlpGetVM(pThis->pDevIns), PDMDevHlpGetVMCPU(pThis->pDevIns), DBGFEVENT_BSOD_VMMDEV,
|
---|
566 | pReq->uBugCheck, pReq->auParameters[0], pReq->auParameters[1],
|
---|
567 | pReq->auParameters[2], pReq->auParameters[3]);
|
---|
568 | }
|
---|
569 | else if (pReqHdr->size == sizeof(VMMDevRequestHeader))
|
---|
570 | {
|
---|
571 | LogRel(("VMMDev: NT BugCheck w/o data.\n"));
|
---|
572 | DBGFR3ReportBugCheck(PDMDevHlpGetVM(pThis->pDevIns), PDMDevHlpGetVMCPU(pThis->pDevIns), DBGFEVENT_BSOD_VMMDEV,
|
---|
573 | 0, 0, 0, 0, 0);
|
---|
574 | }
|
---|
575 | else
|
---|
576 | return VERR_INVALID_PARAMETER;
|
---|
577 | return VINF_SUCCESS;
|
---|
578 | }
|
---|
579 |
|
---|
580 |
|
---|
581 | /**
|
---|
582 | * Validates a publisher tag.
|
---|
583 | *
|
---|
584 | * @returns true / false.
|
---|
585 | * @param pszTag Tag to validate.
|
---|
586 | */
|
---|
587 | static bool vmmdevReqIsValidPublisherTag(const char *pszTag)
|
---|
588 | {
|
---|
589 | /* Note! This character set is also found in Config.kmk. */
|
---|
590 | static char const s_szValidChars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz()[]{}+-.,";
|
---|
591 |
|
---|
592 | while (*pszTag != '\0')
|
---|
593 | {
|
---|
594 | if (!strchr(s_szValidChars, *pszTag))
|
---|
595 | return false;
|
---|
596 | pszTag++;
|
---|
597 | }
|
---|
598 | return true;
|
---|
599 | }
|
---|
600 |
|
---|
601 |
|
---|
602 | /**
|
---|
603 | * Validates a build tag.
|
---|
604 | *
|
---|
605 | * @returns true / false.
|
---|
606 | * @param pszTag Tag to validate.
|
---|
607 | */
|
---|
608 | static bool vmmdevReqIsValidBuildTag(const char *pszTag)
|
---|
609 | {
|
---|
610 | int cchPrefix;
|
---|
611 | if (!strncmp(pszTag, "RC", 2))
|
---|
612 | cchPrefix = 2;
|
---|
613 | else if (!strncmp(pszTag, "BETA", 4))
|
---|
614 | cchPrefix = 4;
|
---|
615 | else if (!strncmp(pszTag, "ALPHA", 5))
|
---|
616 | cchPrefix = 5;
|
---|
617 | else
|
---|
618 | return false;
|
---|
619 |
|
---|
620 | if (pszTag[cchPrefix] == '\0')
|
---|
621 | return true;
|
---|
622 |
|
---|
623 | uint8_t u8;
|
---|
624 | int rc = RTStrToUInt8Full(&pszTag[cchPrefix], 10, &u8);
|
---|
625 | return rc == VINF_SUCCESS;
|
---|
626 | }
|
---|
627 |
|
---|
628 |
|
---|
629 | /**
|
---|
630 | * Handles VMMDevReq_ReportGuestInfo2.
|
---|
631 | *
|
---|
632 | * @returns VBox status code that the guest should see.
|
---|
633 | * @param pThis The VMMDev instance data.
|
---|
634 | * @param pReqHdr The header of the request to handle.
|
---|
635 | */
|
---|
636 | static int vmmdevReqHandler_ReportGuestInfo2(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
637 | {
|
---|
638 | AssertMsgReturn(pReqHdr->size == sizeof(VMMDevReportGuestInfo2), ("%u\n", pReqHdr->size), VERR_INVALID_PARAMETER);
|
---|
639 | VBoxGuestInfo2 const *pInfo2 = &((VMMDevReportGuestInfo2 *)pReqHdr)->guestInfo;
|
---|
640 |
|
---|
641 | LogRel(("VMMDev: Guest Additions information report: Version %d.%d.%d r%d '%.*s'\n",
|
---|
642 | pInfo2->additionsMajor, pInfo2->additionsMinor, pInfo2->additionsBuild,
|
---|
643 | pInfo2->additionsRevision, sizeof(pInfo2->szName), pInfo2->szName));
|
---|
644 |
|
---|
645 | /* The interface was introduced in 3.2 and will definitely not be
|
---|
646 | backported beyond 3.0 (bird). */
|
---|
647 | AssertMsgReturn(pInfo2->additionsMajor >= 3,
|
---|
648 | ("%u.%u.%u\n", pInfo2->additionsMajor, pInfo2->additionsMinor, pInfo2->additionsBuild),
|
---|
649 | VERR_INVALID_PARAMETER);
|
---|
650 |
|
---|
651 | /* The version must fit in a full version compression. */
|
---|
652 | uint32_t uFullVersion = VBOX_FULL_VERSION_MAKE(pInfo2->additionsMajor, pInfo2->additionsMinor, pInfo2->additionsBuild);
|
---|
653 | AssertMsgReturn( VBOX_FULL_VERSION_GET_MAJOR(uFullVersion) == pInfo2->additionsMajor
|
---|
654 | && VBOX_FULL_VERSION_GET_MINOR(uFullVersion) == pInfo2->additionsMinor
|
---|
655 | && VBOX_FULL_VERSION_GET_BUILD(uFullVersion) == pInfo2->additionsBuild,
|
---|
656 | ("%u.%u.%u\n", pInfo2->additionsMajor, pInfo2->additionsMinor, pInfo2->additionsBuild),
|
---|
657 | VERR_OUT_OF_RANGE);
|
---|
658 |
|
---|
659 | /*
|
---|
660 | * Validate the name.
|
---|
661 | * Be less strict towards older additions (< v4.1.50).
|
---|
662 | */
|
---|
663 | AssertCompile(sizeof(pThis->guestInfo2.szName) == sizeof(pInfo2->szName));
|
---|
664 | AssertReturn(RTStrEnd(pInfo2->szName, sizeof(pInfo2->szName)) != NULL, VERR_INVALID_PARAMETER);
|
---|
665 | const char *pszName = pInfo2->szName;
|
---|
666 |
|
---|
667 | /* The version number which shouldn't be there. */
|
---|
668 | char szTmp[sizeof(pInfo2->szName)];
|
---|
669 | size_t cchStart = RTStrPrintf(szTmp, sizeof(szTmp), "%u.%u.%u", pInfo2->additionsMajor, pInfo2->additionsMinor, pInfo2->additionsBuild);
|
---|
670 | AssertMsgReturn(!strncmp(pszName, szTmp, cchStart), ("%s != %s\n", pszName, szTmp), VERR_INVALID_PARAMETER);
|
---|
671 | pszName += cchStart;
|
---|
672 |
|
---|
673 | /* Now we can either have nothing or a build tag or/and a publisher tag. */
|
---|
674 | if (*pszName != '\0')
|
---|
675 | {
|
---|
676 | const char *pszRelaxedName = "";
|
---|
677 | bool const fStrict = pInfo2->additionsMajor > 4
|
---|
678 | || (pInfo2->additionsMajor == 4 && pInfo2->additionsMinor > 1)
|
---|
679 | || (pInfo2->additionsMajor == 4 && pInfo2->additionsMinor == 1 && pInfo2->additionsBuild >= 50);
|
---|
680 | bool fOk = false;
|
---|
681 | if (*pszName == '_')
|
---|
682 | {
|
---|
683 | pszName++;
|
---|
684 | strcpy(szTmp, pszName);
|
---|
685 | char *pszTag2 = strchr(szTmp, '_');
|
---|
686 | if (!pszTag2)
|
---|
687 | {
|
---|
688 | fOk = vmmdevReqIsValidBuildTag(szTmp)
|
---|
689 | || vmmdevReqIsValidPublisherTag(szTmp);
|
---|
690 | }
|
---|
691 | else
|
---|
692 | {
|
---|
693 | *pszTag2++ = '\0';
|
---|
694 | fOk = vmmdevReqIsValidBuildTag(szTmp);
|
---|
695 | if (fOk)
|
---|
696 | {
|
---|
697 | fOk = vmmdevReqIsValidPublisherTag(pszTag2);
|
---|
698 | if (!fOk)
|
---|
699 | pszRelaxedName = szTmp;
|
---|
700 | }
|
---|
701 | }
|
---|
702 | }
|
---|
703 |
|
---|
704 | if (!fOk)
|
---|
705 | {
|
---|
706 | AssertLogRelMsgReturn(!fStrict, ("%s", pszName), VERR_INVALID_PARAMETER);
|
---|
707 |
|
---|
708 | /* non-strict mode, just zap the extra stuff. */
|
---|
709 | LogRel(("VMMDev: ReportGuestInfo2: Ignoring unparsable version name bits: '%s' -> '%s'.\n", pszName, pszRelaxedName));
|
---|
710 | pszName = pszRelaxedName;
|
---|
711 | }
|
---|
712 | }
|
---|
713 |
|
---|
714 | /*
|
---|
715 | * Save the info and tell Main or whoever is listening.
|
---|
716 | */
|
---|
717 | pThis->guestInfo2.uFullVersion = uFullVersion;
|
---|
718 | pThis->guestInfo2.uRevision = pInfo2->additionsRevision;
|
---|
719 | pThis->guestInfo2.fFeatures = pInfo2->additionsFeatures;
|
---|
720 | strcpy(pThis->guestInfo2.szName, pszName);
|
---|
721 |
|
---|
722 | if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestInfo2)
|
---|
723 | pThis->pDrv->pfnUpdateGuestInfo2(pThis->pDrv, uFullVersion, pszName, pInfo2->additionsRevision, pInfo2->additionsFeatures);
|
---|
724 |
|
---|
725 | /* Clear our IRQ in case it was high for whatever reason. */
|
---|
726 | PDMDevHlpPCISetIrqNoWait(pThis->pDevIns, 0, 0);
|
---|
727 |
|
---|
728 | return VINF_SUCCESS;
|
---|
729 | }
|
---|
730 |
|
---|
731 |
|
---|
732 | /**
|
---|
733 | * Allocates a new facility status entry, initializing it to inactive.
|
---|
734 | *
|
---|
735 | * @returns Pointer to a facility status entry on success, NULL on failure
|
---|
736 | * (table full).
|
---|
737 | * @param pThis The VMMDev instance data.
|
---|
738 | * @param enmFacility The facility type code.
|
---|
739 | * @param fFixed This is set when allocating the standard entries
|
---|
740 | * from the constructor.
|
---|
741 | * @param pTimeSpecNow Optionally giving the entry timestamp to use (ctor).
|
---|
742 | */
|
---|
743 | static PVMMDEVFACILITYSTATUSENTRY
|
---|
744 | vmmdevAllocFacilityStatusEntry(PVMMDEV pThis, VBoxGuestFacilityType enmFacility, bool fFixed, PCRTTIMESPEC pTimeSpecNow)
|
---|
745 | {
|
---|
746 | /* If full, expunge one inactive entry. */
|
---|
747 | if (pThis->cFacilityStatuses == RT_ELEMENTS(pThis->aFacilityStatuses))
|
---|
748 | {
|
---|
749 | uint32_t i = pThis->cFacilityStatuses;
|
---|
750 | while (i-- > 0)
|
---|
751 | {
|
---|
752 | if ( pThis->aFacilityStatuses[i].enmStatus == VBoxGuestFacilityStatus_Inactive
|
---|
753 | && !pThis->aFacilityStatuses[i].fFixed)
|
---|
754 | {
|
---|
755 | pThis->cFacilityStatuses--;
|
---|
756 | int cToMove = pThis->cFacilityStatuses - i;
|
---|
757 | if (cToMove)
|
---|
758 | memmove(&pThis->aFacilityStatuses[i], &pThis->aFacilityStatuses[i + 1],
|
---|
759 | cToMove * sizeof(pThis->aFacilityStatuses[i]));
|
---|
760 | RT_ZERO(pThis->aFacilityStatuses[pThis->cFacilityStatuses]);
|
---|
761 | break;
|
---|
762 | }
|
---|
763 | }
|
---|
764 |
|
---|
765 | if (pThis->cFacilityStatuses == RT_ELEMENTS(pThis->aFacilityStatuses))
|
---|
766 | return NULL;
|
---|
767 | }
|
---|
768 |
|
---|
769 | /* Find location in array (it's sorted). */
|
---|
770 | uint32_t i = pThis->cFacilityStatuses;
|
---|
771 | while (i-- > 0)
|
---|
772 | if ((uint32_t)pThis->aFacilityStatuses[i].enmFacility < (uint32_t)enmFacility)
|
---|
773 | break;
|
---|
774 | i++;
|
---|
775 |
|
---|
776 | /* Move. */
|
---|
777 | int cToMove = pThis->cFacilityStatuses - i;
|
---|
778 | if (cToMove > 0)
|
---|
779 | memmove(&pThis->aFacilityStatuses[i + 1], &pThis->aFacilityStatuses[i],
|
---|
780 | cToMove * sizeof(pThis->aFacilityStatuses[i]));
|
---|
781 | pThis->cFacilityStatuses++;
|
---|
782 |
|
---|
783 | /* Initialize. */
|
---|
784 | pThis->aFacilityStatuses[i].enmFacility = enmFacility;
|
---|
785 | pThis->aFacilityStatuses[i].enmStatus = VBoxGuestFacilityStatus_Inactive;
|
---|
786 | pThis->aFacilityStatuses[i].fFixed = fFixed;
|
---|
787 | pThis->aFacilityStatuses[i].afPadding[0] = 0;
|
---|
788 | pThis->aFacilityStatuses[i].afPadding[1] = 0;
|
---|
789 | pThis->aFacilityStatuses[i].afPadding[2] = 0;
|
---|
790 | pThis->aFacilityStatuses[i].fFlags = 0;
|
---|
791 | if (pTimeSpecNow)
|
---|
792 | pThis->aFacilityStatuses[i].TimeSpecTS = *pTimeSpecNow;
|
---|
793 | else
|
---|
794 | RTTimeSpecSetNano(&pThis->aFacilityStatuses[i].TimeSpecTS, 0);
|
---|
795 |
|
---|
796 | return &pThis->aFacilityStatuses[i];
|
---|
797 | }
|
---|
798 |
|
---|
799 |
|
---|
800 | /**
|
---|
801 | * Gets a facility status entry, allocating a new one if not already present.
|
---|
802 | *
|
---|
803 | * @returns Pointer to a facility status entry on success, NULL on failure
|
---|
804 | * (table full).
|
---|
805 | * @param pThis The VMMDev instance data.
|
---|
806 | * @param enmFacility The facility type code.
|
---|
807 | */
|
---|
808 | static PVMMDEVFACILITYSTATUSENTRY vmmdevGetFacilityStatusEntry(PVMMDEV pThis, VBoxGuestFacilityType enmFacility)
|
---|
809 | {
|
---|
810 | /** @todo change to binary search. */
|
---|
811 | uint32_t i = pThis->cFacilityStatuses;
|
---|
812 | while (i-- > 0)
|
---|
813 | {
|
---|
814 | if (pThis->aFacilityStatuses[i].enmFacility == enmFacility)
|
---|
815 | return &pThis->aFacilityStatuses[i];
|
---|
816 | if ((uint32_t)pThis->aFacilityStatuses[i].enmFacility < (uint32_t)enmFacility)
|
---|
817 | break;
|
---|
818 | }
|
---|
819 | return vmmdevAllocFacilityStatusEntry(pThis, enmFacility, false /*fFixed*/, NULL);
|
---|
820 | }
|
---|
821 |
|
---|
822 |
|
---|
823 | /**
|
---|
824 | * Handles VMMDevReq_ReportGuestStatus.
|
---|
825 | *
|
---|
826 | * @returns VBox status code that the guest should see.
|
---|
827 | * @param pThis The VMMDev instance data.
|
---|
828 | * @param pReqHdr The header of the request to handle.
|
---|
829 | */
|
---|
830 | static int vmmdevReqHandler_ReportGuestStatus(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
831 | {
|
---|
832 | /*
|
---|
833 | * Validate input.
|
---|
834 | */
|
---|
835 | AssertMsgReturn(pReqHdr->size == sizeof(VMMDevReportGuestStatus), ("%u\n", pReqHdr->size), VERR_INVALID_PARAMETER);
|
---|
836 | VBoxGuestStatus *pStatus = &((VMMDevReportGuestStatus *)pReqHdr)->guestStatus;
|
---|
837 | AssertMsgReturn( pStatus->facility > VBoxGuestFacilityType_Unknown
|
---|
838 | && pStatus->facility <= VBoxGuestFacilityType_All,
|
---|
839 | ("%d\n", pStatus->facility),
|
---|
840 | VERR_INVALID_PARAMETER);
|
---|
841 | AssertMsgReturn(pStatus->status == (VBoxGuestFacilityStatus)(uint16_t)pStatus->status,
|
---|
842 | ("%#x (%u)\n", pStatus->status, pStatus->status),
|
---|
843 | VERR_OUT_OF_RANGE);
|
---|
844 |
|
---|
845 | /*
|
---|
846 | * Do the update.
|
---|
847 | */
|
---|
848 | RTTIMESPEC Now;
|
---|
849 | RTTimeNow(&Now);
|
---|
850 | if (pStatus->facility == VBoxGuestFacilityType_All)
|
---|
851 | {
|
---|
852 | uint32_t i = pThis->cFacilityStatuses;
|
---|
853 | while (i-- > 0)
|
---|
854 | {
|
---|
855 | pThis->aFacilityStatuses[i].TimeSpecTS = Now;
|
---|
856 | pThis->aFacilityStatuses[i].enmStatus = pStatus->status;
|
---|
857 | pThis->aFacilityStatuses[i].fFlags = pStatus->flags;
|
---|
858 | }
|
---|
859 | }
|
---|
860 | else
|
---|
861 | {
|
---|
862 | PVMMDEVFACILITYSTATUSENTRY pEntry = vmmdevGetFacilityStatusEntry(pThis, pStatus->facility);
|
---|
863 | if (!pEntry)
|
---|
864 | {
|
---|
865 | LogRelMax(10, ("VMMDev: Facility table is full - facility=%u status=%u\n", pStatus->facility, pStatus->status));
|
---|
866 | return VERR_OUT_OF_RESOURCES;
|
---|
867 | }
|
---|
868 |
|
---|
869 | pEntry->TimeSpecTS = Now;
|
---|
870 | pEntry->enmStatus = pStatus->status;
|
---|
871 | pEntry->fFlags = pStatus->flags;
|
---|
872 | }
|
---|
873 |
|
---|
874 | if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestStatus)
|
---|
875 | pThis->pDrv->pfnUpdateGuestStatus(pThis->pDrv, pStatus->facility, pStatus->status, pStatus->flags, &Now);
|
---|
876 |
|
---|
877 | return VINF_SUCCESS;
|
---|
878 | }
|
---|
879 |
|
---|
880 |
|
---|
881 | /**
|
---|
882 | * Handles VMMDevReq_ReportGuestUserState.
|
---|
883 | *
|
---|
884 | * @returns VBox status code that the guest should see.
|
---|
885 | * @param pThis The VMMDev instance data.
|
---|
886 | * @param pReqHdr The header of the request to handle.
|
---|
887 | */
|
---|
888 | static int vmmdevReqHandler_ReportGuestUserState(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
889 | {
|
---|
890 | /*
|
---|
891 | * Validate input.
|
---|
892 | */
|
---|
893 | VMMDevReportGuestUserState *pReq = (VMMDevReportGuestUserState *)pReqHdr;
|
---|
894 | AssertMsgReturn(pReq->header.size >= sizeof(*pReq), ("%u\n", pReqHdr->size), VERR_INVALID_PARAMETER);
|
---|
895 |
|
---|
896 | if ( pThis->pDrv
|
---|
897 | && pThis->pDrv->pfnUpdateGuestUserState)
|
---|
898 | {
|
---|
899 | /* Play safe. */
|
---|
900 | AssertReturn(pReq->header.size <= _2K, VERR_TOO_MUCH_DATA);
|
---|
901 | AssertReturn(pReq->status.cbUser <= 256, VERR_TOO_MUCH_DATA);
|
---|
902 | AssertReturn(pReq->status.cbDomain <= 256, VERR_TOO_MUCH_DATA);
|
---|
903 | AssertReturn(pReq->status.cbDetails <= _1K, VERR_TOO_MUCH_DATA);
|
---|
904 |
|
---|
905 | /* pbDynamic marks the beginning of the struct's dynamically
|
---|
906 | * allocated data area. */
|
---|
907 | uint8_t *pbDynamic = (uint8_t *)&pReq->status.szUser;
|
---|
908 | uint32_t cbLeft = pReqHdr->size - RT_UOFFSETOF(VMMDevReportGuestUserState, status.szUser);
|
---|
909 |
|
---|
910 | /* The user. */
|
---|
911 | AssertReturn(pReq->status.cbUser > 0, VERR_INVALID_PARAMETER); /* User name is required. */
|
---|
912 | AssertReturn(pReq->status.cbUser <= cbLeft, VERR_INVALID_PARAMETER);
|
---|
913 | const char *pszUser = (const char *)pbDynamic;
|
---|
914 | AssertReturn(RTStrEnd(pszUser, pReq->status.cbUser), VERR_INVALID_PARAMETER);
|
---|
915 | int rc = RTStrValidateEncoding(pszUser);
|
---|
916 | AssertRCReturn(rc, rc);
|
---|
917 |
|
---|
918 | /* Advance to the next field. */
|
---|
919 | pbDynamic += pReq->status.cbUser;
|
---|
920 | cbLeft -= pReq->status.cbUser;
|
---|
921 |
|
---|
922 | /* pszDomain can be NULL. */
|
---|
923 | AssertReturn(pReq->status.cbDomain <= cbLeft, VERR_INVALID_PARAMETER);
|
---|
924 | const char *pszDomain = NULL;
|
---|
925 | if (pReq->status.cbDomain)
|
---|
926 | {
|
---|
927 | pszDomain = (const char *)pbDynamic;
|
---|
928 | AssertReturn(RTStrEnd(pszDomain, pReq->status.cbDomain), VERR_INVALID_PARAMETER);
|
---|
929 | rc = RTStrValidateEncoding(pszDomain);
|
---|
930 | AssertRCReturn(rc, rc);
|
---|
931 |
|
---|
932 | /* Advance to the next field. */
|
---|
933 | pbDynamic += pReq->status.cbDomain;
|
---|
934 | cbLeft -= pReq->status.cbDomain;
|
---|
935 | }
|
---|
936 |
|
---|
937 | /* pbDetails can be NULL. */
|
---|
938 | const uint8_t *pbDetails = NULL;
|
---|
939 | AssertReturn(pReq->status.cbDetails <= cbLeft, VERR_INVALID_PARAMETER);
|
---|
940 | if (pReq->status.cbDetails > 0)
|
---|
941 | pbDetails = pbDynamic;
|
---|
942 |
|
---|
943 | pThis->pDrv->pfnUpdateGuestUserState(pThis->pDrv, pszUser, pszDomain, (uint32_t)pReq->status.state,
|
---|
944 | pbDetails, pReq->status.cbDetails);
|
---|
945 | }
|
---|
946 |
|
---|
947 | return VINF_SUCCESS;
|
---|
948 | }
|
---|
949 |
|
---|
950 |
|
---|
951 | /**
|
---|
952 | * Handles VMMDevReq_ReportGuestCapabilities.
|
---|
953 | *
|
---|
954 | * @returns VBox status code that the guest should see.
|
---|
955 | * @param pThis The VMMDev instance data.
|
---|
956 | * @param pReqHdr The header of the request to handle.
|
---|
957 | */
|
---|
958 | static int vmmdevReqHandler_ReportGuestCapabilities(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
959 | {
|
---|
960 | VMMDevReqGuestCapabilities *pReq = (VMMDevReqGuestCapabilities *)pReqHdr;
|
---|
961 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
962 |
|
---|
963 | /* Enable VMMDEV_GUEST_SUPPORTS_GRAPHICS automatically for guests using the old
|
---|
964 | * request to report their capabilities.
|
---|
965 | */
|
---|
966 | const uint32_t fu32Caps = pReq->caps | VMMDEV_GUEST_SUPPORTS_GRAPHICS;
|
---|
967 |
|
---|
968 | if (pThis->guestCaps != fu32Caps)
|
---|
969 | {
|
---|
970 | /* make a copy of supplied information */
|
---|
971 | pThis->guestCaps = fu32Caps;
|
---|
972 |
|
---|
973 | LogRel(("VMMDev: Guest Additions capability report (legacy): (0x%x) seamless: %s, hostWindowMapping: %s, graphics: yes\n",
|
---|
974 | fu32Caps,
|
---|
975 | fu32Caps & VMMDEV_GUEST_SUPPORTS_SEAMLESS ? "yes" : "no",
|
---|
976 | fu32Caps & VMMDEV_GUEST_SUPPORTS_GUEST_HOST_WINDOW_MAPPING ? "yes" : "no"));
|
---|
977 |
|
---|
978 | if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestCapabilities)
|
---|
979 | pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, fu32Caps);
|
---|
980 | }
|
---|
981 | return VINF_SUCCESS;
|
---|
982 | }
|
---|
983 |
|
---|
984 |
|
---|
985 | /**
|
---|
986 | * Handles VMMDevReq_SetGuestCapabilities.
|
---|
987 | *
|
---|
988 | * @returns VBox status code that the guest should see.
|
---|
989 | * @param pThis The VMMDev instance data.
|
---|
990 | * @param pReqHdr The header of the request to handle.
|
---|
991 | */
|
---|
992 | static int vmmdevReqHandler_SetGuestCapabilities(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
993 | {
|
---|
994 | VMMDevReqGuestCapabilities2 *pReq = (VMMDevReqGuestCapabilities2 *)pReqHdr;
|
---|
995 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
996 |
|
---|
997 | uint32_t fu32Caps = pThis->guestCaps;
|
---|
998 | fu32Caps |= pReq->u32OrMask;
|
---|
999 | fu32Caps &= ~pReq->u32NotMask;
|
---|
1000 |
|
---|
1001 | LogRel(("VMMDev: Guest Additions capability report: (%#x -> %#x) seamless: %s, hostWindowMapping: %s, graphics: %s\n",
|
---|
1002 | pThis->guestCaps, fu32Caps,
|
---|
1003 | fu32Caps & VMMDEV_GUEST_SUPPORTS_SEAMLESS ? "yes" : "no",
|
---|
1004 | fu32Caps & VMMDEV_GUEST_SUPPORTS_GUEST_HOST_WINDOW_MAPPING ? "yes" : "no",
|
---|
1005 | fu32Caps & VMMDEV_GUEST_SUPPORTS_GRAPHICS ? "yes" : "no"));
|
---|
1006 |
|
---|
1007 | pThis->guestCaps = fu32Caps;
|
---|
1008 |
|
---|
1009 | if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestCapabilities)
|
---|
1010 | pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, fu32Caps);
|
---|
1011 |
|
---|
1012 | return VINF_SUCCESS;
|
---|
1013 | }
|
---|
1014 |
|
---|
1015 |
|
---|
1016 | /**
|
---|
1017 | * Handles VMMDevReq_GetMouseStatus.
|
---|
1018 | *
|
---|
1019 | * @returns VBox status code that the guest should see.
|
---|
1020 | * @param pThis The VMMDev instance data.
|
---|
1021 | * @param pReqHdr The header of the request to handle.
|
---|
1022 | */
|
---|
1023 | static int vmmdevReqHandler_GetMouseStatus(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1024 | {
|
---|
1025 | VMMDevReqMouseStatus *pReq = (VMMDevReqMouseStatus *)pReqHdr;
|
---|
1026 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1027 |
|
---|
1028 | pReq->mouseFeatures = pThis->mouseCapabilities
|
---|
1029 | & VMMDEV_MOUSE_MASK;
|
---|
1030 | pReq->pointerXPos = pThis->mouseXAbs;
|
---|
1031 | pReq->pointerYPos = pThis->mouseYAbs;
|
---|
1032 | LogRel2(("VMMDev: vmmdevReqHandler_GetMouseStatus: mouseFeatures=%#x, xAbs=%d, yAbs=%d\n",
|
---|
1033 | pReq->mouseFeatures, pReq->pointerXPos, pReq->pointerYPos));
|
---|
1034 | return VINF_SUCCESS;
|
---|
1035 | }
|
---|
1036 |
|
---|
1037 |
|
---|
1038 | /**
|
---|
1039 | * Handles VMMDevReq_SetMouseStatus.
|
---|
1040 | *
|
---|
1041 | * @returns VBox status code that the guest should see.
|
---|
1042 | * @param pThis The VMMDev instance data.
|
---|
1043 | * @param pReqHdr The header of the request to handle.
|
---|
1044 | */
|
---|
1045 | static int vmmdevReqHandler_SetMouseStatus(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1046 | {
|
---|
1047 | VMMDevReqMouseStatus *pReq = (VMMDevReqMouseStatus *)pReqHdr;
|
---|
1048 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1049 |
|
---|
1050 | LogRelFlow(("VMMDev: vmmdevReqHandler_SetMouseStatus: mouseFeatures=%#x\n", pReq->mouseFeatures));
|
---|
1051 |
|
---|
1052 | bool fNotify = false;
|
---|
1053 | if ( (pReq->mouseFeatures & VMMDEV_MOUSE_NOTIFY_HOST_MASK)
|
---|
1054 | != ( pThis->mouseCapabilities
|
---|
1055 | & VMMDEV_MOUSE_NOTIFY_HOST_MASK))
|
---|
1056 | fNotify = true;
|
---|
1057 |
|
---|
1058 | pThis->mouseCapabilities &= ~VMMDEV_MOUSE_GUEST_MASK;
|
---|
1059 | pThis->mouseCapabilities |= (pReq->mouseFeatures & VMMDEV_MOUSE_GUEST_MASK);
|
---|
1060 |
|
---|
1061 | LogRelFlow(("VMMDev: vmmdevReqHandler_SetMouseStatus: New host capabilities: %#x\n", pThis->mouseCapabilities));
|
---|
1062 |
|
---|
1063 | /*
|
---|
1064 | * Notify connector if something changed.
|
---|
1065 | */
|
---|
1066 | if (fNotify)
|
---|
1067 | {
|
---|
1068 | LogRelFlow(("VMMDev: vmmdevReqHandler_SetMouseStatus: Notifying connector\n"));
|
---|
1069 | pThis->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->mouseCapabilities);
|
---|
1070 | }
|
---|
1071 |
|
---|
1072 | return VINF_SUCCESS;
|
---|
1073 | }
|
---|
1074 |
|
---|
1075 | static int vmmdevVerifyPointerShape(VMMDevReqMousePointer *pReq)
|
---|
1076 | {
|
---|
1077 | /* Should be enough for most mouse pointers. */
|
---|
1078 | if (pReq->width > 8192 || pReq->height > 8192)
|
---|
1079 | return VERR_INVALID_PARAMETER;
|
---|
1080 |
|
---|
1081 | uint32_t cbShape = (pReq->width + 7) / 8 * pReq->height; /* size of the AND mask */
|
---|
1082 | cbShape = ((cbShape + 3) & ~3) + pReq->width * 4 * pReq->height; /* + gap + size of the XOR mask */
|
---|
1083 | if (RT_UOFFSETOF(VMMDevReqMousePointer, pointerData) + cbShape > pReq->header.size)
|
---|
1084 | return VERR_INVALID_PARAMETER;
|
---|
1085 |
|
---|
1086 | return VINF_SUCCESS;
|
---|
1087 | }
|
---|
1088 |
|
---|
1089 | /**
|
---|
1090 | * Handles VMMDevReq_SetPointerShape.
|
---|
1091 | *
|
---|
1092 | * @returns VBox status code that the guest should see.
|
---|
1093 | * @param pThis The VMMDev instance data.
|
---|
1094 | * @param pReqHdr The header of the request to handle.
|
---|
1095 | */
|
---|
1096 | static int vmmdevReqHandler_SetPointerShape(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1097 | {
|
---|
1098 | VMMDevReqMousePointer *pReq = (VMMDevReqMousePointer *)pReqHdr;
|
---|
1099 | if (pReq->header.size < sizeof(*pReq))
|
---|
1100 | {
|
---|
1101 | AssertMsg(pReq->header.size == 0x10028 && pReq->header.version == 10000, /* don't complain about legacy!!! */
|
---|
1102 | ("VMMDev mouse shape structure has invalid size %d (%#x) version=%d!\n",
|
---|
1103 | pReq->header.size, pReq->header.size, pReq->header.version));
|
---|
1104 | return VERR_INVALID_PARAMETER;
|
---|
1105 | }
|
---|
1106 |
|
---|
1107 | bool fVisible = RT_BOOL(pReq->fFlags & VBOX_MOUSE_POINTER_VISIBLE);
|
---|
1108 | bool fAlpha = RT_BOOL(pReq->fFlags & VBOX_MOUSE_POINTER_ALPHA);
|
---|
1109 | bool fShape = RT_BOOL(pReq->fFlags & VBOX_MOUSE_POINTER_SHAPE);
|
---|
1110 |
|
---|
1111 | Log(("VMMDevReq_SetPointerShape: visible: %d, alpha: %d, shape = %d, width: %d, height: %d\n",
|
---|
1112 | fVisible, fAlpha, fShape, pReq->width, pReq->height));
|
---|
1113 |
|
---|
1114 | if (pReq->header.size == sizeof(VMMDevReqMousePointer))
|
---|
1115 | {
|
---|
1116 | /* The guest did not provide the shape actually. */
|
---|
1117 | fShape = false;
|
---|
1118 | }
|
---|
1119 |
|
---|
1120 | /* forward call to driver */
|
---|
1121 | if (fShape)
|
---|
1122 | {
|
---|
1123 | int rc = vmmdevVerifyPointerShape(pReq);
|
---|
1124 | if (RT_FAILURE(rc))
|
---|
1125 | return rc;
|
---|
1126 |
|
---|
1127 | pThis->pDrv->pfnUpdatePointerShape(pThis->pDrv,
|
---|
1128 | fVisible,
|
---|
1129 | fAlpha,
|
---|
1130 | pReq->xHot, pReq->yHot,
|
---|
1131 | pReq->width, pReq->height,
|
---|
1132 | pReq->pointerData);
|
---|
1133 | }
|
---|
1134 | else
|
---|
1135 | {
|
---|
1136 | pThis->pDrv->pfnUpdatePointerShape(pThis->pDrv,
|
---|
1137 | fVisible,
|
---|
1138 | 0,
|
---|
1139 | 0, 0,
|
---|
1140 | 0, 0,
|
---|
1141 | NULL);
|
---|
1142 | }
|
---|
1143 |
|
---|
1144 | pThis->fHostCursorRequested = fVisible;
|
---|
1145 | return VINF_SUCCESS;
|
---|
1146 | }
|
---|
1147 |
|
---|
1148 |
|
---|
1149 | /**
|
---|
1150 | * Handles VMMDevReq_GetHostTime.
|
---|
1151 | *
|
---|
1152 | * @returns VBox status code that the guest should see.
|
---|
1153 | * @param pThis The VMMDev instance data.
|
---|
1154 | * @param pReqHdr The header of the request to handle.
|
---|
1155 | */
|
---|
1156 | static int vmmdevReqHandler_GetHostTime(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1157 | {
|
---|
1158 | VMMDevReqHostTime *pReq = (VMMDevReqHostTime *)pReqHdr;
|
---|
1159 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1160 |
|
---|
1161 | if (RT_LIKELY(!pThis->fGetHostTimeDisabled))
|
---|
1162 | {
|
---|
1163 | RTTIMESPEC now;
|
---|
1164 | pReq->time = RTTimeSpecGetMilli(PDMDevHlpTMUtcNow(pThis->pDevIns, &now));
|
---|
1165 | return VINF_SUCCESS;
|
---|
1166 | }
|
---|
1167 | return VERR_NOT_SUPPORTED;
|
---|
1168 | }
|
---|
1169 |
|
---|
1170 |
|
---|
1171 | /**
|
---|
1172 | * Handles VMMDevReq_GetHypervisorInfo.
|
---|
1173 | *
|
---|
1174 | * @returns VBox status code that the guest should see.
|
---|
1175 | * @param pThis The VMMDev instance data.
|
---|
1176 | * @param pReqHdr The header of the request to handle.
|
---|
1177 | */
|
---|
1178 | static int vmmdevReqHandler_GetHypervisorInfo(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1179 | {
|
---|
1180 | VMMDevReqHypervisorInfo *pReq = (VMMDevReqHypervisorInfo *)pReqHdr;
|
---|
1181 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1182 |
|
---|
1183 | return PGMR3MappingsSize(PDMDevHlpGetVM(pThis->pDevIns), &pReq->hypervisorSize);
|
---|
1184 | }
|
---|
1185 |
|
---|
1186 |
|
---|
1187 | /**
|
---|
1188 | * Handles VMMDevReq_SetHypervisorInfo.
|
---|
1189 | *
|
---|
1190 | * @returns VBox status code that the guest should see.
|
---|
1191 | * @param pThis The VMMDev instance data.
|
---|
1192 | * @param pReqHdr The header of the request to handle.
|
---|
1193 | */
|
---|
1194 | static int vmmdevReqHandler_SetHypervisorInfo(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1195 | {
|
---|
1196 | VMMDevReqHypervisorInfo *pReq = (VMMDevReqHypervisorInfo *)pReqHdr;
|
---|
1197 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1198 |
|
---|
1199 | int rc;
|
---|
1200 | PVM pVM = PDMDevHlpGetVM(pThis->pDevIns);
|
---|
1201 | if (pReq->hypervisorStart == 0)
|
---|
1202 | rc = PGMR3MappingsUnfix(pVM);
|
---|
1203 | else
|
---|
1204 | {
|
---|
1205 | /* only if the client has queried the size before! */
|
---|
1206 | uint32_t cbMappings;
|
---|
1207 | rc = PGMR3MappingsSize(pVM, &cbMappings);
|
---|
1208 | if (RT_SUCCESS(rc) && pReq->hypervisorSize == cbMappings)
|
---|
1209 | {
|
---|
1210 | /* new reservation */
|
---|
1211 | rc = PGMR3MappingsFix(pVM, pReq->hypervisorStart, pReq->hypervisorSize);
|
---|
1212 | LogRel(("VMMDev: Guest reported fixed hypervisor window at 0%010x LB %#x (rc=%Rrc)\n",
|
---|
1213 | pReq->hypervisorStart, pReq->hypervisorSize, rc));
|
---|
1214 | }
|
---|
1215 | else if (RT_FAILURE(rc))
|
---|
1216 | rc = VERR_TRY_AGAIN;
|
---|
1217 | }
|
---|
1218 | return rc;
|
---|
1219 | }
|
---|
1220 |
|
---|
1221 |
|
---|
1222 | /**
|
---|
1223 | * Handles VMMDevReq_RegisterPatchMemory.
|
---|
1224 | *
|
---|
1225 | * @returns VBox status code that the guest should see.
|
---|
1226 | * @param pThis The VMMDev instance data.
|
---|
1227 | * @param pReqHdr The header of the request to handle.
|
---|
1228 | */
|
---|
1229 | static int vmmdevReqHandler_RegisterPatchMemory(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1230 | {
|
---|
1231 | VMMDevReqPatchMemory *pReq = (VMMDevReqPatchMemory *)pReqHdr;
|
---|
1232 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1233 |
|
---|
1234 | return VMMR3RegisterPatchMemory(PDMDevHlpGetVM(pThis->pDevIns), pReq->pPatchMem, pReq->cbPatchMem);
|
---|
1235 | }
|
---|
1236 |
|
---|
1237 |
|
---|
1238 | /**
|
---|
1239 | * Handles VMMDevReq_DeregisterPatchMemory.
|
---|
1240 | *
|
---|
1241 | * @returns VBox status code that the guest should see.
|
---|
1242 | * @param pThis The VMMDev instance data.
|
---|
1243 | * @param pReqHdr The header of the request to handle.
|
---|
1244 | */
|
---|
1245 | static int vmmdevReqHandler_DeregisterPatchMemory(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1246 | {
|
---|
1247 | VMMDevReqPatchMemory *pReq = (VMMDevReqPatchMemory *)pReqHdr;
|
---|
1248 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1249 |
|
---|
1250 | return VMMR3DeregisterPatchMemory(PDMDevHlpGetVM(pThis->pDevIns), pReq->pPatchMem, pReq->cbPatchMem);
|
---|
1251 | }
|
---|
1252 |
|
---|
1253 |
|
---|
1254 | /**
|
---|
1255 | * Handles VMMDevReq_SetPowerStatus.
|
---|
1256 | *
|
---|
1257 | * @returns VBox status code that the guest should see.
|
---|
1258 | * @param pThis The VMMDev instance data.
|
---|
1259 | * @param pReqHdr The header of the request to handle.
|
---|
1260 | */
|
---|
1261 | static int vmmdevReqHandler_SetPowerStatus(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1262 | {
|
---|
1263 | VMMDevPowerStateRequest *pReq = (VMMDevPowerStateRequest *)pReqHdr;
|
---|
1264 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1265 |
|
---|
1266 | switch (pReq->powerState)
|
---|
1267 | {
|
---|
1268 | case VMMDevPowerState_Pause:
|
---|
1269 | {
|
---|
1270 | LogRel(("VMMDev: Guest requests the VM to be suspended (paused)\n"));
|
---|
1271 | return PDMDevHlpVMSuspend(pThis->pDevIns);
|
---|
1272 | }
|
---|
1273 |
|
---|
1274 | case VMMDevPowerState_PowerOff:
|
---|
1275 | {
|
---|
1276 | LogRel(("VMMDev: Guest requests the VM to be turned off\n"));
|
---|
1277 | return PDMDevHlpVMPowerOff(pThis->pDevIns);
|
---|
1278 | }
|
---|
1279 |
|
---|
1280 | case VMMDevPowerState_SaveState:
|
---|
1281 | {
|
---|
1282 | if (true /*pThis->fAllowGuestToSaveState*/)
|
---|
1283 | {
|
---|
1284 | LogRel(("VMMDev: Guest requests the VM to be saved and powered off\n"));
|
---|
1285 | return PDMDevHlpVMSuspendSaveAndPowerOff(pThis->pDevIns);
|
---|
1286 | }
|
---|
1287 | LogRel(("VMMDev: Guest requests the VM to be saved and powered off, declined\n"));
|
---|
1288 | return VERR_ACCESS_DENIED;
|
---|
1289 | }
|
---|
1290 |
|
---|
1291 | default:
|
---|
1292 | AssertMsgFailed(("VMMDev: Invalid power state request: %d\n", pReq->powerState));
|
---|
1293 | return VERR_INVALID_PARAMETER;
|
---|
1294 | }
|
---|
1295 | }
|
---|
1296 |
|
---|
1297 |
|
---|
1298 | /**
|
---|
1299 | * Handles VMMDevReq_GetDisplayChangeRequest
|
---|
1300 | *
|
---|
1301 | * @returns VBox status code that the guest should see.
|
---|
1302 | * @param pThis The VMMDev instance data.
|
---|
1303 | * @param pReqHdr The header of the request to handle.
|
---|
1304 | * @remarks Deprecated.
|
---|
1305 | */
|
---|
1306 | static int vmmdevReqHandler_GetDisplayChangeRequest(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1307 | {
|
---|
1308 | VMMDevDisplayChangeRequest *pReq = (VMMDevDisplayChangeRequest *)pReqHdr;
|
---|
1309 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1310 |
|
---|
1311 | /**
|
---|
1312 | * @todo It looks like a multi-monitor guest which only uses
|
---|
1313 | * @c VMMDevReq_GetDisplayChangeRequest (not the *2 version) will get
|
---|
1314 | * into a @c VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST event loop if it tries
|
---|
1315 | * to acknowlege host requests for additional monitors. Should the loop
|
---|
1316 | * which checks for those requests be removed?
|
---|
1317 | */
|
---|
1318 |
|
---|
1319 | DISPLAYCHANGEREQUEST *pDispRequest = &pThis->displayChangeData.aRequests[0];
|
---|
1320 |
|
---|
1321 | if (pReq->eventAck == VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST)
|
---|
1322 | {
|
---|
1323 | /* Current request has been read at least once. */
|
---|
1324 | pDispRequest->fPending = false;
|
---|
1325 |
|
---|
1326 | /* Check if there are more pending requests. */
|
---|
1327 | for (unsigned i = 1; i < RT_ELEMENTS(pThis->displayChangeData.aRequests); i++)
|
---|
1328 | {
|
---|
1329 | if (pThis->displayChangeData.aRequests[i].fPending)
|
---|
1330 | {
|
---|
1331 | VMMDevNotifyGuest(pThis, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);
|
---|
1332 | break;
|
---|
1333 | }
|
---|
1334 | }
|
---|
1335 |
|
---|
1336 | /* Remember which resolution the client has queried, subsequent reads
|
---|
1337 | * will return the same values. */
|
---|
1338 | pDispRequest->lastReadDisplayChangeRequest = pDispRequest->displayChangeRequest;
|
---|
1339 | pThis->displayChangeData.fGuestSentChangeEventAck = true;
|
---|
1340 | }
|
---|
1341 |
|
---|
1342 | /* If not a response to a VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, just
|
---|
1343 | * read the last valid video mode hint. This happens when the guest X server
|
---|
1344 | * determines the initial mode. */
|
---|
1345 | VMMDevDisplayDef const *pDisplayDef = pThis->displayChangeData.fGuestSentChangeEventAck ?
|
---|
1346 | &pDispRequest->lastReadDisplayChangeRequest :
|
---|
1347 | &pDispRequest->displayChangeRequest;
|
---|
1348 | pReq->xres = RT_BOOL(pDisplayDef->fDisplayFlags & VMMDEV_DISPLAY_CX) ? pDisplayDef->cx : 0;
|
---|
1349 | pReq->yres = RT_BOOL(pDisplayDef->fDisplayFlags & VMMDEV_DISPLAY_CY) ? pDisplayDef->cy : 0;
|
---|
1350 | pReq->bpp = RT_BOOL(pDisplayDef->fDisplayFlags & VMMDEV_DISPLAY_BPP) ? pDisplayDef->cBitsPerPixel : 0;
|
---|
1351 |
|
---|
1352 | Log(("VMMDev: returning display change request xres = %d, yres = %d, bpp = %d\n", pReq->xres, pReq->yres, pReq->bpp));
|
---|
1353 |
|
---|
1354 | return VINF_SUCCESS;
|
---|
1355 | }
|
---|
1356 |
|
---|
1357 |
|
---|
1358 | /**
|
---|
1359 | * Handles VMMDevReq_GetDisplayChangeRequest2.
|
---|
1360 | *
|
---|
1361 | * @returns VBox status code that the guest should see.
|
---|
1362 | * @param pThis The VMMDev instance data.
|
---|
1363 | * @param pReqHdr The header of the request to handle.
|
---|
1364 | */
|
---|
1365 | static int vmmdevReqHandler_GetDisplayChangeRequest2(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1366 | {
|
---|
1367 | VMMDevDisplayChangeRequest2 *pReq = (VMMDevDisplayChangeRequest2 *)pReqHdr;
|
---|
1368 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1369 |
|
---|
1370 | DISPLAYCHANGEREQUEST *pDispRequest = NULL;
|
---|
1371 |
|
---|
1372 | if (pReq->eventAck == VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST)
|
---|
1373 | {
|
---|
1374 | /* Select a pending request to report. */
|
---|
1375 | unsigned i;
|
---|
1376 | for (i = 0; i < RT_ELEMENTS(pThis->displayChangeData.aRequests); i++)
|
---|
1377 | {
|
---|
1378 | if (pThis->displayChangeData.aRequests[i].fPending)
|
---|
1379 | {
|
---|
1380 | pDispRequest = &pThis->displayChangeData.aRequests[i];
|
---|
1381 | /* Remember which request should be reported. */
|
---|
1382 | pThis->displayChangeData.iCurrentMonitor = i;
|
---|
1383 | Log3(("VMMDev: will report pending request for %u\n", i));
|
---|
1384 | break;
|
---|
1385 | }
|
---|
1386 | }
|
---|
1387 |
|
---|
1388 | /* Check if there are more pending requests. */
|
---|
1389 | i++;
|
---|
1390 | for (; i < RT_ELEMENTS(pThis->displayChangeData.aRequests); i++)
|
---|
1391 | {
|
---|
1392 | if (pThis->displayChangeData.aRequests[i].fPending)
|
---|
1393 | {
|
---|
1394 | VMMDevNotifyGuest(pThis, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);
|
---|
1395 | Log3(("VMMDev: another pending at %u\n", i));
|
---|
1396 | break;
|
---|
1397 | }
|
---|
1398 | }
|
---|
1399 |
|
---|
1400 | if (pDispRequest)
|
---|
1401 | {
|
---|
1402 | /* Current request has been read at least once. */
|
---|
1403 | pDispRequest->fPending = false;
|
---|
1404 |
|
---|
1405 | /* Remember which resolution the client has queried, subsequent reads
|
---|
1406 | * will return the same values. */
|
---|
1407 | pDispRequest->lastReadDisplayChangeRequest = pDispRequest->displayChangeRequest;
|
---|
1408 | pThis->displayChangeData.fGuestSentChangeEventAck = true;
|
---|
1409 | }
|
---|
1410 | else
|
---|
1411 | {
|
---|
1412 | Log3(("VMMDev: no pending request!!!\n"));
|
---|
1413 | }
|
---|
1414 | }
|
---|
1415 |
|
---|
1416 | if (!pDispRequest)
|
---|
1417 | {
|
---|
1418 | Log3(("VMMDev: default to %d\n", pThis->displayChangeData.iCurrentMonitor));
|
---|
1419 | pDispRequest = &pThis->displayChangeData.aRequests[pThis->displayChangeData.iCurrentMonitor];
|
---|
1420 | }
|
---|
1421 |
|
---|
1422 | /* If not a response to a VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, just
|
---|
1423 | * read the last valid video mode hint. This happens when the guest X server
|
---|
1424 | * determines the initial mode. */
|
---|
1425 | VMMDevDisplayDef const *pDisplayDef = pThis->displayChangeData.fGuestSentChangeEventAck ?
|
---|
1426 | &pDispRequest->lastReadDisplayChangeRequest :
|
---|
1427 | &pDispRequest->displayChangeRequest;
|
---|
1428 | pReq->xres = RT_BOOL(pDisplayDef->fDisplayFlags & VMMDEV_DISPLAY_CX) ? pDisplayDef->cx : 0;
|
---|
1429 | pReq->yres = RT_BOOL(pDisplayDef->fDisplayFlags & VMMDEV_DISPLAY_CY) ? pDisplayDef->cy : 0;
|
---|
1430 | pReq->bpp = RT_BOOL(pDisplayDef->fDisplayFlags & VMMDEV_DISPLAY_BPP) ? pDisplayDef->cBitsPerPixel : 0;
|
---|
1431 | pReq->display = pDisplayDef->idDisplay;
|
---|
1432 |
|
---|
1433 | Log(("VMMDev: returning display change request xres = %d, yres = %d, bpp = %d at %d\n",
|
---|
1434 | pReq->xres, pReq->yres, pReq->bpp, pReq->display));
|
---|
1435 |
|
---|
1436 | return VINF_SUCCESS;
|
---|
1437 | }
|
---|
1438 |
|
---|
1439 |
|
---|
1440 | /**
|
---|
1441 | * Handles VMMDevReq_GetDisplayChangeRequestEx.
|
---|
1442 | *
|
---|
1443 | * @returns VBox status code that the guest should see.
|
---|
1444 | * @param pThis The VMMDev instance data.
|
---|
1445 | * @param pReqHdr The header of the request to handle.
|
---|
1446 | */
|
---|
1447 | static int vmmdevReqHandler_GetDisplayChangeRequestEx(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1448 | {
|
---|
1449 | VMMDevDisplayChangeRequestEx *pReq = (VMMDevDisplayChangeRequestEx *)pReqHdr;
|
---|
1450 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1451 |
|
---|
1452 | DISPLAYCHANGEREQUEST *pDispRequest = NULL;
|
---|
1453 |
|
---|
1454 | if (pReq->eventAck == VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST)
|
---|
1455 | {
|
---|
1456 | /* Select a pending request to report. */
|
---|
1457 | unsigned i;
|
---|
1458 | for (i = 0; i < RT_ELEMENTS(pThis->displayChangeData.aRequests); i++)
|
---|
1459 | {
|
---|
1460 | if (pThis->displayChangeData.aRequests[i].fPending)
|
---|
1461 | {
|
---|
1462 | pDispRequest = &pThis->displayChangeData.aRequests[i];
|
---|
1463 | /* Remember which request should be reported. */
|
---|
1464 | pThis->displayChangeData.iCurrentMonitor = i;
|
---|
1465 | Log3(("VMMDev: will report pending request for %d\n",
|
---|
1466 | i));
|
---|
1467 | break;
|
---|
1468 | }
|
---|
1469 | }
|
---|
1470 |
|
---|
1471 | /* Check if there are more pending requests. */
|
---|
1472 | i++;
|
---|
1473 | for (; i < RT_ELEMENTS(pThis->displayChangeData.aRequests); i++)
|
---|
1474 | {
|
---|
1475 | if (pThis->displayChangeData.aRequests[i].fPending)
|
---|
1476 | {
|
---|
1477 | VMMDevNotifyGuest(pThis, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);
|
---|
1478 | Log3(("VMMDev: another pending at %d\n",
|
---|
1479 | i));
|
---|
1480 | break;
|
---|
1481 | }
|
---|
1482 | }
|
---|
1483 |
|
---|
1484 | if (pDispRequest)
|
---|
1485 | {
|
---|
1486 | /* Current request has been read at least once. */
|
---|
1487 | pDispRequest->fPending = false;
|
---|
1488 |
|
---|
1489 | /* Remember which resolution the client has queried, subsequent reads
|
---|
1490 | * will return the same values. */
|
---|
1491 | pDispRequest->lastReadDisplayChangeRequest = pDispRequest->displayChangeRequest;
|
---|
1492 | pThis->displayChangeData.fGuestSentChangeEventAck = true;
|
---|
1493 | }
|
---|
1494 | else
|
---|
1495 | {
|
---|
1496 | Log3(("VMMDev: no pending request!!!\n"));
|
---|
1497 | }
|
---|
1498 | }
|
---|
1499 |
|
---|
1500 | if (!pDispRequest)
|
---|
1501 | {
|
---|
1502 | Log3(("VMMDev: default to %d\n",
|
---|
1503 | pThis->displayChangeData.iCurrentMonitor));
|
---|
1504 | pDispRequest = &pThis->displayChangeData.aRequests[pThis->displayChangeData.iCurrentMonitor];
|
---|
1505 | }
|
---|
1506 |
|
---|
1507 | /* If not a response to a VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, just
|
---|
1508 | * read the last valid video mode hint. This happens when the guest X server
|
---|
1509 | * determines the initial mode. */
|
---|
1510 | VMMDevDisplayDef const *pDisplayDef = pThis->displayChangeData.fGuestSentChangeEventAck ?
|
---|
1511 | &pDispRequest->lastReadDisplayChangeRequest :
|
---|
1512 | &pDispRequest->displayChangeRequest;
|
---|
1513 | pReq->xres = RT_BOOL(pDisplayDef->fDisplayFlags & VMMDEV_DISPLAY_CX) ? pDisplayDef->cx : 0;
|
---|
1514 | pReq->yres = RT_BOOL(pDisplayDef->fDisplayFlags & VMMDEV_DISPLAY_CY) ? pDisplayDef->cy : 0;
|
---|
1515 | pReq->bpp = RT_BOOL(pDisplayDef->fDisplayFlags & VMMDEV_DISPLAY_BPP) ? pDisplayDef->cBitsPerPixel : 0;
|
---|
1516 | pReq->display = pDisplayDef->idDisplay;
|
---|
1517 | pReq->cxOrigin = pDisplayDef->xOrigin;
|
---|
1518 | pReq->cyOrigin = pDisplayDef->yOrigin;
|
---|
1519 | pReq->fEnabled = !RT_BOOL(pDisplayDef->fDisplayFlags & VMMDEV_DISPLAY_DISABLED);
|
---|
1520 | pReq->fChangeOrigin = RT_BOOL(pDisplayDef->fDisplayFlags & VMMDEV_DISPLAY_ORIGIN);
|
---|
1521 |
|
---|
1522 | Log(("VMMDevEx: returning display change request xres = %d, yres = %d, bpp = %d id %d xPos = %d, yPos = %d & Enabled=%d\n",
|
---|
1523 | pReq->xres, pReq->yres, pReq->bpp, pReq->display, pReq->cxOrigin, pReq->cyOrigin, pReq->fEnabled));
|
---|
1524 |
|
---|
1525 | return VINF_SUCCESS;
|
---|
1526 | }
|
---|
1527 |
|
---|
1528 |
|
---|
1529 | /**
|
---|
1530 | * Handles VMMDevReq_GetDisplayChangeRequestMulti.
|
---|
1531 | *
|
---|
1532 | * @returns VBox status code that the guest should see.
|
---|
1533 | * @param pThis The VMMDev instance data.
|
---|
1534 | * @param pReqHdr The header of the request to handle.
|
---|
1535 | */
|
---|
1536 | static int vmmdevReqHandler_GetDisplayChangeRequestMulti(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1537 | {
|
---|
1538 | VMMDevDisplayChangeRequestMulti *pReq = (VMMDevDisplayChangeRequestMulti *)pReqHdr;
|
---|
1539 | unsigned i;
|
---|
1540 |
|
---|
1541 | ASSERT_GUEST_MSG_RETURN(pReq->header.size >= sizeof(*pReq),
|
---|
1542 | ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1543 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1544 |
|
---|
1545 | uint32_t const cDisplays = pReq->cDisplays;
|
---|
1546 | ASSERT_GUEST_MSG_RETURN(cDisplays > 0 && cDisplays <= RT_ELEMENTS(pThis->displayChangeData.aRequests),
|
---|
1547 | ("cDisplays %u\n", cDisplays), VERR_INVALID_PARAMETER);
|
---|
1548 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1549 |
|
---|
1550 | ASSERT_GUEST_MSG_RETURN(pReq->header.size >= sizeof(*pReq) + (cDisplays - 1) * sizeof(VMMDevDisplayDef),
|
---|
1551 | ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1552 | RT_UNTRUSTED_VALIDATED_FENCE();
|
---|
1553 |
|
---|
1554 | if (pReq->eventAck == VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST)
|
---|
1555 | {
|
---|
1556 | uint32_t cDisplaysOut = 0;
|
---|
1557 | /* Remember which resolution the client has queried, subsequent reads
|
---|
1558 | * will return the same values. */
|
---|
1559 | for (i = 0; i < RT_ELEMENTS(pThis->displayChangeData.aRequests); ++i)
|
---|
1560 | {
|
---|
1561 | DISPLAYCHANGEREQUEST *pDCR = &pThis->displayChangeData.aRequests[i];
|
---|
1562 |
|
---|
1563 | pDCR->lastReadDisplayChangeRequest = pDCR->displayChangeRequest;
|
---|
1564 |
|
---|
1565 | if (pDCR->fPending)
|
---|
1566 | {
|
---|
1567 | if (cDisplaysOut < cDisplays)
|
---|
1568 | pReq->aDisplays[cDisplaysOut] = pDCR->lastReadDisplayChangeRequest;
|
---|
1569 |
|
---|
1570 | cDisplaysOut++;
|
---|
1571 | pDCR->fPending = false;
|
---|
1572 | }
|
---|
1573 | }
|
---|
1574 |
|
---|
1575 | pReq->cDisplays = cDisplaysOut;
|
---|
1576 | pThis->displayChangeData.fGuestSentChangeEventAck = true;
|
---|
1577 | }
|
---|
1578 | else
|
---|
1579 | {
|
---|
1580 | /* Fill the guest request with monitor layout data. */
|
---|
1581 | for (i = 0; i < cDisplays; ++i)
|
---|
1582 | {
|
---|
1583 | /* If not a response to a VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, just
|
---|
1584 | * read the last valid video mode hint. This happens when the guest X server
|
---|
1585 | * determines the initial mode. */
|
---|
1586 | DISPLAYCHANGEREQUEST const *pDCR = &pThis->displayChangeData.aRequests[i];
|
---|
1587 | VMMDevDisplayDef const *pDisplayDef = pThis->displayChangeData.fGuestSentChangeEventAck ?
|
---|
1588 | &pDCR->lastReadDisplayChangeRequest :
|
---|
1589 | &pDCR->displayChangeRequest;
|
---|
1590 | pReq->aDisplays[i] = *pDisplayDef;
|
---|
1591 | }
|
---|
1592 | }
|
---|
1593 |
|
---|
1594 | Log(("VMMDev: returning multimonitor display change request cDisplays %d\n", cDisplays));
|
---|
1595 |
|
---|
1596 | return VINF_SUCCESS;
|
---|
1597 | }
|
---|
1598 |
|
---|
1599 |
|
---|
1600 | /**
|
---|
1601 | * Handles VMMDevReq_VideoModeSupported.
|
---|
1602 | *
|
---|
1603 | * Query whether the given video mode is supported.
|
---|
1604 | *
|
---|
1605 | * @returns VBox status code that the guest should see.
|
---|
1606 | * @param pThis The VMMDev instance data.
|
---|
1607 | * @param pReqHdr The header of the request to handle.
|
---|
1608 | */
|
---|
1609 | static int vmmdevReqHandler_VideoModeSupported(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1610 | {
|
---|
1611 | VMMDevVideoModeSupportedRequest *pReq = (VMMDevVideoModeSupportedRequest *)pReqHdr;
|
---|
1612 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1613 |
|
---|
1614 | /* forward the call */
|
---|
1615 | return pThis->pDrv->pfnVideoModeSupported(pThis->pDrv,
|
---|
1616 | 0, /* primary screen. */
|
---|
1617 | pReq->width,
|
---|
1618 | pReq->height,
|
---|
1619 | pReq->bpp,
|
---|
1620 | &pReq->fSupported);
|
---|
1621 | }
|
---|
1622 |
|
---|
1623 |
|
---|
1624 | /**
|
---|
1625 | * Handles VMMDevReq_VideoModeSupported2.
|
---|
1626 | *
|
---|
1627 | * Query whether the given video mode is supported for a specific display
|
---|
1628 | *
|
---|
1629 | * @returns VBox status code that the guest should see.
|
---|
1630 | * @param pThis The VMMDev instance data.
|
---|
1631 | * @param pReqHdr The header of the request to handle.
|
---|
1632 | */
|
---|
1633 | static int vmmdevReqHandler_VideoModeSupported2(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1634 | {
|
---|
1635 | VMMDevVideoModeSupportedRequest2 *pReq = (VMMDevVideoModeSupportedRequest2 *)pReqHdr;
|
---|
1636 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1637 |
|
---|
1638 | /* forward the call */
|
---|
1639 | return pThis->pDrv->pfnVideoModeSupported(pThis->pDrv,
|
---|
1640 | pReq->display,
|
---|
1641 | pReq->width,
|
---|
1642 | pReq->height,
|
---|
1643 | pReq->bpp,
|
---|
1644 | &pReq->fSupported);
|
---|
1645 | }
|
---|
1646 |
|
---|
1647 |
|
---|
1648 |
|
---|
1649 | /**
|
---|
1650 | * Handles VMMDevReq_GetHeightReduction.
|
---|
1651 | *
|
---|
1652 | * @returns VBox status code that the guest should see.
|
---|
1653 | * @param pThis The VMMDev instance data.
|
---|
1654 | * @param pReqHdr The header of the request to handle.
|
---|
1655 | */
|
---|
1656 | static int vmmdevReqHandler_GetHeightReduction(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1657 | {
|
---|
1658 | VMMDevGetHeightReductionRequest *pReq = (VMMDevGetHeightReductionRequest *)pReqHdr;
|
---|
1659 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1660 |
|
---|
1661 | /* forward the call */
|
---|
1662 | return pThis->pDrv->pfnGetHeightReduction(pThis->pDrv, &pReq->heightReduction);
|
---|
1663 | }
|
---|
1664 |
|
---|
1665 |
|
---|
1666 | /**
|
---|
1667 | * Handles VMMDevReq_AcknowledgeEvents.
|
---|
1668 | *
|
---|
1669 | * @returns VBox status code that the guest should see.
|
---|
1670 | * @param pThis The VMMDev instance data.
|
---|
1671 | * @param pReqHdr The header of the request to handle.
|
---|
1672 | */
|
---|
1673 | static int vmmdevReqHandler_AcknowledgeEvents(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1674 | {
|
---|
1675 | VMMDevEvents *pReq = (VMMDevEvents *)pReqHdr;
|
---|
1676 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1677 |
|
---|
1678 | if (!VMMDEV_INTERFACE_VERSION_IS_1_03(pThis))
|
---|
1679 | {
|
---|
1680 | if (pThis->fNewGuestFilterMask)
|
---|
1681 | {
|
---|
1682 | pThis->fNewGuestFilterMask = false;
|
---|
1683 | pThis->u32GuestFilterMask = pThis->u32NewGuestFilterMask;
|
---|
1684 | }
|
---|
1685 |
|
---|
1686 | pReq->events = pThis->u32HostEventFlags & pThis->u32GuestFilterMask;
|
---|
1687 |
|
---|
1688 | pThis->u32HostEventFlags &= ~pThis->u32GuestFilterMask;
|
---|
1689 | pThis->pVMMDevRAMR3->V.V1_04.fHaveEvents = false;
|
---|
1690 | PDMDevHlpPCISetIrqNoWait(pThis->pDevIns, 0, 0);
|
---|
1691 | }
|
---|
1692 | else
|
---|
1693 | vmmdevSetIRQ_Legacy(pThis);
|
---|
1694 | return VINF_SUCCESS;
|
---|
1695 | }
|
---|
1696 |
|
---|
1697 |
|
---|
1698 | /**
|
---|
1699 | * Handles VMMDevReq_CtlGuestFilterMask.
|
---|
1700 | *
|
---|
1701 | * @returns VBox status code that the guest should see.
|
---|
1702 | * @param pThis The VMMDev instance data.
|
---|
1703 | * @param pReqHdr The header of the request to handle.
|
---|
1704 | */
|
---|
1705 | static int vmmdevReqHandler_CtlGuestFilterMask(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1706 | {
|
---|
1707 | VMMDevCtlGuestFilterMask *pReq = (VMMDevCtlGuestFilterMask *)pReqHdr;
|
---|
1708 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1709 |
|
---|
1710 | LogRelFlow(("VMMDev: vmmdevReqHandler_CtlGuestFilterMask: OR mask: %#x, NOT mask: %#x\n", pReq->u32OrMask, pReq->u32NotMask));
|
---|
1711 |
|
---|
1712 | /* HGCM event notification is enabled by the VMMDev device
|
---|
1713 | * automatically when any HGCM command is issued. The guest
|
---|
1714 | * cannot disable these notifications. */
|
---|
1715 | VMMDevCtlSetGuestFilterMask(pThis, pReq->u32OrMask, pReq->u32NotMask & ~VMMDEV_EVENT_HGCM);
|
---|
1716 | return VINF_SUCCESS;
|
---|
1717 | }
|
---|
1718 |
|
---|
1719 | #ifdef VBOX_WITH_HGCM
|
---|
1720 |
|
---|
1721 | /**
|
---|
1722 | * Handles VMMDevReq_HGCMConnect.
|
---|
1723 | *
|
---|
1724 | * @returns VBox status code that the guest should see.
|
---|
1725 | * @param pThis The VMMDev instance data.
|
---|
1726 | * @param pReqHdr The header of the request to handle.
|
---|
1727 | * @param GCPhysReqHdr The guest physical address of the request header.
|
---|
1728 | */
|
---|
1729 | static int vmmdevReqHandler_HGCMConnect(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr)
|
---|
1730 | {
|
---|
1731 | VMMDevHGCMConnect *pReq = (VMMDevHGCMConnect *)pReqHdr;
|
---|
1732 | AssertMsgReturn(pReq->header.header.size >= sizeof(*pReq), ("%u\n", pReq->header.header.size), VERR_INVALID_PARAMETER); /** @todo Not sure why this is >= ... */
|
---|
1733 |
|
---|
1734 | if (pThis->pHGCMDrv)
|
---|
1735 | {
|
---|
1736 | Log(("VMMDevReq_HGCMConnect\n"));
|
---|
1737 | return vmmdevHGCMConnect(pThis, pReq, GCPhysReqHdr);
|
---|
1738 | }
|
---|
1739 |
|
---|
1740 | Log(("VMMDevReq_HGCMConnect: HGCM Connector is NULL!\n"));
|
---|
1741 | return VERR_NOT_SUPPORTED;
|
---|
1742 | }
|
---|
1743 |
|
---|
1744 |
|
---|
1745 | /**
|
---|
1746 | * Handles VMMDevReq_HGCMDisconnect.
|
---|
1747 | *
|
---|
1748 | * @returns VBox status code that the guest should see.
|
---|
1749 | * @param pThis The VMMDev instance data.
|
---|
1750 | * @param pReqHdr The header of the request to handle.
|
---|
1751 | * @param GCPhysReqHdr The guest physical address of the request header.
|
---|
1752 | */
|
---|
1753 | static int vmmdevReqHandler_HGCMDisconnect(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr)
|
---|
1754 | {
|
---|
1755 | VMMDevHGCMDisconnect *pReq = (VMMDevHGCMDisconnect *)pReqHdr;
|
---|
1756 | AssertMsgReturn(pReq->header.header.size >= sizeof(*pReq), ("%u\n", pReq->header.header.size), VERR_INVALID_PARAMETER); /** @todo Not sure why this >= ... */
|
---|
1757 |
|
---|
1758 | if (pThis->pHGCMDrv)
|
---|
1759 | {
|
---|
1760 | Log(("VMMDevReq_VMMDevHGCMDisconnect\n"));
|
---|
1761 | return vmmdevHGCMDisconnect(pThis, pReq, GCPhysReqHdr);
|
---|
1762 | }
|
---|
1763 |
|
---|
1764 | Log(("VMMDevReq_VMMDevHGCMDisconnect: HGCM Connector is NULL!\n"));
|
---|
1765 | return VERR_NOT_SUPPORTED;
|
---|
1766 | }
|
---|
1767 |
|
---|
1768 |
|
---|
1769 | /**
|
---|
1770 | * Handles VMMDevReq_HGCMCall.
|
---|
1771 | *
|
---|
1772 | * @returns VBox status code that the guest should see.
|
---|
1773 | * @param pThis The VMMDev instance data.
|
---|
1774 | * @param pReqHdr The header of the request to handle.
|
---|
1775 | * @param GCPhysReqHdr The guest physical address of the request header.
|
---|
1776 | */
|
---|
1777 | static int vmmdevReqHandler_HGCMCall(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr)
|
---|
1778 | {
|
---|
1779 | VMMDevHGCMCall *pReq = (VMMDevHGCMCall *)pReqHdr;
|
---|
1780 | AssertMsgReturn(pReq->header.header.size >= sizeof(*pReq), ("%u\n", pReq->header.header.size), VERR_INVALID_PARAMETER);
|
---|
1781 |
|
---|
1782 | if (pThis->pHGCMDrv)
|
---|
1783 | {
|
---|
1784 | Log2(("VMMDevReq_HGCMCall: sizeof(VMMDevHGCMRequest) = %04X\n", sizeof(VMMDevHGCMCall)));
|
---|
1785 | Log2(("%.*Rhxd\n", pReq->header.header.size, pReq));
|
---|
1786 |
|
---|
1787 | return vmmdevHGCMCall(pThis, pReq, pReq->header.header.size, GCPhysReqHdr, pReq->header.header.requestType);
|
---|
1788 | }
|
---|
1789 |
|
---|
1790 | Log(("VMMDevReq_HGCMCall: HGCM Connector is NULL!\n"));
|
---|
1791 | return VERR_NOT_SUPPORTED;
|
---|
1792 | }
|
---|
1793 |
|
---|
1794 | /**
|
---|
1795 | * Handles VMMDevReq_HGCMCancel.
|
---|
1796 | *
|
---|
1797 | * @returns VBox status code that the guest should see.
|
---|
1798 | * @param pThis The VMMDev instance data.
|
---|
1799 | * @param pReqHdr The header of the request to handle.
|
---|
1800 | * @param GCPhysReqHdr The guest physical address of the request header.
|
---|
1801 | */
|
---|
1802 | static int vmmdevReqHandler_HGCMCancel(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr)
|
---|
1803 | {
|
---|
1804 | VMMDevHGCMCancel *pReq = (VMMDevHGCMCancel *)pReqHdr;
|
---|
1805 | AssertMsgReturn(pReq->header.header.size >= sizeof(*pReq), ("%u\n", pReq->header.header.size), VERR_INVALID_PARAMETER); /** @todo Not sure why this >= ... */
|
---|
1806 |
|
---|
1807 | if (pThis->pHGCMDrv)
|
---|
1808 | {
|
---|
1809 | Log(("VMMDevReq_VMMDevHGCMCancel\n"));
|
---|
1810 | return vmmdevHGCMCancel(pThis, pReq, GCPhysReqHdr);
|
---|
1811 | }
|
---|
1812 |
|
---|
1813 | Log(("VMMDevReq_VMMDevHGCMCancel: HGCM Connector is NULL!\n"));
|
---|
1814 | return VERR_NOT_SUPPORTED;
|
---|
1815 | }
|
---|
1816 |
|
---|
1817 |
|
---|
1818 | /**
|
---|
1819 | * Handles VMMDevReq_HGCMCancel2.
|
---|
1820 | *
|
---|
1821 | * @returns VBox status code that the guest should see.
|
---|
1822 | * @param pThis The VMMDev instance data.
|
---|
1823 | * @param pReqHdr The header of the request to handle.
|
---|
1824 | */
|
---|
1825 | static int vmmdevReqHandler_HGCMCancel2(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1826 | {
|
---|
1827 | VMMDevHGCMCancel2 *pReq = (VMMDevHGCMCancel2 *)pReqHdr;
|
---|
1828 | AssertMsgReturn(pReq->header.size >= sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER); /** @todo Not sure why this >= ... */
|
---|
1829 |
|
---|
1830 | if (pThis->pHGCMDrv)
|
---|
1831 | {
|
---|
1832 | Log(("VMMDevReq_HGCMCancel2\n"));
|
---|
1833 | return vmmdevHGCMCancel2(pThis, pReq->physReqToCancel);
|
---|
1834 | }
|
---|
1835 |
|
---|
1836 | Log(("VMMDevReq_HGCMConnect2: HGCM Connector is NULL!\n"));
|
---|
1837 | return VERR_NOT_SUPPORTED;
|
---|
1838 | }
|
---|
1839 |
|
---|
1840 | #endif /* VBOX_WITH_HGCM */
|
---|
1841 |
|
---|
1842 |
|
---|
1843 | /**
|
---|
1844 | * Handles VMMDevReq_VideoAccelEnable.
|
---|
1845 | *
|
---|
1846 | * @returns VBox status code that the guest should see.
|
---|
1847 | * @param pThis The VMMDev instance data.
|
---|
1848 | * @param pReqHdr The header of the request to handle.
|
---|
1849 | */
|
---|
1850 | static int vmmdevReqHandler_VideoAccelEnable(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1851 | {
|
---|
1852 | VMMDevVideoAccelEnable *pReq = (VMMDevVideoAccelEnable *)pReqHdr;
|
---|
1853 | AssertMsgReturn(pReq->header.size >= sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER); /** @todo Not sure why this >= ... */
|
---|
1854 |
|
---|
1855 | if (!pThis->pDrv)
|
---|
1856 | {
|
---|
1857 | Log(("VMMDevReq_VideoAccelEnable Connector is NULL!!\n"));
|
---|
1858 | return VERR_NOT_SUPPORTED;
|
---|
1859 | }
|
---|
1860 |
|
---|
1861 | if (pReq->cbRingBuffer != VMMDEV_VBVA_RING_BUFFER_SIZE)
|
---|
1862 | {
|
---|
1863 | /* The guest driver seems compiled with different headers. */
|
---|
1864 | LogRelMax(16,("VMMDevReq_VideoAccelEnable guest ring buffer size %#x, should be %#x!!\n", pReq->cbRingBuffer, VMMDEV_VBVA_RING_BUFFER_SIZE));
|
---|
1865 | return VERR_INVALID_PARAMETER;
|
---|
1866 | }
|
---|
1867 |
|
---|
1868 | /* The request is correct. */
|
---|
1869 | pReq->fu32Status |= VBVA_F_STATUS_ACCEPTED;
|
---|
1870 |
|
---|
1871 | LogFlow(("VMMDevReq_VideoAccelEnable pReq->u32Enable = %d\n", pReq->u32Enable));
|
---|
1872 |
|
---|
1873 | int rc = pReq->u32Enable
|
---|
1874 | ? pThis->pDrv->pfnVideoAccelEnable(pThis->pDrv, true, &pThis->pVMMDevRAMR3->vbvaMemory)
|
---|
1875 | : pThis->pDrv->pfnVideoAccelEnable(pThis->pDrv, false, NULL);
|
---|
1876 |
|
---|
1877 | if ( pReq->u32Enable
|
---|
1878 | && RT_SUCCESS(rc))
|
---|
1879 | {
|
---|
1880 | pReq->fu32Status |= VBVA_F_STATUS_ENABLED;
|
---|
1881 |
|
---|
1882 | /* Remember that guest successfully enabled acceleration.
|
---|
1883 | * We need to reestablish it on restoring the VM from saved state.
|
---|
1884 | */
|
---|
1885 | pThis->u32VideoAccelEnabled = 1;
|
---|
1886 | }
|
---|
1887 | else
|
---|
1888 | {
|
---|
1889 | /* The acceleration was not enabled. Remember that. */
|
---|
1890 | pThis->u32VideoAccelEnabled = 0;
|
---|
1891 | }
|
---|
1892 | return VINF_SUCCESS;
|
---|
1893 | }
|
---|
1894 |
|
---|
1895 |
|
---|
1896 | /**
|
---|
1897 | * Handles VMMDevReq_VideoAccelFlush.
|
---|
1898 | *
|
---|
1899 | * @returns VBox status code that the guest should see.
|
---|
1900 | * @param pThis The VMMDev instance data.
|
---|
1901 | * @param pReqHdr The header of the request to handle.
|
---|
1902 | */
|
---|
1903 | static int vmmdevReqHandler_VideoAccelFlush(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1904 | {
|
---|
1905 | VMMDevVideoAccelFlush *pReq = (VMMDevVideoAccelFlush *)pReqHdr;
|
---|
1906 | AssertMsgReturn(pReq->header.size >= sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER); /** @todo Not sure why this >= ... */
|
---|
1907 |
|
---|
1908 | if (!pThis->pDrv)
|
---|
1909 | {
|
---|
1910 | Log(("VMMDevReq_VideoAccelFlush: Connector is NULL!!!\n"));
|
---|
1911 | return VERR_NOT_SUPPORTED;
|
---|
1912 | }
|
---|
1913 |
|
---|
1914 | pThis->pDrv->pfnVideoAccelFlush(pThis->pDrv);
|
---|
1915 | return VINF_SUCCESS;
|
---|
1916 | }
|
---|
1917 |
|
---|
1918 |
|
---|
1919 | /**
|
---|
1920 | * Handles VMMDevReq_VideoSetVisibleRegion.
|
---|
1921 | *
|
---|
1922 | * @returns VBox status code that the guest should see.
|
---|
1923 | * @param pThis The VMMDev instance data.
|
---|
1924 | * @param pReqHdr The header of the request to handle.
|
---|
1925 | */
|
---|
1926 | static int vmmdevReqHandler_VideoSetVisibleRegion(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1927 | {
|
---|
1928 | VMMDevVideoSetVisibleRegion *pReq = (VMMDevVideoSetVisibleRegion *)pReqHdr;
|
---|
1929 | AssertMsgReturn(pReq->header.size + sizeof(RTRECT) >= sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1930 |
|
---|
1931 | if (!pThis->pDrv)
|
---|
1932 | {
|
---|
1933 | Log(("VMMDevReq_VideoSetVisibleRegion: Connector is NULL!!!\n"));
|
---|
1934 | return VERR_NOT_SUPPORTED;
|
---|
1935 | }
|
---|
1936 |
|
---|
1937 | if ( pReq->cRect > _1M /* restrict to sane range */
|
---|
1938 | || pReq->header.size != sizeof(VMMDevVideoSetVisibleRegion) + pReq->cRect * sizeof(RTRECT) - sizeof(RTRECT))
|
---|
1939 | {
|
---|
1940 | Log(("VMMDevReq_VideoSetVisibleRegion: cRects=%#x doesn't match size=%#x or is out of bounds\n",
|
---|
1941 | pReq->cRect, pReq->header.size));
|
---|
1942 | return VERR_INVALID_PARAMETER;
|
---|
1943 | }
|
---|
1944 |
|
---|
1945 | Log(("VMMDevReq_VideoSetVisibleRegion %d rectangles\n", pReq->cRect));
|
---|
1946 | /* forward the call */
|
---|
1947 | return pThis->pDrv->pfnSetVisibleRegion(pThis->pDrv, pReq->cRect, &pReq->Rect);
|
---|
1948 | }
|
---|
1949 |
|
---|
1950 |
|
---|
1951 | /**
|
---|
1952 | * Handles VMMDevReq_GetSeamlessChangeRequest.
|
---|
1953 | *
|
---|
1954 | * @returns VBox status code that the guest should see.
|
---|
1955 | * @param pThis The VMMDev instance data.
|
---|
1956 | * @param pReqHdr The header of the request to handle.
|
---|
1957 | */
|
---|
1958 | static int vmmdevReqHandler_GetSeamlessChangeRequest(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1959 | {
|
---|
1960 | VMMDevSeamlessChangeRequest *pReq = (VMMDevSeamlessChangeRequest *)pReqHdr;
|
---|
1961 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1962 |
|
---|
1963 | /* just pass on the information */
|
---|
1964 | Log(("VMMDev: returning seamless change request mode=%d\n", pThis->fSeamlessEnabled));
|
---|
1965 | if (pThis->fSeamlessEnabled)
|
---|
1966 | pReq->mode = VMMDev_Seamless_Visible_Region;
|
---|
1967 | else
|
---|
1968 | pReq->mode = VMMDev_Seamless_Disabled;
|
---|
1969 |
|
---|
1970 | if (pReq->eventAck == VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST)
|
---|
1971 | {
|
---|
1972 | /* Remember which mode the client has queried. */
|
---|
1973 | pThis->fLastSeamlessEnabled = pThis->fSeamlessEnabled;
|
---|
1974 | }
|
---|
1975 |
|
---|
1976 | return VINF_SUCCESS;
|
---|
1977 | }
|
---|
1978 |
|
---|
1979 |
|
---|
1980 | /**
|
---|
1981 | * Handles VMMDevReq_GetVRDPChangeRequest.
|
---|
1982 | *
|
---|
1983 | * @returns VBox status code that the guest should see.
|
---|
1984 | * @param pThis The VMMDev instance data.
|
---|
1985 | * @param pReqHdr The header of the request to handle.
|
---|
1986 | */
|
---|
1987 | static int vmmdevReqHandler_GetVRDPChangeRequest(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
1988 | {
|
---|
1989 | VMMDevVRDPChangeRequest *pReq = (VMMDevVRDPChangeRequest *)pReqHdr;
|
---|
1990 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
1991 |
|
---|
1992 | /* just pass on the information */
|
---|
1993 | Log(("VMMDev: returning VRDP status %d level %d\n", pThis->fVRDPEnabled, pThis->uVRDPExperienceLevel));
|
---|
1994 |
|
---|
1995 | pReq->u8VRDPActive = pThis->fVRDPEnabled;
|
---|
1996 | pReq->u32VRDPExperienceLevel = pThis->uVRDPExperienceLevel;
|
---|
1997 |
|
---|
1998 | return VINF_SUCCESS;
|
---|
1999 | }
|
---|
2000 |
|
---|
2001 |
|
---|
2002 | /**
|
---|
2003 | * Handles VMMDevReq_GetMemBalloonChangeRequest.
|
---|
2004 | *
|
---|
2005 | * @returns VBox status code that the guest should see.
|
---|
2006 | * @param pThis The VMMDev instance data.
|
---|
2007 | * @param pReqHdr The header of the request to handle.
|
---|
2008 | */
|
---|
2009 | static int vmmdevReqHandler_GetMemBalloonChangeRequest(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
2010 | {
|
---|
2011 | VMMDevGetMemBalloonChangeRequest *pReq = (VMMDevGetMemBalloonChangeRequest *)pReqHdr;
|
---|
2012 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
2013 |
|
---|
2014 | /* just pass on the information */
|
---|
2015 | Log(("VMMDev: returning memory balloon size =%d\n", pThis->cMbMemoryBalloon));
|
---|
2016 | pReq->cBalloonChunks = pThis->cMbMemoryBalloon;
|
---|
2017 | pReq->cPhysMemChunks = pThis->cbGuestRAM / (uint64_t)_1M;
|
---|
2018 |
|
---|
2019 | if (pReq->eventAck == VMMDEV_EVENT_BALLOON_CHANGE_REQUEST)
|
---|
2020 | {
|
---|
2021 | /* Remember which mode the client has queried. */
|
---|
2022 | pThis->cMbMemoryBalloonLast = pThis->cMbMemoryBalloon;
|
---|
2023 | }
|
---|
2024 |
|
---|
2025 | return VINF_SUCCESS;
|
---|
2026 | }
|
---|
2027 |
|
---|
2028 |
|
---|
2029 | /**
|
---|
2030 | * Handles VMMDevReq_ChangeMemBalloon.
|
---|
2031 | *
|
---|
2032 | * @returns VBox status code that the guest should see.
|
---|
2033 | * @param pThis The VMMDev instance data.
|
---|
2034 | * @param pReqHdr The header of the request to handle.
|
---|
2035 | */
|
---|
2036 | static int vmmdevReqHandler_ChangeMemBalloon(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
2037 | {
|
---|
2038 | VMMDevChangeMemBalloon *pReq = (VMMDevChangeMemBalloon *)pReqHdr;
|
---|
2039 | AssertMsgReturn(pReq->header.size >= sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
2040 | AssertMsgReturn(pReq->cPages == VMMDEV_MEMORY_BALLOON_CHUNK_PAGES, ("%u\n", pReq->cPages), VERR_INVALID_PARAMETER);
|
---|
2041 | AssertMsgReturn(pReq->header.size == (uint32_t)RT_UOFFSETOF_DYN(VMMDevChangeMemBalloon, aPhysPage[pReq->cPages]),
|
---|
2042 | ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
2043 |
|
---|
2044 | Log(("VMMDevReq_ChangeMemBalloon\n"));
|
---|
2045 | int rc = PGMR3PhysChangeMemBalloon(PDMDevHlpGetVM(pThis->pDevIns), !!pReq->fInflate, pReq->cPages, pReq->aPhysPage);
|
---|
2046 | if (pReq->fInflate)
|
---|
2047 | STAM_REL_U32_INC(&pThis->StatMemBalloonChunks);
|
---|
2048 | else
|
---|
2049 | STAM_REL_U32_DEC(&pThis->StatMemBalloonChunks);
|
---|
2050 | return rc;
|
---|
2051 | }
|
---|
2052 |
|
---|
2053 |
|
---|
2054 | /**
|
---|
2055 | * Handles VMMDevReq_GetStatisticsChangeRequest.
|
---|
2056 | *
|
---|
2057 | * @returns VBox status code that the guest should see.
|
---|
2058 | * @param pThis The VMMDev instance data.
|
---|
2059 | * @param pReqHdr The header of the request to handle.
|
---|
2060 | */
|
---|
2061 | static int vmmdevReqHandler_GetStatisticsChangeRequest(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
2062 | {
|
---|
2063 | VMMDevGetStatisticsChangeRequest *pReq = (VMMDevGetStatisticsChangeRequest *)pReqHdr;
|
---|
2064 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
2065 |
|
---|
2066 | Log(("VMMDevReq_GetStatisticsChangeRequest\n"));
|
---|
2067 | /* just pass on the information */
|
---|
2068 | Log(("VMMDev: returning statistics interval %d seconds\n", pThis->u32StatIntervalSize));
|
---|
2069 | pReq->u32StatInterval = pThis->u32StatIntervalSize;
|
---|
2070 |
|
---|
2071 | if (pReq->eventAck == VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST)
|
---|
2072 | {
|
---|
2073 | /* Remember which mode the client has queried. */
|
---|
2074 | pThis->u32LastStatIntervalSize= pThis->u32StatIntervalSize;
|
---|
2075 | }
|
---|
2076 |
|
---|
2077 | return VINF_SUCCESS;
|
---|
2078 | }
|
---|
2079 |
|
---|
2080 |
|
---|
2081 | /**
|
---|
2082 | * Handles VMMDevReq_ReportGuestStats.
|
---|
2083 | *
|
---|
2084 | * @returns VBox status code that the guest should see.
|
---|
2085 | * @param pThis The VMMDev instance data.
|
---|
2086 | * @param pReqHdr The header of the request to handle.
|
---|
2087 | */
|
---|
2088 | static int vmmdevReqHandler_ReportGuestStats(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
2089 | {
|
---|
2090 | VMMDevReportGuestStats *pReq = (VMMDevReportGuestStats *)pReqHdr;
|
---|
2091 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
2092 |
|
---|
2093 | Log(("VMMDevReq_ReportGuestStats\n"));
|
---|
2094 | #ifdef LOG_ENABLED
|
---|
2095 | VBoxGuestStatistics *pGuestStats = &pReq->guestStats;
|
---|
2096 |
|
---|
2097 | Log(("Current statistics:\n"));
|
---|
2098 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_IDLE)
|
---|
2099 | Log(("CPU%u: CPU Load Idle %-3d%%\n", pGuestStats->u32CpuId, pGuestStats->u32CpuLoad_Idle));
|
---|
2100 |
|
---|
2101 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_KERNEL)
|
---|
2102 | Log(("CPU%u: CPU Load Kernel %-3d%%\n", pGuestStats->u32CpuId, pGuestStats->u32CpuLoad_Kernel));
|
---|
2103 |
|
---|
2104 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_USER)
|
---|
2105 | Log(("CPU%u: CPU Load User %-3d%%\n", pGuestStats->u32CpuId, pGuestStats->u32CpuLoad_User));
|
---|
2106 |
|
---|
2107 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_THREADS)
|
---|
2108 | Log(("CPU%u: Thread %d\n", pGuestStats->u32CpuId, pGuestStats->u32Threads));
|
---|
2109 |
|
---|
2110 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PROCESSES)
|
---|
2111 | Log(("CPU%u: Processes %d\n", pGuestStats->u32CpuId, pGuestStats->u32Processes));
|
---|
2112 |
|
---|
2113 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_HANDLES)
|
---|
2114 | Log(("CPU%u: Handles %d\n", pGuestStats->u32CpuId, pGuestStats->u32Handles));
|
---|
2115 |
|
---|
2116 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEMORY_LOAD)
|
---|
2117 | Log(("CPU%u: Memory Load %d%%\n", pGuestStats->u32CpuId, pGuestStats->u32MemoryLoad));
|
---|
2118 |
|
---|
2119 | /* Note that reported values are in pages; upper layers expect them in megabytes */
|
---|
2120 | Log(("CPU%u: Page size %-4d bytes\n", pGuestStats->u32CpuId, pGuestStats->u32PageSize));
|
---|
2121 | Assert(pGuestStats->u32PageSize == 4096);
|
---|
2122 |
|
---|
2123 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_TOTAL)
|
---|
2124 | Log(("CPU%u: Total physical memory %-4d MB\n", pGuestStats->u32CpuId, (pGuestStats->u32PhysMemTotal + (_1M/_4K)-1) / (_1M/_4K)));
|
---|
2125 |
|
---|
2126 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_AVAIL)
|
---|
2127 | Log(("CPU%u: Free physical memory %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32PhysMemAvail / (_1M/_4K)));
|
---|
2128 |
|
---|
2129 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_BALLOON)
|
---|
2130 | Log(("CPU%u: Memory balloon size %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32PhysMemBalloon / (_1M/_4K)));
|
---|
2131 |
|
---|
2132 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_COMMIT_TOTAL)
|
---|
2133 | Log(("CPU%u: Committed memory %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32MemCommitTotal / (_1M/_4K)));
|
---|
2134 |
|
---|
2135 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_KERNEL_TOTAL)
|
---|
2136 | Log(("CPU%u: Total kernel memory %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32MemKernelTotal / (_1M/_4K)));
|
---|
2137 |
|
---|
2138 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_KERNEL_PAGED)
|
---|
2139 | Log(("CPU%u: Paged kernel memory %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32MemKernelPaged / (_1M/_4K)));
|
---|
2140 |
|
---|
2141 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_KERNEL_NONPAGED)
|
---|
2142 | Log(("CPU%u: Nonpaged kernel memory %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32MemKernelNonPaged / (_1M/_4K)));
|
---|
2143 |
|
---|
2144 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_SYSTEM_CACHE)
|
---|
2145 | Log(("CPU%u: System cache size %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32MemSystemCache / (_1M/_4K)));
|
---|
2146 |
|
---|
2147 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PAGE_FILE_SIZE)
|
---|
2148 | Log(("CPU%u: Page file size %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32PageFileSize / (_1M/_4K)));
|
---|
2149 | Log(("Statistics end *******************\n"));
|
---|
2150 | #endif /* LOG_ENABLED */
|
---|
2151 |
|
---|
2152 | /* forward the call */
|
---|
2153 | return pThis->pDrv->pfnReportStatistics(pThis->pDrv, &pReq->guestStats);
|
---|
2154 | }
|
---|
2155 |
|
---|
2156 |
|
---|
2157 | /**
|
---|
2158 | * Handles VMMDevReq_QueryCredentials.
|
---|
2159 | *
|
---|
2160 | * @returns VBox status code that the guest should see.
|
---|
2161 | * @param pThis The VMMDev instance data.
|
---|
2162 | * @param pReqHdr The header of the request to handle.
|
---|
2163 | */
|
---|
2164 | static int vmmdevReqHandler_QueryCredentials(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
2165 | {
|
---|
2166 | VMMDevCredentials *pReq = (VMMDevCredentials *)pReqHdr;
|
---|
2167 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
2168 |
|
---|
2169 | /* let's start by nulling out the data */
|
---|
2170 | memset(pReq->szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2171 | memset(pReq->szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2172 | memset(pReq->szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2173 |
|
---|
2174 | /* should we return whether we got credentials for a logon? */
|
---|
2175 | if (pReq->u32Flags & VMMDEV_CREDENTIALS_QUERYPRESENCE)
|
---|
2176 | {
|
---|
2177 | if ( pThis->pCredentials->Logon.szUserName[0]
|
---|
2178 | || pThis->pCredentials->Logon.szPassword[0]
|
---|
2179 | || pThis->pCredentials->Logon.szDomain[0])
|
---|
2180 | pReq->u32Flags |= VMMDEV_CREDENTIALS_PRESENT;
|
---|
2181 | else
|
---|
2182 | pReq->u32Flags &= ~VMMDEV_CREDENTIALS_PRESENT;
|
---|
2183 | }
|
---|
2184 |
|
---|
2185 | /* does the guest want to read logon credentials? */
|
---|
2186 | if (pReq->u32Flags & VMMDEV_CREDENTIALS_READ)
|
---|
2187 | {
|
---|
2188 | if (pThis->pCredentials->Logon.szUserName[0])
|
---|
2189 | strcpy(pReq->szUserName, pThis->pCredentials->Logon.szUserName);
|
---|
2190 | if (pThis->pCredentials->Logon.szPassword[0])
|
---|
2191 | strcpy(pReq->szPassword, pThis->pCredentials->Logon.szPassword);
|
---|
2192 | if (pThis->pCredentials->Logon.szDomain[0])
|
---|
2193 | strcpy(pReq->szDomain, pThis->pCredentials->Logon.szDomain);
|
---|
2194 | if (!pThis->pCredentials->Logon.fAllowInteractiveLogon)
|
---|
2195 | pReq->u32Flags |= VMMDEV_CREDENTIALS_NOLOCALLOGON;
|
---|
2196 | else
|
---|
2197 | pReq->u32Flags &= ~VMMDEV_CREDENTIALS_NOLOCALLOGON;
|
---|
2198 | }
|
---|
2199 |
|
---|
2200 | if (!pThis->fKeepCredentials)
|
---|
2201 | {
|
---|
2202 | /* does the caller want us to destroy the logon credentials? */
|
---|
2203 | if (pReq->u32Flags & VMMDEV_CREDENTIALS_CLEAR)
|
---|
2204 | {
|
---|
2205 | memset(pThis->pCredentials->Logon.szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2206 | memset(pThis->pCredentials->Logon.szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2207 | memset(pThis->pCredentials->Logon.szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2208 | }
|
---|
2209 | }
|
---|
2210 |
|
---|
2211 | /* does the guest want to read credentials for verification? */
|
---|
2212 | if (pReq->u32Flags & VMMDEV_CREDENTIALS_READJUDGE)
|
---|
2213 | {
|
---|
2214 | if (pThis->pCredentials->Judge.szUserName[0])
|
---|
2215 | strcpy(pReq->szUserName, pThis->pCredentials->Judge.szUserName);
|
---|
2216 | if (pThis->pCredentials->Judge.szPassword[0])
|
---|
2217 | strcpy(pReq->szPassword, pThis->pCredentials->Judge.szPassword);
|
---|
2218 | if (pThis->pCredentials->Judge.szDomain[0])
|
---|
2219 | strcpy(pReq->szDomain, pThis->pCredentials->Judge.szDomain);
|
---|
2220 | }
|
---|
2221 |
|
---|
2222 | /* does the caller want us to destroy the judgement credentials? */
|
---|
2223 | if (pReq->u32Flags & VMMDEV_CREDENTIALS_CLEARJUDGE)
|
---|
2224 | {
|
---|
2225 | memset(pThis->pCredentials->Judge.szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2226 | memset(pThis->pCredentials->Judge.szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2227 | memset(pThis->pCredentials->Judge.szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2228 | }
|
---|
2229 |
|
---|
2230 | return VINF_SUCCESS;
|
---|
2231 | }
|
---|
2232 |
|
---|
2233 |
|
---|
2234 | /**
|
---|
2235 | * Handles VMMDevReq_ReportCredentialsJudgement.
|
---|
2236 | *
|
---|
2237 | * @returns VBox status code that the guest should see.
|
---|
2238 | * @param pThis The VMMDev instance data.
|
---|
2239 | * @param pReqHdr The header of the request to handle.
|
---|
2240 | */
|
---|
2241 | static int vmmdevReqHandler_ReportCredentialsJudgement(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
2242 | {
|
---|
2243 | VMMDevCredentials *pReq = (VMMDevCredentials *)pReqHdr;
|
---|
2244 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
2245 |
|
---|
2246 | /* what does the guest think about the credentials? (note: the order is important here!) */
|
---|
2247 | if (pReq->u32Flags & VMMDEV_CREDENTIALS_JUDGE_DENY)
|
---|
2248 | pThis->pDrv->pfnSetCredentialsJudgementResult(pThis->pDrv, VMMDEV_CREDENTIALS_JUDGE_DENY);
|
---|
2249 | else if (pReq->u32Flags & VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT)
|
---|
2250 | pThis->pDrv->pfnSetCredentialsJudgementResult(pThis->pDrv, VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT);
|
---|
2251 | else if (pReq->u32Flags & VMMDEV_CREDENTIALS_JUDGE_OK)
|
---|
2252 | pThis->pDrv->pfnSetCredentialsJudgementResult(pThis->pDrv, VMMDEV_CREDENTIALS_JUDGE_OK);
|
---|
2253 | else
|
---|
2254 | {
|
---|
2255 | Log(("VMMDevReq_ReportCredentialsJudgement: invalid flags: %d!!!\n", pReq->u32Flags));
|
---|
2256 | /** @todo why don't we return VERR_INVALID_PARAMETER to the guest? */
|
---|
2257 | }
|
---|
2258 |
|
---|
2259 | return VINF_SUCCESS;
|
---|
2260 | }
|
---|
2261 |
|
---|
2262 |
|
---|
2263 | /**
|
---|
2264 | * Handles VMMDevReq_GetHostVersion.
|
---|
2265 | *
|
---|
2266 | * @returns VBox status code that the guest should see.
|
---|
2267 | * @param pReqHdr The header of the request to handle.
|
---|
2268 | * @since 3.1.0
|
---|
2269 | * @note The ring-0 VBoxGuestLib uses this to check whether
|
---|
2270 | * VMMDevHGCMParmType_PageList is supported.
|
---|
2271 | */
|
---|
2272 | static int vmmdevReqHandler_GetHostVersion(VMMDevRequestHeader *pReqHdr)
|
---|
2273 | {
|
---|
2274 | VMMDevReqHostVersion *pReq = (VMMDevReqHostVersion *)pReqHdr;
|
---|
2275 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
2276 |
|
---|
2277 | pReq->major = RTBldCfgVersionMajor();
|
---|
2278 | pReq->minor = RTBldCfgVersionMinor();
|
---|
2279 | pReq->build = RTBldCfgVersionBuild();
|
---|
2280 | pReq->revision = RTBldCfgRevision();
|
---|
2281 | pReq->features = VMMDEV_HVF_HGCM_PHYS_PAGE_LIST;
|
---|
2282 | return VINF_SUCCESS;
|
---|
2283 | }
|
---|
2284 |
|
---|
2285 |
|
---|
2286 | /**
|
---|
2287 | * Handles VMMDevReq_GetCpuHotPlugRequest.
|
---|
2288 | *
|
---|
2289 | * @returns VBox status code that the guest should see.
|
---|
2290 | * @param pThis The VMMDev instance data.
|
---|
2291 | * @param pReqHdr The header of the request to handle.
|
---|
2292 | */
|
---|
2293 | static int vmmdevReqHandler_GetCpuHotPlugRequest(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
2294 | {
|
---|
2295 | VMMDevGetCpuHotPlugRequest *pReq = (VMMDevGetCpuHotPlugRequest *)pReqHdr;
|
---|
2296 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
2297 |
|
---|
2298 | pReq->enmEventType = pThis->enmCpuHotPlugEvent;
|
---|
2299 | pReq->idCpuCore = pThis->idCpuCore;
|
---|
2300 | pReq->idCpuPackage = pThis->idCpuPackage;
|
---|
2301 |
|
---|
2302 | /* Clear the event */
|
---|
2303 | pThis->enmCpuHotPlugEvent = VMMDevCpuEventType_None;
|
---|
2304 | pThis->idCpuCore = UINT32_MAX;
|
---|
2305 | pThis->idCpuPackage = UINT32_MAX;
|
---|
2306 |
|
---|
2307 | return VINF_SUCCESS;
|
---|
2308 | }
|
---|
2309 |
|
---|
2310 |
|
---|
2311 | /**
|
---|
2312 | * Handles VMMDevReq_SetCpuHotPlugStatus.
|
---|
2313 | *
|
---|
2314 | * @returns VBox status code that the guest should see.
|
---|
2315 | * @param pThis The VMMDev instance data.
|
---|
2316 | * @param pReqHdr The header of the request to handle.
|
---|
2317 | */
|
---|
2318 | static int vmmdevReqHandler_SetCpuHotPlugStatus(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
2319 | {
|
---|
2320 | VMMDevCpuHotPlugStatusRequest *pReq = (VMMDevCpuHotPlugStatusRequest *)pReqHdr;
|
---|
2321 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
2322 |
|
---|
2323 | if (pReq->enmStatusType == VMMDevCpuStatusType_Disable)
|
---|
2324 | pThis->fCpuHotPlugEventsEnabled = false;
|
---|
2325 | else if (pReq->enmStatusType == VMMDevCpuStatusType_Enable)
|
---|
2326 | pThis->fCpuHotPlugEventsEnabled = true;
|
---|
2327 | else
|
---|
2328 | return VERR_INVALID_PARAMETER;
|
---|
2329 | return VINF_SUCCESS;
|
---|
2330 | }
|
---|
2331 |
|
---|
2332 |
|
---|
2333 | #ifdef DEBUG
|
---|
2334 | /**
|
---|
2335 | * Handles VMMDevReq_LogString.
|
---|
2336 | *
|
---|
2337 | * @returns VBox status code that the guest should see.
|
---|
2338 | * @param pReqHdr The header of the request to handle.
|
---|
2339 | */
|
---|
2340 | static int vmmdevReqHandler_LogString(VMMDevRequestHeader *pReqHdr)
|
---|
2341 | {
|
---|
2342 | VMMDevReqLogString *pReq = (VMMDevReqLogString *)pReqHdr;
|
---|
2343 | AssertMsgReturn(pReq->header.size >= sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
2344 | AssertMsgReturn(pReq->szString[pReq->header.size - RT_UOFFSETOF(VMMDevReqLogString, szString) - 1] == '\0',
|
---|
2345 | ("not null terminated\n"), VERR_INVALID_PARAMETER);
|
---|
2346 |
|
---|
2347 | LogIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP_DEV_VMM_BACKDOOR, ("DEBUG LOG: %s", pReq->szString));
|
---|
2348 | return VINF_SUCCESS;
|
---|
2349 | }
|
---|
2350 | #endif /* DEBUG */
|
---|
2351 |
|
---|
2352 | /**
|
---|
2353 | * Handles VMMDevReq_GetSessionId.
|
---|
2354 | *
|
---|
2355 | * Get a unique "session" ID for this VM, where the ID will be different after each
|
---|
2356 | * start, reset or restore of the VM. This can be used for restore detection
|
---|
2357 | * inside the guest.
|
---|
2358 | *
|
---|
2359 | * @returns VBox status code that the guest should see.
|
---|
2360 | * @param pThis The VMMDev instance data.
|
---|
2361 | * @param pReqHdr The header of the request to handle.
|
---|
2362 | */
|
---|
2363 | static int vmmdevReqHandler_GetSessionId(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
2364 | {
|
---|
2365 | VMMDevReqSessionId *pReq = (VMMDevReqSessionId *)pReqHdr;
|
---|
2366 | AssertMsgReturn(pReq->header.size == sizeof(*pReq), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
2367 |
|
---|
2368 | pReq->idSession = pThis->idSession;
|
---|
2369 | return VINF_SUCCESS;
|
---|
2370 | }
|
---|
2371 |
|
---|
2372 |
|
---|
2373 | #ifdef VBOX_WITH_PAGE_SHARING
|
---|
2374 |
|
---|
2375 | /**
|
---|
2376 | * Handles VMMDevReq_RegisterSharedModule.
|
---|
2377 | *
|
---|
2378 | * @returns VBox status code that the guest should see.
|
---|
2379 | * @param pThis The VMMDev instance data.
|
---|
2380 | * @param pReqHdr The header of the request to handle.
|
---|
2381 | */
|
---|
2382 | static int vmmdevReqHandler_RegisterSharedModule(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
2383 | {
|
---|
2384 | /*
|
---|
2385 | * Basic input validation (more done by GMM).
|
---|
2386 | */
|
---|
2387 | VMMDevSharedModuleRegistrationRequest *pReq = (VMMDevSharedModuleRegistrationRequest *)pReqHdr;
|
---|
2388 | AssertMsgReturn(pReq->header.size >= sizeof(VMMDevSharedModuleRegistrationRequest),
|
---|
2389 | ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
2390 | AssertMsgReturn(pReq->header.size == RT_UOFFSETOF_DYN(VMMDevSharedModuleRegistrationRequest, aRegions[pReq->cRegions]),
|
---|
2391 | ("%u cRegions=%u\n", pReq->header.size, pReq->cRegions), VERR_INVALID_PARAMETER);
|
---|
2392 |
|
---|
2393 | AssertReturn(RTStrEnd(pReq->szName, sizeof(pReq->szName)), VERR_INVALID_PARAMETER);
|
---|
2394 | AssertReturn(RTStrEnd(pReq->szVersion, sizeof(pReq->szVersion)), VERR_INVALID_PARAMETER);
|
---|
2395 | int rc = RTStrValidateEncoding(pReq->szName);
|
---|
2396 | AssertRCReturn(rc, rc);
|
---|
2397 | rc = RTStrValidateEncoding(pReq->szVersion);
|
---|
2398 | AssertRCReturn(rc, rc);
|
---|
2399 |
|
---|
2400 | /*
|
---|
2401 | * Forward the request to the VMM.
|
---|
2402 | */
|
---|
2403 | return PGMR3SharedModuleRegister(PDMDevHlpGetVM(pThis->pDevIns), pReq->enmGuestOS, pReq->szName, pReq->szVersion,
|
---|
2404 | pReq->GCBaseAddr, pReq->cbModule, pReq->cRegions, pReq->aRegions);
|
---|
2405 | }
|
---|
2406 |
|
---|
2407 | /**
|
---|
2408 | * Handles VMMDevReq_UnregisterSharedModule.
|
---|
2409 | *
|
---|
2410 | * @returns VBox status code that the guest should see.
|
---|
2411 | * @param pThis The VMMDev instance data.
|
---|
2412 | * @param pReqHdr The header of the request to handle.
|
---|
2413 | */
|
---|
2414 | static int vmmdevReqHandler_UnregisterSharedModule(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
2415 | {
|
---|
2416 | /*
|
---|
2417 | * Basic input validation.
|
---|
2418 | */
|
---|
2419 | VMMDevSharedModuleUnregistrationRequest *pReq = (VMMDevSharedModuleUnregistrationRequest *)pReqHdr;
|
---|
2420 | AssertMsgReturn(pReq->header.size == sizeof(VMMDevSharedModuleUnregistrationRequest),
|
---|
2421 | ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
2422 |
|
---|
2423 | AssertReturn(RTStrEnd(pReq->szName, sizeof(pReq->szName)), VERR_INVALID_PARAMETER);
|
---|
2424 | AssertReturn(RTStrEnd(pReq->szVersion, sizeof(pReq->szVersion)), VERR_INVALID_PARAMETER);
|
---|
2425 | int rc = RTStrValidateEncoding(pReq->szName);
|
---|
2426 | AssertRCReturn(rc, rc);
|
---|
2427 | rc = RTStrValidateEncoding(pReq->szVersion);
|
---|
2428 | AssertRCReturn(rc, rc);
|
---|
2429 |
|
---|
2430 | /*
|
---|
2431 | * Forward the request to the VMM.
|
---|
2432 | */
|
---|
2433 | return PGMR3SharedModuleUnregister(PDMDevHlpGetVM(pThis->pDevIns), pReq->szName, pReq->szVersion,
|
---|
2434 | pReq->GCBaseAddr, pReq->cbModule);
|
---|
2435 | }
|
---|
2436 |
|
---|
2437 | /**
|
---|
2438 | * Handles VMMDevReq_CheckSharedModules.
|
---|
2439 | *
|
---|
2440 | * @returns VBox status code that the guest should see.
|
---|
2441 | * @param pThis The VMMDev instance data.
|
---|
2442 | * @param pReqHdr The header of the request to handle.
|
---|
2443 | */
|
---|
2444 | static int vmmdevReqHandler_CheckSharedModules(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
2445 | {
|
---|
2446 | VMMDevSharedModuleCheckRequest *pReq = (VMMDevSharedModuleCheckRequest *)pReqHdr;
|
---|
2447 | AssertMsgReturn(pReq->header.size == sizeof(VMMDevSharedModuleCheckRequest),
|
---|
2448 | ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
2449 | return PGMR3SharedModuleCheckAll(PDMDevHlpGetVM(pThis->pDevIns));
|
---|
2450 | }
|
---|
2451 |
|
---|
2452 | /**
|
---|
2453 | * Handles VMMDevReq_GetPageSharingStatus.
|
---|
2454 | *
|
---|
2455 | * @returns VBox status code that the guest should see.
|
---|
2456 | * @param pThis The VMMDev instance data.
|
---|
2457 | * @param pReqHdr The header of the request to handle.
|
---|
2458 | */
|
---|
2459 | static int vmmdevReqHandler_GetPageSharingStatus(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
2460 | {
|
---|
2461 | VMMDevPageSharingStatusRequest *pReq = (VMMDevPageSharingStatusRequest *)pReqHdr;
|
---|
2462 | AssertMsgReturn(pReq->header.size == sizeof(VMMDevPageSharingStatusRequest),
|
---|
2463 | ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
2464 |
|
---|
2465 | pReq->fEnabled = false;
|
---|
2466 | int rc = pThis->pDrv->pfnIsPageFusionEnabled(pThis->pDrv, &pReq->fEnabled);
|
---|
2467 | if (RT_FAILURE(rc))
|
---|
2468 | pReq->fEnabled = false;
|
---|
2469 | return VINF_SUCCESS;
|
---|
2470 | }
|
---|
2471 |
|
---|
2472 |
|
---|
2473 | /**
|
---|
2474 | * Handles VMMDevReq_DebugIsPageShared.
|
---|
2475 | *
|
---|
2476 | * @returns VBox status code that the guest should see.
|
---|
2477 | * @param pThis The VMMDev instance data.
|
---|
2478 | * @param pReqHdr The header of the request to handle.
|
---|
2479 | */
|
---|
2480 | static int vmmdevReqHandler_DebugIsPageShared(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
2481 | {
|
---|
2482 | VMMDevPageIsSharedRequest *pReq = (VMMDevPageIsSharedRequest *)pReqHdr;
|
---|
2483 | AssertMsgReturn(pReq->header.size == sizeof(VMMDevPageIsSharedRequest),
|
---|
2484 | ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
2485 |
|
---|
2486 | # ifdef DEBUG
|
---|
2487 | return PGMR3SharedModuleGetPageState(PDMDevHlpGetVM(pThis->pDevIns), pReq->GCPtrPage, &pReq->fShared, &pReq->uPageFlags);
|
---|
2488 | # else
|
---|
2489 | RT_NOREF1(pThis);
|
---|
2490 | return VERR_NOT_IMPLEMENTED;
|
---|
2491 | # endif
|
---|
2492 | }
|
---|
2493 |
|
---|
2494 | #endif /* VBOX_WITH_PAGE_SHARING */
|
---|
2495 |
|
---|
2496 |
|
---|
2497 | /**
|
---|
2498 | * Handles VMMDevReq_WriteCoreDumpe
|
---|
2499 | *
|
---|
2500 | * @returns VBox status code that the guest should see.
|
---|
2501 | * @param pThis The VMMDev instance data.
|
---|
2502 | * @param pReqHdr Pointer to the request header.
|
---|
2503 | */
|
---|
2504 | static int vmmdevReqHandler_WriteCoreDump(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr)
|
---|
2505 | {
|
---|
2506 | VMMDevReqWriteCoreDump *pReq = (VMMDevReqWriteCoreDump *)pReqHdr;
|
---|
2507 | AssertMsgReturn(pReq->header.size == sizeof(VMMDevReqWriteCoreDump), ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
2508 |
|
---|
2509 | /*
|
---|
2510 | * Only available if explicitly enabled by the user.
|
---|
2511 | */
|
---|
2512 | if (!pThis->fGuestCoreDumpEnabled)
|
---|
2513 | return VERR_ACCESS_DENIED;
|
---|
2514 |
|
---|
2515 | /*
|
---|
2516 | * User makes sure the directory exists before composing the path.
|
---|
2517 | */
|
---|
2518 | if (!RTDirExists(pThis->szGuestCoreDumpDir))
|
---|
2519 | return VERR_PATH_NOT_FOUND;
|
---|
2520 |
|
---|
2521 | char szCorePath[RTPATH_MAX];
|
---|
2522 | RTStrCopy(szCorePath, sizeof(szCorePath), pThis->szGuestCoreDumpDir);
|
---|
2523 | RTPathAppend(szCorePath, sizeof(szCorePath), "VBox.core");
|
---|
2524 |
|
---|
2525 | /*
|
---|
2526 | * Rotate existing cores based on number of additional cores to keep around.
|
---|
2527 | */
|
---|
2528 | if (pThis->cGuestCoreDumps > 0)
|
---|
2529 | for (int64_t i = pThis->cGuestCoreDumps - 1; i >= 0; i--)
|
---|
2530 | {
|
---|
2531 | char szFilePathOld[RTPATH_MAX];
|
---|
2532 | if (i == 0)
|
---|
2533 | RTStrCopy(szFilePathOld, sizeof(szFilePathOld), szCorePath);
|
---|
2534 | else
|
---|
2535 | RTStrPrintf(szFilePathOld, sizeof(szFilePathOld), "%s.%lld", szCorePath, i);
|
---|
2536 |
|
---|
2537 | char szFilePathNew[RTPATH_MAX];
|
---|
2538 | RTStrPrintf(szFilePathNew, sizeof(szFilePathNew), "%s.%lld", szCorePath, i + 1);
|
---|
2539 | int vrc = RTFileMove(szFilePathOld, szFilePathNew, RTFILEMOVE_FLAGS_REPLACE);
|
---|
2540 | if (vrc == VERR_FILE_NOT_FOUND)
|
---|
2541 | RTFileDelete(szFilePathNew);
|
---|
2542 | }
|
---|
2543 |
|
---|
2544 | /*
|
---|
2545 | * Write the core file.
|
---|
2546 | */
|
---|
2547 | PUVM pUVM = PDMDevHlpGetUVM(pThis->pDevIns);
|
---|
2548 | return DBGFR3CoreWrite(pUVM, szCorePath, true /*fReplaceFile*/);
|
---|
2549 | }
|
---|
2550 |
|
---|
2551 |
|
---|
2552 | /**
|
---|
2553 | * Dispatch the request to the appropriate handler function.
|
---|
2554 | *
|
---|
2555 | * @returns Port I/O handler exit code.
|
---|
2556 | * @param pThis The VMM device instance data.
|
---|
2557 | * @param pReqHdr The request header (cached in host memory).
|
---|
2558 | * @param GCPhysReqHdr The guest physical address of the request (for
|
---|
2559 | * HGCM).
|
---|
2560 | * @param pfDelayedUnlock Where to indicate whether the critical section exit
|
---|
2561 | * needs to be delayed till after the request has been
|
---|
2562 | * written back. This is a HGCM kludge, see critsect
|
---|
2563 | * work in hgcmCompletedWorker for more details.
|
---|
2564 | */
|
---|
2565 | static int vmmdevReqDispatcher(PVMMDEV pThis, VMMDevRequestHeader *pReqHdr, RTGCPHYS GCPhysReqHdr, bool *pfDelayedUnlock)
|
---|
2566 | {
|
---|
2567 | int rcRet = VINF_SUCCESS;
|
---|
2568 | *pfDelayedUnlock = false;
|
---|
2569 |
|
---|
2570 | switch (pReqHdr->requestType)
|
---|
2571 | {
|
---|
2572 | case VMMDevReq_ReportGuestInfo:
|
---|
2573 | pReqHdr->rc = vmmdevReqHandler_ReportGuestInfo(pThis, pReqHdr);
|
---|
2574 | break;
|
---|
2575 |
|
---|
2576 | case VMMDevReq_ReportGuestInfo2:
|
---|
2577 | pReqHdr->rc = vmmdevReqHandler_ReportGuestInfo2(pThis, pReqHdr);
|
---|
2578 | break;
|
---|
2579 |
|
---|
2580 | case VMMDevReq_ReportGuestStatus:
|
---|
2581 | pReqHdr->rc = vmmdevReqHandler_ReportGuestStatus(pThis, pReqHdr);
|
---|
2582 | break;
|
---|
2583 |
|
---|
2584 | case VMMDevReq_ReportGuestUserState:
|
---|
2585 | pReqHdr->rc = vmmdevReqHandler_ReportGuestUserState(pThis, pReqHdr);
|
---|
2586 | break;
|
---|
2587 |
|
---|
2588 | case VMMDevReq_ReportGuestCapabilities:
|
---|
2589 | pReqHdr->rc = vmmdevReqHandler_ReportGuestCapabilities(pThis, pReqHdr);
|
---|
2590 | break;
|
---|
2591 |
|
---|
2592 | case VMMDevReq_SetGuestCapabilities:
|
---|
2593 | pReqHdr->rc = vmmdevReqHandler_SetGuestCapabilities(pThis, pReqHdr);
|
---|
2594 | break;
|
---|
2595 |
|
---|
2596 | case VMMDevReq_WriteCoreDump:
|
---|
2597 | pReqHdr->rc = vmmdevReqHandler_WriteCoreDump(pThis, pReqHdr);
|
---|
2598 | break;
|
---|
2599 |
|
---|
2600 | case VMMDevReq_GetMouseStatus:
|
---|
2601 | pReqHdr->rc = vmmdevReqHandler_GetMouseStatus(pThis, pReqHdr);
|
---|
2602 | break;
|
---|
2603 |
|
---|
2604 | case VMMDevReq_SetMouseStatus:
|
---|
2605 | pReqHdr->rc = vmmdevReqHandler_SetMouseStatus(pThis, pReqHdr);
|
---|
2606 | break;
|
---|
2607 |
|
---|
2608 | case VMMDevReq_SetPointerShape:
|
---|
2609 | pReqHdr->rc = vmmdevReqHandler_SetPointerShape(pThis, pReqHdr);
|
---|
2610 | break;
|
---|
2611 |
|
---|
2612 | case VMMDevReq_GetHostTime:
|
---|
2613 | pReqHdr->rc = vmmdevReqHandler_GetHostTime(pThis, pReqHdr);
|
---|
2614 | break;
|
---|
2615 |
|
---|
2616 | case VMMDevReq_GetHypervisorInfo:
|
---|
2617 | pReqHdr->rc = vmmdevReqHandler_GetHypervisorInfo(pThis, pReqHdr);
|
---|
2618 | break;
|
---|
2619 |
|
---|
2620 | case VMMDevReq_SetHypervisorInfo:
|
---|
2621 | pReqHdr->rc = vmmdevReqHandler_SetHypervisorInfo(pThis, pReqHdr);
|
---|
2622 | break;
|
---|
2623 |
|
---|
2624 | case VMMDevReq_RegisterPatchMemory:
|
---|
2625 | pReqHdr->rc = vmmdevReqHandler_RegisterPatchMemory(pThis, pReqHdr);
|
---|
2626 | break;
|
---|
2627 |
|
---|
2628 | case VMMDevReq_DeregisterPatchMemory:
|
---|
2629 | pReqHdr->rc = vmmdevReqHandler_DeregisterPatchMemory(pThis, pReqHdr);
|
---|
2630 | break;
|
---|
2631 |
|
---|
2632 | case VMMDevReq_SetPowerStatus:
|
---|
2633 | {
|
---|
2634 | int rc = pReqHdr->rc = vmmdevReqHandler_SetPowerStatus(pThis, pReqHdr);
|
---|
2635 | if (rc != VINF_SUCCESS && RT_SUCCESS(rc))
|
---|
2636 | rcRet = rc;
|
---|
2637 | break;
|
---|
2638 | }
|
---|
2639 |
|
---|
2640 | case VMMDevReq_GetDisplayChangeRequest:
|
---|
2641 | pReqHdr->rc = vmmdevReqHandler_GetDisplayChangeRequest(pThis, pReqHdr);
|
---|
2642 | break;
|
---|
2643 |
|
---|
2644 | case VMMDevReq_GetDisplayChangeRequest2:
|
---|
2645 | pReqHdr->rc = vmmdevReqHandler_GetDisplayChangeRequest2(pThis, pReqHdr);
|
---|
2646 | break;
|
---|
2647 |
|
---|
2648 | case VMMDevReq_GetDisplayChangeRequestEx:
|
---|
2649 | pReqHdr->rc = vmmdevReqHandler_GetDisplayChangeRequestEx(pThis, pReqHdr);
|
---|
2650 | break;
|
---|
2651 |
|
---|
2652 | case VMMDevReq_GetDisplayChangeRequestMulti:
|
---|
2653 | pReqHdr->rc = vmmdevReqHandler_GetDisplayChangeRequestMulti(pThis, pReqHdr);
|
---|
2654 | break;
|
---|
2655 |
|
---|
2656 | case VMMDevReq_VideoModeSupported:
|
---|
2657 | pReqHdr->rc = vmmdevReqHandler_VideoModeSupported(pThis, pReqHdr);
|
---|
2658 | break;
|
---|
2659 |
|
---|
2660 | case VMMDevReq_VideoModeSupported2:
|
---|
2661 | pReqHdr->rc = vmmdevReqHandler_VideoModeSupported2(pThis, pReqHdr);
|
---|
2662 | break;
|
---|
2663 |
|
---|
2664 | case VMMDevReq_GetHeightReduction:
|
---|
2665 | pReqHdr->rc = vmmdevReqHandler_GetHeightReduction(pThis, pReqHdr);
|
---|
2666 | break;
|
---|
2667 |
|
---|
2668 | case VMMDevReq_AcknowledgeEvents:
|
---|
2669 | pReqHdr->rc = vmmdevReqHandler_AcknowledgeEvents(pThis, pReqHdr);
|
---|
2670 | break;
|
---|
2671 |
|
---|
2672 | case VMMDevReq_CtlGuestFilterMask:
|
---|
2673 | pReqHdr->rc = vmmdevReqHandler_CtlGuestFilterMask(pThis, pReqHdr);
|
---|
2674 | break;
|
---|
2675 |
|
---|
2676 | #ifdef VBOX_WITH_HGCM
|
---|
2677 | case VMMDevReq_HGCMConnect:
|
---|
2678 | pReqHdr->rc = vmmdevReqHandler_HGCMConnect(pThis, pReqHdr, GCPhysReqHdr);
|
---|
2679 | *pfDelayedUnlock = true;
|
---|
2680 | break;
|
---|
2681 |
|
---|
2682 | case VMMDevReq_HGCMDisconnect:
|
---|
2683 | pReqHdr->rc = vmmdevReqHandler_HGCMDisconnect(pThis, pReqHdr, GCPhysReqHdr);
|
---|
2684 | *pfDelayedUnlock = true;
|
---|
2685 | break;
|
---|
2686 |
|
---|
2687 | # ifdef VBOX_WITH_64_BITS_GUESTS
|
---|
2688 | case VMMDevReq_HGCMCall32:
|
---|
2689 | case VMMDevReq_HGCMCall64:
|
---|
2690 | # else
|
---|
2691 | case VMMDevReq_HGCMCall:
|
---|
2692 | # endif /* VBOX_WITH_64_BITS_GUESTS */
|
---|
2693 | pReqHdr->rc = vmmdevReqHandler_HGCMCall(pThis, pReqHdr, GCPhysReqHdr);
|
---|
2694 | *pfDelayedUnlock = true;
|
---|
2695 | break;
|
---|
2696 |
|
---|
2697 | case VMMDevReq_HGCMCancel:
|
---|
2698 | pReqHdr->rc = vmmdevReqHandler_HGCMCancel(pThis, pReqHdr, GCPhysReqHdr);
|
---|
2699 | *pfDelayedUnlock = true;
|
---|
2700 | break;
|
---|
2701 |
|
---|
2702 | case VMMDevReq_HGCMCancel2:
|
---|
2703 | pReqHdr->rc = vmmdevReqHandler_HGCMCancel2(pThis, pReqHdr);
|
---|
2704 | break;
|
---|
2705 | #endif /* VBOX_WITH_HGCM */
|
---|
2706 |
|
---|
2707 | case VMMDevReq_VideoAccelEnable:
|
---|
2708 | pReqHdr->rc = vmmdevReqHandler_VideoAccelEnable(pThis, pReqHdr);
|
---|
2709 | break;
|
---|
2710 |
|
---|
2711 | case VMMDevReq_VideoAccelFlush:
|
---|
2712 | pReqHdr->rc = vmmdevReqHandler_VideoAccelFlush(pThis, pReqHdr);
|
---|
2713 | break;
|
---|
2714 |
|
---|
2715 | case VMMDevReq_VideoSetVisibleRegion:
|
---|
2716 | pReqHdr->rc = vmmdevReqHandler_VideoSetVisibleRegion(pThis, pReqHdr);
|
---|
2717 | break;
|
---|
2718 |
|
---|
2719 | case VMMDevReq_GetSeamlessChangeRequest:
|
---|
2720 | pReqHdr->rc = vmmdevReqHandler_GetSeamlessChangeRequest(pThis, pReqHdr);
|
---|
2721 | break;
|
---|
2722 |
|
---|
2723 | case VMMDevReq_GetVRDPChangeRequest:
|
---|
2724 | pReqHdr->rc = vmmdevReqHandler_GetVRDPChangeRequest(pThis, pReqHdr);
|
---|
2725 | break;
|
---|
2726 |
|
---|
2727 | case VMMDevReq_GetMemBalloonChangeRequest:
|
---|
2728 | pReqHdr->rc = vmmdevReqHandler_GetMemBalloonChangeRequest(pThis, pReqHdr);
|
---|
2729 | break;
|
---|
2730 |
|
---|
2731 | case VMMDevReq_ChangeMemBalloon:
|
---|
2732 | pReqHdr->rc = vmmdevReqHandler_ChangeMemBalloon(pThis, pReqHdr);
|
---|
2733 | break;
|
---|
2734 |
|
---|
2735 | case VMMDevReq_GetStatisticsChangeRequest:
|
---|
2736 | pReqHdr->rc = vmmdevReqHandler_GetStatisticsChangeRequest(pThis, pReqHdr);
|
---|
2737 | break;
|
---|
2738 |
|
---|
2739 | case VMMDevReq_ReportGuestStats:
|
---|
2740 | pReqHdr->rc = vmmdevReqHandler_ReportGuestStats(pThis, pReqHdr);
|
---|
2741 | break;
|
---|
2742 |
|
---|
2743 | case VMMDevReq_QueryCredentials:
|
---|
2744 | pReqHdr->rc = vmmdevReqHandler_QueryCredentials(pThis, pReqHdr);
|
---|
2745 | break;
|
---|
2746 |
|
---|
2747 | case VMMDevReq_ReportCredentialsJudgement:
|
---|
2748 | pReqHdr->rc = vmmdevReqHandler_ReportCredentialsJudgement(pThis, pReqHdr);
|
---|
2749 | break;
|
---|
2750 |
|
---|
2751 | case VMMDevReq_GetHostVersion:
|
---|
2752 | pReqHdr->rc = vmmdevReqHandler_GetHostVersion(pReqHdr);
|
---|
2753 | break;
|
---|
2754 |
|
---|
2755 | case VMMDevReq_GetCpuHotPlugRequest:
|
---|
2756 | pReqHdr->rc = vmmdevReqHandler_GetCpuHotPlugRequest(pThis, pReqHdr);
|
---|
2757 | break;
|
---|
2758 |
|
---|
2759 | case VMMDevReq_SetCpuHotPlugStatus:
|
---|
2760 | pReqHdr->rc = vmmdevReqHandler_SetCpuHotPlugStatus(pThis, pReqHdr);
|
---|
2761 | break;
|
---|
2762 |
|
---|
2763 | #ifdef VBOX_WITH_PAGE_SHARING
|
---|
2764 | case VMMDevReq_RegisterSharedModule:
|
---|
2765 | pReqHdr->rc = vmmdevReqHandler_RegisterSharedModule(pThis, pReqHdr);
|
---|
2766 | break;
|
---|
2767 |
|
---|
2768 | case VMMDevReq_UnregisterSharedModule:
|
---|
2769 | pReqHdr->rc = vmmdevReqHandler_UnregisterSharedModule(pThis, pReqHdr);
|
---|
2770 | break;
|
---|
2771 |
|
---|
2772 | case VMMDevReq_CheckSharedModules:
|
---|
2773 | pReqHdr->rc = vmmdevReqHandler_CheckSharedModules(pThis, pReqHdr);
|
---|
2774 | break;
|
---|
2775 |
|
---|
2776 | case VMMDevReq_GetPageSharingStatus:
|
---|
2777 | pReqHdr->rc = vmmdevReqHandler_GetPageSharingStatus(pThis, pReqHdr);
|
---|
2778 | break;
|
---|
2779 |
|
---|
2780 | case VMMDevReq_DebugIsPageShared:
|
---|
2781 | pReqHdr->rc = vmmdevReqHandler_DebugIsPageShared(pThis, pReqHdr);
|
---|
2782 | break;
|
---|
2783 |
|
---|
2784 | #endif /* VBOX_WITH_PAGE_SHARING */
|
---|
2785 |
|
---|
2786 | #ifdef DEBUG
|
---|
2787 | case VMMDevReq_LogString:
|
---|
2788 | pReqHdr->rc = vmmdevReqHandler_LogString(pReqHdr);
|
---|
2789 | break;
|
---|
2790 | #endif
|
---|
2791 |
|
---|
2792 | case VMMDevReq_GetSessionId:
|
---|
2793 | pReqHdr->rc = vmmdevReqHandler_GetSessionId(pThis, pReqHdr);
|
---|
2794 | break;
|
---|
2795 |
|
---|
2796 | /*
|
---|
2797 | * Guest wants to give up a timeslice.
|
---|
2798 | * Note! This was only ever used by experimental GAs!
|
---|
2799 | */
|
---|
2800 | /** @todo maybe we could just remove this? */
|
---|
2801 | case VMMDevReq_Idle:
|
---|
2802 | {
|
---|
2803 | /* just return to EMT telling it that we want to halt */
|
---|
2804 | rcRet = VINF_EM_HALT;
|
---|
2805 | break;
|
---|
2806 | }
|
---|
2807 |
|
---|
2808 | case VMMDevReq_GuestHeartbeat:
|
---|
2809 | pReqHdr->rc = vmmDevReqHandler_GuestHeartbeat(pThis);
|
---|
2810 | break;
|
---|
2811 |
|
---|
2812 | case VMMDevReq_HeartbeatConfigure:
|
---|
2813 | pReqHdr->rc = vmmDevReqHandler_HeartbeatConfigure(pThis, pReqHdr);
|
---|
2814 | break;
|
---|
2815 |
|
---|
2816 | case VMMDevReq_NtBugCheck:
|
---|
2817 | pReqHdr->rc = vmmDevReqHandler_NtBugCheck(pThis, pReqHdr);
|
---|
2818 | break;
|
---|
2819 |
|
---|
2820 | default:
|
---|
2821 | {
|
---|
2822 | pReqHdr->rc = VERR_NOT_IMPLEMENTED;
|
---|
2823 | Log(("VMMDev unknown request type %d\n", pReqHdr->requestType));
|
---|
2824 | break;
|
---|
2825 | }
|
---|
2826 | }
|
---|
2827 | return rcRet;
|
---|
2828 | }
|
---|
2829 |
|
---|
2830 |
|
---|
2831 | /**
|
---|
2832 | * @callback_method_impl{FNIOMIOPORTOUT, Port I/O Handler for the generic
|
---|
2833 | * request interface.}
|
---|
2834 | */
|
---|
2835 | static DECLCALLBACK(int) vmmdevRequestHandler(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
|
---|
2836 | {
|
---|
2837 | RT_NOREF2(Port, cb);
|
---|
2838 | PVMMDEV pThis = (VMMDevState*)pvUser;
|
---|
2839 |
|
---|
2840 | /*
|
---|
2841 | * The caller has passed the guest context physical address of the request
|
---|
2842 | * structure. We'll copy all of it into a heap buffer eventually, but we
|
---|
2843 | * will have to start off with the header.
|
---|
2844 | */
|
---|
2845 | VMMDevRequestHeader requestHeader;
|
---|
2846 | RT_ZERO(requestHeader);
|
---|
2847 | PDMDevHlpPhysRead(pDevIns, (RTGCPHYS)u32, &requestHeader, sizeof(requestHeader));
|
---|
2848 |
|
---|
2849 | /* The structure size must be greater or equal to the header size. */
|
---|
2850 | if (requestHeader.size < sizeof(VMMDevRequestHeader))
|
---|
2851 | {
|
---|
2852 | Log(("VMMDev request header size too small! size = %d\n", requestHeader.size));
|
---|
2853 | return VINF_SUCCESS;
|
---|
2854 | }
|
---|
2855 |
|
---|
2856 | /* Check the version of the header structure. */
|
---|
2857 | if (requestHeader.version != VMMDEV_REQUEST_HEADER_VERSION)
|
---|
2858 | {
|
---|
2859 | Log(("VMMDev: guest header version (0x%08X) differs from ours (0x%08X)\n", requestHeader.version, VMMDEV_REQUEST_HEADER_VERSION));
|
---|
2860 | return VINF_SUCCESS;
|
---|
2861 | }
|
---|
2862 |
|
---|
2863 | Log2(("VMMDev request issued: %d\n", requestHeader.requestType));
|
---|
2864 |
|
---|
2865 | int rcRet = VINF_SUCCESS;
|
---|
2866 | bool fDelayedUnlock = false;
|
---|
2867 | VMMDevRequestHeader *pRequestHeader = NULL;
|
---|
2868 |
|
---|
2869 | /* Check that is doesn't exceed the max packet size. */
|
---|
2870 | if (requestHeader.size <= VMMDEV_MAX_VMMDEVREQ_SIZE)
|
---|
2871 | {
|
---|
2872 | /*
|
---|
2873 | * We require the GAs to report it's information before we let it have
|
---|
2874 | * access to all the functions. The VMMDevReq_ReportGuestInfo request
|
---|
2875 | * is the one which unlocks the access. Newer additions will first
|
---|
2876 | * issue VMMDevReq_ReportGuestInfo2, older ones doesn't know this one.
|
---|
2877 | * Two exceptions: VMMDevReq_GetHostVersion and VMMDevReq_WriteCoreDump.
|
---|
2878 | */
|
---|
2879 | if ( pThis->fu32AdditionsOk
|
---|
2880 | || requestHeader.requestType == VMMDevReq_ReportGuestInfo2
|
---|
2881 | || requestHeader.requestType == VMMDevReq_ReportGuestInfo
|
---|
2882 | || requestHeader.requestType == VMMDevReq_WriteCoreDump
|
---|
2883 | || requestHeader.requestType == VMMDevReq_GetHostVersion
|
---|
2884 | )
|
---|
2885 | {
|
---|
2886 | /*
|
---|
2887 | * The request looks fine. Allocate a heap block for it, read the
|
---|
2888 | * entire package from guest memory and feed it to the dispatcher.
|
---|
2889 | */
|
---|
2890 | pRequestHeader = (VMMDevRequestHeader *)RTMemAlloc(requestHeader.size);
|
---|
2891 | if (pRequestHeader)
|
---|
2892 | {
|
---|
2893 | memcpy(pRequestHeader, &requestHeader, sizeof(VMMDevRequestHeader));
|
---|
2894 | size_t cbLeft = requestHeader.size - sizeof(VMMDevRequestHeader);
|
---|
2895 | if (cbLeft)
|
---|
2896 | PDMDevHlpPhysRead(pDevIns,
|
---|
2897 | (RTGCPHYS)u32 + sizeof(VMMDevRequestHeader),
|
---|
2898 | (uint8_t *)pRequestHeader + sizeof(VMMDevRequestHeader),
|
---|
2899 | cbLeft);
|
---|
2900 |
|
---|
2901 | PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
|
---|
2902 | rcRet = vmmdevReqDispatcher(pThis, pRequestHeader, u32, &fDelayedUnlock);
|
---|
2903 | if (!fDelayedUnlock)
|
---|
2904 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2905 | }
|
---|
2906 | else
|
---|
2907 | {
|
---|
2908 | Log(("VMMDev: RTMemAlloc failed!\n"));
|
---|
2909 | requestHeader.rc = VERR_NO_MEMORY;
|
---|
2910 | }
|
---|
2911 | }
|
---|
2912 | else
|
---|
2913 | {
|
---|
2914 | LogRelMax(10, ("VMMDev: Guest has not yet reported to us -- refusing operation of request #%d\n",
|
---|
2915 | requestHeader.requestType));
|
---|
2916 | requestHeader.rc = VERR_NOT_SUPPORTED;
|
---|
2917 | }
|
---|
2918 | }
|
---|
2919 | else
|
---|
2920 | {
|
---|
2921 | LogRelMax(50, ("VMMDev: Request packet too big (%x), refusing operation\n", requestHeader.size));
|
---|
2922 | requestHeader.rc = VERR_NOT_SUPPORTED;
|
---|
2923 | }
|
---|
2924 |
|
---|
2925 | /*
|
---|
2926 | * Write the result back to guest memory
|
---|
2927 | */
|
---|
2928 | if (pRequestHeader)
|
---|
2929 | {
|
---|
2930 | PDMDevHlpPhysWrite(pDevIns, u32, pRequestHeader, pRequestHeader->size);
|
---|
2931 | if (fDelayedUnlock)
|
---|
2932 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2933 | RTMemFree(pRequestHeader);
|
---|
2934 | }
|
---|
2935 | else
|
---|
2936 | {
|
---|
2937 | /* early error case; write back header only */
|
---|
2938 | PDMDevHlpPhysWrite(pDevIns, u32, &requestHeader, sizeof(requestHeader));
|
---|
2939 | Assert(!fDelayedUnlock);
|
---|
2940 | }
|
---|
2941 |
|
---|
2942 | return rcRet;
|
---|
2943 | }
|
---|
2944 |
|
---|
2945 |
|
---|
2946 | /* -=-=-=-=-=- PCI Device -=-=-=-=-=- */
|
---|
2947 |
|
---|
2948 |
|
---|
2949 | /**
|
---|
2950 | * @callback_method_impl{FNPCIIOREGIONMAP,MMIO/MMIO2 regions}
|
---|
2951 | */
|
---|
2952 | static DECLCALLBACK(int) vmmdevIORAMRegionMap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
|
---|
2953 | RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType)
|
---|
2954 | {
|
---|
2955 | RT_NOREF1(cb);
|
---|
2956 | LogFlow(("vmmdevR3IORAMRegionMap: iRegion=%d GCPhysAddress=%RGp cb=%RGp enmType=%d\n", iRegion, GCPhysAddress, cb, enmType));
|
---|
2957 | PVMMDEV pThis = RT_FROM_MEMBER(pPciDev, VMMDEV, PciDev);
|
---|
2958 | int rc;
|
---|
2959 |
|
---|
2960 | if (iRegion == 1)
|
---|
2961 | {
|
---|
2962 | AssertReturn(enmType == PCI_ADDRESS_SPACE_MEM, VERR_INTERNAL_ERROR);
|
---|
2963 | Assert(pThis->pVMMDevRAMR3 != NULL);
|
---|
2964 | if (GCPhysAddress != NIL_RTGCPHYS)
|
---|
2965 | {
|
---|
2966 | /*
|
---|
2967 | * Map the MMIO2 memory.
|
---|
2968 | */
|
---|
2969 | pThis->GCPhysVMMDevRAM = GCPhysAddress;
|
---|
2970 | Assert(pThis->GCPhysVMMDevRAM == GCPhysAddress);
|
---|
2971 | rc = PDMDevHlpMMIOExMap(pDevIns, pPciDev, iRegion, GCPhysAddress);
|
---|
2972 | }
|
---|
2973 | else
|
---|
2974 | {
|
---|
2975 | /*
|
---|
2976 | * It is about to be unmapped, just clean up.
|
---|
2977 | */
|
---|
2978 | pThis->GCPhysVMMDevRAM = NIL_RTGCPHYS32;
|
---|
2979 | rc = VINF_SUCCESS;
|
---|
2980 | }
|
---|
2981 | }
|
---|
2982 | else if (iRegion == 2)
|
---|
2983 | {
|
---|
2984 | AssertReturn(enmType == PCI_ADDRESS_SPACE_MEM_PREFETCH, VERR_INTERNAL_ERROR);
|
---|
2985 | Assert(pThis->pVMMDevHeapR3 != NULL);
|
---|
2986 | if (GCPhysAddress != NIL_RTGCPHYS)
|
---|
2987 | {
|
---|
2988 | /*
|
---|
2989 | * Map the MMIO2 memory.
|
---|
2990 | */
|
---|
2991 | pThis->GCPhysVMMDevHeap = GCPhysAddress;
|
---|
2992 | Assert(pThis->GCPhysVMMDevHeap == GCPhysAddress);
|
---|
2993 | rc = PDMDevHlpMMIOExMap(pDevIns, pPciDev, iRegion, GCPhysAddress);
|
---|
2994 | if (RT_SUCCESS(rc))
|
---|
2995 | rc = PDMDevHlpRegisterVMMDevHeap(pDevIns, GCPhysAddress, pThis->pVMMDevHeapR3, VMMDEV_HEAP_SIZE);
|
---|
2996 | }
|
---|
2997 | else
|
---|
2998 | {
|
---|
2999 | /*
|
---|
3000 | * It is about to be unmapped, just clean up.
|
---|
3001 | */
|
---|
3002 | PDMDevHlpRegisterVMMDevHeap(pDevIns, NIL_RTGCPHYS, pThis->pVMMDevHeapR3, VMMDEV_HEAP_SIZE);
|
---|
3003 | pThis->GCPhysVMMDevHeap = NIL_RTGCPHYS32;
|
---|
3004 | rc = VINF_SUCCESS;
|
---|
3005 | }
|
---|
3006 | }
|
---|
3007 | else
|
---|
3008 | {
|
---|
3009 | AssertMsgFailed(("%d\n", iRegion));
|
---|
3010 | rc = VERR_INVALID_PARAMETER;
|
---|
3011 | }
|
---|
3012 |
|
---|
3013 | return rc;
|
---|
3014 | }
|
---|
3015 |
|
---|
3016 |
|
---|
3017 | /**
|
---|
3018 | * @callback_method_impl{FNPCIIOREGIONMAP,I/O Port Region}
|
---|
3019 | */
|
---|
3020 | static DECLCALLBACK(int) vmmdevIOPortRegionMap(PPDMDEVINS pDevIns, PPDMPCIDEV pPciDev, uint32_t iRegion,
|
---|
3021 | RTGCPHYS GCPhysAddress, RTGCPHYS cb, PCIADDRESSSPACE enmType)
|
---|
3022 | {
|
---|
3023 | LogFlow(("vmmdevIOPortRegionMap: iRegion=%d GCPhysAddress=%RGp cb=%RGp enmType=%d\n", iRegion, GCPhysAddress, cb, enmType));
|
---|
3024 | RT_NOREF3(iRegion, cb, enmType);
|
---|
3025 | PVMMDEV pThis = RT_FROM_MEMBER(pPciDev, VMMDEV, PciDev);
|
---|
3026 |
|
---|
3027 | Assert(enmType == PCI_ADDRESS_SPACE_IO);
|
---|
3028 | Assert(iRegion == 0);
|
---|
3029 | AssertMsg(RT_ALIGN(GCPhysAddress, 8) == GCPhysAddress, ("Expected 8 byte alignment. GCPhysAddress=%#x\n", GCPhysAddress));
|
---|
3030 |
|
---|
3031 | /*
|
---|
3032 | * Register our port IO handlers.
|
---|
3033 | */
|
---|
3034 | int rc = PDMDevHlpIOPortRegister(pDevIns, (RTIOPORT)GCPhysAddress + VMMDEV_PORT_OFF_REQUEST, 1,
|
---|
3035 | pThis, vmmdevRequestHandler, NULL, NULL, NULL, "VMMDev Request Handler");
|
---|
3036 | AssertRC(rc);
|
---|
3037 | return rc;
|
---|
3038 | }
|
---|
3039 |
|
---|
3040 |
|
---|
3041 |
|
---|
3042 | /* -=-=-=-=-=- Backdoor Logging and Time Sync. -=-=-=-=-=- */
|
---|
3043 |
|
---|
3044 | /**
|
---|
3045 | * @callback_method_impl{FNIOMIOPORTOUT, Backdoor Logging.}
|
---|
3046 | */
|
---|
3047 | static DECLCALLBACK(int) vmmdevBackdoorLog(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
|
---|
3048 | {
|
---|
3049 | RT_NOREF1(pvUser);
|
---|
3050 | PVMMDEV pThis = PDMINS_2_DATA(pDevIns, VMMDevState *);
|
---|
3051 |
|
---|
3052 | if (!pThis->fBackdoorLogDisabled && cb == 1 && Port == RTLOG_DEBUG_PORT)
|
---|
3053 | {
|
---|
3054 |
|
---|
3055 | /* The raw version. */
|
---|
3056 | switch (u32)
|
---|
3057 | {
|
---|
3058 | case '\r': LogIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP_DEV_VMM_BACKDOOR, ("vmmdev: <return>\n")); break;
|
---|
3059 | case '\n': LogIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP_DEV_VMM_BACKDOOR, ("vmmdev: <newline>\n")); break;
|
---|
3060 | case '\t': LogIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP_DEV_VMM_BACKDOOR, ("vmmdev: <tab>\n")); break;
|
---|
3061 | default: LogIt(RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP_DEV_VMM_BACKDOOR, ("vmmdev: %c (%02x)\n", u32, u32)); break;
|
---|
3062 | }
|
---|
3063 |
|
---|
3064 | /* The readable, buffered version. */
|
---|
3065 | if (u32 == '\n' || u32 == '\r')
|
---|
3066 | {
|
---|
3067 | pThis->szMsg[pThis->iMsg] = '\0';
|
---|
3068 | if (pThis->iMsg)
|
---|
3069 | LogRelIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP_DEV_VMM_BACKDOOR, ("VMMDev: Guest Log: %s\n", pThis->szMsg));
|
---|
3070 | pThis->iMsg = 0;
|
---|
3071 | }
|
---|
3072 | else
|
---|
3073 | {
|
---|
3074 | if (pThis->iMsg >= sizeof(pThis->szMsg)-1)
|
---|
3075 | {
|
---|
3076 | pThis->szMsg[pThis->iMsg] = '\0';
|
---|
3077 | LogRelIt(RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP_DEV_VMM_BACKDOOR, ("VMMDev: Guest Log: %s\n", pThis->szMsg));
|
---|
3078 | pThis->iMsg = 0;
|
---|
3079 | }
|
---|
3080 | pThis->szMsg[pThis->iMsg] = (char )u32;
|
---|
3081 | pThis->szMsg[++pThis->iMsg] = '\0';
|
---|
3082 | }
|
---|
3083 | }
|
---|
3084 | return VINF_SUCCESS;
|
---|
3085 | }
|
---|
3086 |
|
---|
3087 | #ifdef VMMDEV_WITH_ALT_TIMESYNC
|
---|
3088 |
|
---|
3089 | /**
|
---|
3090 | * @callback_method_impl{FNIOMIOPORTOUT, Alternative time synchronization.}
|
---|
3091 | */
|
---|
3092 | static DECLCALLBACK(int) vmmdevAltTimeSyncWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
|
---|
3093 | {
|
---|
3094 | RT_NOREF2(pvUser, Port);
|
---|
3095 | PVMMDEV pThis = PDMINS_2_DATA(pDevIns, VMMDevState *);
|
---|
3096 | if (cb == 4)
|
---|
3097 | {
|
---|
3098 | /* Selects high (0) or low (1) DWORD. The high has to be read first. */
|
---|
3099 | switch (u32)
|
---|
3100 | {
|
---|
3101 | case 0:
|
---|
3102 | pThis->fTimesyncBackdoorLo = false;
|
---|
3103 | break;
|
---|
3104 | case 1:
|
---|
3105 | pThis->fTimesyncBackdoorLo = true;
|
---|
3106 | break;
|
---|
3107 | default:
|
---|
3108 | Log(("vmmdevAltTimeSyncWrite: Invalid access cb=%#x u32=%#x\n", cb, u32));
|
---|
3109 | break;
|
---|
3110 | }
|
---|
3111 | }
|
---|
3112 | else
|
---|
3113 | Log(("vmmdevAltTimeSyncWrite: Invalid access cb=%#x u32=%#x\n", cb, u32));
|
---|
3114 | return VINF_SUCCESS;
|
---|
3115 | }
|
---|
3116 |
|
---|
3117 | /**
|
---|
3118 | * @callback_method_impl{FNIOMIOPORTOUT, Alternative time synchronization.}
|
---|
3119 | */
|
---|
3120 | static DECLCALLBACK(int) vmmdevAltTimeSyncRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
|
---|
3121 | {
|
---|
3122 | RT_NOREF2(pvUser, Port);
|
---|
3123 | PVMMDEV pThis = PDMINS_2_DATA(pDevIns, VMMDevState *);
|
---|
3124 | int rc;
|
---|
3125 | if (cb == 4)
|
---|
3126 | {
|
---|
3127 | if (pThis->fTimesyncBackdoorLo)
|
---|
3128 | *pu32 = (uint32_t)pThis->hostTime;
|
---|
3129 | else
|
---|
3130 | {
|
---|
3131 | /* Reading the high dword gets and saves the current time. */
|
---|
3132 | RTTIMESPEC Now;
|
---|
3133 | pThis->hostTime = RTTimeSpecGetMilli(PDMDevHlpTMUtcNow(pDevIns, &Now));
|
---|
3134 | *pu32 = (uint32_t)(pThis->hostTime >> 32);
|
---|
3135 | }
|
---|
3136 | rc = VINF_SUCCESS;
|
---|
3137 | }
|
---|
3138 | else
|
---|
3139 | {
|
---|
3140 | Log(("vmmdevAltTimeSyncRead: Invalid access cb=%#x\n", cb));
|
---|
3141 | rc = VERR_IOM_IOPORT_UNUSED;
|
---|
3142 | }
|
---|
3143 | return rc;
|
---|
3144 | }
|
---|
3145 |
|
---|
3146 | #endif /* VMMDEV_WITH_ALT_TIMESYNC */
|
---|
3147 |
|
---|
3148 |
|
---|
3149 | /* -=-=-=-=-=- IBase -=-=-=-=-=- */
|
---|
3150 |
|
---|
3151 | /**
|
---|
3152 | * @interface_method_impl{PDMIBASE,pfnQueryInterface}
|
---|
3153 | */
|
---|
3154 | static DECLCALLBACK(void *) vmmdevPortQueryInterface(PPDMIBASE pInterface, const char *pszIID)
|
---|
3155 | {
|
---|
3156 | PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IBase);
|
---|
3157 |
|
---|
3158 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase);
|
---|
3159 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIVMMDEVPORT, &pThis->IPort);
|
---|
3160 | #ifdef VBOX_WITH_HGCM
|
---|
3161 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHGCMPORT, &pThis->IHGCMPort);
|
---|
3162 | #endif
|
---|
3163 | /* Currently only for shared folders. */
|
---|
3164 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThis->SharedFolders.ILeds);
|
---|
3165 | return NULL;
|
---|
3166 | }
|
---|
3167 |
|
---|
3168 |
|
---|
3169 | /* -=-=-=-=-=- ILeds -=-=-=-=-=- */
|
---|
3170 |
|
---|
3171 | /**
|
---|
3172 | * Gets the pointer to the status LED of a unit.
|
---|
3173 | *
|
---|
3174 | * @returns VBox status code.
|
---|
3175 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
3176 | * @param iLUN The unit which status LED we desire.
|
---|
3177 | * @param ppLed Where to store the LED pointer.
|
---|
3178 | */
|
---|
3179 | static DECLCALLBACK(int) vmmdevQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed)
|
---|
3180 | {
|
---|
3181 | PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, SharedFolders.ILeds);
|
---|
3182 | if (iLUN == 0) /* LUN 0 is shared folders */
|
---|
3183 | {
|
---|
3184 | *ppLed = &pThis->SharedFolders.Led;
|
---|
3185 | return VINF_SUCCESS;
|
---|
3186 | }
|
---|
3187 | return VERR_PDM_LUN_NOT_FOUND;
|
---|
3188 | }
|
---|
3189 |
|
---|
3190 |
|
---|
3191 | /* -=-=-=-=-=- PDMIVMMDEVPORT (VMMDEV::IPort) -=-=-=-=-=- */
|
---|
3192 |
|
---|
3193 | /**
|
---|
3194 | * @interface_method_impl{PDMIVMMDEVPORT,pfnQueryAbsoluteMouse}
|
---|
3195 | */
|
---|
3196 | static DECLCALLBACK(int) vmmdevIPort_QueryAbsoluteMouse(PPDMIVMMDEVPORT pInterface, int32_t *pxAbs, int32_t *pyAbs)
|
---|
3197 | {
|
---|
3198 | PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
|
---|
3199 |
|
---|
3200 | /** @todo at the first sign of trouble in this area, just enter the critsect.
|
---|
3201 | * As indicated by the comment below, the atomic reads serves no real purpose
|
---|
3202 | * here since we can assume cache coherency protocoles and int32_t alignment
|
---|
3203 | * rules making sure we won't see a halfwritten value. */
|
---|
3204 | if (pxAbs)
|
---|
3205 | *pxAbs = ASMAtomicReadS32(&pThis->mouseXAbs); /* why the atomic read? */
|
---|
3206 | if (pyAbs)
|
---|
3207 | *pyAbs = ASMAtomicReadS32(&pThis->mouseYAbs);
|
---|
3208 |
|
---|
3209 | return VINF_SUCCESS;
|
---|
3210 | }
|
---|
3211 |
|
---|
3212 | /**
|
---|
3213 | * @interface_method_impl{PDMIVMMDEVPORT,pfnSetAbsoluteMouse}
|
---|
3214 | */
|
---|
3215 | static DECLCALLBACK(int) vmmdevIPort_SetAbsoluteMouse(PPDMIVMMDEVPORT pInterface, int32_t xAbs, int32_t yAbs)
|
---|
3216 | {
|
---|
3217 | PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
|
---|
3218 | PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
|
---|
3219 |
|
---|
3220 | if ( pThis->mouseXAbs != xAbs
|
---|
3221 | || pThis->mouseYAbs != yAbs)
|
---|
3222 | {
|
---|
3223 | Log2(("vmmdevIPort_SetAbsoluteMouse : settings absolute position to x = %d, y = %d\n", xAbs, yAbs));
|
---|
3224 | pThis->mouseXAbs = xAbs;
|
---|
3225 | pThis->mouseYAbs = yAbs;
|
---|
3226 | VMMDevNotifyGuest(pThis, VMMDEV_EVENT_MOUSE_POSITION_CHANGED);
|
---|
3227 | }
|
---|
3228 |
|
---|
3229 | PDMCritSectLeave(&pThis->CritSect);
|
---|
3230 | return VINF_SUCCESS;
|
---|
3231 | }
|
---|
3232 |
|
---|
3233 | /**
|
---|
3234 | * @interface_method_impl{PDMIVMMDEVPORT,pfnQueryMouseCapabilities}
|
---|
3235 | */
|
---|
3236 | static DECLCALLBACK(int) vmmdevIPort_QueryMouseCapabilities(PPDMIVMMDEVPORT pInterface, uint32_t *pfCapabilities)
|
---|
3237 | {
|
---|
3238 | PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
|
---|
3239 | AssertPtrReturn(pfCapabilities, VERR_INVALID_PARAMETER);
|
---|
3240 |
|
---|
3241 | *pfCapabilities = pThis->mouseCapabilities;
|
---|
3242 | return VINF_SUCCESS;
|
---|
3243 | }
|
---|
3244 |
|
---|
3245 | /**
|
---|
3246 | * @interface_method_impl{PDMIVMMDEVPORT,pfnUpdateMouseCapabilities}
|
---|
3247 | */
|
---|
3248 | static DECLCALLBACK(int)
|
---|
3249 | vmmdevIPort_UpdateMouseCapabilities(PPDMIVMMDEVPORT pInterface, uint32_t fCapsAdded, uint32_t fCapsRemoved)
|
---|
3250 | {
|
---|
3251 | PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
|
---|
3252 | PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
|
---|
3253 |
|
---|
3254 | uint32_t fOldCaps = pThis->mouseCapabilities;
|
---|
3255 | pThis->mouseCapabilities &= ~(fCapsRemoved & VMMDEV_MOUSE_HOST_MASK);
|
---|
3256 | pThis->mouseCapabilities |= (fCapsAdded & VMMDEV_MOUSE_HOST_MASK)
|
---|
3257 | | VMMDEV_MOUSE_HOST_RECHECKS_NEEDS_HOST_CURSOR;
|
---|
3258 | bool fNotify = fOldCaps != pThis->mouseCapabilities;
|
---|
3259 |
|
---|
3260 | LogRelFlow(("VMMDev: vmmdevIPort_UpdateMouseCapabilities: fCapsAdded=0x%x, fCapsRemoved=0x%x, fNotify=%RTbool\n", fCapsAdded,
|
---|
3261 | fCapsRemoved, fNotify));
|
---|
3262 |
|
---|
3263 | if (fNotify)
|
---|
3264 | VMMDevNotifyGuest(pThis, VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED);
|
---|
3265 |
|
---|
3266 | PDMCritSectLeave(&pThis->CritSect);
|
---|
3267 | return VINF_SUCCESS;
|
---|
3268 | }
|
---|
3269 |
|
---|
3270 | static bool vmmdevIsMonitorDefEqual(VMMDevDisplayDef const *pNew, VMMDevDisplayDef const *pOld)
|
---|
3271 | {
|
---|
3272 | bool fEqual = pNew->idDisplay == pOld->idDisplay;
|
---|
3273 |
|
---|
3274 | fEqual = fEqual && ( !RT_BOOL(pNew->fDisplayFlags & VMMDEV_DISPLAY_ORIGIN) /* No change. */
|
---|
3275 | || ( RT_BOOL(pOld->fDisplayFlags & VMMDEV_DISPLAY_ORIGIN) /* Old value exists and */
|
---|
3276 | && pNew->xOrigin == pOld->xOrigin /* the old is equal to the new. */
|
---|
3277 | && pNew->yOrigin == pOld->yOrigin));
|
---|
3278 |
|
---|
3279 | fEqual = fEqual && ( !RT_BOOL(pNew->fDisplayFlags & VMMDEV_DISPLAY_CX)
|
---|
3280 | || ( RT_BOOL(pOld->fDisplayFlags & VMMDEV_DISPLAY_CX)
|
---|
3281 | && pNew->cx == pOld->cx));
|
---|
3282 |
|
---|
3283 | fEqual = fEqual && ( !RT_BOOL(pNew->fDisplayFlags & VMMDEV_DISPLAY_CY)
|
---|
3284 | || ( RT_BOOL(pOld->fDisplayFlags & VMMDEV_DISPLAY_CY)
|
---|
3285 | && pNew->cy == pOld->cy));
|
---|
3286 |
|
---|
3287 | fEqual = fEqual && ( !RT_BOOL(pNew->fDisplayFlags & VMMDEV_DISPLAY_BPP)
|
---|
3288 | || ( RT_BOOL(pOld->fDisplayFlags & VMMDEV_DISPLAY_BPP)
|
---|
3289 | && pNew->cBitsPerPixel == pOld->cBitsPerPixel));
|
---|
3290 |
|
---|
3291 | fEqual = fEqual && ( RT_BOOL(pNew->fDisplayFlags & VMMDEV_DISPLAY_DISABLED)
|
---|
3292 | == RT_BOOL(pOld->fDisplayFlags & VMMDEV_DISPLAY_DISABLED));
|
---|
3293 |
|
---|
3294 | fEqual = fEqual && ( RT_BOOL(pNew->fDisplayFlags & VMMDEV_DISPLAY_PRIMARY)
|
---|
3295 | == RT_BOOL(pOld->fDisplayFlags & VMMDEV_DISPLAY_PRIMARY));
|
---|
3296 |
|
---|
3297 | return fEqual;
|
---|
3298 | }
|
---|
3299 |
|
---|
3300 | /**
|
---|
3301 | * @interface_method_impl{PDMIVMMDEVPORT,pfnRequestDisplayChange}
|
---|
3302 | */
|
---|
3303 | static DECLCALLBACK(int)
|
---|
3304 | vmmdevIPort_RequestDisplayChange(PPDMIVMMDEVPORT pInterface, uint32_t cDisplays, VMMDevDisplayDef const *paDisplays, bool fForce)
|
---|
3305 | {
|
---|
3306 | int rc = VINF_SUCCESS;
|
---|
3307 |
|
---|
3308 | PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
|
---|
3309 | bool fNotifyGuest = false;
|
---|
3310 |
|
---|
3311 | PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
|
---|
3312 |
|
---|
3313 | uint32_t i;
|
---|
3314 | for (i = 0; i < cDisplays; ++i)
|
---|
3315 | {
|
---|
3316 | VMMDevDisplayDef const *p = &paDisplays[i];
|
---|
3317 |
|
---|
3318 | /* Either one display definition is provided or the display id must be equal to the array index. */
|
---|
3319 | AssertBreakStmt(cDisplays == 1 || p->idDisplay == i, rc = VERR_INVALID_PARAMETER);
|
---|
3320 | AssertBreakStmt(p->idDisplay < RT_ELEMENTS(pThis->displayChangeData.aRequests), rc = VERR_INVALID_PARAMETER);
|
---|
3321 |
|
---|
3322 | DISPLAYCHANGEREQUEST *pRequest = &pThis->displayChangeData.aRequests[p->idDisplay];
|
---|
3323 |
|
---|
3324 | VMMDevDisplayDef const *pLastRead = &pRequest->lastReadDisplayChangeRequest;
|
---|
3325 |
|
---|
3326 | /* Verify that the new resolution is different and that guest does not yet know about it. */
|
---|
3327 | bool const fDifferentResolution = fForce || !vmmdevIsMonitorDefEqual(p, pLastRead);
|
---|
3328 |
|
---|
3329 | LogFunc(("same=%d. New: %dx%d, cBits=%d, id=%d. Old: %dx%d, cBits=%d, id=%d. @%d,%d, Enabled=%d, ChangeOrigin=%d\n",
|
---|
3330 | !fDifferentResolution, p->cx, p->cy, p->cBitsPerPixel, p->idDisplay,
|
---|
3331 | pLastRead->cx, pLastRead->cy, pLastRead->cBitsPerPixel, pLastRead->idDisplay,
|
---|
3332 | p->xOrigin, p->yOrigin,
|
---|
3333 | !RT_BOOL(p->fDisplayFlags & VMMDEV_DISPLAY_DISABLED),
|
---|
3334 | RT_BOOL(p->fDisplayFlags & VMMDEV_DISPLAY_ORIGIN)));
|
---|
3335 |
|
---|
3336 | /* We could validate the information here but hey, the guest can do that as well! */
|
---|
3337 | pRequest->displayChangeRequest = *p;
|
---|
3338 | pRequest->fPending = fDifferentResolution;
|
---|
3339 |
|
---|
3340 | fNotifyGuest = fNotifyGuest || fDifferentResolution;
|
---|
3341 | }
|
---|
3342 |
|
---|
3343 | if (RT_SUCCESS(rc))
|
---|
3344 | {
|
---|
3345 | if (fNotifyGuest)
|
---|
3346 | {
|
---|
3347 | for (i = 0; i < RT_ELEMENTS(pThis->displayChangeData.aRequests); ++i)
|
---|
3348 | {
|
---|
3349 | DISPLAYCHANGEREQUEST *pRequest = &pThis->displayChangeData.aRequests[i];
|
---|
3350 | if (pRequest->fPending)
|
---|
3351 | {
|
---|
3352 | VMMDevDisplayDef const *p = &pRequest->displayChangeRequest;
|
---|
3353 | LogRel(("VMMDev: SetVideoModeHint: Got a video mode hint (%dx%dx%d)@(%dx%d),(%d;%d) at %d\n",
|
---|
3354 | p->cx, p->cy, p->cBitsPerPixel, p->xOrigin, p->yOrigin,
|
---|
3355 | !RT_BOOL(p->fDisplayFlags & VMMDEV_DISPLAY_DISABLED),
|
---|
3356 | RT_BOOL(p->fDisplayFlags & VMMDEV_DISPLAY_ORIGIN), i));
|
---|
3357 | }
|
---|
3358 | }
|
---|
3359 |
|
---|
3360 | /* IRQ so the guest knows what's going on */
|
---|
3361 | VMMDevNotifyGuest(pThis, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);
|
---|
3362 | }
|
---|
3363 | }
|
---|
3364 |
|
---|
3365 | PDMCritSectLeave(&pThis->CritSect);
|
---|
3366 | return rc;
|
---|
3367 | }
|
---|
3368 |
|
---|
3369 | /**
|
---|
3370 | * @interface_method_impl{PDMIVMMDEVPORT,pfnRequestSeamlessChange}
|
---|
3371 | */
|
---|
3372 | static DECLCALLBACK(int) vmmdevIPort_RequestSeamlessChange(PPDMIVMMDEVPORT pInterface, bool fEnabled)
|
---|
3373 | {
|
---|
3374 | PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
|
---|
3375 | PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
|
---|
3376 |
|
---|
3377 | /* Verify that the new resolution is different and that guest does not yet know about it. */
|
---|
3378 | bool fSameMode = (pThis->fLastSeamlessEnabled == fEnabled);
|
---|
3379 |
|
---|
3380 | Log(("vmmdevIPort_RequestSeamlessChange: same=%d. new=%d\n", fSameMode, fEnabled));
|
---|
3381 |
|
---|
3382 | if (!fSameMode)
|
---|
3383 | {
|
---|
3384 | /* we could validate the information here but hey, the guest can do that as well! */
|
---|
3385 | pThis->fSeamlessEnabled = fEnabled;
|
---|
3386 |
|
---|
3387 | /* IRQ so the guest knows what's going on */
|
---|
3388 | VMMDevNotifyGuest(pThis, VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST);
|
---|
3389 | }
|
---|
3390 |
|
---|
3391 | PDMCritSectLeave(&pThis->CritSect);
|
---|
3392 | return VINF_SUCCESS;
|
---|
3393 | }
|
---|
3394 |
|
---|
3395 | /**
|
---|
3396 | * @interface_method_impl{PDMIVMMDEVPORT,pfnSetMemoryBalloon}
|
---|
3397 | */
|
---|
3398 | static DECLCALLBACK(int) vmmdevIPort_SetMemoryBalloon(PPDMIVMMDEVPORT pInterface, uint32_t cMbBalloon)
|
---|
3399 | {
|
---|
3400 | PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
|
---|
3401 | PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
|
---|
3402 |
|
---|
3403 | /* Verify that the new resolution is different and that guest does not yet know about it. */
|
---|
3404 | Log(("vmmdevIPort_SetMemoryBalloon: old=%u new=%u\n", pThis->cMbMemoryBalloonLast, cMbBalloon));
|
---|
3405 | if (pThis->cMbMemoryBalloonLast != cMbBalloon)
|
---|
3406 | {
|
---|
3407 | /* we could validate the information here but hey, the guest can do that as well! */
|
---|
3408 | pThis->cMbMemoryBalloon = cMbBalloon;
|
---|
3409 |
|
---|
3410 | /* IRQ so the guest knows what's going on */
|
---|
3411 | VMMDevNotifyGuest(pThis, VMMDEV_EVENT_BALLOON_CHANGE_REQUEST);
|
---|
3412 | }
|
---|
3413 |
|
---|
3414 | PDMCritSectLeave(&pThis->CritSect);
|
---|
3415 | return VINF_SUCCESS;
|
---|
3416 | }
|
---|
3417 |
|
---|
3418 | /**
|
---|
3419 | * @interface_method_impl{PDMIVMMDEVPORT,pfnVRDPChange}
|
---|
3420 | */
|
---|
3421 | static DECLCALLBACK(int) vmmdevIPort_VRDPChange(PPDMIVMMDEVPORT pInterface, bool fVRDPEnabled, uint32_t uVRDPExperienceLevel)
|
---|
3422 | {
|
---|
3423 | PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
|
---|
3424 | PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
|
---|
3425 |
|
---|
3426 | bool fSame = (pThis->fVRDPEnabled == fVRDPEnabled);
|
---|
3427 |
|
---|
3428 | Log(("vmmdevIPort_VRDPChange: old=%d. new=%d\n", pThis->fVRDPEnabled, fVRDPEnabled));
|
---|
3429 |
|
---|
3430 | if (!fSame)
|
---|
3431 | {
|
---|
3432 | pThis->fVRDPEnabled = fVRDPEnabled;
|
---|
3433 | pThis->uVRDPExperienceLevel = uVRDPExperienceLevel;
|
---|
3434 |
|
---|
3435 | VMMDevNotifyGuest(pThis, VMMDEV_EVENT_VRDP);
|
---|
3436 | }
|
---|
3437 |
|
---|
3438 | PDMCritSectLeave(&pThis->CritSect);
|
---|
3439 | return VINF_SUCCESS;
|
---|
3440 | }
|
---|
3441 |
|
---|
3442 | /**
|
---|
3443 | * @interface_method_impl{PDMIVMMDEVPORT,pfnSetStatisticsInterval}
|
---|
3444 | */
|
---|
3445 | static DECLCALLBACK(int) vmmdevIPort_SetStatisticsInterval(PPDMIVMMDEVPORT pInterface, uint32_t cSecsStatInterval)
|
---|
3446 | {
|
---|
3447 | PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
|
---|
3448 | PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
|
---|
3449 |
|
---|
3450 | /* Verify that the new resolution is different and that guest does not yet know about it. */
|
---|
3451 | bool fSame = (pThis->u32LastStatIntervalSize == cSecsStatInterval);
|
---|
3452 |
|
---|
3453 | Log(("vmmdevIPort_SetStatisticsInterval: old=%d. new=%d\n", pThis->u32LastStatIntervalSize, cSecsStatInterval));
|
---|
3454 |
|
---|
3455 | if (!fSame)
|
---|
3456 | {
|
---|
3457 | /* we could validate the information here but hey, the guest can do that as well! */
|
---|
3458 | pThis->u32StatIntervalSize = cSecsStatInterval;
|
---|
3459 |
|
---|
3460 | /* IRQ so the guest knows what's going on */
|
---|
3461 | VMMDevNotifyGuest(pThis, VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST);
|
---|
3462 | }
|
---|
3463 |
|
---|
3464 | PDMCritSectLeave(&pThis->CritSect);
|
---|
3465 | return VINF_SUCCESS;
|
---|
3466 | }
|
---|
3467 |
|
---|
3468 | /**
|
---|
3469 | * @interface_method_impl{PDMIVMMDEVPORT,pfnSetCredentials}
|
---|
3470 | */
|
---|
3471 | static DECLCALLBACK(int) vmmdevIPort_SetCredentials(PPDMIVMMDEVPORT pInterface, const char *pszUsername,
|
---|
3472 | const char *pszPassword, const char *pszDomain, uint32_t fFlags)
|
---|
3473 | {
|
---|
3474 | PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
|
---|
3475 | AssertReturn(fFlags & (VMMDEV_SETCREDENTIALS_GUESTLOGON | VMMDEV_SETCREDENTIALS_JUDGE), VERR_INVALID_PARAMETER);
|
---|
3476 | size_t const cchUsername = strlen(pszUsername);
|
---|
3477 | AssertReturn(cchUsername < VMMDEV_CREDENTIALS_SZ_SIZE, VERR_BUFFER_OVERFLOW);
|
---|
3478 | size_t const cchPassword = strlen(pszPassword);
|
---|
3479 | AssertReturn(cchPassword < VMMDEV_CREDENTIALS_SZ_SIZE, VERR_BUFFER_OVERFLOW);
|
---|
3480 | size_t const cchDomain = strlen(pszDomain);
|
---|
3481 | AssertReturn(cchDomain < VMMDEV_CREDENTIALS_SZ_SIZE, VERR_BUFFER_OVERFLOW);
|
---|
3482 |
|
---|
3483 | PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
|
---|
3484 |
|
---|
3485 | /*
|
---|
3486 | * Logon mode
|
---|
3487 | */
|
---|
3488 | if (fFlags & VMMDEV_SETCREDENTIALS_GUESTLOGON)
|
---|
3489 | {
|
---|
3490 | /* memorize the data */
|
---|
3491 | memcpy(pThis->pCredentials->Logon.szUserName, pszUsername, cchUsername);
|
---|
3492 | pThis->pCredentials->Logon.szUserName[cchUsername] = '\0';
|
---|
3493 | memcpy(pThis->pCredentials->Logon.szPassword, pszPassword, cchPassword);
|
---|
3494 | pThis->pCredentials->Logon.szPassword[cchPassword] = '\0';
|
---|
3495 | memcpy(pThis->pCredentials->Logon.szDomain, pszDomain, cchDomain);
|
---|
3496 | pThis->pCredentials->Logon.szDomain[cchDomain] = '\0';
|
---|
3497 | pThis->pCredentials->Logon.fAllowInteractiveLogon = !(fFlags & VMMDEV_SETCREDENTIALS_NOLOCALLOGON);
|
---|
3498 | }
|
---|
3499 | /*
|
---|
3500 | * Credentials verification mode?
|
---|
3501 | */
|
---|
3502 | else
|
---|
3503 | {
|
---|
3504 | /* memorize the data */
|
---|
3505 | memcpy(pThis->pCredentials->Judge.szUserName, pszUsername, cchUsername);
|
---|
3506 | pThis->pCredentials->Judge.szUserName[cchUsername] = '\0';
|
---|
3507 | memcpy(pThis->pCredentials->Judge.szPassword, pszPassword, cchPassword);
|
---|
3508 | pThis->pCredentials->Judge.szPassword[cchPassword] = '\0';
|
---|
3509 | memcpy(pThis->pCredentials->Judge.szDomain, pszDomain, cchDomain);
|
---|
3510 | pThis->pCredentials->Judge.szDomain[cchDomain] = '\0';
|
---|
3511 |
|
---|
3512 | VMMDevNotifyGuest(pThis, VMMDEV_EVENT_JUDGE_CREDENTIALS);
|
---|
3513 | }
|
---|
3514 |
|
---|
3515 | PDMCritSectLeave(&pThis->CritSect);
|
---|
3516 | return VINF_SUCCESS;
|
---|
3517 | }
|
---|
3518 |
|
---|
3519 | /**
|
---|
3520 | * @interface_method_impl{PDMIVMMDEVPORT,pfnVBVAChange}
|
---|
3521 | *
|
---|
3522 | * Notification from the Display. Especially useful when acceleration is
|
---|
3523 | * disabled after a video mode change.
|
---|
3524 | */
|
---|
3525 | static DECLCALLBACK(void) vmmdevIPort_VBVAChange(PPDMIVMMDEVPORT pInterface, bool fEnabled)
|
---|
3526 | {
|
---|
3527 | PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
|
---|
3528 | Log(("vmmdevIPort_VBVAChange: fEnabled = %d\n", fEnabled));
|
---|
3529 |
|
---|
3530 | /* Only used by saved state, which I guess is why we don't bother with locking here. */
|
---|
3531 | pThis->u32VideoAccelEnabled = fEnabled;
|
---|
3532 | }
|
---|
3533 |
|
---|
3534 | /**
|
---|
3535 | * @interface_method_impl{PDMIVMMDEVPORT,pfnCpuHotUnplug}
|
---|
3536 | */
|
---|
3537 | static DECLCALLBACK(int) vmmdevIPort_CpuHotUnplug(PPDMIVMMDEVPORT pInterface, uint32_t idCpuCore, uint32_t idCpuPackage)
|
---|
3538 | {
|
---|
3539 | PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
|
---|
3540 | int rc = VINF_SUCCESS;
|
---|
3541 |
|
---|
3542 | Log(("vmmdevIPort_CpuHotUnplug: idCpuCore=%u idCpuPackage=%u\n", idCpuCore, idCpuPackage));
|
---|
3543 |
|
---|
3544 | PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
|
---|
3545 |
|
---|
3546 | if (pThis->fCpuHotPlugEventsEnabled)
|
---|
3547 | {
|
---|
3548 | pThis->enmCpuHotPlugEvent = VMMDevCpuEventType_Unplug;
|
---|
3549 | pThis->idCpuCore = idCpuCore;
|
---|
3550 | pThis->idCpuPackage = idCpuPackage;
|
---|
3551 | VMMDevNotifyGuest(pThis, VMMDEV_EVENT_CPU_HOTPLUG);
|
---|
3552 | }
|
---|
3553 | else
|
---|
3554 | rc = VERR_VMMDEV_CPU_HOTPLUG_NOT_MONITORED_BY_GUEST;
|
---|
3555 |
|
---|
3556 | PDMCritSectLeave(&pThis->CritSect);
|
---|
3557 | return rc;
|
---|
3558 | }
|
---|
3559 |
|
---|
3560 | /**
|
---|
3561 | * @interface_method_impl{PDMIVMMDEVPORT,pfnCpuHotPlug}
|
---|
3562 | */
|
---|
3563 | static DECLCALLBACK(int) vmmdevIPort_CpuHotPlug(PPDMIVMMDEVPORT pInterface, uint32_t idCpuCore, uint32_t idCpuPackage)
|
---|
3564 | {
|
---|
3565 | PVMMDEV pThis = RT_FROM_MEMBER(pInterface, VMMDEV, IPort);
|
---|
3566 | int rc = VINF_SUCCESS;
|
---|
3567 |
|
---|
3568 | Log(("vmmdevCpuPlug: idCpuCore=%u idCpuPackage=%u\n", idCpuCore, idCpuPackage));
|
---|
3569 |
|
---|
3570 | PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
|
---|
3571 |
|
---|
3572 | if (pThis->fCpuHotPlugEventsEnabled)
|
---|
3573 | {
|
---|
3574 | pThis->enmCpuHotPlugEvent = VMMDevCpuEventType_Plug;
|
---|
3575 | pThis->idCpuCore = idCpuCore;
|
---|
3576 | pThis->idCpuPackage = idCpuPackage;
|
---|
3577 | VMMDevNotifyGuest(pThis, VMMDEV_EVENT_CPU_HOTPLUG);
|
---|
3578 | }
|
---|
3579 | else
|
---|
3580 | rc = VERR_VMMDEV_CPU_HOTPLUG_NOT_MONITORED_BY_GUEST;
|
---|
3581 |
|
---|
3582 | PDMCritSectLeave(&pThis->CritSect);
|
---|
3583 | return rc;
|
---|
3584 | }
|
---|
3585 |
|
---|
3586 |
|
---|
3587 | /* -=-=-=-=-=- Saved State -=-=-=-=-=- */
|
---|
3588 |
|
---|
3589 | /**
|
---|
3590 | * @callback_method_impl{FNSSMDEVLIVEEXEC}
|
---|
3591 | */
|
---|
3592 | static DECLCALLBACK(int) vmmdevLiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass)
|
---|
3593 | {
|
---|
3594 | RT_NOREF1(uPass);
|
---|
3595 | PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
|
---|
3596 |
|
---|
3597 | SSMR3PutBool(pSSM, pThis->fGetHostTimeDisabled);
|
---|
3598 | SSMR3PutBool(pSSM, pThis->fBackdoorLogDisabled);
|
---|
3599 | SSMR3PutBool(pSSM, pThis->fKeepCredentials);
|
---|
3600 | SSMR3PutBool(pSSM, pThis->fHeapEnabled);
|
---|
3601 |
|
---|
3602 | return VINF_SSM_DONT_CALL_AGAIN;
|
---|
3603 | }
|
---|
3604 |
|
---|
3605 |
|
---|
3606 | /**
|
---|
3607 | * @callback_method_impl{FNSSMDEVSAVEEXEC}
|
---|
3608 | */
|
---|
3609 | static DECLCALLBACK(int) vmmdevSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
|
---|
3610 | {
|
---|
3611 | PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
|
---|
3612 | PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
|
---|
3613 |
|
---|
3614 | vmmdevLiveExec(pDevIns, pSSM, SSM_PASS_FINAL);
|
---|
3615 |
|
---|
3616 | SSMR3PutU32(pSSM, pThis->hypervisorSize);
|
---|
3617 | SSMR3PutU32(pSSM, pThis->mouseCapabilities);
|
---|
3618 | SSMR3PutS32(pSSM, pThis->mouseXAbs);
|
---|
3619 | SSMR3PutS32(pSSM, pThis->mouseYAbs);
|
---|
3620 |
|
---|
3621 | SSMR3PutBool(pSSM, pThis->fNewGuestFilterMask);
|
---|
3622 | SSMR3PutU32(pSSM, pThis->u32NewGuestFilterMask);
|
---|
3623 | SSMR3PutU32(pSSM, pThis->u32GuestFilterMask);
|
---|
3624 | SSMR3PutU32(pSSM, pThis->u32HostEventFlags);
|
---|
3625 | /* The following is not strictly necessary as PGM restores MMIO2, keeping it for historical reasons. */
|
---|
3626 | SSMR3PutMem(pSSM, &pThis->pVMMDevRAMR3->V, sizeof(pThis->pVMMDevRAMR3->V));
|
---|
3627 |
|
---|
3628 | SSMR3PutMem(pSSM, &pThis->guestInfo, sizeof(pThis->guestInfo));
|
---|
3629 | SSMR3PutU32(pSSM, pThis->fu32AdditionsOk);
|
---|
3630 | SSMR3PutU32(pSSM, pThis->u32VideoAccelEnabled);
|
---|
3631 | SSMR3PutBool(pSSM, pThis->displayChangeData.fGuestSentChangeEventAck);
|
---|
3632 |
|
---|
3633 | SSMR3PutU32(pSSM, pThis->guestCaps);
|
---|
3634 |
|
---|
3635 | #ifdef VBOX_WITH_HGCM
|
---|
3636 | vmmdevHGCMSaveState(pThis, pSSM);
|
---|
3637 | #endif /* VBOX_WITH_HGCM */
|
---|
3638 |
|
---|
3639 | SSMR3PutU32(pSSM, pThis->fHostCursorRequested);
|
---|
3640 |
|
---|
3641 | SSMR3PutU32(pSSM, pThis->guestInfo2.uFullVersion);
|
---|
3642 | SSMR3PutU32(pSSM, pThis->guestInfo2.uRevision);
|
---|
3643 | SSMR3PutU32(pSSM, pThis->guestInfo2.fFeatures);
|
---|
3644 | SSMR3PutStrZ(pSSM, pThis->guestInfo2.szName);
|
---|
3645 | SSMR3PutU32(pSSM, pThis->cFacilityStatuses);
|
---|
3646 | for (uint32_t i = 0; i < pThis->cFacilityStatuses; i++)
|
---|
3647 | {
|
---|
3648 | SSMR3PutU32(pSSM, pThis->aFacilityStatuses[i].enmFacility);
|
---|
3649 | SSMR3PutU32(pSSM, pThis->aFacilityStatuses[i].fFlags);
|
---|
3650 | SSMR3PutU16(pSSM, (uint16_t)pThis->aFacilityStatuses[i].enmStatus);
|
---|
3651 | SSMR3PutS64(pSSM, RTTimeSpecGetNano(&pThis->aFacilityStatuses[i].TimeSpecTS));
|
---|
3652 | }
|
---|
3653 |
|
---|
3654 | /* Heartbeat: */
|
---|
3655 | SSMR3PutBool(pSSM, pThis->fHeartbeatActive);
|
---|
3656 | SSMR3PutBool(pSSM, pThis->fFlatlined);
|
---|
3657 | SSMR3PutU64(pSSM, pThis->nsLastHeartbeatTS);
|
---|
3658 | TMR3TimerSave(pThis->pFlatlinedTimer, pSSM);
|
---|
3659 |
|
---|
3660 | PDMCritSectLeave(&pThis->CritSect);
|
---|
3661 | return VINF_SUCCESS;
|
---|
3662 | }
|
---|
3663 |
|
---|
3664 | /**
|
---|
3665 | * @callback_method_impl{FNSSMDEVLOADEXEC}
|
---|
3666 | */
|
---|
3667 | static DECLCALLBACK(int) vmmdevLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
|
---|
3668 | {
|
---|
3669 | /** @todo The code load code is assuming we're always loaded into a freshly
|
---|
3670 | * constructed VM. */
|
---|
3671 | PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
|
---|
3672 | int rc;
|
---|
3673 |
|
---|
3674 | if ( uVersion > VMMDEV_SAVED_STATE_VERSION
|
---|
3675 | || uVersion < 6)
|
---|
3676 | return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
|
---|
3677 |
|
---|
3678 | /* config */
|
---|
3679 | if (uVersion > VMMDEV_SAVED_STATE_VERSION_VBOX_30)
|
---|
3680 | {
|
---|
3681 | bool f;
|
---|
3682 | rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);
|
---|
3683 | if (pThis->fGetHostTimeDisabled != f)
|
---|
3684 | LogRel(("VMMDev: Config mismatch - fGetHostTimeDisabled: config=%RTbool saved=%RTbool\n", pThis->fGetHostTimeDisabled, f));
|
---|
3685 |
|
---|
3686 | rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);
|
---|
3687 | if (pThis->fBackdoorLogDisabled != f)
|
---|
3688 | LogRel(("VMMDev: Config mismatch - fBackdoorLogDisabled: config=%RTbool saved=%RTbool\n", pThis->fBackdoorLogDisabled, f));
|
---|
3689 |
|
---|
3690 | rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);
|
---|
3691 | if (pThis->fKeepCredentials != f)
|
---|
3692 | return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch - fKeepCredentials: config=%RTbool saved=%RTbool"),
|
---|
3693 | pThis->fKeepCredentials, f);
|
---|
3694 | rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);
|
---|
3695 | if (pThis->fHeapEnabled != f)
|
---|
3696 | return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch - fHeapEnabled: config=%RTbool saved=%RTbool"),
|
---|
3697 | pThis->fHeapEnabled, f);
|
---|
3698 | }
|
---|
3699 |
|
---|
3700 | if (uPass != SSM_PASS_FINAL)
|
---|
3701 | return VINF_SUCCESS;
|
---|
3702 |
|
---|
3703 | /* state */
|
---|
3704 | SSMR3GetU32(pSSM, &pThis->hypervisorSize);
|
---|
3705 | SSMR3GetU32(pSSM, &pThis->mouseCapabilities);
|
---|
3706 | SSMR3GetS32(pSSM, &pThis->mouseXAbs);
|
---|
3707 | SSMR3GetS32(pSSM, &pThis->mouseYAbs);
|
---|
3708 |
|
---|
3709 | SSMR3GetBool(pSSM, &pThis->fNewGuestFilterMask);
|
---|
3710 | SSMR3GetU32(pSSM, &pThis->u32NewGuestFilterMask);
|
---|
3711 | SSMR3GetU32(pSSM, &pThis->u32GuestFilterMask);
|
---|
3712 | SSMR3GetU32(pSSM, &pThis->u32HostEventFlags);
|
---|
3713 |
|
---|
3714 | //SSMR3GetBool(pSSM, &pThis->pVMMDevRAMR3->fHaveEvents);
|
---|
3715 | // here be dragons (probably)
|
---|
3716 | SSMR3GetMem(pSSM, &pThis->pVMMDevRAMR3->V, sizeof (pThis->pVMMDevRAMR3->V));
|
---|
3717 |
|
---|
3718 | SSMR3GetMem(pSSM, &pThis->guestInfo, sizeof (pThis->guestInfo));
|
---|
3719 | SSMR3GetU32(pSSM, &pThis->fu32AdditionsOk);
|
---|
3720 | SSMR3GetU32(pSSM, &pThis->u32VideoAccelEnabled);
|
---|
3721 | if (uVersion > 10)
|
---|
3722 | SSMR3GetBool(pSSM, &pThis->displayChangeData.fGuestSentChangeEventAck);
|
---|
3723 |
|
---|
3724 | rc = SSMR3GetU32(pSSM, &pThis->guestCaps);
|
---|
3725 |
|
---|
3726 | /* Attributes which were temporarily introduced in r30072 */
|
---|
3727 | if (uVersion == 7)
|
---|
3728 | {
|
---|
3729 | uint32_t temp;
|
---|
3730 | SSMR3GetU32(pSSM, &temp);
|
---|
3731 | rc = SSMR3GetU32(pSSM, &temp);
|
---|
3732 | }
|
---|
3733 | AssertRCReturn(rc, rc);
|
---|
3734 |
|
---|
3735 | #ifdef VBOX_WITH_HGCM
|
---|
3736 | rc = vmmdevHGCMLoadState(pThis, pSSM, uVersion);
|
---|
3737 | AssertRCReturn(rc, rc);
|
---|
3738 | #endif /* VBOX_WITH_HGCM */
|
---|
3739 |
|
---|
3740 | if (uVersion >= 10)
|
---|
3741 | rc = SSMR3GetU32(pSSM, &pThis->fHostCursorRequested);
|
---|
3742 | AssertRCReturn(rc, rc);
|
---|
3743 |
|
---|
3744 | if (uVersion > VMMDEV_SAVED_STATE_VERSION_MISSING_GUEST_INFO_2)
|
---|
3745 | {
|
---|
3746 | SSMR3GetU32(pSSM, &pThis->guestInfo2.uFullVersion);
|
---|
3747 | SSMR3GetU32(pSSM, &pThis->guestInfo2.uRevision);
|
---|
3748 | SSMR3GetU32(pSSM, &pThis->guestInfo2.fFeatures);
|
---|
3749 | rc = SSMR3GetStrZ(pSSM, &pThis->guestInfo2.szName[0], sizeof(pThis->guestInfo2.szName));
|
---|
3750 | AssertRCReturn(rc, rc);
|
---|
3751 | }
|
---|
3752 |
|
---|
3753 | if (uVersion > VMMDEV_SAVED_STATE_VERSION_MISSING_FACILITY_STATUSES)
|
---|
3754 | {
|
---|
3755 | uint32_t cFacilityStatuses;
|
---|
3756 | rc = SSMR3GetU32(pSSM, &cFacilityStatuses);
|
---|
3757 | AssertRCReturn(rc, rc);
|
---|
3758 |
|
---|
3759 | for (uint32_t i = 0; i < cFacilityStatuses; i++)
|
---|
3760 | {
|
---|
3761 | uint32_t uFacility, fFlags;
|
---|
3762 | uint16_t uStatus;
|
---|
3763 | int64_t iTimeStampNano;
|
---|
3764 |
|
---|
3765 | SSMR3GetU32(pSSM, &uFacility);
|
---|
3766 | SSMR3GetU32(pSSM, &fFlags);
|
---|
3767 | SSMR3GetU16(pSSM, &uStatus);
|
---|
3768 | rc = SSMR3GetS64(pSSM, &iTimeStampNano);
|
---|
3769 | AssertRCReturn(rc, rc);
|
---|
3770 |
|
---|
3771 | PVMMDEVFACILITYSTATUSENTRY pEntry = vmmdevGetFacilityStatusEntry(pThis, (VBoxGuestFacilityType)uFacility);
|
---|
3772 | AssertLogRelMsgReturn(pEntry,
|
---|
3773 | ("VMMDev: Ran out of entries restoring the guest facility statuses. Saved state has %u.\n", cFacilityStatuses),
|
---|
3774 | VERR_OUT_OF_RESOURCES);
|
---|
3775 | pEntry->enmStatus = (VBoxGuestFacilityStatus)uStatus;
|
---|
3776 | pEntry->fFlags = fFlags;
|
---|
3777 | RTTimeSpecSetNano(&pEntry->TimeSpecTS, iTimeStampNano);
|
---|
3778 | }
|
---|
3779 | }
|
---|
3780 |
|
---|
3781 | /*
|
---|
3782 | * Heartbeat.
|
---|
3783 | */
|
---|
3784 | if (uVersion >= VMMDEV_SAVED_STATE_VERSION_HEARTBEAT)
|
---|
3785 | {
|
---|
3786 | SSMR3GetBool(pSSM, (bool *)&pThis->fHeartbeatActive);
|
---|
3787 | SSMR3GetBool(pSSM, (bool *)&pThis->fFlatlined);
|
---|
3788 | SSMR3GetU64(pSSM, (uint64_t *)&pThis->nsLastHeartbeatTS);
|
---|
3789 | rc = TMR3TimerLoad(pThis->pFlatlinedTimer, pSSM);
|
---|
3790 | AssertRCReturn(rc, rc);
|
---|
3791 | if (pThis->fFlatlined)
|
---|
3792 | LogRel(("vmmdevLoadState: Guest has flatlined. Last heartbeat %'RU64 ns before state was saved.\n",
|
---|
3793 | TMTimerGetNano(pThis->pFlatlinedTimer) - pThis->nsLastHeartbeatTS));
|
---|
3794 | }
|
---|
3795 |
|
---|
3796 | /*
|
---|
3797 | * On a resume, we send the capabilities changed message so
|
---|
3798 | * that listeners can sync their state again
|
---|
3799 | */
|
---|
3800 | Log(("vmmdevLoadState: capabilities changed (%x), informing connector\n", pThis->mouseCapabilities));
|
---|
3801 | if (pThis->pDrv)
|
---|
3802 | {
|
---|
3803 | pThis->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->mouseCapabilities);
|
---|
3804 | if (uVersion >= 10)
|
---|
3805 | pThis->pDrv->pfnUpdatePointerShape(pThis->pDrv,
|
---|
3806 | /*fVisible=*/!!pThis->fHostCursorRequested,
|
---|
3807 | /*fAlpha=*/false,
|
---|
3808 | /*xHot=*/0, /*yHot=*/0,
|
---|
3809 | /*cx=*/0, /*cy=*/0,
|
---|
3810 | /*pvShape=*/NULL);
|
---|
3811 | }
|
---|
3812 |
|
---|
3813 | if (pThis->fu32AdditionsOk)
|
---|
3814 | {
|
---|
3815 | vmmdevLogGuestOsInfo(&pThis->guestInfo);
|
---|
3816 | if (pThis->pDrv)
|
---|
3817 | {
|
---|
3818 | if (pThis->guestInfo2.uFullVersion && pThis->pDrv->pfnUpdateGuestInfo2)
|
---|
3819 | pThis->pDrv->pfnUpdateGuestInfo2(pThis->pDrv, pThis->guestInfo2.uFullVersion, pThis->guestInfo2.szName,
|
---|
3820 | pThis->guestInfo2.uRevision, pThis->guestInfo2.fFeatures);
|
---|
3821 | if (pThis->pDrv->pfnUpdateGuestInfo)
|
---|
3822 | pThis->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);
|
---|
3823 |
|
---|
3824 | if (pThis->pDrv->pfnUpdateGuestStatus)
|
---|
3825 | {
|
---|
3826 | for (uint32_t i = 0; i < pThis->cFacilityStatuses; i++) /* ascending order! */
|
---|
3827 | if ( pThis->aFacilityStatuses[i].enmStatus != VBoxGuestFacilityStatus_Inactive
|
---|
3828 | || !pThis->aFacilityStatuses[i].fFixed)
|
---|
3829 | pThis->pDrv->pfnUpdateGuestStatus(pThis->pDrv,
|
---|
3830 | pThis->aFacilityStatuses[i].enmFacility,
|
---|
3831 | (uint16_t)pThis->aFacilityStatuses[i].enmStatus,
|
---|
3832 | pThis->aFacilityStatuses[i].fFlags,
|
---|
3833 | &pThis->aFacilityStatuses[i].TimeSpecTS);
|
---|
3834 | }
|
---|
3835 | }
|
---|
3836 | }
|
---|
3837 | if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestCapabilities)
|
---|
3838 | pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, pThis->guestCaps);
|
---|
3839 |
|
---|
3840 | return VINF_SUCCESS;
|
---|
3841 | }
|
---|
3842 |
|
---|
3843 | /**
|
---|
3844 | * Load state done callback. Notify guest of restore event.
|
---|
3845 | *
|
---|
3846 | * @returns VBox status code.
|
---|
3847 | * @param pDevIns The device instance.
|
---|
3848 | * @param pSSM The handle to the saved state.
|
---|
3849 | */
|
---|
3850 | static DECLCALLBACK(int) vmmdevLoadStateDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
|
---|
3851 | {
|
---|
3852 | RT_NOREF1(pSSM);
|
---|
3853 | PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
|
---|
3854 |
|
---|
3855 | #ifdef VBOX_WITH_HGCM
|
---|
3856 | int rc = vmmdevHGCMLoadStateDone(pThis);
|
---|
3857 | AssertLogRelRCReturn(rc, rc);
|
---|
3858 | #endif /* VBOX_WITH_HGCM */
|
---|
3859 |
|
---|
3860 | /* Reestablish the acceleration status. */
|
---|
3861 | if ( pThis->u32VideoAccelEnabled
|
---|
3862 | && pThis->pDrv)
|
---|
3863 | {
|
---|
3864 | pThis->pDrv->pfnVideoAccelEnable(pThis->pDrv, !!pThis->u32VideoAccelEnabled, &pThis->pVMMDevRAMR3->vbvaMemory);
|
---|
3865 | }
|
---|
3866 |
|
---|
3867 | VMMDevNotifyGuest(pThis, VMMDEV_EVENT_RESTORED);
|
---|
3868 |
|
---|
3869 | return VINF_SUCCESS;
|
---|
3870 | }
|
---|
3871 |
|
---|
3872 |
|
---|
3873 | /* -=-=-=-=- PDMDEVREG -=-=-=-=- */
|
---|
3874 |
|
---|
3875 | /**
|
---|
3876 | * (Re-)initializes the MMIO2 data.
|
---|
3877 | *
|
---|
3878 | * @param pThis Pointer to the VMMDev instance data.
|
---|
3879 | */
|
---|
3880 | static void vmmdevInitRam(PVMMDEV pThis)
|
---|
3881 | {
|
---|
3882 | memset(pThis->pVMMDevRAMR3, 0, sizeof(VMMDevMemory));
|
---|
3883 | pThis->pVMMDevRAMR3->u32Size = sizeof(VMMDevMemory);
|
---|
3884 | pThis->pVMMDevRAMR3->u32Version = VMMDEV_MEMORY_VERSION;
|
---|
3885 | }
|
---|
3886 |
|
---|
3887 |
|
---|
3888 | /**
|
---|
3889 | * @interface_method_impl{PDMDEVREG,pfnReset}
|
---|
3890 | */
|
---|
3891 | static DECLCALLBACK(void) vmmdevReset(PPDMDEVINS pDevIns)
|
---|
3892 | {
|
---|
3893 | PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
|
---|
3894 | PDMCritSectEnter(&pThis->CritSect, VERR_IGNORED);
|
---|
3895 |
|
---|
3896 | /*
|
---|
3897 | * Reset the mouse integration feature bits
|
---|
3898 | */
|
---|
3899 | if (pThis->mouseCapabilities & VMMDEV_MOUSE_GUEST_MASK)
|
---|
3900 | {
|
---|
3901 | pThis->mouseCapabilities &= ~VMMDEV_MOUSE_GUEST_MASK;
|
---|
3902 | /* notify the connector */
|
---|
3903 | Log(("vmmdevReset: capabilities changed (%x), informing connector\n", pThis->mouseCapabilities));
|
---|
3904 | pThis->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->mouseCapabilities);
|
---|
3905 | }
|
---|
3906 | pThis->fHostCursorRequested = false;
|
---|
3907 |
|
---|
3908 | pThis->hypervisorSize = 0;
|
---|
3909 |
|
---|
3910 | /* re-initialize the VMMDev memory */
|
---|
3911 | if (pThis->pVMMDevRAMR3)
|
---|
3912 | vmmdevInitRam(pThis);
|
---|
3913 |
|
---|
3914 | /* credentials have to go away (by default) */
|
---|
3915 | if (!pThis->fKeepCredentials)
|
---|
3916 | {
|
---|
3917 | memset(pThis->pCredentials->Logon.szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
3918 | memset(pThis->pCredentials->Logon.szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
3919 | memset(pThis->pCredentials->Logon.szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
3920 | }
|
---|
3921 | memset(pThis->pCredentials->Judge.szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
3922 | memset(pThis->pCredentials->Judge.szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
3923 | memset(pThis->pCredentials->Judge.szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
3924 |
|
---|
3925 | /* Reset means that additions will report again. */
|
---|
3926 | const bool fVersionChanged = pThis->fu32AdditionsOk
|
---|
3927 | || pThis->guestInfo.interfaceVersion
|
---|
3928 | || pThis->guestInfo.osType != VBOXOSTYPE_Unknown;
|
---|
3929 | if (fVersionChanged)
|
---|
3930 | Log(("vmmdevReset: fu32AdditionsOk=%d additionsVersion=%x osType=%#x\n",
|
---|
3931 | pThis->fu32AdditionsOk, pThis->guestInfo.interfaceVersion, pThis->guestInfo.osType));
|
---|
3932 | pThis->fu32AdditionsOk = false;
|
---|
3933 | memset (&pThis->guestInfo, 0, sizeof (pThis->guestInfo));
|
---|
3934 | RT_ZERO(pThis->guestInfo2);
|
---|
3935 | const bool fCapsChanged = pThis->guestCaps != 0; /* Report transition to 0. */
|
---|
3936 | pThis->guestCaps = 0;
|
---|
3937 |
|
---|
3938 | /* Clear facilities. No need to tell Main as it will get a
|
---|
3939 | pfnUpdateGuestInfo callback. */
|
---|
3940 | RTTIMESPEC TimeStampNow;
|
---|
3941 | RTTimeNow(&TimeStampNow);
|
---|
3942 | uint32_t iFacility = pThis->cFacilityStatuses;
|
---|
3943 | while (iFacility-- > 0)
|
---|
3944 | {
|
---|
3945 | pThis->aFacilityStatuses[iFacility].enmStatus = VBoxGuestFacilityStatus_Inactive;
|
---|
3946 | pThis->aFacilityStatuses[iFacility].TimeSpecTS = TimeStampNow;
|
---|
3947 | }
|
---|
3948 |
|
---|
3949 | /* clear pending display change request. */
|
---|
3950 | for (unsigned i = 0; i < RT_ELEMENTS(pThis->displayChangeData.aRequests); i++)
|
---|
3951 | {
|
---|
3952 | DISPLAYCHANGEREQUEST *pRequest = &pThis->displayChangeData.aRequests[i];
|
---|
3953 | memset (&pRequest->lastReadDisplayChangeRequest, 0, sizeof (pRequest->lastReadDisplayChangeRequest));
|
---|
3954 | }
|
---|
3955 | pThis->displayChangeData.iCurrentMonitor = 0;
|
---|
3956 | pThis->displayChangeData.fGuestSentChangeEventAck = false;
|
---|
3957 |
|
---|
3958 | /* disable seamless mode */
|
---|
3959 | pThis->fLastSeamlessEnabled = false;
|
---|
3960 |
|
---|
3961 | /* disabled memory ballooning */
|
---|
3962 | pThis->cMbMemoryBalloonLast = 0;
|
---|
3963 |
|
---|
3964 | /* disabled statistics updating */
|
---|
3965 | pThis->u32LastStatIntervalSize = 0;
|
---|
3966 |
|
---|
3967 | #ifdef VBOX_WITH_HGCM
|
---|
3968 | /* Clear the "HGCM event enabled" flag so the event can be automatically reenabled. */
|
---|
3969 | pThis->u32HGCMEnabled = 0;
|
---|
3970 | #endif
|
---|
3971 |
|
---|
3972 | /*
|
---|
3973 | * Deactive heartbeat.
|
---|
3974 | */
|
---|
3975 | if (pThis->fHeartbeatActive)
|
---|
3976 | {
|
---|
3977 | TMTimerStop(pThis->pFlatlinedTimer);
|
---|
3978 | pThis->fFlatlined = false;
|
---|
3979 | pThis->fHeartbeatActive = true;
|
---|
3980 | }
|
---|
3981 |
|
---|
3982 | /*
|
---|
3983 | * Clear the event variables.
|
---|
3984 | *
|
---|
3985 | * XXX By design we should NOT clear pThis->u32HostEventFlags because it is designed
|
---|
3986 | * that way so host events do not depend on guest resets. However, the pending
|
---|
3987 | * event flags actually _were_ cleared since ages so we mask out events from
|
---|
3988 | * clearing which we really need to survive the reset. See xtracker 5767.
|
---|
3989 | */
|
---|
3990 | pThis->u32HostEventFlags &= VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
|
---|
3991 | pThis->u32GuestFilterMask = 0;
|
---|
3992 | pThis->u32NewGuestFilterMask = 0;
|
---|
3993 | pThis->fNewGuestFilterMask = 0;
|
---|
3994 |
|
---|
3995 | /*
|
---|
3996 | * Call the update functions as required.
|
---|
3997 | */
|
---|
3998 | if (fVersionChanged && pThis->pDrv && pThis->pDrv->pfnUpdateGuestInfo)
|
---|
3999 | pThis->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);
|
---|
4000 | if (fCapsChanged && pThis->pDrv && pThis->pDrv->pfnUpdateGuestCapabilities)
|
---|
4001 | pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, pThis->guestCaps);
|
---|
4002 |
|
---|
4003 | /*
|
---|
4004 | * Generate a unique session id for this VM; it will be changed for each start, reset or restore.
|
---|
4005 | * This can be used for restore detection inside the guest.
|
---|
4006 | */
|
---|
4007 | pThis->idSession = ASMReadTSC();
|
---|
4008 |
|
---|
4009 | PDMCritSectLeave(&pThis->CritSect);
|
---|
4010 | }
|
---|
4011 |
|
---|
4012 |
|
---|
4013 | /**
|
---|
4014 | * @interface_method_impl{PDMDEVREG,pfnRelocate}
|
---|
4015 | */
|
---|
4016 | static DECLCALLBACK(void) vmmdevRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
|
---|
4017 | {
|
---|
4018 | NOREF(pDevIns);
|
---|
4019 | NOREF(offDelta);
|
---|
4020 | }
|
---|
4021 |
|
---|
4022 |
|
---|
4023 | /**
|
---|
4024 | * @interface_method_impl{PDMDEVREG,pfnDestruct}
|
---|
4025 | */
|
---|
4026 | static DECLCALLBACK(int) vmmdevDestruct(PPDMDEVINS pDevIns)
|
---|
4027 | {
|
---|
4028 | PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
|
---|
4029 | PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
|
---|
4030 |
|
---|
4031 | /*
|
---|
4032 | * Wipe and free the credentials.
|
---|
4033 | */
|
---|
4034 | if (pThis->pCredentials)
|
---|
4035 | {
|
---|
4036 | RTMemWipeThoroughly(pThis->pCredentials, sizeof(*pThis->pCredentials), 10);
|
---|
4037 | RTMemFree(pThis->pCredentials);
|
---|
4038 | pThis->pCredentials = NULL;
|
---|
4039 | }
|
---|
4040 |
|
---|
4041 | #ifdef VBOX_WITH_HGCM
|
---|
4042 | vmmdevHGCMDestroy(pThis);
|
---|
4043 | RTCritSectDelete(&pThis->critsectHGCMCmdList);
|
---|
4044 | #endif
|
---|
4045 |
|
---|
4046 | #ifndef VBOX_WITHOUT_TESTING_FEATURES
|
---|
4047 | /*
|
---|
4048 | * Clean up the testing device.
|
---|
4049 | */
|
---|
4050 | vmmdevTestingTerminate(pDevIns);
|
---|
4051 | #endif
|
---|
4052 |
|
---|
4053 | return VINF_SUCCESS;
|
---|
4054 | }
|
---|
4055 |
|
---|
4056 |
|
---|
4057 | /**
|
---|
4058 | * @interface_method_impl{PDMDEVREG,pfnConstruct}
|
---|
4059 | */
|
---|
4060 | static DECLCALLBACK(int) vmmdevConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
|
---|
4061 | {
|
---|
4062 | PVMMDEV pThis = PDMINS_2_DATA(pDevIns, PVMMDEV);
|
---|
4063 | int rc;
|
---|
4064 |
|
---|
4065 | Assert(iInstance == 0);
|
---|
4066 | PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
|
---|
4067 |
|
---|
4068 | /*
|
---|
4069 | * Initialize data (most of it anyway).
|
---|
4070 | */
|
---|
4071 | /* Save PDM device instance data for future reference. */
|
---|
4072 | pThis->pDevIns = pDevIns;
|
---|
4073 |
|
---|
4074 | /* PCI vendor, just a free bogus value */
|
---|
4075 | PCIDevSetVendorId(&pThis->PciDev, 0x80ee);
|
---|
4076 | /* device ID */
|
---|
4077 | PCIDevSetDeviceId(&pThis->PciDev, 0xcafe);
|
---|
4078 | /* class sub code (other type of system peripheral) */
|
---|
4079 | PCIDevSetClassSub(&pThis->PciDev, 0x80);
|
---|
4080 | /* class base code (base system peripheral) */
|
---|
4081 | PCIDevSetClassBase(&pThis->PciDev, 0x08);
|
---|
4082 | /* header type */
|
---|
4083 | PCIDevSetHeaderType(&pThis->PciDev, 0x00);
|
---|
4084 | /* interrupt on pin 0 */
|
---|
4085 | PCIDevSetInterruptPin(&pThis->PciDev, 0x01);
|
---|
4086 |
|
---|
4087 | RTTIMESPEC TimeStampNow;
|
---|
4088 | RTTimeNow(&TimeStampNow);
|
---|
4089 | vmmdevAllocFacilityStatusEntry(pThis, VBoxGuestFacilityType_VBoxGuestDriver, true /*fFixed*/, &TimeStampNow);
|
---|
4090 | vmmdevAllocFacilityStatusEntry(pThis, VBoxGuestFacilityType_VBoxService, true /*fFixed*/, &TimeStampNow);
|
---|
4091 | vmmdevAllocFacilityStatusEntry(pThis, VBoxGuestFacilityType_VBoxTrayClient, true /*fFixed*/, &TimeStampNow);
|
---|
4092 | vmmdevAllocFacilityStatusEntry(pThis, VBoxGuestFacilityType_Seamless, true /*fFixed*/, &TimeStampNow);
|
---|
4093 | vmmdevAllocFacilityStatusEntry(pThis, VBoxGuestFacilityType_Graphics, true /*fFixed*/, &TimeStampNow);
|
---|
4094 | Assert(pThis->cFacilityStatuses == 5);
|
---|
4095 |
|
---|
4096 | /*
|
---|
4097 | * Interfaces
|
---|
4098 | */
|
---|
4099 | /* IBase */
|
---|
4100 | pThis->IBase.pfnQueryInterface = vmmdevPortQueryInterface;
|
---|
4101 |
|
---|
4102 | /* VMMDev port */
|
---|
4103 | pThis->IPort.pfnQueryAbsoluteMouse = vmmdevIPort_QueryAbsoluteMouse;
|
---|
4104 | pThis->IPort.pfnSetAbsoluteMouse = vmmdevIPort_SetAbsoluteMouse ;
|
---|
4105 | pThis->IPort.pfnQueryMouseCapabilities = vmmdevIPort_QueryMouseCapabilities;
|
---|
4106 | pThis->IPort.pfnUpdateMouseCapabilities = vmmdevIPort_UpdateMouseCapabilities;
|
---|
4107 | pThis->IPort.pfnRequestDisplayChange = vmmdevIPort_RequestDisplayChange;
|
---|
4108 | pThis->IPort.pfnSetCredentials = vmmdevIPort_SetCredentials;
|
---|
4109 | pThis->IPort.pfnVBVAChange = vmmdevIPort_VBVAChange;
|
---|
4110 | pThis->IPort.pfnRequestSeamlessChange = vmmdevIPort_RequestSeamlessChange;
|
---|
4111 | pThis->IPort.pfnSetMemoryBalloon = vmmdevIPort_SetMemoryBalloon;
|
---|
4112 | pThis->IPort.pfnSetStatisticsInterval = vmmdevIPort_SetStatisticsInterval;
|
---|
4113 | pThis->IPort.pfnVRDPChange = vmmdevIPort_VRDPChange;
|
---|
4114 | pThis->IPort.pfnCpuHotUnplug = vmmdevIPort_CpuHotUnplug;
|
---|
4115 | pThis->IPort.pfnCpuHotPlug = vmmdevIPort_CpuHotPlug;
|
---|
4116 |
|
---|
4117 | /* Shared folder LED */
|
---|
4118 | pThis->SharedFolders.Led.u32Magic = PDMLED_MAGIC;
|
---|
4119 | pThis->SharedFolders.ILeds.pfnQueryStatusLed = vmmdevQueryStatusLed;
|
---|
4120 |
|
---|
4121 | #ifdef VBOX_WITH_HGCM
|
---|
4122 | /* HGCM port */
|
---|
4123 | pThis->IHGCMPort.pfnCompleted = hgcmCompleted;
|
---|
4124 | #endif
|
---|
4125 |
|
---|
4126 | pThis->pCredentials = (VMMDEVCREDS *)RTMemAllocZ(sizeof(*pThis->pCredentials));
|
---|
4127 | if (!pThis->pCredentials)
|
---|
4128 | return VERR_NO_MEMORY;
|
---|
4129 |
|
---|
4130 |
|
---|
4131 | /*
|
---|
4132 | * Validate and read the configuration.
|
---|
4133 | */
|
---|
4134 | PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns,
|
---|
4135 | "GetHostTimeDisabled|"
|
---|
4136 | "BackdoorLogDisabled|"
|
---|
4137 | "KeepCredentials|"
|
---|
4138 | "HeapEnabled|"
|
---|
4139 | "RZEnabled|"
|
---|
4140 | "GuestCoreDumpEnabled|"
|
---|
4141 | "GuestCoreDumpDir|"
|
---|
4142 | "GuestCoreDumpCount|"
|
---|
4143 | "HeartbeatInterval|"
|
---|
4144 | "HeartbeatTimeout|"
|
---|
4145 | "TestingEnabled|"
|
---|
4146 | "TestingMMIO|"
|
---|
4147 | "TestintXmlOutputFile"
|
---|
4148 | ,
|
---|
4149 | "");
|
---|
4150 |
|
---|
4151 | rc = CFGMR3QueryBoolDef(pCfg, "GetHostTimeDisabled", &pThis->fGetHostTimeDisabled, false);
|
---|
4152 | if (RT_FAILURE(rc))
|
---|
4153 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
4154 | N_("Configuration error: Failed querying \"GetHostTimeDisabled\" as a boolean"));
|
---|
4155 |
|
---|
4156 | rc = CFGMR3QueryBoolDef(pCfg, "BackdoorLogDisabled", &pThis->fBackdoorLogDisabled, false);
|
---|
4157 | if (RT_FAILURE(rc))
|
---|
4158 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
4159 | N_("Configuration error: Failed querying \"BackdoorLogDisabled\" as a boolean"));
|
---|
4160 |
|
---|
4161 | rc = CFGMR3QueryBoolDef(pCfg, "KeepCredentials", &pThis->fKeepCredentials, false);
|
---|
4162 | if (RT_FAILURE(rc))
|
---|
4163 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
4164 | N_("Configuration error: Failed querying \"KeepCredentials\" as a boolean"));
|
---|
4165 |
|
---|
4166 | rc = CFGMR3QueryBoolDef(pCfg, "HeapEnabled", &pThis->fHeapEnabled, true);
|
---|
4167 | if (RT_FAILURE(rc))
|
---|
4168 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
4169 | N_("Configuration error: Failed querying \"HeapEnabled\" as a boolean"));
|
---|
4170 |
|
---|
4171 | rc = CFGMR3QueryBoolDef(pCfg, "RZEnabled", &pThis->fRZEnabled, true);
|
---|
4172 | if (RT_FAILURE(rc))
|
---|
4173 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
4174 | N_("Configuration error: Failed querying \"RZEnabled\" as a boolean"));
|
---|
4175 |
|
---|
4176 | rc = CFGMR3QueryBoolDef(pCfg, "GuestCoreDumpEnabled", &pThis->fGuestCoreDumpEnabled, false);
|
---|
4177 | if (RT_FAILURE(rc))
|
---|
4178 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
4179 | N_("Configuration error: Failed querying \"GuestCoreDumpEnabled\" as a boolean"));
|
---|
4180 |
|
---|
4181 | char *pszGuestCoreDumpDir = NULL;
|
---|
4182 | rc = CFGMR3QueryStringAllocDef(pCfg, "GuestCoreDumpDir", &pszGuestCoreDumpDir, "");
|
---|
4183 | if (RT_FAILURE(rc))
|
---|
4184 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
4185 | N_("Configuration error: Failed querying \"GuestCoreDumpDir\" as a string"));
|
---|
4186 |
|
---|
4187 | RTStrCopy(pThis->szGuestCoreDumpDir, sizeof(pThis->szGuestCoreDumpDir), pszGuestCoreDumpDir);
|
---|
4188 | MMR3HeapFree(pszGuestCoreDumpDir);
|
---|
4189 |
|
---|
4190 | rc = CFGMR3QueryU32Def(pCfg, "GuestCoreDumpCount", &pThis->cGuestCoreDumps, 3);
|
---|
4191 | if (RT_FAILURE(rc))
|
---|
4192 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
4193 | N_("Configuration error: Failed querying \"GuestCoreDumpCount\" as a 32-bit unsigned integer"));
|
---|
4194 |
|
---|
4195 | rc = CFGMR3QueryU64Def(pCfg, "HeartbeatInterval", &pThis->cNsHeartbeatInterval, VMMDEV_HEARTBEAT_DEFAULT_INTERVAL);
|
---|
4196 | if (RT_FAILURE(rc))
|
---|
4197 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
4198 | N_("Configuration error: Failed querying \"HeartbeatInterval\" as a 64-bit unsigned integer"));
|
---|
4199 | if (pThis->cNsHeartbeatInterval < RT_NS_100MS / 2)
|
---|
4200 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
4201 | N_("Configuration error: Heartbeat interval \"HeartbeatInterval\" too small"));
|
---|
4202 |
|
---|
4203 | rc = CFGMR3QueryU64Def(pCfg, "HeartbeatTimeout", &pThis->cNsHeartbeatTimeout, pThis->cNsHeartbeatInterval * 2);
|
---|
4204 | if (RT_FAILURE(rc))
|
---|
4205 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
4206 | N_("Configuration error: Failed querying \"HeartbeatTimeout\" as a 64-bit unsigned integer"));
|
---|
4207 | if (pThis->cNsHeartbeatTimeout < RT_NS_100MS)
|
---|
4208 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
4209 | N_("Configuration error: Heartbeat timeout \"HeartbeatTimeout\" too small"));
|
---|
4210 | if (pThis->cNsHeartbeatTimeout <= pThis->cNsHeartbeatInterval + RT_NS_10MS)
|
---|
4211 | return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
|
---|
4212 | N_("Configuration error: Heartbeat timeout \"HeartbeatTimeout\" value (%'ull ns) is too close to the interval (%'ull ns)"),
|
---|
4213 | pThis->cNsHeartbeatTimeout, pThis->cNsHeartbeatInterval);
|
---|
4214 |
|
---|
4215 | #ifndef VBOX_WITHOUT_TESTING_FEATURES
|
---|
4216 | rc = CFGMR3QueryBoolDef(pCfg, "TestingEnabled", &pThis->fTestingEnabled, false);
|
---|
4217 | if (RT_FAILURE(rc))
|
---|
4218 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
4219 | N_("Configuration error: Failed querying \"TestingEnabled\" as a boolean"));
|
---|
4220 | rc = CFGMR3QueryBoolDef(pCfg, "TestingMMIO", &pThis->fTestingMMIO, false);
|
---|
4221 | if (RT_FAILURE(rc))
|
---|
4222 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
4223 | N_("Configuration error: Failed querying \"TestingMMIO\" as a boolean"));
|
---|
4224 | rc = CFGMR3QueryStringAllocDef(pCfg, "TestintXmlOutputFile", &pThis->pszTestingXmlOutput, NULL);
|
---|
4225 | if (RT_FAILURE(rc))
|
---|
4226 | return PDMDEV_SET_ERROR(pDevIns, rc, N_("Configuration error: Failed querying \"TestintXmlOutputFile\" as a string"));
|
---|
4227 |
|
---|
4228 | /** @todo image-to-load-filename? */
|
---|
4229 | #endif
|
---|
4230 |
|
---|
4231 | pThis->cbGuestRAM = MMR3PhysGetRamSize(PDMDevHlpGetVM(pDevIns));
|
---|
4232 |
|
---|
4233 | /*
|
---|
4234 | * We do our own locking entirely. So, install NOP critsect for the device
|
---|
4235 | * and create our own critsect for use where it really matters (++).
|
---|
4236 | */
|
---|
4237 | rc = PDMDevHlpSetDeviceCritSect(pDevIns, PDMDevHlpCritSectGetNop(pDevIns));
|
---|
4238 | AssertRCReturn(rc, rc);
|
---|
4239 | rc = PDMDevHlpCritSectInit(pDevIns, &pThis->CritSect, RT_SRC_POS, "VMMDev#%u", iInstance);
|
---|
4240 | AssertRCReturn(rc, rc);
|
---|
4241 |
|
---|
4242 | /*
|
---|
4243 | * Register the backdoor logging port
|
---|
4244 | */
|
---|
4245 | rc = PDMDevHlpIOPortRegister(pDevIns, RTLOG_DEBUG_PORT, 1, NULL, vmmdevBackdoorLog,
|
---|
4246 | NULL, NULL, NULL, "VMMDev backdoor logging");
|
---|
4247 | AssertRCReturn(rc, rc);
|
---|
4248 |
|
---|
4249 | #ifdef VMMDEV_WITH_ALT_TIMESYNC
|
---|
4250 | /*
|
---|
4251 | * Alternative timesync source.
|
---|
4252 | *
|
---|
4253 | * This was orignally added for creating a simple time sync service in an
|
---|
4254 | * OpenBSD guest without requiring VBoxGuest and VBoxService to be ported
|
---|
4255 | * first. We keep it in case it comes in handy.
|
---|
4256 | */
|
---|
4257 | rc = PDMDevHlpIOPortRegister(pDevIns, 0x505, 1, NULL,
|
---|
4258 | vmmdevAltTimeSyncWrite, vmmdevAltTimeSyncRead,
|
---|
4259 | NULL, NULL, "VMMDev timesync backdoor");
|
---|
4260 | AssertRCReturn(rc, rc);
|
---|
4261 | #endif
|
---|
4262 |
|
---|
4263 | /*
|
---|
4264 | * Register the PCI device.
|
---|
4265 | */
|
---|
4266 | rc = PDMDevHlpPCIRegister(pDevIns, &pThis->PciDev);
|
---|
4267 | if (RT_FAILURE(rc))
|
---|
4268 | return rc;
|
---|
4269 | if (pThis->PciDev.uDevFn != 32 || iInstance != 0)
|
---|
4270 | Log(("!!WARNING!!: pThis->PciDev.uDevFn=%d (ignore if testcase or no started by Main)\n", pThis->PciDev.uDevFn));
|
---|
4271 | rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 0x20, PCI_ADDRESS_SPACE_IO, vmmdevIOPortRegionMap);
|
---|
4272 | if (RT_FAILURE(rc))
|
---|
4273 | return rc;
|
---|
4274 | rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, VMMDEV_RAM_SIZE, PCI_ADDRESS_SPACE_MEM, vmmdevIORAMRegionMap);
|
---|
4275 | if (RT_FAILURE(rc))
|
---|
4276 | return rc;
|
---|
4277 | if (pThis->fHeapEnabled)
|
---|
4278 | {
|
---|
4279 | rc = PDMDevHlpPCIIORegionRegister(pDevIns, 2, VMMDEV_HEAP_SIZE, PCI_ADDRESS_SPACE_MEM_PREFETCH, vmmdevIORAMRegionMap);
|
---|
4280 | if (RT_FAILURE(rc))
|
---|
4281 | return rc;
|
---|
4282 | }
|
---|
4283 |
|
---|
4284 | /*
|
---|
4285 | * Allocate and initialize the MMIO2 memory.
|
---|
4286 | */
|
---|
4287 | rc = PDMDevHlpMMIO2Register(pDevIns, &pThis->PciDev, 1 /*iRegion*/, VMMDEV_RAM_SIZE, 0 /*fFlags*/,
|
---|
4288 | (void **)&pThis->pVMMDevRAMR3, "VMMDev");
|
---|
4289 | if (RT_FAILURE(rc))
|
---|
4290 | return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
|
---|
4291 | N_("Failed to allocate %u bytes of memory for the VMM device"), VMMDEV_RAM_SIZE);
|
---|
4292 | vmmdevInitRam(pThis);
|
---|
4293 |
|
---|
4294 | if (pThis->fHeapEnabled)
|
---|
4295 | {
|
---|
4296 | rc = PDMDevHlpMMIO2Register(pDevIns, &pThis->PciDev, 2 /*iRegion*/, VMMDEV_HEAP_SIZE, 0 /*fFlags*/,
|
---|
4297 | (void **)&pThis->pVMMDevHeapR3, "VMMDev Heap");
|
---|
4298 | if (RT_FAILURE(rc))
|
---|
4299 | return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
|
---|
4300 | N_("Failed to allocate %u bytes of memory for the VMM device heap"), PAGE_SIZE);
|
---|
4301 |
|
---|
4302 | /* Register the memory area with PDM so HM can access it before it's mapped. */
|
---|
4303 | rc = PDMDevHlpRegisterVMMDevHeap(pDevIns, NIL_RTGCPHYS, pThis->pVMMDevHeapR3, VMMDEV_HEAP_SIZE);
|
---|
4304 | AssertLogRelRCReturn(rc, rc);
|
---|
4305 | }
|
---|
4306 |
|
---|
4307 | #ifndef VBOX_WITHOUT_TESTING_FEATURES
|
---|
4308 | /*
|
---|
4309 | * Initialize testing.
|
---|
4310 | */
|
---|
4311 | rc = vmmdevTestingInitialize(pDevIns);
|
---|
4312 | if (RT_FAILURE(rc))
|
---|
4313 | return rc;
|
---|
4314 | #endif
|
---|
4315 |
|
---|
4316 | /*
|
---|
4317 | * Get the corresponding connector interface
|
---|
4318 | */
|
---|
4319 | rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase, "VMM Driver Port");
|
---|
4320 | if (RT_SUCCESS(rc))
|
---|
4321 | {
|
---|
4322 | pThis->pDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIVMMDEVCONNECTOR);
|
---|
4323 | AssertMsgReturn(pThis->pDrv, ("LUN #0 doesn't have a VMMDev connector interface!\n"), VERR_PDM_MISSING_INTERFACE);
|
---|
4324 | #ifdef VBOX_WITH_HGCM
|
---|
4325 | pThis->pHGCMDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIHGCMCONNECTOR);
|
---|
4326 | if (!pThis->pHGCMDrv)
|
---|
4327 | {
|
---|
4328 | Log(("LUN #0 doesn't have a HGCM connector interface, HGCM is not supported. rc=%Rrc\n", rc));
|
---|
4329 | /* this is not actually an error, just means that there is no support for HGCM */
|
---|
4330 | }
|
---|
4331 | #endif
|
---|
4332 | /* Query the initial balloon size. */
|
---|
4333 | AssertPtr(pThis->pDrv->pfnQueryBalloonSize);
|
---|
4334 | rc = pThis->pDrv->pfnQueryBalloonSize(pThis->pDrv, &pThis->cMbMemoryBalloon);
|
---|
4335 | AssertRC(rc);
|
---|
4336 |
|
---|
4337 | Log(("Initial balloon size %x\n", pThis->cMbMemoryBalloon));
|
---|
4338 | }
|
---|
4339 | else if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
|
---|
4340 | {
|
---|
4341 | Log(("%s/%d: warning: no driver attached to LUN #0!\n", pDevIns->pReg->szName, pDevIns->iInstance));
|
---|
4342 | rc = VINF_SUCCESS;
|
---|
4343 | }
|
---|
4344 | else
|
---|
4345 | AssertMsgFailedReturn(("Failed to attach LUN #0! rc=%Rrc\n", rc), rc);
|
---|
4346 |
|
---|
4347 | /*
|
---|
4348 | * Attach status driver for shared folders (optional).
|
---|
4349 | */
|
---|
4350 | PPDMIBASE pBase;
|
---|
4351 | rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pThis->IBase, &pBase, "Status Port");
|
---|
4352 | if (RT_SUCCESS(rc))
|
---|
4353 | pThis->SharedFolders.pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS);
|
---|
4354 | else if (rc != VERR_PDM_NO_ATTACHED_DRIVER)
|
---|
4355 | {
|
---|
4356 | AssertMsgFailed(("Failed to attach to status driver. rc=%Rrc\n", rc));
|
---|
4357 | return rc;
|
---|
4358 | }
|
---|
4359 |
|
---|
4360 | /*
|
---|
4361 | * Register saved state and init the HGCM CmdList critsect.
|
---|
4362 | */
|
---|
4363 | rc = PDMDevHlpSSMRegisterEx(pDevIns, VMMDEV_SAVED_STATE_VERSION, sizeof(*pThis), NULL,
|
---|
4364 | NULL, vmmdevLiveExec, NULL,
|
---|
4365 | NULL, vmmdevSaveExec, NULL,
|
---|
4366 | NULL, vmmdevLoadExec, vmmdevLoadStateDone);
|
---|
4367 | AssertRCReturn(rc, rc);
|
---|
4368 |
|
---|
4369 | /*
|
---|
4370 | * Create heartbeat checking timer.
|
---|
4371 | */
|
---|
4372 | rc = PDMDevHlpTMTimerCreate(pDevIns, TMCLOCK_VIRTUAL, vmmDevHeartbeatFlatlinedTimer, pThis,
|
---|
4373 | TMTIMER_FLAGS_NO_CRIT_SECT, "Heartbeat flatlined", &pThis->pFlatlinedTimer);
|
---|
4374 | AssertRCReturn(rc, rc);
|
---|
4375 |
|
---|
4376 | #ifdef VBOX_WITH_HGCM
|
---|
4377 | RTListInit(&pThis->listHGCMCmd);
|
---|
4378 | rc = RTCritSectInit(&pThis->critsectHGCMCmdList);
|
---|
4379 | AssertRCReturn(rc, rc);
|
---|
4380 | pThis->u32HGCMEnabled = 0;
|
---|
4381 | #endif /* VBOX_WITH_HGCM */
|
---|
4382 |
|
---|
4383 | /*
|
---|
4384 | * In this version of VirtualBox the GUI checks whether "needs host cursor"
|
---|
4385 | * changes.
|
---|
4386 | */
|
---|
4387 | pThis->mouseCapabilities |= VMMDEV_MOUSE_HOST_RECHECKS_NEEDS_HOST_CURSOR;
|
---|
4388 |
|
---|
4389 | PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatMemBalloonChunks, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Memory balloon size", "/Devices/VMMDev/BalloonChunks");
|
---|
4390 |
|
---|
4391 | /*
|
---|
4392 | * Generate a unique session id for this VM; it will be changed for each
|
---|
4393 | * start, reset or restore. This can be used for restore detection inside
|
---|
4394 | * the guest.
|
---|
4395 | */
|
---|
4396 | pThis->idSession = ASMReadTSC();
|
---|
4397 | return rc;
|
---|
4398 | }
|
---|
4399 |
|
---|
4400 | /**
|
---|
4401 | * The device registration structure.
|
---|
4402 | */
|
---|
4403 | extern "C" const PDMDEVREG g_DeviceVMMDev =
|
---|
4404 | {
|
---|
4405 | /* u32Version */
|
---|
4406 | PDM_DEVREG_VERSION,
|
---|
4407 | /* szName */
|
---|
4408 | "VMMDev",
|
---|
4409 | /* szRCMod */
|
---|
4410 | "VBoxDDRC.rc",
|
---|
4411 | /* szR0Mod */
|
---|
4412 | "VBoxDDR0.r0",
|
---|
4413 | /* pszDescription */
|
---|
4414 | "VirtualBox VMM Device\n",
|
---|
4415 | /* fFlags */
|
---|
4416 | PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT | PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT | PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_R0,
|
---|
4417 | /* fClass */
|
---|
4418 | PDM_DEVREG_CLASS_VMM_DEV,
|
---|
4419 | /* cMaxInstances */
|
---|
4420 | 1,
|
---|
4421 | /* cbInstance */
|
---|
4422 | sizeof(VMMDevState),
|
---|
4423 | /* pfnConstruct */
|
---|
4424 | vmmdevConstruct,
|
---|
4425 | /* pfnDestruct */
|
---|
4426 | vmmdevDestruct,
|
---|
4427 | /* pfnRelocate */
|
---|
4428 | vmmdevRelocate,
|
---|
4429 | /* pfnMemSetup */
|
---|
4430 | NULL,
|
---|
4431 | /* pfnPowerOn */
|
---|
4432 | NULL,
|
---|
4433 | /* pfnReset */
|
---|
4434 | vmmdevReset,
|
---|
4435 | /* pfnSuspend */
|
---|
4436 | NULL,
|
---|
4437 | /* pfnResume */
|
---|
4438 | NULL,
|
---|
4439 | /* pfnAttach */
|
---|
4440 | NULL,
|
---|
4441 | /* pfnDetach */
|
---|
4442 | NULL,
|
---|
4443 | /* pfnQueryInterface. */
|
---|
4444 | NULL,
|
---|
4445 | /* pfnInitComplete */
|
---|
4446 | NULL,
|
---|
4447 | /* pfnPowerOff */
|
---|
4448 | NULL,
|
---|
4449 | /* pfnSoftReset */
|
---|
4450 | NULL,
|
---|
4451 | /* u32VersionEnd */
|
---|
4452 | PDM_DEVREG_VERSION
|
---|
4453 | };
|
---|
4454 | #endif /* !VBOX_DEVICE_STRUCT_TESTCASE */
|
---|
4455 |
|
---|