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