1 | /* $Id: VMMDev.cpp 44528 2013-02-04 14:27:54Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VMMDev - Guest <-> VMM/Host communication device.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2013 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 |
|
---|
19 | /*******************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *******************************************************************************/
|
---|
22 |
|
---|
23 | /* Enable dev_vmm Log3 statements to get IRQ-related logging. */
|
---|
24 |
|
---|
25 | #define LOG_GROUP LOG_GROUP_DEV_VMM
|
---|
26 | #include <VBox/VMMDev.h>
|
---|
27 | #include <VBox/vmm/mm.h>
|
---|
28 | #include <VBox/log.h>
|
---|
29 | #include <VBox/param.h>
|
---|
30 | #include <iprt/path.h>
|
---|
31 | #include <iprt/dir.h>
|
---|
32 | #include <iprt/file.h>
|
---|
33 | #include <VBox/vmm/pgm.h>
|
---|
34 | #include <VBox/err.h>
|
---|
35 | #include <VBox/vmm/vm.h> /* for VM_IS_EMT */
|
---|
36 | #include <VBox/dbg.h>
|
---|
37 | #include <VBox/version.h>
|
---|
38 |
|
---|
39 | #include <iprt/asm.h>
|
---|
40 | #include <iprt/asm-amd64-x86.h>
|
---|
41 | #include <iprt/assert.h>
|
---|
42 | #include <iprt/buildconfig.h>
|
---|
43 | #include <iprt/string.h>
|
---|
44 | #include <iprt/time.h>
|
---|
45 | #ifndef IN_RC
|
---|
46 | # include <iprt/mem.h>
|
---|
47 | #endif
|
---|
48 | #ifdef IN_RING3
|
---|
49 | # include <iprt/uuid.h>
|
---|
50 | #endif
|
---|
51 |
|
---|
52 | #include "VMMDevState.h"
|
---|
53 | #ifdef VBOX_WITH_HGCM
|
---|
54 | # include "VMMDevHGCM.h"
|
---|
55 | #endif
|
---|
56 | #ifndef VBOX_WITHOUT_TESTING_FEATURES
|
---|
57 | # include "VMMDevTesting.h"
|
---|
58 | #endif
|
---|
59 |
|
---|
60 |
|
---|
61 | /*******************************************************************************
|
---|
62 | * Defined Constants And Macros *
|
---|
63 | *******************************************************************************/
|
---|
64 | #define PCIDEV_2_VMMDEVSTATE(pPciDev) ( (VMMDevState *)(pPciDev) )
|
---|
65 | #define VMMDEVSTATE_2_DEVINS(pVMMDevState) ( (pVMMDevState)->pDevIns )
|
---|
66 |
|
---|
67 | #define VBOX_GUEST_INTERFACE_VERSION_1_03(s) \
|
---|
68 | ( RT_HIWORD((s)->guestInfo.interfaceVersion) == 1 \
|
---|
69 | && RT_LOWORD((s)->guestInfo.interfaceVersion) == 3 )
|
---|
70 |
|
---|
71 | #define VBOX_GUEST_INTERFACE_VERSION_OK(additionsVersion) \
|
---|
72 | ( RT_HIWORD(additionsVersion) == RT_HIWORD(VMMDEV_VERSION) \
|
---|
73 | && RT_LOWORD(additionsVersion) <= RT_LOWORD(VMMDEV_VERSION) )
|
---|
74 |
|
---|
75 | #define VBOX_GUEST_INTERFACE_VERSION_OLD(additionsVersion) \
|
---|
76 | ( (RT_HIWORD(additionsVersion) < RT_HIWORD(VMMDEV_VERSION) \
|
---|
77 | || ( RT_HIWORD(additionsVersion) == RT_HIWORD(VMMDEV_VERSION) \
|
---|
78 | && RT_LOWORD(additionsVersion) <= RT_LOWORD(VMMDEV_VERSION) ) )
|
---|
79 |
|
---|
80 | #define VBOX_GUEST_INTERFACE_VERSION_TOO_OLD(additionsVersion) \
|
---|
81 | ( RT_HIWORD(additionsVersion) < RT_HIWORD(VMMDEV_VERSION) )
|
---|
82 |
|
---|
83 | #define VBOX_GUEST_INTERFACE_VERSION_NEW(additionsVersion) \
|
---|
84 | ( RT_HIWORD(additionsVersion) > RT_HIWORD(VMMDEV_VERSION) \
|
---|
85 | || ( RT_HIWORD(additionsVersion) == RT_HIWORD(VMMDEV_VERSION) \
|
---|
86 | && RT_LOWORD(additionsVersion) > RT_LOWORD(VMMDEV_VERSION) ) )
|
---|
87 |
|
---|
88 | /** The saved state version. */
|
---|
89 | #define VMMDEV_SAVED_STATE_VERSION 15
|
---|
90 | /** The saved state version which is missing the guest facility statuses. */
|
---|
91 | #define VMMDEV_SAVED_STATE_VERSION_MISSING_FACILITY_STATUSES 14
|
---|
92 | /** The saved state version which is missing the guestInfo2 bits. */
|
---|
93 | #define VMMDEV_SAVED_STATE_VERSION_MISSING_GUEST_INFO_2 13
|
---|
94 | /** The saved state version used by VirtualBox 3.0.
|
---|
95 | * This doesn't have the config part. */
|
---|
96 | #define VMMDEV_SAVED_STATE_VERSION_VBOX_30 11
|
---|
97 |
|
---|
98 |
|
---|
99 | #ifndef VBOX_DEVICE_STRUCT_TESTCASE
|
---|
100 |
|
---|
101 | /* Whenever host wants to inform guest about something
|
---|
102 | * an IRQ notification will be raised.
|
---|
103 | *
|
---|
104 | * VMMDev PDM interface will contain the guest notification method.
|
---|
105 | *
|
---|
106 | * There is a 32 bit event mask which will be read
|
---|
107 | * by guest on an interrupt. A non zero bit in the mask
|
---|
108 | * means that the specific event occurred and requires
|
---|
109 | * processing on guest side.
|
---|
110 | *
|
---|
111 | * After reading the event mask guest must issue a
|
---|
112 | * generic request AcknowlegdeEvents.
|
---|
113 | *
|
---|
114 | * IRQ line is set to 1 (request) if there are unprocessed
|
---|
115 | * events, that is the event mask is not zero.
|
---|
116 | *
|
---|
117 | * After receiving an interrupt and checking event mask,
|
---|
118 | * the guest must process events using the event specific
|
---|
119 | * mechanism.
|
---|
120 | *
|
---|
121 | * That is if mouse capabilities were changed,
|
---|
122 | * guest will use VMMDev_GetMouseStatus generic request.
|
---|
123 | *
|
---|
124 | * Event mask is only a set of flags indicating that guest
|
---|
125 | * must proceed with a procedure.
|
---|
126 | *
|
---|
127 | * Unsupported events are therefore ignored.
|
---|
128 | * The guest additions must inform host which events they
|
---|
129 | * want to receive, to avoid unnecessary IRQ processing.
|
---|
130 | * By default no events are signalled to guest.
|
---|
131 | *
|
---|
132 | * This seems to be fast method. It requires
|
---|
133 | * only one context switch for an event processing.
|
---|
134 | *
|
---|
135 | */
|
---|
136 |
|
---|
137 | static void vmmdevSetIRQ_Legacy_EMT (VMMDevState *pVMMDevState)
|
---|
138 | {
|
---|
139 | if (!pVMMDevState->fu32AdditionsOk)
|
---|
140 | {
|
---|
141 | Log(("vmmdevSetIRQ: IRQ is not generated, guest has not yet reported to us.\n"));
|
---|
142 | return;
|
---|
143 | }
|
---|
144 |
|
---|
145 | uint32_t u32IRQLevel = 0;
|
---|
146 |
|
---|
147 | /* Filter unsupported events */
|
---|
148 | uint32_t u32EventFlags =
|
---|
149 | pVMMDevState->u32HostEventFlags
|
---|
150 | & pVMMDevState->pVMMDevRAMR3->V.V1_03.u32GuestEventMask;
|
---|
151 |
|
---|
152 | Log(("vmmdevSetIRQ: u32EventFlags = 0x%08X, "
|
---|
153 | "pVMMDevState->u32HostEventFlags = 0x%08X, "
|
---|
154 | "pVMMDevState->pVMMDevRAMR3->u32GuestEventMask = 0x%08X\n",
|
---|
155 | u32EventFlags,
|
---|
156 | pVMMDevState->u32HostEventFlags,
|
---|
157 | pVMMDevState->pVMMDevRAMR3->V.V1_03.u32GuestEventMask));
|
---|
158 |
|
---|
159 | /* Move event flags to VMMDev RAM */
|
---|
160 | pVMMDevState->pVMMDevRAMR3->V.V1_03.u32HostEvents = u32EventFlags;
|
---|
161 |
|
---|
162 | if (u32EventFlags)
|
---|
163 | {
|
---|
164 | /* Clear host flags which will be delivered to guest. */
|
---|
165 | pVMMDevState->u32HostEventFlags &= ~u32EventFlags;
|
---|
166 | Log(("vmmdevSetIRQ: pVMMDevState->u32HostEventFlags = 0x%08X\n",
|
---|
167 | pVMMDevState->u32HostEventFlags));
|
---|
168 | u32IRQLevel = 1;
|
---|
169 | }
|
---|
170 |
|
---|
171 | /* Set IRQ level for pin 0 */
|
---|
172 | /** @todo make IRQ pin configurable, at least a symbolic constant */
|
---|
173 | PPDMDEVINS pDevIns = VMMDEVSTATE_2_DEVINS(pVMMDevState);
|
---|
174 | PDMDevHlpPCISetIrqNoWait(pDevIns, 0, u32IRQLevel);
|
---|
175 | Log(("vmmdevSetIRQ: IRQ set %d\n", u32IRQLevel));
|
---|
176 | }
|
---|
177 |
|
---|
178 | static void vmmdevMaybeSetIRQ_EMT (VMMDevState *pVMMDevState)
|
---|
179 | {
|
---|
180 | PPDMDEVINS pDevIns = VMMDEVSTATE_2_DEVINS (pVMMDevState);
|
---|
181 |
|
---|
182 | Log3(("vmmdevMaybeSetIRQ_EMT: u32HostEventFlags = 0x%08X, u32GuestFilterMask = 0x%08X.\n",
|
---|
183 | pVMMDevState->u32HostEventFlags, pVMMDevState->u32GuestFilterMask));
|
---|
184 |
|
---|
185 | if (pVMMDevState->u32HostEventFlags & pVMMDevState->u32GuestFilterMask)
|
---|
186 | {
|
---|
187 | pVMMDevState->pVMMDevRAMR3->V.V1_04.fHaveEvents = true;
|
---|
188 | PDMDevHlpPCISetIrqNoWait (pDevIns, 0, 1);
|
---|
189 | Log3(("vmmdevMaybeSetIRQ_EMT: IRQ set.\n"));
|
---|
190 | }
|
---|
191 | }
|
---|
192 |
|
---|
193 | static void vmmdevNotifyGuest_EMT (VMMDevState *pVMMDevState, uint32_t u32EventMask)
|
---|
194 | {
|
---|
195 | Log3(("VMMDevNotifyGuest_EMT: u32EventMask = 0x%08X.\n", u32EventMask));
|
---|
196 |
|
---|
197 | if (VBOX_GUEST_INTERFACE_VERSION_1_03 (pVMMDevState))
|
---|
198 | {
|
---|
199 | Log3(("VMMDevNotifyGuest_EMT: Old additions detected.\n"));
|
---|
200 |
|
---|
201 | pVMMDevState->u32HostEventFlags |= u32EventMask;
|
---|
202 | vmmdevSetIRQ_Legacy_EMT (pVMMDevState);
|
---|
203 | }
|
---|
204 | else
|
---|
205 | {
|
---|
206 | Log3(("VMMDevNotifyGuest_EMT: New additions detected.\n"));
|
---|
207 |
|
---|
208 | if (!pVMMDevState->fu32AdditionsOk)
|
---|
209 | {
|
---|
210 | pVMMDevState->u32HostEventFlags |= u32EventMask;
|
---|
211 | Log(("vmmdevNotifyGuest_EMT: IRQ is not generated, guest has not yet reported to us.\n"));
|
---|
212 | return;
|
---|
213 | }
|
---|
214 |
|
---|
215 | const bool fHadEvents =
|
---|
216 | (pVMMDevState->u32HostEventFlags & pVMMDevState->u32GuestFilterMask) != 0;
|
---|
217 |
|
---|
218 | Log3(("VMMDevNotifyGuest_EMT: fHadEvents = %d, u32HostEventFlags = 0x%08X, u32GuestFilterMask = 0x%08X.\n",
|
---|
219 | fHadEvents, pVMMDevState->u32HostEventFlags, pVMMDevState->u32GuestFilterMask));
|
---|
220 |
|
---|
221 | pVMMDevState->u32HostEventFlags |= u32EventMask;
|
---|
222 |
|
---|
223 | if (!fHadEvents)
|
---|
224 | vmmdevMaybeSetIRQ_EMT (pVMMDevState);
|
---|
225 | }
|
---|
226 | }
|
---|
227 |
|
---|
228 | void VMMDevCtlSetGuestFilterMask (VMMDevState *pVMMDevState,
|
---|
229 | uint32_t u32OrMask,
|
---|
230 | uint32_t u32NotMask)
|
---|
231 | {
|
---|
232 | PDMCritSectEnter(&pVMMDevState->CritSect, VERR_SEM_BUSY);
|
---|
233 |
|
---|
234 | const bool fHadEvents =
|
---|
235 | (pVMMDevState->u32HostEventFlags & pVMMDevState->u32GuestFilterMask) != 0;
|
---|
236 |
|
---|
237 | Log(("VMMDevCtlSetGuestFilterMask: u32OrMask = 0x%08X, u32NotMask = 0x%08X, fHadEvents = %d.\n", u32OrMask, u32NotMask, fHadEvents));
|
---|
238 | if (fHadEvents)
|
---|
239 | {
|
---|
240 | if (!pVMMDevState->fNewGuestFilterMask)
|
---|
241 | pVMMDevState->u32NewGuestFilterMask = pVMMDevState->u32GuestFilterMask;
|
---|
242 |
|
---|
243 | pVMMDevState->u32NewGuestFilterMask |= u32OrMask;
|
---|
244 | pVMMDevState->u32NewGuestFilterMask &= ~u32NotMask;
|
---|
245 | pVMMDevState->fNewGuestFilterMask = true;
|
---|
246 | }
|
---|
247 | else
|
---|
248 | {
|
---|
249 | pVMMDevState->u32GuestFilterMask |= u32OrMask;
|
---|
250 | pVMMDevState->u32GuestFilterMask &= ~u32NotMask;
|
---|
251 | vmmdevMaybeSetIRQ_EMT (pVMMDevState);
|
---|
252 | }
|
---|
253 | PDMCritSectLeave(&pVMMDevState->CritSect);
|
---|
254 | }
|
---|
255 |
|
---|
256 | void VMMDevNotifyGuest (VMMDevState *pVMMDevState, uint32_t u32EventMask)
|
---|
257 | {
|
---|
258 | PPDMDEVINS pDevIns = VMMDEVSTATE_2_DEVINS(pVMMDevState);
|
---|
259 |
|
---|
260 | Log3(("VMMDevNotifyGuest: u32EventMask = 0x%08X.\n", u32EventMask));
|
---|
261 |
|
---|
262 | /*
|
---|
263 | * Drop notifications if the VM is not running yet/anymore.
|
---|
264 | */
|
---|
265 | VMSTATE enmVMState = PDMDevHlpVMState(pDevIns);
|
---|
266 | if ( enmVMState != VMSTATE_RUNNING
|
---|
267 | && enmVMState != VMSTATE_RUNNING_LS)
|
---|
268 | return;
|
---|
269 |
|
---|
270 | PDMCritSectEnter(&pVMMDevState->CritSect, VERR_SEM_BUSY);
|
---|
271 | /* No need to wait for the completion of this request. It is a notification
|
---|
272 | * about something, which has already happened.
|
---|
273 | */
|
---|
274 | vmmdevNotifyGuest_EMT(pVMMDevState, u32EventMask);
|
---|
275 | PDMCritSectLeave(&pVMMDevState->CritSect);
|
---|
276 | }
|
---|
277 |
|
---|
278 | /**
|
---|
279 | * Port I/O Handler for OUT operations.
|
---|
280 | *
|
---|
281 | * @returns VBox status code.
|
---|
282 | *
|
---|
283 | * @param pDevIns The device instance.
|
---|
284 | * @param pvUser User argument - ignored.
|
---|
285 | * @param uPort Port number used for the IN operation.
|
---|
286 | * @param u32 The value to output.
|
---|
287 | * @param cb The value size in bytes.
|
---|
288 | */
|
---|
289 | static DECLCALLBACK(int) vmmdevBackdoorLog(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
|
---|
290 | {
|
---|
291 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState *);
|
---|
292 |
|
---|
293 | if (!pThis->fBackdoorLogDisabled && cb == 1 && Port == RTLOG_DEBUG_PORT)
|
---|
294 | {
|
---|
295 |
|
---|
296 | /* The raw version. */
|
---|
297 | switch (u32)
|
---|
298 | {
|
---|
299 | case '\r': LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP_DEV_VMM_BACKDOOR, ("vmmdev: <return>\n")); break;
|
---|
300 | case '\n': LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP_DEV_VMM_BACKDOOR, ("vmmdev: <newline>\n")); break;
|
---|
301 | case '\t': LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP_DEV_VMM_BACKDOOR, ("vmmdev: <tab>\n")); break;
|
---|
302 | default: LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_2, LOG_GROUP_DEV_VMM_BACKDOOR, ("vmmdev: %c (%02x)\n", u32, u32)); break;
|
---|
303 | }
|
---|
304 |
|
---|
305 | /* The readable, buffered version. */
|
---|
306 | if (u32 == '\n' || u32 == '\r')
|
---|
307 | {
|
---|
308 | pThis->szMsg[pThis->iMsg] = '\0';
|
---|
309 | if (pThis->iMsg)
|
---|
310 | LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP_DEV_VMM_BACKDOOR, ("Guest Log: %s\n", pThis->szMsg));
|
---|
311 | pThis->iMsg = 0;
|
---|
312 | }
|
---|
313 | else
|
---|
314 | {
|
---|
315 | if (pThis->iMsg >= sizeof(pThis->szMsg)-1)
|
---|
316 | {
|
---|
317 | pThis->szMsg[pThis->iMsg] = '\0';
|
---|
318 | LogRelIt(LOG_REL_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP_DEV_VMM_BACKDOOR, ("Guest Log: %s\n", pThis->szMsg));
|
---|
319 | pThis->iMsg = 0;
|
---|
320 | }
|
---|
321 | pThis->szMsg[pThis->iMsg] = (char )u32;
|
---|
322 | pThis->szMsg[++pThis->iMsg] = '\0';
|
---|
323 | }
|
---|
324 | }
|
---|
325 | return VINF_SUCCESS;
|
---|
326 | }
|
---|
327 |
|
---|
328 | #ifdef TIMESYNC_BACKDOOR
|
---|
329 | /**
|
---|
330 | * Port I/O Handler for OUT operations.
|
---|
331 | *
|
---|
332 | * @returns VBox status code.
|
---|
333 | *
|
---|
334 | * @param pDevIns The device instance.
|
---|
335 | * @param pvUser User argument - ignored.
|
---|
336 | * @param uPort Port number used for the IN operation.
|
---|
337 | * @param u32 The value to output.
|
---|
338 | * @param cb The value size in bytes.
|
---|
339 | */
|
---|
340 | static DECLCALLBACK(int) vmmdevTimesyncBackdoorWrite(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
|
---|
341 | {
|
---|
342 | NOREF(pvUser);
|
---|
343 | if (cb == 4)
|
---|
344 | {
|
---|
345 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState *);
|
---|
346 | switch (u32)
|
---|
347 | {
|
---|
348 | case 0:
|
---|
349 | pThis->fTimesyncBackdoorLo = false;
|
---|
350 | break;
|
---|
351 | case 1:
|
---|
352 | pThis->fTimesyncBackdoorLo = true;
|
---|
353 | }
|
---|
354 | return VINF_SUCCESS;
|
---|
355 |
|
---|
356 | }
|
---|
357 | return VINF_SUCCESS;
|
---|
358 | }
|
---|
359 |
|
---|
360 | /**
|
---|
361 | * Port I/O Handler for backdoor timesync IN operations.
|
---|
362 | *
|
---|
363 | * @returns VBox status code.
|
---|
364 | *
|
---|
365 | * @param pDevIns The device instance.
|
---|
366 | * @param pvUser User argument - ignored.
|
---|
367 | * @param uPort Port number used for the IN operation.
|
---|
368 | * @param pu32 Where to store the result.
|
---|
369 | * @param cb Number of bytes read.
|
---|
370 | */
|
---|
371 | static DECLCALLBACK(int) vmmdevTimesyncBackdoorRead(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t *pu32, unsigned cb)
|
---|
372 | {
|
---|
373 | int rc;
|
---|
374 | NOREF(pvUser);
|
---|
375 | if (cb == 4)
|
---|
376 | {
|
---|
377 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState *);
|
---|
378 | RTTIMESPEC now;
|
---|
379 |
|
---|
380 | if (pThis->fTimesyncBackdoorLo)
|
---|
381 | *pu32 = (uint32_t)pThis->hostTime;
|
---|
382 | else
|
---|
383 | {
|
---|
384 | pThis->hostTime = RTTimeSpecGetMilli(PDMDevHlpTMUtcNow(pDevIns, &now));
|
---|
385 | *pu32 = (uint32_t)(pThis->hostTime >> 32);
|
---|
386 | }
|
---|
387 | rc = VINF_SUCCESS;
|
---|
388 | }
|
---|
389 | else
|
---|
390 | rc = VERR_IOM_IOPORT_UNUSED;
|
---|
391 | return rc;
|
---|
392 | }
|
---|
393 | #endif /* TIMESYNC_BACKDOOR */
|
---|
394 |
|
---|
395 | /**
|
---|
396 | * Validates a publisher tag.
|
---|
397 | *
|
---|
398 | * @returns true / false.
|
---|
399 | * @param pszTag Tag to validate.
|
---|
400 | */
|
---|
401 | static bool vmmdevReqIsValidPublisherTag(const char *pszTag)
|
---|
402 | {
|
---|
403 | /* Note! This character set is also found in Config.kmk. */
|
---|
404 | static char const s_szValidChars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz()[]{}+-.,";
|
---|
405 |
|
---|
406 | while (*pszTag != '\0')
|
---|
407 | {
|
---|
408 | if (!strchr(s_szValidChars, *pszTag))
|
---|
409 | return false;
|
---|
410 | pszTag++;
|
---|
411 | }
|
---|
412 | return true;
|
---|
413 | }
|
---|
414 |
|
---|
415 |
|
---|
416 | /**
|
---|
417 | * Validates a build tag.
|
---|
418 | *
|
---|
419 | * @returns true / false.
|
---|
420 | * @param pszTag Tag to validate.
|
---|
421 | */
|
---|
422 | static bool vmmdevReqIsValidBuildTag(const char *pszTag)
|
---|
423 | {
|
---|
424 | int cchPrefix;
|
---|
425 | if (!strncmp(pszTag, "RC", 2))
|
---|
426 | cchPrefix = 2;
|
---|
427 | else if (!strncmp(pszTag, "BETA", 4))
|
---|
428 | cchPrefix = 4;
|
---|
429 | else if (!strncmp(pszTag, "ALPHA", 5))
|
---|
430 | cchPrefix = 5;
|
---|
431 | else
|
---|
432 | return false;
|
---|
433 |
|
---|
434 | if (pszTag[cchPrefix] == '\0')
|
---|
435 | return true;
|
---|
436 |
|
---|
437 | uint8_t u8;
|
---|
438 | int rc = RTStrToUInt8Full(&pszTag[cchPrefix], 10, &u8);
|
---|
439 | return rc == VINF_SUCCESS;
|
---|
440 | }
|
---|
441 |
|
---|
442 | /**
|
---|
443 | * Handles VMMDevReq_ReportGuestInfo2.
|
---|
444 | *
|
---|
445 | * @returns VBox status code that the guest should see.
|
---|
446 | * @param pThis The VMMDev instance data.
|
---|
447 | * @param pRequestHeader The header of the request to handle.
|
---|
448 | */
|
---|
449 | static int vmmdevReqHandler_ReportGuestInfo2(VMMDevState *pThis, VMMDevRequestHeader *pRequestHeader)
|
---|
450 | {
|
---|
451 | AssertMsgReturn(pRequestHeader->size == sizeof(VMMDevReportGuestInfo2), ("%u\n", pRequestHeader->size), VERR_INVALID_PARAMETER);
|
---|
452 | VBoxGuestInfo2 const *pInfo2 = &((VMMDevReportGuestInfo2 *)pRequestHeader)->guestInfo;
|
---|
453 |
|
---|
454 | LogRel(("Guest Additions information report: Version %d.%d.%d r%d '%.*s'\n",
|
---|
455 | pInfo2->additionsMajor, pInfo2->additionsMinor, pInfo2->additionsBuild,
|
---|
456 | pInfo2->additionsRevision, sizeof(pInfo2->szName), pInfo2->szName));
|
---|
457 |
|
---|
458 | /* The interface was introduced in 3.2 and will definitely not be
|
---|
459 | backported beyond 3.0 (bird). */
|
---|
460 | AssertMsgReturn(pInfo2->additionsMajor >= 3,
|
---|
461 | ("%u.%u.%u\n", pInfo2->additionsMajor, pInfo2->additionsMinor, pInfo2->additionsBuild),
|
---|
462 | VERR_INVALID_PARAMETER);
|
---|
463 |
|
---|
464 | /* The version must fit in a full version compression. */
|
---|
465 | uint32_t uFullVersion = VBOX_FULL_VERSION_MAKE(pInfo2->additionsMajor, pInfo2->additionsMinor, pInfo2->additionsBuild);
|
---|
466 | AssertMsgReturn( VBOX_FULL_VERSION_GET_MAJOR(uFullVersion) == pInfo2->additionsMajor
|
---|
467 | && VBOX_FULL_VERSION_GET_MINOR(uFullVersion) == pInfo2->additionsMinor
|
---|
468 | && VBOX_FULL_VERSION_GET_BUILD(uFullVersion) == pInfo2->additionsBuild,
|
---|
469 | ("%u.%u.%u\n", pInfo2->additionsMajor, pInfo2->additionsMinor, pInfo2->additionsBuild),
|
---|
470 | VERR_OUT_OF_RANGE);
|
---|
471 |
|
---|
472 | /*
|
---|
473 | * Validate the name.
|
---|
474 | * Be less strict towards older additions (< v4.1.50).
|
---|
475 | */
|
---|
476 | AssertCompile(sizeof(pThis->guestInfo2.szName) == sizeof(pInfo2->szName));
|
---|
477 | AssertReturn(memchr(pInfo2->szName, '\0', sizeof(pInfo2->szName)) != NULL, VERR_INVALID_PARAMETER);
|
---|
478 | const char *pszName = pInfo2->szName;
|
---|
479 |
|
---|
480 | /* The version number which shouldn't be there. */
|
---|
481 | char szTmp[sizeof(pInfo2->szName)];
|
---|
482 | size_t cchStart = RTStrPrintf(szTmp, sizeof(szTmp), "%u.%u.%u", pInfo2->additionsMajor, pInfo2->additionsMinor, pInfo2->additionsBuild);
|
---|
483 | AssertMsgReturn(!strncmp(pszName, szTmp, cchStart), ("%s != %s\n", pszName, szTmp), VERR_INVALID_PARAMETER);
|
---|
484 | pszName += cchStart;
|
---|
485 |
|
---|
486 | /* Now we can either have nothing or a build tag or/and a publisher tag. */
|
---|
487 | if (*pszName != '\0')
|
---|
488 | {
|
---|
489 | const char *pszRelaxedName = "";
|
---|
490 | bool const fStrict = pInfo2->additionsMajor > 4
|
---|
491 | || (pInfo2->additionsMajor == 4 && pInfo2->additionsMinor > 1)
|
---|
492 | || (pInfo2->additionsMajor == 4 && pInfo2->additionsMinor == 1 && pInfo2->additionsBuild >= 50);
|
---|
493 | bool fOk = false;
|
---|
494 | if (*pszName == '_')
|
---|
495 | {
|
---|
496 | pszName++;
|
---|
497 | strcpy(szTmp, pszName);
|
---|
498 | char *pszTag2 = strchr(szTmp, '_');
|
---|
499 | if (!pszTag2)
|
---|
500 | {
|
---|
501 | fOk = vmmdevReqIsValidBuildTag(szTmp)
|
---|
502 | || vmmdevReqIsValidPublisherTag(szTmp);
|
---|
503 | }
|
---|
504 | else
|
---|
505 | {
|
---|
506 | *pszTag2++ = '\0';
|
---|
507 | fOk = vmmdevReqIsValidBuildTag(szTmp);
|
---|
508 | if (fOk)
|
---|
509 | {
|
---|
510 | fOk = vmmdevReqIsValidPublisherTag(pszTag2);
|
---|
511 | if (!fOk)
|
---|
512 | pszRelaxedName = szTmp;
|
---|
513 | }
|
---|
514 | }
|
---|
515 | }
|
---|
516 |
|
---|
517 | if (!fOk)
|
---|
518 | {
|
---|
519 | AssertLogRelMsgReturn(!fStrict, ("%s", pszName), VERR_INVALID_PARAMETER);
|
---|
520 |
|
---|
521 | /* non-strict mode, just zap the extra stuff. */
|
---|
522 | LogRel(("ReportGuestInfo2: Ignoring unparsable version name bits: '%s' -> '%s'.\n", pszName, pszRelaxedName));
|
---|
523 | pszName = pszRelaxedName;
|
---|
524 | }
|
---|
525 | }
|
---|
526 |
|
---|
527 | /*
|
---|
528 | * Save the info and tell Main or whoever is listening.
|
---|
529 | */
|
---|
530 | pThis->guestInfo2.uFullVersion = uFullVersion;
|
---|
531 | pThis->guestInfo2.uRevision = pInfo2->additionsRevision;
|
---|
532 | pThis->guestInfo2.fFeatures = pInfo2->additionsFeatures;
|
---|
533 | strcpy(pThis->guestInfo2.szName, pszName);
|
---|
534 |
|
---|
535 | if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestInfo2)
|
---|
536 | pThis->pDrv->pfnUpdateGuestInfo2(pThis->pDrv, uFullVersion, pszName, pInfo2->additionsRevision, pInfo2->additionsFeatures);
|
---|
537 |
|
---|
538 | /* Clear our IRQ in case it was high for whatever reason. */
|
---|
539 | PDMDevHlpPCISetIrqNoWait (pThis->pDevIns, 0, 0);
|
---|
540 |
|
---|
541 | return VINF_SUCCESS;
|
---|
542 | }
|
---|
543 |
|
---|
544 | /**
|
---|
545 | * Allocates a new facility status entry, initializing it to inactive.
|
---|
546 | *
|
---|
547 | * @returns Pointer to a facility status entry on success, NULL on failure
|
---|
548 | * (table full).
|
---|
549 | * @param pThis The VMMDev instance data.
|
---|
550 | * @param uFacility The facility type code - VBoxGuestFacilityType.
|
---|
551 | * @param fFixed This is set when allocating the standard entries
|
---|
552 | * from the constructor.
|
---|
553 | * @param pTimeSpecNow Optionally giving the entry timestamp to use (ctor).
|
---|
554 | */
|
---|
555 | static PVMMDEVFACILITYSTATUSENTRY
|
---|
556 | vmmdevAllocFacilityStatusEntry(VMMDevState *pThis, uint32_t uFacility, bool fFixed, PCRTTIMESPEC pTimeSpecNow)
|
---|
557 | {
|
---|
558 | /* If full, expunge one inactive entry. */
|
---|
559 | if (pThis->cFacilityStatuses == RT_ELEMENTS(pThis->aFacilityStatuses))
|
---|
560 | {
|
---|
561 | uint32_t i = pThis->cFacilityStatuses;
|
---|
562 | while (i-- > 0)
|
---|
563 | {
|
---|
564 | if ( pThis->aFacilityStatuses[i].uStatus == VBoxGuestFacilityStatus_Inactive
|
---|
565 | && !pThis->aFacilityStatuses[i].fFixed)
|
---|
566 | {
|
---|
567 | pThis->cFacilityStatuses--;
|
---|
568 | int cToMove = pThis->cFacilityStatuses - i;
|
---|
569 | if (cToMove)
|
---|
570 | memmove(&pThis->aFacilityStatuses[i], &pThis->aFacilityStatuses[i + 1],
|
---|
571 | cToMove * sizeof(pThis->aFacilityStatuses[i]));
|
---|
572 | RT_ZERO(pThis->aFacilityStatuses[pThis->cFacilityStatuses]);
|
---|
573 | break;
|
---|
574 | }
|
---|
575 | }
|
---|
576 |
|
---|
577 | if (pThis->cFacilityStatuses == RT_ELEMENTS(pThis->aFacilityStatuses))
|
---|
578 | return NULL;
|
---|
579 | }
|
---|
580 |
|
---|
581 | /* Find location in array (it's sorted). */
|
---|
582 | uint32_t i = pThis->cFacilityStatuses;
|
---|
583 | while (i-- > 0)
|
---|
584 | if (pThis->aFacilityStatuses[i].uFacility < uFacility)
|
---|
585 | break;
|
---|
586 | i++;
|
---|
587 |
|
---|
588 | /* Move. */
|
---|
589 | int cToMove = pThis->cFacilityStatuses - i;
|
---|
590 | if (cToMove > 0)
|
---|
591 | memmove(&pThis->aFacilityStatuses[i + 1], &pThis->aFacilityStatuses[i],
|
---|
592 | cToMove * sizeof(pThis->aFacilityStatuses[i]));
|
---|
593 | pThis->cFacilityStatuses++;
|
---|
594 |
|
---|
595 | /* Initialize. */
|
---|
596 | pThis->aFacilityStatuses[i].uFacility = uFacility;
|
---|
597 | pThis->aFacilityStatuses[i].uStatus = VBoxGuestFacilityStatus_Inactive;
|
---|
598 | pThis->aFacilityStatuses[i].fFixed = fFixed;
|
---|
599 | pThis->aFacilityStatuses[i].fPadding = 0;
|
---|
600 | pThis->aFacilityStatuses[i].fFlags = 0;
|
---|
601 | pThis->aFacilityStatuses[i].uPadding = 0;
|
---|
602 | if (pTimeSpecNow)
|
---|
603 | pThis->aFacilityStatuses[i].TimeSpecTS = *pTimeSpecNow;
|
---|
604 | else
|
---|
605 | RTTimeSpecSetNano(&pThis->aFacilityStatuses[i].TimeSpecTS, 0);
|
---|
606 |
|
---|
607 | return &pThis->aFacilityStatuses[i];
|
---|
608 |
|
---|
609 | }
|
---|
610 |
|
---|
611 | /**
|
---|
612 | * Gets a facility status entry, allocating a new one if not already present.
|
---|
613 | *
|
---|
614 | * @returns Pointer to a facility status entry on success, NULL on failure
|
---|
615 | * (table full).
|
---|
616 | * @param pThis The VMMDev instance data.
|
---|
617 | * @param uFacility The facility type code - VBoxGuestFacilityType.
|
---|
618 | */
|
---|
619 | static PVMMDEVFACILITYSTATUSENTRY vmmdevGetFacilityStatusEntry(VMMDevState *pThis, uint32_t uFacility)
|
---|
620 | {
|
---|
621 | /** @todo change to binary search. */
|
---|
622 | uint32_t i = pThis->cFacilityStatuses;
|
---|
623 | while (i-- > 0)
|
---|
624 | {
|
---|
625 | if (pThis->aFacilityStatuses[i].uFacility == uFacility)
|
---|
626 | return &pThis->aFacilityStatuses[i];
|
---|
627 | if (pThis->aFacilityStatuses[i].uFacility < uFacility)
|
---|
628 | break;
|
---|
629 | }
|
---|
630 | return vmmdevAllocFacilityStatusEntry(pThis, uFacility, false /*fFixed*/, NULL);
|
---|
631 | }
|
---|
632 |
|
---|
633 | /**
|
---|
634 | * Handles VMMDevReq_ReportGuestStatus.
|
---|
635 | *
|
---|
636 | * @returns VBox status code that the guest should see.
|
---|
637 | * @param pThis The VMMDev instance data.
|
---|
638 | * @param pRequestHeader The header of the request to handle.
|
---|
639 | */
|
---|
640 | static int vmmdevReqHandler_ReportGuestStatus(VMMDevState *pThis, VMMDevRequestHeader *pRequestHeader)
|
---|
641 | {
|
---|
642 | /*
|
---|
643 | * Validate input.
|
---|
644 | */
|
---|
645 | AssertMsgReturn(pRequestHeader->size == sizeof(VMMDevReportGuestStatus), ("%u\n", pRequestHeader->size), VERR_INVALID_PARAMETER);
|
---|
646 | VBoxGuestStatus *pStatus = &((VMMDevReportGuestStatus *)pRequestHeader)->guestStatus;
|
---|
647 | AssertMsgReturn( pStatus->facility > VBoxGuestFacilityType_Unknown
|
---|
648 | && pStatus->facility <= VBoxGuestFacilityType_All,
|
---|
649 | ("%d\n", pStatus->facility),
|
---|
650 | VERR_INVALID_PARAMETER);
|
---|
651 | AssertMsgReturn(pStatus->status == (VBoxGuestFacilityStatus)(uint16_t)pStatus->status,
|
---|
652 | ("%#x (%u)\n", pStatus->status, pStatus->status),
|
---|
653 | VERR_OUT_OF_RANGE);
|
---|
654 |
|
---|
655 | /*
|
---|
656 | * Do the update.
|
---|
657 | */
|
---|
658 | RTTIMESPEC Now;
|
---|
659 | RTTimeNow(&Now);
|
---|
660 | if (pStatus->facility == VBoxGuestFacilityType_All)
|
---|
661 | {
|
---|
662 | uint32_t i = pThis->cFacilityStatuses;
|
---|
663 | while (i-- > 0)
|
---|
664 | {
|
---|
665 | pThis->aFacilityStatuses[i].TimeSpecTS = Now;
|
---|
666 | pThis->aFacilityStatuses[i].uStatus = (uint16_t)pStatus->status;
|
---|
667 | pThis->aFacilityStatuses[i].fFlags = pStatus->flags;
|
---|
668 | }
|
---|
669 | }
|
---|
670 | else
|
---|
671 | {
|
---|
672 | PVMMDEVFACILITYSTATUSENTRY pEntry = vmmdevGetFacilityStatusEntry(pThis, pStatus->facility);
|
---|
673 | if (!pEntry)
|
---|
674 | {
|
---|
675 | static int g_cLogEntries = 0;
|
---|
676 | if (g_cLogEntries++ < 10)
|
---|
677 | LogRel(("VMM: Facility table is full - facility=%u status=%u.\n", pStatus->facility, pStatus->status));
|
---|
678 | return VERR_OUT_OF_RESOURCES;
|
---|
679 | }
|
---|
680 |
|
---|
681 | pEntry->TimeSpecTS = Now;
|
---|
682 | pEntry->uStatus = (uint16_t)pStatus->status;
|
---|
683 | pEntry->fFlags = pStatus->flags;
|
---|
684 | }
|
---|
685 |
|
---|
686 | if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestStatus)
|
---|
687 | pThis->pDrv->pfnUpdateGuestStatus(pThis->pDrv, pStatus->facility, pStatus->status, pStatus->flags, &Now);
|
---|
688 |
|
---|
689 | return VINF_SUCCESS;
|
---|
690 | }
|
---|
691 |
|
---|
692 | #ifdef VBOX_WITH_PAGE_SHARING
|
---|
693 |
|
---|
694 | /**
|
---|
695 | * Handles VMMDevReq_RegisterSharedModule.
|
---|
696 | *
|
---|
697 | * @returns VBox status code that the guest should see.
|
---|
698 | * @param pDevIns The VMMDev device instance.
|
---|
699 | * @param pReq Pointer to the request.
|
---|
700 | */
|
---|
701 | static int vmmdevReqHandler_RegisterSharedModule(PPDMDEVINS pDevIns, VMMDevSharedModuleRegistrationRequest *pReq)
|
---|
702 | {
|
---|
703 | /*
|
---|
704 | * Basic input validation (more done by GMM).
|
---|
705 | */
|
---|
706 | AssertMsgReturn(pReq->header.size >= sizeof(VMMDevSharedModuleRegistrationRequest),
|
---|
707 | ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
708 | AssertMsgReturn(pReq->header.size == RT_UOFFSETOF(VMMDevSharedModuleRegistrationRequest, aRegions[pReq->cRegions]),
|
---|
709 | ("%u cRegions=%u\n", pReq->header.size, pReq->cRegions), VERR_INVALID_PARAMETER);
|
---|
710 |
|
---|
711 | AssertReturn(memchr(pReq->szName, '\0', sizeof(pReq->szName)), VERR_INVALID_PARAMETER);
|
---|
712 | AssertReturn(memchr(pReq->szVersion, '\0', sizeof(pReq->szVersion)), VERR_INVALID_PARAMETER);
|
---|
713 |
|
---|
714 | /*
|
---|
715 | * Forward the request to the VMM.
|
---|
716 | */
|
---|
717 | return PGMR3SharedModuleRegister(PDMDevHlpGetVM(pDevIns), pReq->enmGuestOS, pReq->szName, pReq->szVersion,
|
---|
718 | pReq->GCBaseAddr, pReq->cbModule, pReq->cRegions, pReq->aRegions);
|
---|
719 | }
|
---|
720 |
|
---|
721 | /**
|
---|
722 | * Handles VMMDevReq_UnregisterSharedModule.
|
---|
723 | *
|
---|
724 | * @returns VBox status code that the guest should see.
|
---|
725 | * @param pDevIns The VMMDev device instance.
|
---|
726 | * @param pReq Pointer to the request.
|
---|
727 | */
|
---|
728 | static int vmmdevReqHandler_UnregisterSharedModule(PPDMDEVINS pDevIns, VMMDevSharedModuleUnregistrationRequest *pReq)
|
---|
729 | {
|
---|
730 | /*
|
---|
731 | * Basic input validation.
|
---|
732 | */
|
---|
733 | AssertMsgReturn(pReq->header.size == sizeof(VMMDevSharedModuleUnregistrationRequest),
|
---|
734 | ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
735 |
|
---|
736 | AssertReturn(memchr(pReq->szName, '\0', sizeof(pReq->szName)), VERR_INVALID_PARAMETER);
|
---|
737 | AssertReturn(memchr(pReq->szVersion, '\0', sizeof(pReq->szVersion)), VERR_INVALID_PARAMETER);
|
---|
738 |
|
---|
739 | /*
|
---|
740 | * Forward the request to the VMM.
|
---|
741 | */
|
---|
742 | return PGMR3SharedModuleUnregister(PDMDevHlpGetVM(pDevIns), pReq->szName, pReq->szVersion,
|
---|
743 | pReq->GCBaseAddr, pReq->cbModule);
|
---|
744 | }
|
---|
745 |
|
---|
746 | /**
|
---|
747 | * Handles VMMDevReq_CheckSharedModules.
|
---|
748 | *
|
---|
749 | * @returns VBox status code that the guest should see.
|
---|
750 | * @param pDevIns The VMMDev device instance.
|
---|
751 | * @param pReq Pointer to the request.
|
---|
752 | */
|
---|
753 | static int vmmdevReqHandler_CheckSharedModules(PPDMDEVINS pDevIns, VMMDevSharedModuleCheckRequest *pReq)
|
---|
754 | {
|
---|
755 | AssertMsgReturn(pReq->header.size == sizeof(VMMDevSharedModuleCheckRequest),
|
---|
756 | ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
757 | return PGMR3SharedModuleCheckAll(PDMDevHlpGetVM(pDevIns));
|
---|
758 | }
|
---|
759 |
|
---|
760 | /**
|
---|
761 | * Handles VMMDevReq_GetPageSharingStatus.
|
---|
762 | *
|
---|
763 | * @returns VBox status code that the guest should see.
|
---|
764 | * @param pThis The VMMDev instance data.
|
---|
765 | * @param pReq Pointer to the request.
|
---|
766 | */
|
---|
767 | static int vmmdevReqHandler_GetPageSharingStatus(VMMDevState *pThis, VMMDevPageSharingStatusRequest *pReq)
|
---|
768 | {
|
---|
769 | AssertMsgReturn(pReq->header.size == sizeof(VMMDevPageSharingStatusRequest),
|
---|
770 | ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
771 |
|
---|
772 | pReq->fEnabled = false;
|
---|
773 | int rc = pThis->pDrv->pfnIsPageFusionEnabled(pThis->pDrv, &pReq->fEnabled);
|
---|
774 | if (RT_FAILURE(rc))
|
---|
775 | pReq->fEnabled = false;
|
---|
776 | return VINF_SUCCESS;
|
---|
777 | }
|
---|
778 |
|
---|
779 |
|
---|
780 | /**
|
---|
781 | * Handles VMMDevReq_DebugIsPageShared.
|
---|
782 | *
|
---|
783 | * @returns VBox status code that the guest should see.
|
---|
784 | * @param pDevIns The VMMDev device instance.
|
---|
785 | * @param pReq Pointer to the request.
|
---|
786 | */
|
---|
787 | static int vmmdevReqHandler_DebugIsPageShared(PPDMDEVINS pDevIns, VMMDevPageIsSharedRequest *pReq)
|
---|
788 | {
|
---|
789 | AssertMsgReturn(pReq->header.size == sizeof(VMMDevPageIsSharedRequest),
|
---|
790 | ("%u\n", pReq->header.size), VERR_INVALID_PARAMETER);
|
---|
791 |
|
---|
792 | #ifdef DEBUG
|
---|
793 | return PGMR3SharedModuleGetPageState(PDMDevHlpGetVM(pDevIns), pReq->GCPtrPage, &pReq->fShared, &pReq->uPageFlags);
|
---|
794 | #else
|
---|
795 | return VERR_NOT_IMPLEMENTED;
|
---|
796 | #endif
|
---|
797 | }
|
---|
798 |
|
---|
799 | #endif /* VBOX_WITH_PAGE_SHARING */
|
---|
800 |
|
---|
801 | /**
|
---|
802 | * Port I/O Handler for the generic request interface
|
---|
803 | * @see FNIOMIOPORTOUT for details.
|
---|
804 | *
|
---|
805 | * @todo This function is too long!! All new request SHALL be implemented as
|
---|
806 | * functions called from the switch! When making changes, please move the
|
---|
807 | * relevant cases into functions.
|
---|
808 | */
|
---|
809 | static DECLCALLBACK(int) vmmdevRequestHandler(PPDMDEVINS pDevIns, void *pvUser, RTIOPORT Port, uint32_t u32, unsigned cb)
|
---|
810 | {
|
---|
811 | VMMDevState *pThis = (VMMDevState*)pvUser;
|
---|
812 | int rcRet = VINF_SUCCESS;
|
---|
813 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
814 |
|
---|
815 | /*
|
---|
816 | * The caller has passed the guest context physical address
|
---|
817 | * of the request structure. Copy the request packet.
|
---|
818 | */
|
---|
819 | VMMDevRequestHeader *pRequestHeader = NULL;
|
---|
820 | VMMDevRequestHeader requestHeader;
|
---|
821 | RT_ZERO(requestHeader);
|
---|
822 |
|
---|
823 | PDMDevHlpPhysRead(pDevIns, (RTGCPHYS)u32, &requestHeader, sizeof(requestHeader));
|
---|
824 |
|
---|
825 | /* the structure size must be greater or equal to the header size */
|
---|
826 | if (requestHeader.size < sizeof(VMMDevRequestHeader))
|
---|
827 | {
|
---|
828 | Log(("VMMDev request header size too small! size = %d\n", requestHeader.size));
|
---|
829 | rcRet = VINF_SUCCESS;
|
---|
830 | goto l_end; /** @todo shouldn't (/ no need to) write back.*/
|
---|
831 | }
|
---|
832 |
|
---|
833 | /* check the version of the header structure */
|
---|
834 | if (requestHeader.version != VMMDEV_REQUEST_HEADER_VERSION)
|
---|
835 | {
|
---|
836 | Log(("VMMDev: guest header version (0x%08X) differs from ours (0x%08X)\n", requestHeader.version, VMMDEV_REQUEST_HEADER_VERSION));
|
---|
837 | rcRet = VINF_SUCCESS;
|
---|
838 | goto l_end; /** @todo shouldn't (/ no need to) write back.*/
|
---|
839 | }
|
---|
840 |
|
---|
841 | Log2(("VMMDev request issued: %d\n", requestHeader.requestType));
|
---|
842 |
|
---|
843 | /* Newer additions starts with VMMDevReq_ReportGuestInfo2, older additions
|
---|
844 | started with VMMDevReq_ReportGuestInfo. */
|
---|
845 | if ( !pThis->fu32AdditionsOk
|
---|
846 | && requestHeader.requestType != VMMDevReq_ReportGuestInfo2
|
---|
847 | && requestHeader.requestType != VMMDevReq_ReportGuestInfo
|
---|
848 | && requestHeader.requestType != VMMDevReq_WriteCoreDump
|
---|
849 | && requestHeader.requestType != VMMDevReq_GetHostVersion) /* Always allow the guest to query the host capabilities. */
|
---|
850 | {
|
---|
851 | Log(("VMMDev: guest has not yet reported to us. Refusing operation of request #%d!\n",
|
---|
852 | requestHeader.requestType));
|
---|
853 | requestHeader.rc = VERR_NOT_SUPPORTED;
|
---|
854 | static int cRelWarn;
|
---|
855 | if (cRelWarn < 10)
|
---|
856 | {
|
---|
857 | cRelWarn++;
|
---|
858 | LogRel(("VMMDev: the guest has not yet reported to us -- refusing operation of request #%d\n",
|
---|
859 | requestHeader.requestType));
|
---|
860 | }
|
---|
861 | rcRet = VINF_SUCCESS;
|
---|
862 | goto l_end;
|
---|
863 | }
|
---|
864 |
|
---|
865 | /* Check upper limit */
|
---|
866 | if (requestHeader.size > VMMDEV_MAX_VMMDEVREQ_SIZE)
|
---|
867 | {
|
---|
868 | static int cRelWarn;
|
---|
869 | if (cRelWarn < 50)
|
---|
870 | {
|
---|
871 | cRelWarn++;
|
---|
872 | LogRel(("VMMDev: request packet too big (%x). Refusing operation.\n", requestHeader.size));
|
---|
873 | }
|
---|
874 | requestHeader.rc = VERR_NOT_SUPPORTED;
|
---|
875 | rcRet = VINF_SUCCESS;
|
---|
876 | goto l_end;
|
---|
877 | }
|
---|
878 |
|
---|
879 | /* Read the entire request packet */
|
---|
880 | pRequestHeader = (VMMDevRequestHeader *)RTMemAlloc(requestHeader.size);
|
---|
881 | if (!pRequestHeader)
|
---|
882 | {
|
---|
883 | Log(("VMMDev: RTMemAlloc failed!\n"));
|
---|
884 | rcRet = VINF_SUCCESS;
|
---|
885 | requestHeader.rc = VERR_NO_MEMORY;
|
---|
886 | goto l_end;
|
---|
887 | }
|
---|
888 | PDMDevHlpPhysRead(pDevIns, (RTGCPHYS)u32, pRequestHeader, requestHeader.size);
|
---|
889 |
|
---|
890 | /* which request was sent? */
|
---|
891 | switch (pRequestHeader->requestType)
|
---|
892 | {
|
---|
893 | /*
|
---|
894 | * Guest wants to give up a timeslice
|
---|
895 | */
|
---|
896 | case VMMDevReq_Idle:
|
---|
897 | {
|
---|
898 | /* just return to EMT telling it that we want to halt */
|
---|
899 | rcRet = VINF_EM_HALT;
|
---|
900 | break;
|
---|
901 | }
|
---|
902 |
|
---|
903 | /*
|
---|
904 | * Guest is reporting its information
|
---|
905 | */
|
---|
906 | case VMMDevReq_ReportGuestInfo:
|
---|
907 | {
|
---|
908 | AssertMsgBreakStmt(pRequestHeader->size == sizeof(VMMDevReportGuestInfo), ("%u\n", pRequestHeader->size),
|
---|
909 | pRequestHeader->rc = VERR_INVALID_PARAMETER);
|
---|
910 | VBoxGuestInfo *pGuestInfo = &((VMMDevReportGuestInfo*)pRequestHeader)->guestInfo;
|
---|
911 |
|
---|
912 | if (memcmp(&pThis->guestInfo, pGuestInfo, sizeof(*pGuestInfo)) != 0)
|
---|
913 | {
|
---|
914 | /* make a copy of supplied information */
|
---|
915 | pThis->guestInfo = *pGuestInfo;
|
---|
916 |
|
---|
917 | /* Check additions version */
|
---|
918 | pThis->fu32AdditionsOk = VBOX_GUEST_INTERFACE_VERSION_OK(pThis->guestInfo.interfaceVersion);
|
---|
919 |
|
---|
920 | LogRel(("Guest Additions information report: Interface = 0x%08X osType = 0x%08X\n",
|
---|
921 | pThis->guestInfo.interfaceVersion,
|
---|
922 | pThis->guestInfo.osType));
|
---|
923 | if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestInfo)
|
---|
924 | pThis->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);
|
---|
925 | }
|
---|
926 |
|
---|
927 | if (pThis->fu32AdditionsOk)
|
---|
928 | {
|
---|
929 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
930 | /* Clear our IRQ in case it was high for whatever reason. */
|
---|
931 | PDMDevHlpPCISetIrqNoWait (pThis->pDevIns, 0, 0);
|
---|
932 | }
|
---|
933 | else
|
---|
934 | pRequestHeader->rc = VERR_VERSION_MISMATCH;
|
---|
935 | break;
|
---|
936 | }
|
---|
937 |
|
---|
938 | case VMMDevReq_ReportGuestInfo2:
|
---|
939 | {
|
---|
940 | pRequestHeader->rc = vmmdevReqHandler_ReportGuestInfo2(pThis, pRequestHeader);
|
---|
941 | break;
|
---|
942 | }
|
---|
943 |
|
---|
944 | case VMMDevReq_WriteCoreDump:
|
---|
945 | {
|
---|
946 | if (pRequestHeader->size != sizeof(VMMDevReqWriteCoreDump))
|
---|
947 | {
|
---|
948 | AssertMsgFailed(("VMMDev WriteCoreDump structure has an invalid size!\n"));
|
---|
949 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
950 | }
|
---|
951 | else
|
---|
952 | {
|
---|
953 | if (pThis->fGuestCoreDumpEnabled)
|
---|
954 | {
|
---|
955 | /*
|
---|
956 | * User makes sure the directory exists.
|
---|
957 | */
|
---|
958 | if (!RTDirExists(pThis->szGuestCoreDumpDir))
|
---|
959 | return VERR_PATH_NOT_FOUND;
|
---|
960 |
|
---|
961 | char szCorePath[RTPATH_MAX];
|
---|
962 | RTStrCopy(szCorePath, sizeof(szCorePath), pThis->szGuestCoreDumpDir);
|
---|
963 | RTPathAppend(szCorePath, sizeof(szCorePath), "VBox.core");
|
---|
964 |
|
---|
965 | /*
|
---|
966 | * Rotate existing cores based on number of additional cores to keep around.
|
---|
967 | */
|
---|
968 | if (pThis->cGuestCoreDumps > 0)
|
---|
969 | for (int64_t i = pThis->cGuestCoreDumps - 1; i >= 0; i--)
|
---|
970 | {
|
---|
971 | char szFilePathOld[RTPATH_MAX];
|
---|
972 | if (i == 0)
|
---|
973 | RTStrCopy(szFilePathOld, sizeof(szFilePathOld), szCorePath);
|
---|
974 | else
|
---|
975 | RTStrPrintf(szFilePathOld, sizeof(szFilePathOld), "%s.%lld", szCorePath, i);
|
---|
976 |
|
---|
977 | char szFilePathNew[RTPATH_MAX];
|
---|
978 | RTStrPrintf(szFilePathNew, sizeof(szFilePathNew), "%s.%lld", szCorePath, i + 1);
|
---|
979 | int vrc = RTFileMove(szFilePathOld, szFilePathNew, RTFILEMOVE_FLAGS_REPLACE);
|
---|
980 | if (vrc == VERR_FILE_NOT_FOUND)
|
---|
981 | RTFileDelete(szFilePathNew);
|
---|
982 | }
|
---|
983 |
|
---|
984 | /*
|
---|
985 | * Write the core file.
|
---|
986 | */
|
---|
987 | PUVM pUVM = PDMDevHlpGetUVM(pDevIns);
|
---|
988 | pRequestHeader->rc = DBGFR3CoreWrite(pUVM, szCorePath, true /*fReplaceFile*/);
|
---|
989 | }
|
---|
990 | else
|
---|
991 | pRequestHeader->rc = VERR_ACCESS_DENIED;
|
---|
992 | }
|
---|
993 | break;
|
---|
994 | }
|
---|
995 |
|
---|
996 | case VMMDevReq_ReportGuestStatus:
|
---|
997 | pRequestHeader->rc = vmmdevReqHandler_ReportGuestStatus(pThis, pRequestHeader);
|
---|
998 | break;
|
---|
999 |
|
---|
1000 | /* Report guest capabilities */
|
---|
1001 | case VMMDevReq_ReportGuestCapabilities:
|
---|
1002 | {
|
---|
1003 | if (pRequestHeader->size != sizeof(VMMDevReqGuestCapabilities))
|
---|
1004 | {
|
---|
1005 | AssertMsgFailed(("VMMDev guest caps structure has invalid size!\n"));
|
---|
1006 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1007 | }
|
---|
1008 | else
|
---|
1009 | {
|
---|
1010 | VMMDevReqGuestCapabilities *guestCaps = (VMMDevReqGuestCapabilities*)pRequestHeader;
|
---|
1011 |
|
---|
1012 | /* Enable this automatically for guests using the old
|
---|
1013 | request to report their capabilities. */
|
---|
1014 | /** @todo change this when we next bump the interface version */
|
---|
1015 | guestCaps->caps |= VMMDEV_GUEST_SUPPORTS_GRAPHICS;
|
---|
1016 | if (pThis->guestCaps != guestCaps->caps)
|
---|
1017 | {
|
---|
1018 | /* make a copy of supplied information */
|
---|
1019 | pThis->guestCaps = guestCaps->caps;
|
---|
1020 |
|
---|
1021 | LogRel(("Guest Additions capability report: (0x%x) "
|
---|
1022 | "seamless: %s, "
|
---|
1023 | "hostWindowMapping: %s, "
|
---|
1024 | "graphics: %s\n",
|
---|
1025 | guestCaps->caps,
|
---|
1026 | guestCaps->caps & VMMDEV_GUEST_SUPPORTS_SEAMLESS ? "yes" : "no",
|
---|
1027 | guestCaps->caps & VMMDEV_GUEST_SUPPORTS_GUEST_HOST_WINDOW_MAPPING ? "yes" : "no",
|
---|
1028 | guestCaps->caps & VMMDEV_GUEST_SUPPORTS_GRAPHICS ? "yes" : "no"));
|
---|
1029 |
|
---|
1030 | if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestCapabilities)
|
---|
1031 | pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, guestCaps->caps);
|
---|
1032 | }
|
---|
1033 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1034 | }
|
---|
1035 | break;
|
---|
1036 | }
|
---|
1037 |
|
---|
1038 | /* Change guest capabilities */
|
---|
1039 | case VMMDevReq_SetGuestCapabilities:
|
---|
1040 | {
|
---|
1041 | if (pRequestHeader->size != sizeof(VMMDevReqGuestCapabilities2))
|
---|
1042 | {
|
---|
1043 | AssertMsgFailed(("VMMDev guest caps structure has invalid size!\n"));
|
---|
1044 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1045 | }
|
---|
1046 | else
|
---|
1047 | {
|
---|
1048 | VMMDevReqGuestCapabilities2 *guestCaps = (VMMDevReqGuestCapabilities2*)pRequestHeader;
|
---|
1049 |
|
---|
1050 | pThis->guestCaps |= guestCaps->u32OrMask;
|
---|
1051 | pThis->guestCaps &= ~guestCaps->u32NotMask;
|
---|
1052 |
|
---|
1053 | LogRel(("Guest Additions capability report: (0x%x) "
|
---|
1054 | "seamless: %s, "
|
---|
1055 | "hostWindowMapping: %s, "
|
---|
1056 | "graphics: %s\n",
|
---|
1057 | pThis->guestCaps,
|
---|
1058 | pThis->guestCaps & VMMDEV_GUEST_SUPPORTS_SEAMLESS ? "yes" : "no",
|
---|
1059 | pThis->guestCaps & VMMDEV_GUEST_SUPPORTS_GUEST_HOST_WINDOW_MAPPING ? "yes" : "no",
|
---|
1060 | pThis->guestCaps & VMMDEV_GUEST_SUPPORTS_GRAPHICS ? "yes" : "no"));
|
---|
1061 |
|
---|
1062 | if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestCapabilities)
|
---|
1063 | pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, pThis->guestCaps);
|
---|
1064 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1065 | }
|
---|
1066 | break;
|
---|
1067 | }
|
---|
1068 |
|
---|
1069 | /*
|
---|
1070 | * Retrieve mouse information
|
---|
1071 | */
|
---|
1072 | case VMMDevReq_GetMouseStatus:
|
---|
1073 | {
|
---|
1074 | if (pRequestHeader->size != sizeof(VMMDevReqMouseStatus))
|
---|
1075 | {
|
---|
1076 | AssertMsgFailed(("VMMDev mouse status structure has invalid size!\n"));
|
---|
1077 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1078 | }
|
---|
1079 | else
|
---|
1080 | {
|
---|
1081 | VMMDevReqMouseStatus *mouseStatus = (VMMDevReqMouseStatus*)pRequestHeader;
|
---|
1082 | mouseStatus->mouseFeatures = pThis->mouseCapabilities
|
---|
1083 | & VMMDEV_MOUSE_MASK;
|
---|
1084 | mouseStatus->pointerXPos = pThis->mouseXAbs;
|
---|
1085 | mouseStatus->pointerYPos = pThis->mouseYAbs;
|
---|
1086 | LogRel2(("%s: VMMDevReq_GetMouseStatus: features = 0x%x, absX = %d, absY = %d\n",
|
---|
1087 | __PRETTY_FUNCTION__,
|
---|
1088 | mouseStatus->mouseFeatures,
|
---|
1089 | mouseStatus->pointerXPos,
|
---|
1090 | mouseStatus->pointerYPos));
|
---|
1091 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1092 | }
|
---|
1093 | break;
|
---|
1094 | }
|
---|
1095 |
|
---|
1096 | /*
|
---|
1097 | * Set mouse information
|
---|
1098 | */
|
---|
1099 | case VMMDevReq_SetMouseStatus:
|
---|
1100 | {
|
---|
1101 | if (pRequestHeader->size != sizeof(VMMDevReqMouseStatus))
|
---|
1102 | {
|
---|
1103 | AssertMsgFailed(("VMMDev mouse status structure has invalid size %d (%#x) version=%d!\n",
|
---|
1104 | pRequestHeader->size, pRequestHeader->size, pRequestHeader->size, pRequestHeader->version));
|
---|
1105 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1106 | }
|
---|
1107 | else
|
---|
1108 | {
|
---|
1109 | bool fNotify = false;
|
---|
1110 |
|
---|
1111 | uint32_t fFeatures =
|
---|
1112 | ((VMMDevReqMouseStatus*)pRequestHeader)->mouseFeatures;
|
---|
1113 |
|
---|
1114 | LogRelFlowFunc(("VMMDevReqMouseStatus: mouseFeatures = 0x%x\n",
|
---|
1115 | fFeatures));
|
---|
1116 |
|
---|
1117 | if ( (fFeatures & VMMDEV_MOUSE_NOTIFY_HOST_MASK)
|
---|
1118 | != ( pThis->mouseCapabilities
|
---|
1119 | & VMMDEV_MOUSE_NOTIFY_HOST_MASK))
|
---|
1120 | fNotify = true;
|
---|
1121 | pThis->mouseCapabilities &= ~VMMDEV_MOUSE_GUEST_MASK;
|
---|
1122 | pThis->mouseCapabilities |=
|
---|
1123 | (fFeatures & VMMDEV_MOUSE_GUEST_MASK);
|
---|
1124 | LogRelFlowFunc(("VMMDevReq_SetMouseStatus: new host capabilities: 0x%x\n",
|
---|
1125 | pThis->mouseCapabilities));
|
---|
1126 |
|
---|
1127 | /*
|
---|
1128 | * Notify connector if something has changed
|
---|
1129 | */
|
---|
1130 | if (fNotify)
|
---|
1131 | {
|
---|
1132 | LogRelFlowFunc(("VMMDevReq_SetMouseStatus: notifying connector\n"));
|
---|
1133 | pThis->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->mouseCapabilities);
|
---|
1134 | }
|
---|
1135 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1136 | }
|
---|
1137 |
|
---|
1138 | break;
|
---|
1139 | }
|
---|
1140 |
|
---|
1141 | /*
|
---|
1142 | * Set a new mouse pointer shape
|
---|
1143 | */
|
---|
1144 | case VMMDevReq_SetPointerShape:
|
---|
1145 | {
|
---|
1146 | if (pRequestHeader->size < sizeof(VMMDevReqMousePointer))
|
---|
1147 | {
|
---|
1148 | AssertMsg(pRequestHeader->size == 0x10028 && pRequestHeader->version == 10000, /* don't complain about legacy!!! */
|
---|
1149 | ("VMMDev mouse shape structure has invalid size %d (%#x) version=%d!\n",
|
---|
1150 | pRequestHeader->size, pRequestHeader->size, pRequestHeader->size, pRequestHeader->version));
|
---|
1151 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1152 | }
|
---|
1153 | else
|
---|
1154 | {
|
---|
1155 | VMMDevReqMousePointer *pointerShape = (VMMDevReqMousePointer*)pRequestHeader;
|
---|
1156 |
|
---|
1157 | bool fVisible = (pointerShape->fFlags & VBOX_MOUSE_POINTER_VISIBLE) != 0;
|
---|
1158 | bool fAlpha = (pointerShape->fFlags & VBOX_MOUSE_POINTER_ALPHA) != 0;
|
---|
1159 | bool fShape = (pointerShape->fFlags & VBOX_MOUSE_POINTER_SHAPE) != 0;
|
---|
1160 |
|
---|
1161 | Log(("VMMDevReq_SetPointerShape: visible: %d, alpha: %d, shape = %d, width: %d, height: %d\n",
|
---|
1162 | fVisible, fAlpha, fShape, pointerShape->width, pointerShape->height));
|
---|
1163 |
|
---|
1164 | if (pRequestHeader->size == sizeof(VMMDevReqMousePointer))
|
---|
1165 | {
|
---|
1166 | /* The guest did not provide the shape actually. */
|
---|
1167 | fShape = false;
|
---|
1168 | }
|
---|
1169 |
|
---|
1170 | /* forward call to driver */
|
---|
1171 | if (fShape)
|
---|
1172 | {
|
---|
1173 | pThis->pDrv->pfnUpdatePointerShape(pThis->pDrv,
|
---|
1174 | fVisible,
|
---|
1175 | fAlpha,
|
---|
1176 | pointerShape->xHot, pointerShape->yHot,
|
---|
1177 | pointerShape->width, pointerShape->height,
|
---|
1178 | pointerShape->pointerData);
|
---|
1179 | }
|
---|
1180 | else
|
---|
1181 | {
|
---|
1182 | pThis->pDrv->pfnUpdatePointerShape(pThis->pDrv,
|
---|
1183 | fVisible,
|
---|
1184 | 0,
|
---|
1185 | 0, 0,
|
---|
1186 | 0, 0,
|
---|
1187 | NULL);
|
---|
1188 | }
|
---|
1189 | pThis->fHostCursorRequested = fVisible;
|
---|
1190 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1191 | }
|
---|
1192 | break;
|
---|
1193 | }
|
---|
1194 |
|
---|
1195 | /*
|
---|
1196 | * Query the system time from the host
|
---|
1197 | */
|
---|
1198 | case VMMDevReq_GetHostTime:
|
---|
1199 | {
|
---|
1200 | if (pRequestHeader->size != sizeof(VMMDevReqHostTime))
|
---|
1201 | {
|
---|
1202 | AssertMsgFailed(("VMMDev host time structure has invalid size!\n"));
|
---|
1203 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1204 | }
|
---|
1205 | else if (RT_UNLIKELY(pThis->fGetHostTimeDisabled))
|
---|
1206 | pRequestHeader->rc = VERR_NOT_SUPPORTED;
|
---|
1207 | else
|
---|
1208 | {
|
---|
1209 | VMMDevReqHostTime *hostTimeReq = (VMMDevReqHostTime*)pRequestHeader;
|
---|
1210 | RTTIMESPEC now;
|
---|
1211 | hostTimeReq->time = RTTimeSpecGetMilli(PDMDevHlpTMUtcNow(pDevIns, &now));
|
---|
1212 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1213 | }
|
---|
1214 | break;
|
---|
1215 | }
|
---|
1216 |
|
---|
1217 | /*
|
---|
1218 | * Query information about the hypervisor
|
---|
1219 | */
|
---|
1220 | case VMMDevReq_GetHypervisorInfo:
|
---|
1221 | {
|
---|
1222 | if (pRequestHeader->size != sizeof(VMMDevReqHypervisorInfo))
|
---|
1223 | {
|
---|
1224 | AssertMsgFailed(("VMMDev hypervisor info structure has invalid size!\n"));
|
---|
1225 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1226 | }
|
---|
1227 | else
|
---|
1228 | {
|
---|
1229 | VMMDevReqHypervisorInfo *hypervisorInfo = (VMMDevReqHypervisorInfo*)pRequestHeader;
|
---|
1230 | PVM pVM = PDMDevHlpGetVM(pDevIns);
|
---|
1231 | pRequestHeader->rc = PGMR3MappingsSize(pVM, &hypervisorInfo->hypervisorSize);
|
---|
1232 | }
|
---|
1233 | break;
|
---|
1234 | }
|
---|
1235 |
|
---|
1236 | /*
|
---|
1237 | * Set hypervisor information
|
---|
1238 | */
|
---|
1239 | case VMMDevReq_SetHypervisorInfo:
|
---|
1240 | {
|
---|
1241 | if (pRequestHeader->size != sizeof(VMMDevReqHypervisorInfo))
|
---|
1242 | {
|
---|
1243 | AssertMsgFailed(("VMMDev hypervisor info structure has invalid size!\n"));
|
---|
1244 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1245 | }
|
---|
1246 | else
|
---|
1247 | {
|
---|
1248 | VMMDevReqHypervisorInfo *hypervisorInfo = (VMMDevReqHypervisorInfo*)pRequestHeader;
|
---|
1249 | PVM pVM = PDMDevHlpGetVM(pDevIns);
|
---|
1250 | if (hypervisorInfo->hypervisorStart == 0)
|
---|
1251 | pRequestHeader->rc = PGMR3MappingsUnfix(pVM);
|
---|
1252 | else
|
---|
1253 | {
|
---|
1254 | /* only if the client has queried the size before! */
|
---|
1255 | uint32_t mappingsSize;
|
---|
1256 | pRequestHeader->rc = PGMR3MappingsSize(pVM, &mappingsSize);
|
---|
1257 | if (RT_SUCCESS(pRequestHeader->rc) && hypervisorInfo->hypervisorSize == mappingsSize)
|
---|
1258 | {
|
---|
1259 | /* new reservation */
|
---|
1260 | pRequestHeader->rc = PGMR3MappingsFix(pVM, hypervisorInfo->hypervisorStart,
|
---|
1261 | hypervisorInfo->hypervisorSize);
|
---|
1262 | LogRel(("Guest reported fixed hypervisor window at 0x%p (size = 0x%x, rc = %Rrc)\n",
|
---|
1263 | (uintptr_t)hypervisorInfo->hypervisorStart,
|
---|
1264 | hypervisorInfo->hypervisorSize,
|
---|
1265 | pRequestHeader->rc));
|
---|
1266 | }
|
---|
1267 | }
|
---|
1268 | }
|
---|
1269 | break;
|
---|
1270 | }
|
---|
1271 |
|
---|
1272 | case VMMDevReq_RegisterPatchMemory:
|
---|
1273 | {
|
---|
1274 | if (pRequestHeader->size != sizeof(VMMDevReqPatchMemory))
|
---|
1275 | {
|
---|
1276 | AssertMsgFailed(("VMMDevReq_RegisterPatchMemory structure has invalid size!\n"));
|
---|
1277 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1278 | }
|
---|
1279 | else
|
---|
1280 | {
|
---|
1281 | VMMDevReqPatchMemory *pPatchRequest = (VMMDevReqPatchMemory*)pRequestHeader;
|
---|
1282 |
|
---|
1283 | pRequestHeader->rc = VMMR3RegisterPatchMemory(PDMDevHlpGetVM(pDevIns), pPatchRequest->pPatchMem, pPatchRequest->cbPatchMem);
|
---|
1284 | }
|
---|
1285 | break;
|
---|
1286 | }
|
---|
1287 |
|
---|
1288 | case VMMDevReq_DeregisterPatchMemory:
|
---|
1289 | {
|
---|
1290 | if (pRequestHeader->size != sizeof(VMMDevReqPatchMemory))
|
---|
1291 | {
|
---|
1292 | AssertMsgFailed(("VMMDevReq_DeregisterPatchMemory structure has invalid size!\n"));
|
---|
1293 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1294 | }
|
---|
1295 | else
|
---|
1296 | {
|
---|
1297 | VMMDevReqPatchMemory *pPatchRequest = (VMMDevReqPatchMemory*)pRequestHeader;
|
---|
1298 |
|
---|
1299 | pRequestHeader->rc = VMMR3DeregisterPatchMemory(PDMDevHlpGetVM(pDevIns), pPatchRequest->pPatchMem, pPatchRequest->cbPatchMem);
|
---|
1300 | }
|
---|
1301 | break;
|
---|
1302 | }
|
---|
1303 |
|
---|
1304 | /*
|
---|
1305 | * Set the system power status
|
---|
1306 | */
|
---|
1307 | case VMMDevReq_SetPowerStatus:
|
---|
1308 | {
|
---|
1309 | if (pRequestHeader->size != sizeof(VMMDevPowerStateRequest))
|
---|
1310 | {
|
---|
1311 | AssertMsgFailed(("VMMDev power state request structure has invalid size!\n"));
|
---|
1312 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1313 | }
|
---|
1314 | else
|
---|
1315 | {
|
---|
1316 | VMMDevPowerStateRequest *powerStateRequest = (VMMDevPowerStateRequest*)pRequestHeader;
|
---|
1317 | switch(powerStateRequest->powerState)
|
---|
1318 | {
|
---|
1319 | case VMMDevPowerState_Pause:
|
---|
1320 | {
|
---|
1321 | LogRel(("Guest requests the VM to be suspended (paused)\n"));
|
---|
1322 | pRequestHeader->rc = rcRet = PDMDevHlpVMSuspend(pDevIns);
|
---|
1323 | break;
|
---|
1324 | }
|
---|
1325 |
|
---|
1326 | case VMMDevPowerState_PowerOff:
|
---|
1327 | {
|
---|
1328 | LogRel(("Guest requests the VM to be turned off\n"));
|
---|
1329 | pRequestHeader->rc = rcRet = PDMDevHlpVMPowerOff(pDevIns);
|
---|
1330 | break;
|
---|
1331 | }
|
---|
1332 |
|
---|
1333 | case VMMDevPowerState_SaveState:
|
---|
1334 | {
|
---|
1335 | if (true /*pThis->fAllowGuestToSaveState*/)
|
---|
1336 | {
|
---|
1337 | LogRel(("Guest requests the VM to be saved and powered off\n"));
|
---|
1338 | pRequestHeader->rc = rcRet = PDMDevHlpVMSuspendSaveAndPowerOff(pDevIns);
|
---|
1339 | }
|
---|
1340 | else
|
---|
1341 | {
|
---|
1342 | LogRel(("Guest requests the VM to be saved and powered off, declined\n"));
|
---|
1343 | pRequestHeader->rc = VERR_ACCESS_DENIED;
|
---|
1344 | }
|
---|
1345 | break;
|
---|
1346 | }
|
---|
1347 |
|
---|
1348 | default:
|
---|
1349 | AssertMsgFailed(("VMMDev invalid power state request: %d\n", powerStateRequest->powerState));
|
---|
1350 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1351 | break;
|
---|
1352 | }
|
---|
1353 | }
|
---|
1354 | break;
|
---|
1355 | }
|
---|
1356 |
|
---|
1357 | /*
|
---|
1358 | * Retrieve a display resize request sent by the host using
|
---|
1359 | * @a IDisplay:setVideoModeHint. Deprecated.
|
---|
1360 | * See documentation in VMMDev.h.
|
---|
1361 | */
|
---|
1362 | /**
|
---|
1363 | * @todo It looks like a multi-monitor guest which only uses
|
---|
1364 | * @a VMMDevReq_GetDisplayChangeRequest (not the *2 version)
|
---|
1365 | * will get into a @a VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST event
|
---|
1366 | * loop if it tries to acknowlege host requests for additional
|
---|
1367 | * monitors. Should the loop which checks for those requests
|
---|
1368 | * be removed?
|
---|
1369 | */
|
---|
1370 | case VMMDevReq_GetDisplayChangeRequest:
|
---|
1371 | {
|
---|
1372 | if (pRequestHeader->size != sizeof(VMMDevDisplayChangeRequest))
|
---|
1373 | {
|
---|
1374 | /* Assert only if the size also not equal to a previous version size to prevent
|
---|
1375 | * assertion with old additions.
|
---|
1376 | */
|
---|
1377 | AssertMsg(pRequestHeader->size == sizeof(VMMDevDisplayChangeRequest) - sizeof (uint32_t),
|
---|
1378 | ("VMMDev display change request structure has invalid size!\n"));
|
---|
1379 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1380 | }
|
---|
1381 | else
|
---|
1382 | {
|
---|
1383 | VMMDevDisplayChangeRequest *displayChangeRequest = (VMMDevDisplayChangeRequest*)pRequestHeader;
|
---|
1384 |
|
---|
1385 | DISPLAYCHANGEREQUEST *pRequest = &pThis->displayChangeData.aRequests[0];
|
---|
1386 |
|
---|
1387 | if (displayChangeRequest->eventAck == VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST)
|
---|
1388 | {
|
---|
1389 | /* Current request has been read at least once. */
|
---|
1390 | pRequest->fPending = false;
|
---|
1391 |
|
---|
1392 | /* Check if there are more pending requests. */
|
---|
1393 | for (unsigned i = 1; i < RT_ELEMENTS(pThis->displayChangeData.aRequests); i++)
|
---|
1394 | {
|
---|
1395 | if (pThis->displayChangeData.aRequests[i].fPending)
|
---|
1396 | {
|
---|
1397 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);
|
---|
1398 | break;
|
---|
1399 | }
|
---|
1400 | }
|
---|
1401 |
|
---|
1402 | /* Remember which resolution the client has queried, subsequent reads
|
---|
1403 | * will return the same values. */
|
---|
1404 | pRequest->lastReadDisplayChangeRequest = pRequest->displayChangeRequest;
|
---|
1405 | pThis->displayChangeData.fGuestSentChangeEventAck = true;
|
---|
1406 | }
|
---|
1407 |
|
---|
1408 | if (pThis->displayChangeData.fGuestSentChangeEventAck)
|
---|
1409 | {
|
---|
1410 | displayChangeRequest->xres = pRequest->lastReadDisplayChangeRequest.xres;
|
---|
1411 | displayChangeRequest->yres = pRequest->lastReadDisplayChangeRequest.yres;
|
---|
1412 | displayChangeRequest->bpp = pRequest->lastReadDisplayChangeRequest.bpp;
|
---|
1413 | }
|
---|
1414 | else
|
---|
1415 | {
|
---|
1416 | /* This is not a response to a VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, just
|
---|
1417 | * read the last valid video mode hint. This happens when the guest X server
|
---|
1418 | * determines the initial mode. */
|
---|
1419 | displayChangeRequest->xres = pRequest->displayChangeRequest.xres;
|
---|
1420 | displayChangeRequest->yres = pRequest->displayChangeRequest.yres;
|
---|
1421 | displayChangeRequest->bpp = pRequest->displayChangeRequest.bpp;
|
---|
1422 | }
|
---|
1423 | Log(("VMMDev: returning display change request xres = %d, yres = %d, bpp = %d\n",
|
---|
1424 | displayChangeRequest->xres, displayChangeRequest->yres, displayChangeRequest->bpp));
|
---|
1425 |
|
---|
1426 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1427 | }
|
---|
1428 | break;
|
---|
1429 | }
|
---|
1430 |
|
---|
1431 | /*
|
---|
1432 | * Retrieve a display resize request sent by the host using
|
---|
1433 | * @a IDisplay:setVideoModeHint.
|
---|
1434 | * See documentation in VMMDev.h.
|
---|
1435 | */
|
---|
1436 | case VMMDevReq_GetDisplayChangeRequest2:
|
---|
1437 | {
|
---|
1438 | if (pRequestHeader->size != sizeof(VMMDevDisplayChangeRequest2))
|
---|
1439 | {
|
---|
1440 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1441 | }
|
---|
1442 | else
|
---|
1443 | {
|
---|
1444 | VMMDevDisplayChangeRequest2 *displayChangeRequest = (VMMDevDisplayChangeRequest2*)pRequestHeader;
|
---|
1445 |
|
---|
1446 | DISPLAYCHANGEREQUEST *pRequest = NULL;
|
---|
1447 |
|
---|
1448 | if (displayChangeRequest->eventAck == VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST)
|
---|
1449 | {
|
---|
1450 | /* Select a pending request to report. */
|
---|
1451 | unsigned i;
|
---|
1452 | for (i = 0; i < RT_ELEMENTS(pThis->displayChangeData.aRequests); i++)
|
---|
1453 | {
|
---|
1454 | if (pThis->displayChangeData.aRequests[i].fPending)
|
---|
1455 | {
|
---|
1456 | pRequest = &pThis->displayChangeData.aRequests[i];
|
---|
1457 | /* Remember which request should be reported. */
|
---|
1458 | pThis->displayChangeData.iCurrentMonitor = i;
|
---|
1459 | Log3(("VMMDev: will report pending request for %d\n",
|
---|
1460 | i));
|
---|
1461 | break;
|
---|
1462 | }
|
---|
1463 | }
|
---|
1464 |
|
---|
1465 | /* Check if there are more pending requests. */
|
---|
1466 | i++;
|
---|
1467 | for (; i < RT_ELEMENTS(pThis->displayChangeData.aRequests); i++)
|
---|
1468 | {
|
---|
1469 | if (pThis->displayChangeData.aRequests[i].fPending)
|
---|
1470 | {
|
---|
1471 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);
|
---|
1472 | Log3(("VMMDev: another pending at %d\n",
|
---|
1473 | i));
|
---|
1474 | break;
|
---|
1475 | }
|
---|
1476 | }
|
---|
1477 |
|
---|
1478 | if (pRequest)
|
---|
1479 | {
|
---|
1480 | /* Current request has been read at least once. */
|
---|
1481 | pRequest->fPending = false;
|
---|
1482 |
|
---|
1483 | /* Remember which resolution the client has queried, subsequent reads
|
---|
1484 | * will return the same values. */
|
---|
1485 | pRequest->lastReadDisplayChangeRequest = pRequest->displayChangeRequest;
|
---|
1486 | pThis->displayChangeData.fGuestSentChangeEventAck = true;
|
---|
1487 | }
|
---|
1488 | else
|
---|
1489 | {
|
---|
1490 | Log3(("VMMDev: no pending request!!!\n"));
|
---|
1491 | }
|
---|
1492 | }
|
---|
1493 |
|
---|
1494 | if (!pRequest)
|
---|
1495 | {
|
---|
1496 | Log3(("VMMDev: default to %d\n",
|
---|
1497 | pThis->displayChangeData.iCurrentMonitor));
|
---|
1498 | pRequest = &pThis->displayChangeData.aRequests[pThis->displayChangeData.iCurrentMonitor];
|
---|
1499 | }
|
---|
1500 |
|
---|
1501 | if (pThis->displayChangeData.fGuestSentChangeEventAck)
|
---|
1502 | {
|
---|
1503 | displayChangeRequest->xres = pRequest->lastReadDisplayChangeRequest.xres;
|
---|
1504 | displayChangeRequest->yres = pRequest->lastReadDisplayChangeRequest.yres;
|
---|
1505 | displayChangeRequest->bpp = pRequest->lastReadDisplayChangeRequest.bpp;
|
---|
1506 | displayChangeRequest->display = pRequest->lastReadDisplayChangeRequest.display;
|
---|
1507 | }
|
---|
1508 | else
|
---|
1509 | {
|
---|
1510 | /* This is not a response to a VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, just
|
---|
1511 | * read the last valid video mode hint. This happens when the guest X server
|
---|
1512 | * determines the initial video mode. */
|
---|
1513 | displayChangeRequest->xres = pRequest->displayChangeRequest.xres;
|
---|
1514 | displayChangeRequest->yres = pRequest->displayChangeRequest.yres;
|
---|
1515 | displayChangeRequest->bpp = pRequest->displayChangeRequest.bpp;
|
---|
1516 | displayChangeRequest->display = pRequest->displayChangeRequest.display;
|
---|
1517 | }
|
---|
1518 | Log(("VMMDev: returning display change request xres = %d, yres = %d, bpp = %d at %d\n",
|
---|
1519 | displayChangeRequest->xres, displayChangeRequest->yres, displayChangeRequest->bpp, displayChangeRequest->display));
|
---|
1520 |
|
---|
1521 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1522 | }
|
---|
1523 | break;
|
---|
1524 | }
|
---|
1525 |
|
---|
1526 | /*
|
---|
1527 | * Retrieve a display resize request sent by the host using
|
---|
1528 | * @a IDisplay:setVideoModeHint.
|
---|
1529 | * See documentation in VMMDev.h.
|
---|
1530 | */
|
---|
1531 | case VMMDevReq_GetDisplayChangeRequestEx:
|
---|
1532 | {
|
---|
1533 | LogFlowFunc(("VMMDevReq_GetDisplayChangeRequestEx\n"));
|
---|
1534 | if (pRequestHeader->size != sizeof(VMMDevDisplayChangeRequestEx))
|
---|
1535 | {
|
---|
1536 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1537 | }
|
---|
1538 | else
|
---|
1539 | {
|
---|
1540 | VMMDevDisplayChangeRequestEx *displayChangeRequest = (VMMDevDisplayChangeRequestEx*)pRequestHeader;
|
---|
1541 |
|
---|
1542 | DISPLAYCHANGEREQUEST *pRequest = NULL;
|
---|
1543 |
|
---|
1544 | if (displayChangeRequest->eventAck == VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST)
|
---|
1545 | {
|
---|
1546 | /* Select a pending request to report. */
|
---|
1547 | unsigned i;
|
---|
1548 | for (i = 0; i < RT_ELEMENTS(pThis->displayChangeData.aRequests); i++)
|
---|
1549 | {
|
---|
1550 | if (pThis->displayChangeData.aRequests[i].fPending)
|
---|
1551 | {
|
---|
1552 | pRequest = &pThis->displayChangeData.aRequests[i];
|
---|
1553 | /* Remember which request should be reported. */
|
---|
1554 | pThis->displayChangeData.iCurrentMonitor = i;
|
---|
1555 | Log3(("VMMDev: will report pending request for %d\n",
|
---|
1556 | i));
|
---|
1557 | break;
|
---|
1558 | }
|
---|
1559 | }
|
---|
1560 |
|
---|
1561 | /* Check if there are more pending requests. */
|
---|
1562 | i++;
|
---|
1563 | for (; i < RT_ELEMENTS(pThis->displayChangeData.aRequests); i++)
|
---|
1564 | {
|
---|
1565 | if (pThis->displayChangeData.aRequests[i].fPending)
|
---|
1566 | {
|
---|
1567 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);
|
---|
1568 | Log3(("VMMDev: another pending at %d\n",
|
---|
1569 | i));
|
---|
1570 | break;
|
---|
1571 | }
|
---|
1572 | }
|
---|
1573 |
|
---|
1574 | if (pRequest)
|
---|
1575 | {
|
---|
1576 | /* Current request has been read at least once. */
|
---|
1577 | pRequest->fPending = false;
|
---|
1578 |
|
---|
1579 | /* Remember which resolution the client has queried, subsequent reads
|
---|
1580 | * will return the same values. */
|
---|
1581 | pRequest->lastReadDisplayChangeRequest = pRequest->displayChangeRequest;
|
---|
1582 | pThis->displayChangeData.fGuestSentChangeEventAck = true;
|
---|
1583 | }
|
---|
1584 | else
|
---|
1585 | {
|
---|
1586 | Log3(("VMMDev: no pending request!!!\n"));
|
---|
1587 | }
|
---|
1588 | }
|
---|
1589 |
|
---|
1590 | if (!pRequest)
|
---|
1591 | {
|
---|
1592 | Log3(("VMMDev: default to %d\n",
|
---|
1593 | pThis->displayChangeData.iCurrentMonitor));
|
---|
1594 | pRequest = &pThis->displayChangeData.aRequests[pThis->displayChangeData.iCurrentMonitor];
|
---|
1595 | }
|
---|
1596 |
|
---|
1597 | if (pThis->displayChangeData.fGuestSentChangeEventAck)
|
---|
1598 | {
|
---|
1599 | displayChangeRequest->xres = pRequest->lastReadDisplayChangeRequest.xres;
|
---|
1600 | displayChangeRequest->yres = pRequest->lastReadDisplayChangeRequest.yres;
|
---|
1601 | displayChangeRequest->bpp = pRequest->lastReadDisplayChangeRequest.bpp;
|
---|
1602 | displayChangeRequest->display = pRequest->lastReadDisplayChangeRequest.display;
|
---|
1603 | displayChangeRequest->cxOrigin = pRequest->lastReadDisplayChangeRequest.xOrigin;
|
---|
1604 | displayChangeRequest->cyOrigin = pRequest->lastReadDisplayChangeRequest.yOrigin;
|
---|
1605 | displayChangeRequest->fEnabled = pRequest->lastReadDisplayChangeRequest.fEnabled;
|
---|
1606 | displayChangeRequest->fChangeOrigin = pRequest->lastReadDisplayChangeRequest.fChangeOrigin;
|
---|
1607 | }
|
---|
1608 | else
|
---|
1609 | {
|
---|
1610 | /* This is not a response to a VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST, just
|
---|
1611 | * read the last valid video mode hint. This happens when the guest X server
|
---|
1612 | * determines the initial video mode. */
|
---|
1613 | displayChangeRequest->xres = pRequest->displayChangeRequest.xres;
|
---|
1614 | displayChangeRequest->yres = pRequest->displayChangeRequest.yres;
|
---|
1615 | displayChangeRequest->bpp = pRequest->displayChangeRequest.bpp;
|
---|
1616 | displayChangeRequest->display = pRequest->displayChangeRequest.display;
|
---|
1617 | displayChangeRequest->cxOrigin = pRequest->displayChangeRequest.xOrigin;
|
---|
1618 | displayChangeRequest->cyOrigin = pRequest->displayChangeRequest.yOrigin;
|
---|
1619 | displayChangeRequest->fEnabled = pRequest->displayChangeRequest.fEnabled;
|
---|
1620 | displayChangeRequest->fChangeOrigin = pRequest->displayChangeRequest.fChangeOrigin;
|
---|
1621 |
|
---|
1622 | }
|
---|
1623 | Log(("VMMDevEx: returning display change request xres = %d, yres = %d, bpp = %d id %d \
|
---|
1624 | xPos = %d, yPos = %d & Enabled=%d\n",
|
---|
1625 | displayChangeRequest->xres, displayChangeRequest->yres,
|
---|
1626 | displayChangeRequest->bpp, displayChangeRequest->display,
|
---|
1627 | displayChangeRequest->cxOrigin, displayChangeRequest->cyOrigin,
|
---|
1628 | displayChangeRequest->fEnabled));
|
---|
1629 |
|
---|
1630 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1631 | }
|
---|
1632 | break;
|
---|
1633 | }
|
---|
1634 |
|
---|
1635 |
|
---|
1636 | /*
|
---|
1637 | * Query whether the given video mode is supported
|
---|
1638 | */
|
---|
1639 | case VMMDevReq_VideoModeSupported:
|
---|
1640 | {
|
---|
1641 | if (pRequestHeader->size != sizeof(VMMDevVideoModeSupportedRequest))
|
---|
1642 | {
|
---|
1643 | AssertMsgFailed(("VMMDev video mode supported request structure has invalid size!\n"));
|
---|
1644 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1645 | }
|
---|
1646 | else
|
---|
1647 | {
|
---|
1648 | VMMDevVideoModeSupportedRequest *videoModeSupportedRequest = (VMMDevVideoModeSupportedRequest*)pRequestHeader;
|
---|
1649 | /* forward the call */
|
---|
1650 | pRequestHeader->rc = pThis->pDrv->pfnVideoModeSupported(pThis->pDrv,
|
---|
1651 | 0, /* primary screen. */
|
---|
1652 | videoModeSupportedRequest->width,
|
---|
1653 | videoModeSupportedRequest->height,
|
---|
1654 | videoModeSupportedRequest->bpp,
|
---|
1655 | &videoModeSupportedRequest->fSupported);
|
---|
1656 | }
|
---|
1657 | break;
|
---|
1658 | }
|
---|
1659 |
|
---|
1660 | /*
|
---|
1661 | * Query whether the given video mode is supported for a specific display
|
---|
1662 | */
|
---|
1663 | case VMMDevReq_VideoModeSupported2:
|
---|
1664 | {
|
---|
1665 | if (pRequestHeader->size != sizeof(VMMDevVideoModeSupportedRequest2))
|
---|
1666 | {
|
---|
1667 | AssertMsgFailed(("VMMDev video mode supported request 2 structure has invalid size!\n"));
|
---|
1668 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1669 | }
|
---|
1670 | else
|
---|
1671 | {
|
---|
1672 | VMMDevVideoModeSupportedRequest2 *videoModeSupportedRequest2 = (VMMDevVideoModeSupportedRequest2*)pRequestHeader;
|
---|
1673 | /* forward the call */
|
---|
1674 | pRequestHeader->rc = pThis->pDrv->pfnVideoModeSupported(pThis->pDrv,
|
---|
1675 | videoModeSupportedRequest2->display,
|
---|
1676 | videoModeSupportedRequest2->width,
|
---|
1677 | videoModeSupportedRequest2->height,
|
---|
1678 | videoModeSupportedRequest2->bpp,
|
---|
1679 | &videoModeSupportedRequest2->fSupported);
|
---|
1680 | }
|
---|
1681 | break;
|
---|
1682 | }
|
---|
1683 |
|
---|
1684 | /*
|
---|
1685 | * Query the height reduction in pixels
|
---|
1686 | */
|
---|
1687 | case VMMDevReq_GetHeightReduction:
|
---|
1688 | {
|
---|
1689 | if (pRequestHeader->size != sizeof(VMMDevGetHeightReductionRequest))
|
---|
1690 | {
|
---|
1691 | AssertMsgFailed(("VMMDev height reduction request structure has invalid size!\n"));
|
---|
1692 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1693 | }
|
---|
1694 | else
|
---|
1695 | {
|
---|
1696 | VMMDevGetHeightReductionRequest *heightReductionRequest = (VMMDevGetHeightReductionRequest*)pRequestHeader;
|
---|
1697 | /* forward the call */
|
---|
1698 | pRequestHeader->rc = pThis->pDrv->pfnGetHeightReduction(pThis->pDrv,
|
---|
1699 | &heightReductionRequest->heightReduction);
|
---|
1700 | }
|
---|
1701 | break;
|
---|
1702 | }
|
---|
1703 |
|
---|
1704 | /*
|
---|
1705 | * Acknowledge VMMDev events
|
---|
1706 | */
|
---|
1707 | case VMMDevReq_AcknowledgeEvents:
|
---|
1708 | {
|
---|
1709 | if (pRequestHeader->size != sizeof(VMMDevEvents))
|
---|
1710 | {
|
---|
1711 | AssertMsgFailed(("VMMDevReq_AcknowledgeEvents structure has invalid size!\n"));
|
---|
1712 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1713 | }
|
---|
1714 | else
|
---|
1715 | {
|
---|
1716 | if (VBOX_GUEST_INTERFACE_VERSION_1_03 (pThis))
|
---|
1717 | {
|
---|
1718 | vmmdevSetIRQ_Legacy_EMT (pThis);
|
---|
1719 | }
|
---|
1720 | else
|
---|
1721 | {
|
---|
1722 | VMMDevEvents *pAckRequest;
|
---|
1723 |
|
---|
1724 | if (pThis->fNewGuestFilterMask)
|
---|
1725 | {
|
---|
1726 | pThis->fNewGuestFilterMask = false;
|
---|
1727 | pThis->u32GuestFilterMask = pThis->u32NewGuestFilterMask;
|
---|
1728 | }
|
---|
1729 |
|
---|
1730 | pAckRequest = (VMMDevEvents *)pRequestHeader;
|
---|
1731 | pAckRequest->events =
|
---|
1732 | pThis->u32HostEventFlags & pThis->u32GuestFilterMask;
|
---|
1733 |
|
---|
1734 | pThis->u32HostEventFlags &= ~pThis->u32GuestFilterMask;
|
---|
1735 | pThis->pVMMDevRAMR3->V.V1_04.fHaveEvents = false;
|
---|
1736 | PDMDevHlpPCISetIrqNoWait (pThis->pDevIns, 0, 0);
|
---|
1737 | }
|
---|
1738 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1739 | }
|
---|
1740 | break;
|
---|
1741 | }
|
---|
1742 |
|
---|
1743 | /*
|
---|
1744 | * Change guest filter mask
|
---|
1745 | */
|
---|
1746 | case VMMDevReq_CtlGuestFilterMask:
|
---|
1747 | {
|
---|
1748 | if (pRequestHeader->size != sizeof(VMMDevCtlGuestFilterMask))
|
---|
1749 | {
|
---|
1750 | AssertMsgFailed(("VMMDevReq_AcknowledgeEvents structure has invalid size!\n"));
|
---|
1751 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1752 | }
|
---|
1753 | else
|
---|
1754 | {
|
---|
1755 | VMMDevCtlGuestFilterMask *pCtlMaskRequest;
|
---|
1756 |
|
---|
1757 | pCtlMaskRequest = (VMMDevCtlGuestFilterMask *)pRequestHeader;
|
---|
1758 | LogRelFlowFunc(("VMMDevCtlGuestFilterMask: or mask: 0x%x, not mask: 0x%x\n",
|
---|
1759 | pCtlMaskRequest->u32OrMask,
|
---|
1760 | pCtlMaskRequest->u32NotMask));
|
---|
1761 | /* HGCM event notification is enabled by the VMMDev device
|
---|
1762 | * automatically when any HGCM command is issued. The guest
|
---|
1763 | * cannot disable these notifications.
|
---|
1764 | */
|
---|
1765 | VMMDevCtlSetGuestFilterMask (pThis,
|
---|
1766 | pCtlMaskRequest->u32OrMask,
|
---|
1767 | pCtlMaskRequest->u32NotMask & ~VMMDEV_EVENT_HGCM);
|
---|
1768 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1769 |
|
---|
1770 | }
|
---|
1771 | break;
|
---|
1772 | }
|
---|
1773 |
|
---|
1774 | #ifdef VBOX_WITH_HGCM
|
---|
1775 | /*
|
---|
1776 | * Process HGCM request
|
---|
1777 | */
|
---|
1778 | case VMMDevReq_HGCMConnect:
|
---|
1779 | {
|
---|
1780 | if (pRequestHeader->size < sizeof(VMMDevHGCMConnect))
|
---|
1781 | {
|
---|
1782 | AssertMsgFailed(("VMMDevReq_HGCMConnect structure has invalid size!\n"));
|
---|
1783 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1784 | }
|
---|
1785 | else if (!pThis->pHGCMDrv)
|
---|
1786 | {
|
---|
1787 | Log(("VMMDevReq_HGCMConnect HGCM Connector is NULL!\n"));
|
---|
1788 | pRequestHeader->rc = VERR_NOT_SUPPORTED;
|
---|
1789 | }
|
---|
1790 | else
|
---|
1791 | {
|
---|
1792 | VMMDevHGCMConnect *pHGCMConnect = (VMMDevHGCMConnect *)pRequestHeader;
|
---|
1793 |
|
---|
1794 | Log(("VMMDevReq_HGCMConnect\n"));
|
---|
1795 |
|
---|
1796 | pRequestHeader->rc = vmmdevHGCMConnect (pThis, pHGCMConnect, (RTGCPHYS)u32);
|
---|
1797 | }
|
---|
1798 | break;
|
---|
1799 | }
|
---|
1800 |
|
---|
1801 | case VMMDevReq_HGCMDisconnect:
|
---|
1802 | {
|
---|
1803 | if (pRequestHeader->size < sizeof(VMMDevHGCMDisconnect))
|
---|
1804 | {
|
---|
1805 | AssertMsgFailed(("VMMDevReq_HGCMDisconnect structure has invalid size!\n"));
|
---|
1806 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1807 | }
|
---|
1808 | else if (!pThis->pHGCMDrv)
|
---|
1809 | {
|
---|
1810 | Log(("VMMDevReq_HGCMDisconnect HGCM Connector is NULL!\n"));
|
---|
1811 | pRequestHeader->rc = VERR_NOT_SUPPORTED;
|
---|
1812 | }
|
---|
1813 | else
|
---|
1814 | {
|
---|
1815 | VMMDevHGCMDisconnect *pHGCMDisconnect = (VMMDevHGCMDisconnect *)pRequestHeader;
|
---|
1816 |
|
---|
1817 | Log(("VMMDevReq_VMMDevHGCMDisconnect\n"));
|
---|
1818 | pRequestHeader->rc = vmmdevHGCMDisconnect (pThis, pHGCMDisconnect, (RTGCPHYS)u32);
|
---|
1819 | }
|
---|
1820 | break;
|
---|
1821 | }
|
---|
1822 |
|
---|
1823 | #ifdef VBOX_WITH_64_BITS_GUESTS
|
---|
1824 | case VMMDevReq_HGCMCall32:
|
---|
1825 | case VMMDevReq_HGCMCall64:
|
---|
1826 | #else
|
---|
1827 | case VMMDevReq_HGCMCall:
|
---|
1828 | #endif /* VBOX_WITH_64_BITS_GUESTS */
|
---|
1829 | {
|
---|
1830 | if (pRequestHeader->size < sizeof(VMMDevHGCMCall))
|
---|
1831 | {
|
---|
1832 | AssertMsgFailed(("VMMDevReq_HGCMCall structure has invalid size!\n"));
|
---|
1833 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1834 | }
|
---|
1835 | else if (!pThis->pHGCMDrv)
|
---|
1836 | {
|
---|
1837 | Log(("VMMDevReq_HGCMCall HGCM Connector is NULL!\n"));
|
---|
1838 | pRequestHeader->rc = VERR_NOT_SUPPORTED;
|
---|
1839 | }
|
---|
1840 | else
|
---|
1841 | {
|
---|
1842 | VMMDevHGCMCall *pHGCMCall = (VMMDevHGCMCall *)pRequestHeader;
|
---|
1843 |
|
---|
1844 | Log2(("VMMDevReq_HGCMCall: sizeof (VMMDevHGCMRequest) = %04X\n", sizeof (VMMDevHGCMCall)));
|
---|
1845 | Log2(("%.*Rhxd\n", pRequestHeader->size, pRequestHeader));
|
---|
1846 |
|
---|
1847 | #ifdef VBOX_WITH_64_BITS_GUESTS
|
---|
1848 | bool f64Bits = (pRequestHeader->requestType == VMMDevReq_HGCMCall64);
|
---|
1849 | #else
|
---|
1850 | bool f64Bits = false;
|
---|
1851 | #endif /* VBOX_WITH_64_BITS_GUESTS */
|
---|
1852 |
|
---|
1853 | pRequestHeader->rc = vmmdevHGCMCall (pThis, pHGCMCall, requestHeader.size, (RTGCPHYS)u32, f64Bits);
|
---|
1854 | }
|
---|
1855 | break;
|
---|
1856 | }
|
---|
1857 | #endif /* VBOX_WITH_HGCM */
|
---|
1858 |
|
---|
1859 | case VMMDevReq_HGCMCancel:
|
---|
1860 | {
|
---|
1861 | if (pRequestHeader->size < sizeof(VMMDevHGCMCancel))
|
---|
1862 | {
|
---|
1863 | AssertMsgFailed(("VMMDevReq_HGCMCancel structure has invalid size!\n"));
|
---|
1864 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1865 | }
|
---|
1866 | else if (!pThis->pHGCMDrv)
|
---|
1867 | {
|
---|
1868 | Log(("VMMDevReq_HGCMCancel HGCM Connector is NULL!\n"));
|
---|
1869 | pRequestHeader->rc = VERR_NOT_SUPPORTED;
|
---|
1870 | }
|
---|
1871 | else
|
---|
1872 | {
|
---|
1873 | VMMDevHGCMCancel *pHGCMCancel = (VMMDevHGCMCancel *)pRequestHeader;
|
---|
1874 |
|
---|
1875 | Log(("VMMDevReq_VMMDevHGCMCancel\n"));
|
---|
1876 | pRequestHeader->rc = vmmdevHGCMCancel (pThis, pHGCMCancel, (RTGCPHYS)u32);
|
---|
1877 | }
|
---|
1878 | break;
|
---|
1879 | }
|
---|
1880 |
|
---|
1881 | case VMMDevReq_HGCMCancel2:
|
---|
1882 | {
|
---|
1883 | if (pRequestHeader->size != sizeof(VMMDevHGCMCancel2))
|
---|
1884 | {
|
---|
1885 | AssertMsgFailed(("VMMDevReq_HGCMCancel structure has invalid size!\n"));
|
---|
1886 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1887 | }
|
---|
1888 | else if (!pThis->pHGCMDrv)
|
---|
1889 | {
|
---|
1890 | Log(("VMMDevReq_HGCMCancel HGCM Connector is NULL!\n"));
|
---|
1891 | pRequestHeader->rc = VERR_NOT_SUPPORTED;
|
---|
1892 | }
|
---|
1893 | else
|
---|
1894 | {
|
---|
1895 | VMMDevHGCMCancel2 *pHGCMCancel2 = (VMMDevHGCMCancel2 *)pRequestHeader;
|
---|
1896 |
|
---|
1897 | Log(("VMMDevReq_VMMDevHGCMCancel\n"));
|
---|
1898 | pRequestHeader->rc = vmmdevHGCMCancel2 (pThis, pHGCMCancel2->physReqToCancel);
|
---|
1899 | }
|
---|
1900 | break;
|
---|
1901 | }
|
---|
1902 |
|
---|
1903 | case VMMDevReq_VideoAccelEnable:
|
---|
1904 | {
|
---|
1905 | if (pRequestHeader->size < sizeof(VMMDevVideoAccelEnable))
|
---|
1906 | {
|
---|
1907 | Log(("VMMDevReq_VideoAccelEnable request size too small!!!\n"));
|
---|
1908 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1909 | }
|
---|
1910 | else if (!pThis->pDrv)
|
---|
1911 | {
|
---|
1912 | Log(("VMMDevReq_VideoAccelEnable Connector is NULL!!!\n"));
|
---|
1913 | pRequestHeader->rc = VERR_NOT_SUPPORTED;
|
---|
1914 | }
|
---|
1915 | else
|
---|
1916 | {
|
---|
1917 | VMMDevVideoAccelEnable *ptr = (VMMDevVideoAccelEnable *)pRequestHeader;
|
---|
1918 |
|
---|
1919 | if (ptr->cbRingBuffer != VBVA_RING_BUFFER_SIZE)
|
---|
1920 | {
|
---|
1921 | /* The guest driver seems compiled with another headers. */
|
---|
1922 | Log(("VMMDevReq_VideoAccelEnable guest ring buffer size %d, should be %d!!!\n", ptr->cbRingBuffer, VBVA_RING_BUFFER_SIZE));
|
---|
1923 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1924 | }
|
---|
1925 | else
|
---|
1926 | {
|
---|
1927 | /* The request is correct. */
|
---|
1928 | ptr->fu32Status |= VBVA_F_STATUS_ACCEPTED;
|
---|
1929 |
|
---|
1930 | LogFlow(("VMMDevReq_VideoAccelEnable ptr->u32Enable = %d\n", ptr->u32Enable));
|
---|
1931 |
|
---|
1932 | pRequestHeader->rc = ptr->u32Enable?
|
---|
1933 | pThis->pDrv->pfnVideoAccelEnable (pThis->pDrv, true, &pThis->pVMMDevRAMR3->vbvaMemory):
|
---|
1934 | pThis->pDrv->pfnVideoAccelEnable (pThis->pDrv, false, NULL);
|
---|
1935 |
|
---|
1936 | if ( ptr->u32Enable
|
---|
1937 | && RT_SUCCESS (pRequestHeader->rc))
|
---|
1938 | {
|
---|
1939 | ptr->fu32Status |= VBVA_F_STATUS_ENABLED;
|
---|
1940 |
|
---|
1941 | /* Remember that guest successfully enabled acceleration.
|
---|
1942 | * We need to reestablish it on restoring the VM from saved state.
|
---|
1943 | */
|
---|
1944 | pThis->u32VideoAccelEnabled = 1;
|
---|
1945 | }
|
---|
1946 | else
|
---|
1947 | {
|
---|
1948 | /* The acceleration was not enabled. Remember that. */
|
---|
1949 | pThis->u32VideoAccelEnabled = 0;
|
---|
1950 | }
|
---|
1951 | }
|
---|
1952 | }
|
---|
1953 | break;
|
---|
1954 | }
|
---|
1955 |
|
---|
1956 | case VMMDevReq_VideoAccelFlush:
|
---|
1957 | {
|
---|
1958 | if (pRequestHeader->size < sizeof(VMMDevVideoAccelFlush))
|
---|
1959 | {
|
---|
1960 | AssertMsgFailed(("VMMDevReq_VideoAccelFlush request size too small.\n"));
|
---|
1961 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1962 | }
|
---|
1963 | else if (!pThis->pDrv)
|
---|
1964 | {
|
---|
1965 | Log(("VMMDevReq_VideoAccelFlush Connector is NULL!\n"));
|
---|
1966 | pRequestHeader->rc = VERR_NOT_SUPPORTED;
|
---|
1967 | }
|
---|
1968 | else
|
---|
1969 | {
|
---|
1970 | pThis->pDrv->pfnVideoAccelFlush (pThis->pDrv);
|
---|
1971 |
|
---|
1972 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
1973 | }
|
---|
1974 | break;
|
---|
1975 | }
|
---|
1976 |
|
---|
1977 | case VMMDevReq_VideoSetVisibleRegion:
|
---|
1978 | {
|
---|
1979 | if ( pRequestHeader->size + sizeof(RTRECT)
|
---|
1980 | < sizeof(VMMDevVideoSetVisibleRegion))
|
---|
1981 | {
|
---|
1982 | Log(("VMMDevReq_VideoSetVisibleRegion request size too small!!!\n"));
|
---|
1983 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
1984 | }
|
---|
1985 | else if (!pThis->pDrv)
|
---|
1986 | {
|
---|
1987 | Log(("VMMDevReq_VideoSetVisibleRegion Connector is NULL!!!\n"));
|
---|
1988 | pRequestHeader->rc = VERR_NOT_SUPPORTED;
|
---|
1989 | }
|
---|
1990 | else
|
---|
1991 | {
|
---|
1992 | VMMDevVideoSetVisibleRegion *ptr = (VMMDevVideoSetVisibleRegion *)pRequestHeader;
|
---|
1993 |
|
---|
1994 | if ( ptr->cRect > _1M /* restrict to sane range */
|
---|
1995 | || pRequestHeader->size != sizeof(VMMDevVideoSetVisibleRegion) + ptr->cRect * sizeof(RTRECT) - sizeof(RTRECT))
|
---|
1996 | {
|
---|
1997 | Log(("VMMDevReq_VideoSetVisibleRegion: cRects=%#x doesn't match size=%#x or is out of bounds\n",
|
---|
1998 | ptr->cRect, pRequestHeader->size));
|
---|
1999 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
2000 | }
|
---|
2001 | else
|
---|
2002 | {
|
---|
2003 | Log(("VMMDevReq_VideoSetVisibleRegion %d rectangles\n", ptr->cRect));
|
---|
2004 | /* forward the call */
|
---|
2005 | pRequestHeader->rc = pThis->pDrv->pfnSetVisibleRegion(pThis->pDrv, ptr->cRect, &ptr->Rect);
|
---|
2006 | }
|
---|
2007 | }
|
---|
2008 | break;
|
---|
2009 | }
|
---|
2010 |
|
---|
2011 | case VMMDevReq_GetSeamlessChangeRequest:
|
---|
2012 | {
|
---|
2013 | if (pRequestHeader->size != sizeof(VMMDevSeamlessChangeRequest))
|
---|
2014 | {
|
---|
2015 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
2016 | }
|
---|
2017 | else
|
---|
2018 | {
|
---|
2019 | VMMDevSeamlessChangeRequest *seamlessChangeRequest = (VMMDevSeamlessChangeRequest*)pRequestHeader;
|
---|
2020 | /* just pass on the information */
|
---|
2021 | Log(("VMMDev: returning seamless change request mode=%d\n", pThis->fSeamlessEnabled));
|
---|
2022 | if (pThis->fSeamlessEnabled)
|
---|
2023 | seamlessChangeRequest->mode = VMMDev_Seamless_Visible_Region;
|
---|
2024 | else
|
---|
2025 | seamlessChangeRequest->mode = VMMDev_Seamless_Disabled;
|
---|
2026 |
|
---|
2027 | if (seamlessChangeRequest->eventAck == VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST)
|
---|
2028 | {
|
---|
2029 | /* Remember which mode the client has queried. */
|
---|
2030 | pThis->fLastSeamlessEnabled = pThis->fSeamlessEnabled;
|
---|
2031 | }
|
---|
2032 |
|
---|
2033 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
2034 | }
|
---|
2035 | break;
|
---|
2036 | }
|
---|
2037 |
|
---|
2038 | case VMMDevReq_GetVRDPChangeRequest:
|
---|
2039 | {
|
---|
2040 | if (pRequestHeader->size != sizeof(VMMDevVRDPChangeRequest))
|
---|
2041 | {
|
---|
2042 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
2043 | }
|
---|
2044 | else
|
---|
2045 | {
|
---|
2046 | VMMDevVRDPChangeRequest *vrdpChangeRequest = (VMMDevVRDPChangeRequest*)pRequestHeader;
|
---|
2047 | /* just pass on the information */
|
---|
2048 | Log(("VMMDev: returning VRDP status %d level %d\n", pThis->fVRDPEnabled, pThis->u32VRDPExperienceLevel));
|
---|
2049 |
|
---|
2050 | vrdpChangeRequest->u8VRDPActive = pThis->fVRDPEnabled;
|
---|
2051 | vrdpChangeRequest->u32VRDPExperienceLevel = pThis->u32VRDPExperienceLevel;
|
---|
2052 |
|
---|
2053 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
2054 | }
|
---|
2055 | break;
|
---|
2056 | }
|
---|
2057 |
|
---|
2058 | case VMMDevReq_GetMemBalloonChangeRequest:
|
---|
2059 | {
|
---|
2060 | Log(("VMMDevReq_GetMemBalloonChangeRequest\n"));
|
---|
2061 | if (pRequestHeader->size != sizeof(VMMDevGetMemBalloonChangeRequest))
|
---|
2062 | {
|
---|
2063 | AssertFailed();
|
---|
2064 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
2065 | }
|
---|
2066 | else
|
---|
2067 | {
|
---|
2068 | VMMDevGetMemBalloonChangeRequest *memBalloonChangeRequest = (VMMDevGetMemBalloonChangeRequest*)pRequestHeader;
|
---|
2069 | /* just pass on the information */
|
---|
2070 | Log(("VMMDev: returning memory balloon size =%d\n", pThis->u32MemoryBalloonSize));
|
---|
2071 | memBalloonChangeRequest->cBalloonChunks = pThis->u32MemoryBalloonSize;
|
---|
2072 | memBalloonChangeRequest->cPhysMemChunks = pThis->cbGuestRAM / (uint64_t)_1M;
|
---|
2073 |
|
---|
2074 | if (memBalloonChangeRequest->eventAck == VMMDEV_EVENT_BALLOON_CHANGE_REQUEST)
|
---|
2075 | {
|
---|
2076 | /* Remember which mode the client has queried. */
|
---|
2077 | pThis->u32LastMemoryBalloonSize = pThis->u32MemoryBalloonSize;
|
---|
2078 | }
|
---|
2079 |
|
---|
2080 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
2081 | }
|
---|
2082 | break;
|
---|
2083 | }
|
---|
2084 |
|
---|
2085 | case VMMDevReq_ChangeMemBalloon:
|
---|
2086 | {
|
---|
2087 | VMMDevChangeMemBalloon *memBalloonChange = (VMMDevChangeMemBalloon*)pRequestHeader;
|
---|
2088 |
|
---|
2089 | Log(("VMMDevReq_ChangeMemBalloon\n"));
|
---|
2090 | if ( pRequestHeader->size < sizeof(VMMDevChangeMemBalloon)
|
---|
2091 | || memBalloonChange->cPages != VMMDEV_MEMORY_BALLOON_CHUNK_PAGES
|
---|
2092 | || pRequestHeader->size != (uint32_t)RT_OFFSETOF(VMMDevChangeMemBalloon, aPhysPage[memBalloonChange->cPages]))
|
---|
2093 | {
|
---|
2094 | AssertFailed();
|
---|
2095 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
2096 | }
|
---|
2097 | else
|
---|
2098 | {
|
---|
2099 | pRequestHeader->rc = PGMR3PhysChangeMemBalloon(PDMDevHlpGetVM(pDevIns), !!memBalloonChange->fInflate, memBalloonChange->cPages, memBalloonChange->aPhysPage);
|
---|
2100 | if (memBalloonChange->fInflate)
|
---|
2101 | STAM_REL_U32_INC(&pThis->StatMemBalloonChunks);
|
---|
2102 | else
|
---|
2103 | STAM_REL_U32_DEC(&pThis->StatMemBalloonChunks);
|
---|
2104 | }
|
---|
2105 | break;
|
---|
2106 | }
|
---|
2107 |
|
---|
2108 | case VMMDevReq_GetStatisticsChangeRequest:
|
---|
2109 | {
|
---|
2110 | Log(("VMMDevReq_GetStatisticsChangeRequest\n"));
|
---|
2111 | if (pRequestHeader->size != sizeof(VMMDevGetStatisticsChangeRequest))
|
---|
2112 | {
|
---|
2113 | AssertFailed();
|
---|
2114 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
2115 | }
|
---|
2116 | else
|
---|
2117 | {
|
---|
2118 | VMMDevGetStatisticsChangeRequest *statIntervalChangeRequest = (VMMDevGetStatisticsChangeRequest*)pRequestHeader;
|
---|
2119 | /* just pass on the information */
|
---|
2120 | Log(("VMMDev: returning statistics interval %d seconds\n", pThis->u32StatIntervalSize));
|
---|
2121 | statIntervalChangeRequest->u32StatInterval = pThis->u32StatIntervalSize;
|
---|
2122 |
|
---|
2123 | if (statIntervalChangeRequest->eventAck == VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST)
|
---|
2124 | {
|
---|
2125 | /* Remember which mode the client has queried. */
|
---|
2126 | pThis->u32LastStatIntervalSize= pThis->u32StatIntervalSize;
|
---|
2127 | }
|
---|
2128 |
|
---|
2129 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
2130 | }
|
---|
2131 | break;
|
---|
2132 | }
|
---|
2133 |
|
---|
2134 | case VMMDevReq_ReportGuestStats:
|
---|
2135 | {
|
---|
2136 | Log(("VMMDevReq_ReportGuestStats\n"));
|
---|
2137 | if (pRequestHeader->size != sizeof(VMMDevReportGuestStats))
|
---|
2138 | {
|
---|
2139 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
2140 | }
|
---|
2141 | else
|
---|
2142 | {
|
---|
2143 | VMMDevReportGuestStats *stats = (VMMDevReportGuestStats*)pRequestHeader;
|
---|
2144 |
|
---|
2145 | #ifdef DEBUG
|
---|
2146 | VBoxGuestStatistics *pGuestStats = &stats->guestStats;
|
---|
2147 |
|
---|
2148 | Log(("Current statistics:\n"));
|
---|
2149 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_IDLE)
|
---|
2150 | Log(("CPU%d: CPU Load Idle %-3d%%\n", pGuestStats->u32CpuId, pGuestStats->u32CpuLoad_Idle));
|
---|
2151 |
|
---|
2152 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_KERNEL)
|
---|
2153 | Log(("CPU%d: CPU Load Kernel %-3d%%\n", pGuestStats->u32CpuId, pGuestStats->u32CpuLoad_Kernel));
|
---|
2154 |
|
---|
2155 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_USER)
|
---|
2156 | Log(("CPU%d: CPU Load User %-3d%%\n", pGuestStats->u32CpuId, pGuestStats->u32CpuLoad_User));
|
---|
2157 |
|
---|
2158 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_THREADS)
|
---|
2159 | Log(("CPU%d: Thread %d\n", pGuestStats->u32CpuId, pGuestStats->u32Threads));
|
---|
2160 |
|
---|
2161 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PROCESSES)
|
---|
2162 | Log(("CPU%d: Processes %d\n", pGuestStats->u32CpuId, pGuestStats->u32Processes));
|
---|
2163 |
|
---|
2164 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_HANDLES)
|
---|
2165 | Log(("CPU%d: Handles %d\n", pGuestStats->u32CpuId, pGuestStats->u32Handles));
|
---|
2166 |
|
---|
2167 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEMORY_LOAD)
|
---|
2168 | Log(("CPU%d: Memory Load %d%%\n", pGuestStats->u32CpuId, pGuestStats->u32MemoryLoad));
|
---|
2169 |
|
---|
2170 | /* Note that reported values are in pages; upper layers expect them in megabytes */
|
---|
2171 | Log(("CPU%d: Page size %-4d bytes\n", pGuestStats->u32CpuId, pGuestStats->u32PageSize));
|
---|
2172 | Assert(pGuestStats->u32PageSize == 4096);
|
---|
2173 |
|
---|
2174 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_TOTAL)
|
---|
2175 | Log(("CPU%d: Total physical memory %-4d MB\n", pGuestStats->u32CpuId, (pGuestStats->u32PhysMemTotal + (_1M/_4K)-1) / (_1M/_4K)));
|
---|
2176 |
|
---|
2177 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_AVAIL)
|
---|
2178 | Log(("CPU%d: Free physical memory %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32PhysMemAvail / (_1M/_4K)));
|
---|
2179 |
|
---|
2180 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_BALLOON)
|
---|
2181 | Log(("CPU%d: Memory balloon size %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32PhysMemBalloon / (_1M/_4K)));
|
---|
2182 |
|
---|
2183 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_COMMIT_TOTAL)
|
---|
2184 | Log(("CPU%d: Committed memory %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32MemCommitTotal / (_1M/_4K)));
|
---|
2185 |
|
---|
2186 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_KERNEL_TOTAL)
|
---|
2187 | Log(("CPU%d: Total kernel memory %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32MemKernelTotal / (_1M/_4K)));
|
---|
2188 |
|
---|
2189 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_KERNEL_PAGED)
|
---|
2190 | Log(("CPU%d: Paged kernel memory %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32MemKernelPaged / (_1M/_4K)));
|
---|
2191 |
|
---|
2192 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_KERNEL_NONPAGED)
|
---|
2193 | Log(("CPU%d: Nonpaged kernel memory %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32MemKernelNonPaged / (_1M/_4K)));
|
---|
2194 |
|
---|
2195 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_SYSTEM_CACHE)
|
---|
2196 | Log(("CPU%d: System cache size %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32MemSystemCache / (_1M/_4K)));
|
---|
2197 |
|
---|
2198 | if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PAGE_FILE_SIZE)
|
---|
2199 | Log(("CPU%d: Page file size %-4d MB\n", pGuestStats->u32CpuId, pGuestStats->u32PageFileSize / (_1M/_4K)));
|
---|
2200 | Log(("Statistics end *******************\n"));
|
---|
2201 | #endif
|
---|
2202 |
|
---|
2203 | /* forward the call */
|
---|
2204 | pRequestHeader->rc = pThis->pDrv->pfnReportStatistics(pThis->pDrv, &stats->guestStats);
|
---|
2205 | }
|
---|
2206 | break;
|
---|
2207 | }
|
---|
2208 |
|
---|
2209 | case VMMDevReq_QueryCredentials:
|
---|
2210 | {
|
---|
2211 | if (pRequestHeader->size != sizeof(VMMDevCredentials))
|
---|
2212 | {
|
---|
2213 | AssertMsgFailed(("VMMDevReq_QueryCredentials request size too small.\n"));
|
---|
2214 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
2215 | }
|
---|
2216 | else
|
---|
2217 | {
|
---|
2218 | VMMDevCredentials *credentials = (VMMDevCredentials*)pRequestHeader;
|
---|
2219 |
|
---|
2220 | /* let's start by nulling out the data */
|
---|
2221 | memset(credentials->szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2222 | memset(credentials->szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2223 | memset(credentials->szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2224 |
|
---|
2225 | /* should we return whether we got credentials for a logon? */
|
---|
2226 | if (credentials->u32Flags & VMMDEV_CREDENTIALS_QUERYPRESENCE)
|
---|
2227 | {
|
---|
2228 | if ( pThis->pCredentials->Logon.szUserName[0]
|
---|
2229 | || pThis->pCredentials->Logon.szPassword[0]
|
---|
2230 | || pThis->pCredentials->Logon.szDomain[0])
|
---|
2231 | {
|
---|
2232 | credentials->u32Flags |= VMMDEV_CREDENTIALS_PRESENT;
|
---|
2233 | }
|
---|
2234 | else
|
---|
2235 | {
|
---|
2236 | credentials->u32Flags &= ~VMMDEV_CREDENTIALS_PRESENT;
|
---|
2237 | }
|
---|
2238 | }
|
---|
2239 |
|
---|
2240 | /* does the guest want to read logon credentials? */
|
---|
2241 | if (credentials->u32Flags & VMMDEV_CREDENTIALS_READ)
|
---|
2242 | {
|
---|
2243 | if (pThis->pCredentials->Logon.szUserName[0])
|
---|
2244 | strcpy(credentials->szUserName, pThis->pCredentials->Logon.szUserName);
|
---|
2245 | if (pThis->pCredentials->Logon.szPassword[0])
|
---|
2246 | strcpy(credentials->szPassword, pThis->pCredentials->Logon.szPassword);
|
---|
2247 | if (pThis->pCredentials->Logon.szDomain[0])
|
---|
2248 | strcpy(credentials->szDomain, pThis->pCredentials->Logon.szDomain);
|
---|
2249 | if (!pThis->pCredentials->Logon.fAllowInteractiveLogon)
|
---|
2250 | credentials->u32Flags |= VMMDEV_CREDENTIALS_NOLOCALLOGON;
|
---|
2251 | else
|
---|
2252 | credentials->u32Flags &= ~VMMDEV_CREDENTIALS_NOLOCALLOGON;
|
---|
2253 | }
|
---|
2254 |
|
---|
2255 | if (!pThis->fKeepCredentials)
|
---|
2256 | {
|
---|
2257 | /* does the caller want us to destroy the logon credentials? */
|
---|
2258 | if (credentials->u32Flags & VMMDEV_CREDENTIALS_CLEAR)
|
---|
2259 | {
|
---|
2260 | memset(pThis->pCredentials->Logon.szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2261 | memset(pThis->pCredentials->Logon.szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2262 | memset(pThis->pCredentials->Logon.szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2263 | }
|
---|
2264 | }
|
---|
2265 |
|
---|
2266 | /* does the guest want to read credentials for verification? */
|
---|
2267 | if (credentials->u32Flags & VMMDEV_CREDENTIALS_READJUDGE)
|
---|
2268 | {
|
---|
2269 | if (pThis->pCredentials->Judge.szUserName[0])
|
---|
2270 | strcpy(credentials->szUserName, pThis->pCredentials->Judge.szUserName);
|
---|
2271 | if (pThis->pCredentials->Judge.szPassword[0])
|
---|
2272 | strcpy(credentials->szPassword, pThis->pCredentials->Judge.szPassword);
|
---|
2273 | if (pThis->pCredentials->Judge.szDomain[0])
|
---|
2274 | strcpy(credentials->szDomain, pThis->pCredentials->Judge.szDomain);
|
---|
2275 | }
|
---|
2276 |
|
---|
2277 | /* does the caller want us to destroy the judgement credentials? */
|
---|
2278 | if (credentials->u32Flags & VMMDEV_CREDENTIALS_CLEARJUDGE)
|
---|
2279 | {
|
---|
2280 | memset(pThis->pCredentials->Judge.szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2281 | memset(pThis->pCredentials->Judge.szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2282 | memset(pThis->pCredentials->Judge.szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
2283 | }
|
---|
2284 |
|
---|
2285 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
2286 | }
|
---|
2287 | break;
|
---|
2288 | }
|
---|
2289 |
|
---|
2290 | case VMMDevReq_ReportCredentialsJudgement:
|
---|
2291 | {
|
---|
2292 | if (pRequestHeader->size != sizeof(VMMDevCredentials))
|
---|
2293 | {
|
---|
2294 | AssertMsgFailed(("VMMDevReq_ReportCredentialsJudgement request size too small.\n"));
|
---|
2295 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
2296 | }
|
---|
2297 | else
|
---|
2298 | {
|
---|
2299 | VMMDevCredentials *credentials = (VMMDevCredentials*)pRequestHeader;
|
---|
2300 |
|
---|
2301 | /* what does the guest think about the credentials? (note: the order is important here!) */
|
---|
2302 | if (credentials->u32Flags & VMMDEV_CREDENTIALS_JUDGE_DENY)
|
---|
2303 | {
|
---|
2304 | pThis->pDrv->pfnSetCredentialsJudgementResult(pThis->pDrv, VMMDEV_CREDENTIALS_JUDGE_DENY);
|
---|
2305 | }
|
---|
2306 | else if (credentials->u32Flags & VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT)
|
---|
2307 | {
|
---|
2308 | pThis->pDrv->pfnSetCredentialsJudgementResult(pThis->pDrv, VMMDEV_CREDENTIALS_JUDGE_NOJUDGEMENT);
|
---|
2309 | }
|
---|
2310 | else if (credentials->u32Flags & VMMDEV_CREDENTIALS_JUDGE_OK)
|
---|
2311 | {
|
---|
2312 | pThis->pDrv->pfnSetCredentialsJudgementResult(pThis->pDrv, VMMDEV_CREDENTIALS_JUDGE_OK);
|
---|
2313 | }
|
---|
2314 | else
|
---|
2315 | Log(("VMMDevReq_ReportCredentialsJudgement: invalid flags: %d!!!\n", credentials->u32Flags));
|
---|
2316 |
|
---|
2317 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
2318 | }
|
---|
2319 | break;
|
---|
2320 | }
|
---|
2321 |
|
---|
2322 | /*
|
---|
2323 | * Implemented in 3.1.0.
|
---|
2324 | *
|
---|
2325 | * Note! The ring-0 VBoxGuestLib uses this to check whether
|
---|
2326 | * VMMDevHGCMParmType_PageList is supported.
|
---|
2327 | */
|
---|
2328 | case VMMDevReq_GetHostVersion:
|
---|
2329 | {
|
---|
2330 | AssertMsgBreakStmt(pRequestHeader->size == sizeof(VMMDevReqHostVersion),
|
---|
2331 | ("%#x < %#x\n", pRequestHeader->size, sizeof(VMMDevReqLogString)),
|
---|
2332 | pRequestHeader->rc = VERR_INVALID_PARAMETER);
|
---|
2333 | VMMDevReqHostVersion *pReqHostVer = (VMMDevReqHostVersion*)pRequestHeader;
|
---|
2334 | pReqHostVer->major = RTBldCfgVersionMajor();
|
---|
2335 | pReqHostVer->minor = RTBldCfgVersionMinor();
|
---|
2336 | pReqHostVer->build = RTBldCfgVersionBuild();
|
---|
2337 | pReqHostVer->revision = RTBldCfgRevision();
|
---|
2338 | pReqHostVer->features = VMMDEV_HVF_HGCM_PHYS_PAGE_LIST;
|
---|
2339 | pReqHostVer->header.rc = VINF_SUCCESS;
|
---|
2340 | break;
|
---|
2341 | }
|
---|
2342 |
|
---|
2343 | case VMMDevReq_GetCpuHotPlugRequest:
|
---|
2344 | {
|
---|
2345 | VMMDevGetCpuHotPlugRequest *pReqCpuHotPlug = (VMMDevGetCpuHotPlugRequest *)pRequestHeader;
|
---|
2346 |
|
---|
2347 | if (pRequestHeader->size != sizeof(VMMDevGetCpuHotPlugRequest))
|
---|
2348 | {
|
---|
2349 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
2350 | }
|
---|
2351 | else
|
---|
2352 | {
|
---|
2353 | pReqCpuHotPlug->enmEventType = pThis->enmCpuHotPlugEvent;
|
---|
2354 | pReqCpuHotPlug->idCpuCore = pThis->idCpuCore;
|
---|
2355 | pReqCpuHotPlug->idCpuPackage = pThis->idCpuPackage;
|
---|
2356 | pReqCpuHotPlug->header.rc = VINF_SUCCESS;
|
---|
2357 |
|
---|
2358 | /* Clear the event */
|
---|
2359 | pThis->enmCpuHotPlugEvent = VMMDevCpuEventType_None;
|
---|
2360 | pThis->idCpuCore = UINT32_MAX;
|
---|
2361 | pThis->idCpuPackage = UINT32_MAX;
|
---|
2362 | }
|
---|
2363 | break;
|
---|
2364 | }
|
---|
2365 |
|
---|
2366 | case VMMDevReq_SetCpuHotPlugStatus:
|
---|
2367 | {
|
---|
2368 | VMMDevCpuHotPlugStatusRequest *pReqCpuHotPlugStatus = (VMMDevCpuHotPlugStatusRequest *)pRequestHeader;
|
---|
2369 |
|
---|
2370 | if (pRequestHeader->size != sizeof(VMMDevCpuHotPlugStatusRequest))
|
---|
2371 | {
|
---|
2372 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
2373 | }
|
---|
2374 | else
|
---|
2375 | {
|
---|
2376 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
2377 |
|
---|
2378 | if (pReqCpuHotPlugStatus->enmStatusType == VMMDevCpuStatusType_Disable)
|
---|
2379 | pThis->fCpuHotPlugEventsEnabled = false;
|
---|
2380 | else if (pReqCpuHotPlugStatus->enmStatusType == VMMDevCpuStatusType_Enable)
|
---|
2381 | pThis->fCpuHotPlugEventsEnabled = true;
|
---|
2382 | else
|
---|
2383 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
2384 | }
|
---|
2385 | break;
|
---|
2386 | }
|
---|
2387 |
|
---|
2388 | #ifdef VBOX_WITH_PAGE_SHARING
|
---|
2389 | case VMMDevReq_RegisterSharedModule:
|
---|
2390 | pRequestHeader->rc = vmmdevReqHandler_RegisterSharedModule(pDevIns,
|
---|
2391 | (VMMDevSharedModuleRegistrationRequest *)pRequestHeader);
|
---|
2392 | break;
|
---|
2393 |
|
---|
2394 | case VMMDevReq_UnregisterSharedModule:
|
---|
2395 | pRequestHeader->rc = vmmdevReqHandler_UnregisterSharedModule(pDevIns,
|
---|
2396 | (VMMDevSharedModuleUnregistrationRequest *)pRequestHeader);
|
---|
2397 | break;
|
---|
2398 |
|
---|
2399 | case VMMDevReq_CheckSharedModules:
|
---|
2400 | pRequestHeader->rc = vmmdevReqHandler_CheckSharedModules(pDevIns,
|
---|
2401 | (VMMDevSharedModuleCheckRequest *)pRequestHeader);
|
---|
2402 | break;
|
---|
2403 |
|
---|
2404 | case VMMDevReq_GetPageSharingStatus:
|
---|
2405 | pRequestHeader->rc = vmmdevReqHandler_GetPageSharingStatus(pThis,
|
---|
2406 | (VMMDevPageSharingStatusRequest *)pRequestHeader);
|
---|
2407 | break;
|
---|
2408 |
|
---|
2409 | case VMMDevReq_DebugIsPageShared:
|
---|
2410 | pRequestHeader->rc = vmmdevReqHandler_DebugIsPageShared(pDevIns, (VMMDevPageIsSharedRequest *)pRequestHeader);
|
---|
2411 | break;
|
---|
2412 |
|
---|
2413 | #endif /* VBOX_WITH_PAGE_SHARING */
|
---|
2414 |
|
---|
2415 | #ifdef DEBUG
|
---|
2416 | case VMMDevReq_LogString:
|
---|
2417 | {
|
---|
2418 | if (pRequestHeader->size < sizeof(VMMDevReqLogString))
|
---|
2419 | {
|
---|
2420 | AssertMsgFailed(("VMMDevReq_LogString request size too small.\n"));
|
---|
2421 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
2422 | }
|
---|
2423 | else
|
---|
2424 | {
|
---|
2425 | VMMDevReqLogString *pReqLogString = (VMMDevReqLogString *)pRequestHeader;
|
---|
2426 | LogIt(LOG_INSTANCE, RTLOGGRPFLAGS_LEVEL_1, LOG_GROUP_DEV_VMM_BACKDOOR,
|
---|
2427 | ("DEBUG LOG: %s", pReqLogString->szString));
|
---|
2428 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
2429 | }
|
---|
2430 | break;
|
---|
2431 | }
|
---|
2432 | #endif
|
---|
2433 |
|
---|
2434 | /*
|
---|
2435 | * Get a unique session id for this VM; the id will be different after each start, reset or restore of the VM
|
---|
2436 | * This can be used for restore detection inside the guest.
|
---|
2437 | */
|
---|
2438 | case VMMDevReq_GetSessionId:
|
---|
2439 | {
|
---|
2440 | if (pRequestHeader->size != sizeof(VMMDevReqSessionId))
|
---|
2441 | {
|
---|
2442 | AssertMsgFailed(("VMMDevReq_GetSessionId request size too small.\n"));
|
---|
2443 | pRequestHeader->rc = VERR_INVALID_PARAMETER;
|
---|
2444 | }
|
---|
2445 | else
|
---|
2446 | {
|
---|
2447 | VMMDevReqSessionId *pReq = (VMMDevReqSessionId *)pRequestHeader;
|
---|
2448 | pReq->idSession = pThis->idSession;
|
---|
2449 | pRequestHeader->rc = VINF_SUCCESS;
|
---|
2450 | }
|
---|
2451 | break;
|
---|
2452 | }
|
---|
2453 |
|
---|
2454 | default:
|
---|
2455 | {
|
---|
2456 | pRequestHeader->rc = VERR_NOT_IMPLEMENTED;
|
---|
2457 | Log(("VMMDev unknown request type %d\n", pRequestHeader->requestType));
|
---|
2458 | break;
|
---|
2459 | }
|
---|
2460 | }
|
---|
2461 |
|
---|
2462 | l_end:
|
---|
2463 | /* Write the result back to guest memory */
|
---|
2464 | if (pRequestHeader)
|
---|
2465 | {
|
---|
2466 | PDMDevHlpPhysWrite(pDevIns, (RTGCPHYS)u32, pRequestHeader, pRequestHeader->size);
|
---|
2467 | RTMemFree(pRequestHeader);
|
---|
2468 | }
|
---|
2469 | else
|
---|
2470 | {
|
---|
2471 | /* early error case; write back header only */
|
---|
2472 | PDMDevHlpPhysWrite(pDevIns, (RTGCPHYS)u32, &requestHeader, sizeof(requestHeader));
|
---|
2473 | }
|
---|
2474 |
|
---|
2475 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2476 | return rcRet;
|
---|
2477 | }
|
---|
2478 |
|
---|
2479 | /**
|
---|
2480 | * Callback function for mapping an PCI I/O region.
|
---|
2481 | *
|
---|
2482 | * @return VBox status code.
|
---|
2483 | * @param pPciDev Pointer to PCI device. Use pPciDev->pDevIns to get the device instance.
|
---|
2484 | * @param iRegion The region number.
|
---|
2485 | * @param GCPhysAddress Physical address of the region. If iType is PCI_ADDRESS_SPACE_IO, this is an
|
---|
2486 | * I/O port, else it's a physical address.
|
---|
2487 | * This address is *NOT* relative to pci_mem_base like earlier!
|
---|
2488 | * @param enmType One of the PCI_ADDRESS_SPACE_* values.
|
---|
2489 | */
|
---|
2490 | static DECLCALLBACK(int) vmmdevIORAMRegionMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
|
---|
2491 | {
|
---|
2492 | LogFlow(("vmmdevR3IORAMRegionMap: iRegion=%d GCPhysAddress=%RGp cb=%#x enmType=%d\n", iRegion, GCPhysAddress, cb, enmType));
|
---|
2493 | VMMDevState *pThis = PCIDEV_2_VMMDEVSTATE(pPciDev);
|
---|
2494 | int rc;
|
---|
2495 |
|
---|
2496 | if (iRegion == 1)
|
---|
2497 | {
|
---|
2498 | AssertReturn(enmType == PCI_ADDRESS_SPACE_MEM, VERR_INTERNAL_ERROR);
|
---|
2499 | Assert(pThis->pVMMDevRAMR3 != NULL);
|
---|
2500 | if (GCPhysAddress != NIL_RTGCPHYS)
|
---|
2501 | {
|
---|
2502 | /*
|
---|
2503 | * Map the MMIO2 memory.
|
---|
2504 | */
|
---|
2505 | pThis->GCPhysVMMDevRAM = GCPhysAddress;
|
---|
2506 | Assert(pThis->GCPhysVMMDevRAM == GCPhysAddress);
|
---|
2507 | rc = PDMDevHlpMMIO2Map(pPciDev->pDevIns, iRegion, GCPhysAddress);
|
---|
2508 | }
|
---|
2509 | else
|
---|
2510 | {
|
---|
2511 | /*
|
---|
2512 | * It is about to be unmapped, just clean up.
|
---|
2513 | */
|
---|
2514 | pThis->GCPhysVMMDevRAM = NIL_RTGCPHYS32;
|
---|
2515 | rc = VINF_SUCCESS;
|
---|
2516 | }
|
---|
2517 | }
|
---|
2518 | else if (iRegion == 2)
|
---|
2519 | {
|
---|
2520 | AssertReturn(enmType == PCI_ADDRESS_SPACE_MEM_PREFETCH, VERR_INTERNAL_ERROR);
|
---|
2521 | Assert(pThis->pVMMDevHeapR3 != NULL);
|
---|
2522 | if (GCPhysAddress != NIL_RTGCPHYS)
|
---|
2523 | {
|
---|
2524 | /*
|
---|
2525 | * Map the MMIO2 memory.
|
---|
2526 | */
|
---|
2527 | pThis->GCPhysVMMDevHeap = GCPhysAddress;
|
---|
2528 | Assert(pThis->GCPhysVMMDevHeap == GCPhysAddress);
|
---|
2529 | rc = PDMDevHlpMMIO2Map(pPciDev->pDevIns, iRegion, GCPhysAddress);
|
---|
2530 | if (RT_SUCCESS(rc))
|
---|
2531 | rc = PDMDevHlpRegisterVMMDevHeap(pPciDev->pDevIns, GCPhysAddress, pThis->pVMMDevHeapR3, VMMDEV_HEAP_SIZE);
|
---|
2532 | }
|
---|
2533 | else
|
---|
2534 | {
|
---|
2535 | /*
|
---|
2536 | * It is about to be unmapped, just clean up.
|
---|
2537 | */
|
---|
2538 | PDMDevHlpUnregisterVMMDevHeap(pPciDev->pDevIns, pThis->GCPhysVMMDevHeap);
|
---|
2539 | pThis->GCPhysVMMDevHeap = NIL_RTGCPHYS32;
|
---|
2540 | rc = VINF_SUCCESS;
|
---|
2541 | }
|
---|
2542 | }
|
---|
2543 | else
|
---|
2544 | {
|
---|
2545 | AssertMsgFailed(("%d\n", iRegion));
|
---|
2546 | rc = VERR_INVALID_PARAMETER;
|
---|
2547 | }
|
---|
2548 |
|
---|
2549 | return rc;
|
---|
2550 | }
|
---|
2551 |
|
---|
2552 |
|
---|
2553 | /**
|
---|
2554 | * Callback function for mapping a PCI I/O region.
|
---|
2555 | *
|
---|
2556 | * @return VBox status code.
|
---|
2557 | * @param pPciDev Pointer to PCI device. Use pPciDev->pDevIns to get the device instance.
|
---|
2558 | * @param iRegion The region number.
|
---|
2559 | * @param GCPhysAddress Physical address of the region. If iType is PCI_ADDRESS_SPACE_IO, this is an
|
---|
2560 | * I/O port, else it's a physical address.
|
---|
2561 | * This address is *NOT* relative to pci_mem_base like earlier!
|
---|
2562 | * @param enmType One of the PCI_ADDRESS_SPACE_* values.
|
---|
2563 | */
|
---|
2564 | static DECLCALLBACK(int) vmmdevIOPortRegionMap(PPCIDEVICE pPciDev, /*unsigned*/ int iRegion, RTGCPHYS GCPhysAddress, uint32_t cb, PCIADDRESSSPACE enmType)
|
---|
2565 | {
|
---|
2566 | VMMDevState *pThis = PCIDEV_2_VMMDEVSTATE(pPciDev);
|
---|
2567 | int rc = VINF_SUCCESS;
|
---|
2568 |
|
---|
2569 | Assert(enmType == PCI_ADDRESS_SPACE_IO);
|
---|
2570 | Assert(iRegion == 0);
|
---|
2571 | AssertMsg(RT_ALIGN(GCPhysAddress, 8) == GCPhysAddress, ("Expected 8 byte alignment. GCPhysAddress=%#x\n", GCPhysAddress));
|
---|
2572 |
|
---|
2573 | /*
|
---|
2574 | * Save the base port address to simplify Port offset calculations.
|
---|
2575 | */
|
---|
2576 | pThis->PortBase = (RTIOPORT)GCPhysAddress;
|
---|
2577 |
|
---|
2578 | /*
|
---|
2579 | * Register our port IO handlers.
|
---|
2580 | */
|
---|
2581 | rc = PDMDevHlpIOPortRegister(pPciDev->pDevIns,
|
---|
2582 | (RTIOPORT)GCPhysAddress + VMMDEV_PORT_OFF_REQUEST, 1,
|
---|
2583 | (void*)pThis, vmmdevRequestHandler,
|
---|
2584 | NULL, NULL, NULL, "VMMDev Request Handler");
|
---|
2585 | AssertRC(rc);
|
---|
2586 | return rc;
|
---|
2587 | }
|
---|
2588 |
|
---|
2589 | /**
|
---|
2590 | * @interface_method_impl{PDMIBASE,pfnQueryInterface}
|
---|
2591 | */
|
---|
2592 | static DECLCALLBACK(void *) vmmdevPortQueryInterface(PPDMIBASE pInterface, const char *pszIID)
|
---|
2593 | {
|
---|
2594 | VMMDevState *pThis = RT_FROM_MEMBER(pInterface, VMMDevState, IBase);
|
---|
2595 |
|
---|
2596 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIBASE, &pThis->IBase);
|
---|
2597 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIVMMDEVPORT, &pThis->IPort);
|
---|
2598 | #ifdef VBOX_WITH_HGCM
|
---|
2599 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMIHGCMPORT, &pThis->IHGCMPort);
|
---|
2600 | #endif
|
---|
2601 | /* Currently only for shared folders. */
|
---|
2602 | PDMIBASE_RETURN_INTERFACE(pszIID, PDMILEDPORTS, &pThis->SharedFolders.ILeds);
|
---|
2603 | return NULL;
|
---|
2604 | }
|
---|
2605 |
|
---|
2606 | /**
|
---|
2607 | * Gets the pointer to the status LED of a unit.
|
---|
2608 | *
|
---|
2609 | * @returns VBox status code.
|
---|
2610 | * @param pInterface Pointer to the interface structure containing the called function pointer.
|
---|
2611 | * @param iLUN The unit which status LED we desire.
|
---|
2612 | * @param ppLed Where to store the LED pointer.
|
---|
2613 | */
|
---|
2614 | static DECLCALLBACK(int) vmmdevQueryStatusLed(PPDMILEDPORTS pInterface, unsigned iLUN, PPDMLED *ppLed)
|
---|
2615 | {
|
---|
2616 | VMMDevState *pThis = (VMMDevState *)( (uintptr_t)pInterface - RT_OFFSETOF(VMMDevState, SharedFolders.ILeds) );
|
---|
2617 | if (iLUN == 0) /* LUN 0 is shared folders */
|
---|
2618 | {
|
---|
2619 | *ppLed = &pThis->SharedFolders.Led;
|
---|
2620 | return VINF_SUCCESS;
|
---|
2621 | }
|
---|
2622 | return VERR_PDM_LUN_NOT_FOUND;
|
---|
2623 | }
|
---|
2624 |
|
---|
2625 | /* -=-=-=-=-=- IVMMDevPort -=-=-=-=-=- */
|
---|
2626 |
|
---|
2627 | /** Converts a VMMDev port interface pointer to a VMMDev state pointer. */
|
---|
2628 | #define IVMMDEVPORT_2_VMMDEVSTATE(pInterface) ( (VMMDevState*)((uintptr_t)pInterface - RT_OFFSETOF(VMMDevState, IPort)) )
|
---|
2629 |
|
---|
2630 |
|
---|
2631 | /**
|
---|
2632 | * Return the current absolute mouse position in pixels
|
---|
2633 | *
|
---|
2634 | * @returns VBox status code
|
---|
2635 | * @param pAbsX Pointer of result value, can be NULL
|
---|
2636 | * @param pAbsY Pointer of result value, can be NULL
|
---|
2637 | */
|
---|
2638 | static DECLCALLBACK(int) vmmdevQueryAbsoluteMouse(PPDMIVMMDEVPORT pInterface, int32_t *pAbsX, int32_t *pAbsY)
|
---|
2639 | {
|
---|
2640 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2641 | if (pAbsX)
|
---|
2642 | *pAbsX = ASMAtomicReadS32(&pThis->mouseXAbs); /* why the atomic read? */
|
---|
2643 | if (pAbsY)
|
---|
2644 | *pAbsY = ASMAtomicReadS32(&pThis->mouseYAbs);
|
---|
2645 | return VINF_SUCCESS;
|
---|
2646 | }
|
---|
2647 |
|
---|
2648 | /**
|
---|
2649 | * Set the new absolute mouse position in pixels
|
---|
2650 | *
|
---|
2651 | * @returns VBox status code
|
---|
2652 | * @param absX New absolute X position
|
---|
2653 | * @param absY New absolute Y position
|
---|
2654 | */
|
---|
2655 | static DECLCALLBACK(int) vmmdevSetAbsoluteMouse(PPDMIVMMDEVPORT pInterface, int32_t absX, int32_t absY)
|
---|
2656 | {
|
---|
2657 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2658 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
2659 |
|
---|
2660 | if (pThis->mouseXAbs == absX && pThis->mouseYAbs == absY)
|
---|
2661 | {
|
---|
2662 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2663 | return VINF_SUCCESS;
|
---|
2664 | }
|
---|
2665 | Log2(("vmmdevSetAbsoluteMouse: settings absolute position to x = %d, y = %d\n", absX, absY));
|
---|
2666 | pThis->mouseXAbs = absX;
|
---|
2667 | pThis->mouseYAbs = absY;
|
---|
2668 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_MOUSE_POSITION_CHANGED);
|
---|
2669 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2670 | return VINF_SUCCESS;
|
---|
2671 | }
|
---|
2672 |
|
---|
2673 | /**
|
---|
2674 | * Return the current mouse capability flags
|
---|
2675 | *
|
---|
2676 | * @returns VBox status code
|
---|
2677 | * @param pCapabilities Pointer of result value
|
---|
2678 | */
|
---|
2679 | static DECLCALLBACK(int) vmmdevQueryMouseCapabilities(PPDMIVMMDEVPORT pInterface, uint32_t *pfCaps)
|
---|
2680 | {
|
---|
2681 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2682 | if (!pfCaps)
|
---|
2683 | return VERR_INVALID_PARAMETER;
|
---|
2684 | *pfCaps = pThis->mouseCapabilities;
|
---|
2685 | return VINF_SUCCESS;
|
---|
2686 | }
|
---|
2687 |
|
---|
2688 | /**
|
---|
2689 | * Set the current mouse capability flag (host side)
|
---|
2690 | *
|
---|
2691 | * @returns VBox status code
|
---|
2692 | * @param capabilities Capability mask
|
---|
2693 | */
|
---|
2694 | static DECLCALLBACK(int) vmmdevUpdateMouseCapabilities(PPDMIVMMDEVPORT pInterface, uint32_t fCapsAdded, uint32_t fCapsRemoved)
|
---|
2695 | {
|
---|
2696 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2697 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
2698 |
|
---|
2699 | uint32_t fOldCaps = pThis->mouseCapabilities;
|
---|
2700 | pThis->mouseCapabilities &= ~(fCapsRemoved & VMMDEV_MOUSE_HOST_MASK);
|
---|
2701 | pThis->mouseCapabilities |= (fCapsAdded & VMMDEV_MOUSE_HOST_MASK)
|
---|
2702 | | VMMDEV_MOUSE_HOST_RECHECKS_NEEDS_HOST_CURSOR;
|
---|
2703 | bool fNotify = fOldCaps != pThis->mouseCapabilities;
|
---|
2704 |
|
---|
2705 | LogRelFlowFunc(("fCapsAdded=0x%x, fCapsRemoved=0x%x, fNotify %s\n",
|
---|
2706 | fCapsAdded, fCapsRemoved, fNotify ? "TRUE" : "FALSE"));
|
---|
2707 |
|
---|
2708 | if (fNotify)
|
---|
2709 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_MOUSE_CAPABILITIES_CHANGED);
|
---|
2710 |
|
---|
2711 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2712 | return VINF_SUCCESS;
|
---|
2713 | }
|
---|
2714 |
|
---|
2715 |
|
---|
2716 | static DECLCALLBACK(int) vmmdevRequestDisplayChange(PPDMIVMMDEVPORT pInterface, uint32_t xres, uint32_t yres,
|
---|
2717 | uint32_t bpp, uint32_t display, uint32_t u32OriginX,
|
---|
2718 | uint32_t u32OriginY, bool fEnabled, bool fChangeOrigin)
|
---|
2719 | {
|
---|
2720 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2721 |
|
---|
2722 | if (display >= RT_ELEMENTS(pThis->displayChangeData.aRequests))
|
---|
2723 | {
|
---|
2724 | return VERR_INVALID_PARAMETER;
|
---|
2725 | }
|
---|
2726 |
|
---|
2727 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
2728 |
|
---|
2729 | DISPLAYCHANGEREQUEST *pRequest = &pThis->displayChangeData.aRequests[display];
|
---|
2730 |
|
---|
2731 | /* Verify that the new resolution is different and that guest does not yet know about it. */
|
---|
2732 | bool fSameResolution = (!xres || (pRequest->lastReadDisplayChangeRequest.xres == xres)) &&
|
---|
2733 | (!yres || (pRequest->lastReadDisplayChangeRequest.yres == yres)) &&
|
---|
2734 | (!bpp || (pRequest->lastReadDisplayChangeRequest.bpp == bpp)) &&
|
---|
2735 | (pRequest->lastReadDisplayChangeRequest.xOrigin == u32OriginX) &&
|
---|
2736 | (pRequest->lastReadDisplayChangeRequest.yOrigin == u32OriginY) &&
|
---|
2737 | (pRequest->lastReadDisplayChangeRequest.fEnabled == fEnabled) &&
|
---|
2738 | pRequest->lastReadDisplayChangeRequest.display == display;
|
---|
2739 |
|
---|
2740 | if (!xres && !yres && !bpp)
|
---|
2741 | {
|
---|
2742 | /* Special case of reset video mode. */
|
---|
2743 | fSameResolution = false;
|
---|
2744 | }
|
---|
2745 |
|
---|
2746 | Log3(("vmmdevRequestDisplayChange: same=%d. new: xres=%d, yres=%d, bpp=%d, display=%d.\
|
---|
2747 | old: xres=%d, yres=%d, bpp=%d, display=%d. \n \
|
---|
2748 | ,OriginX = %d , OriginY=%d, Enabled=%d, ChangeOrigin=%d\n",
|
---|
2749 | fSameResolution, xres, yres, bpp, display, pRequest->lastReadDisplayChangeRequest.xres,
|
---|
2750 | pRequest->lastReadDisplayChangeRequest.yres, pRequest->lastReadDisplayChangeRequest.bpp,
|
---|
2751 | pRequest->lastReadDisplayChangeRequest.display,
|
---|
2752 | u32OriginX, u32OriginY, fEnabled, fChangeOrigin));
|
---|
2753 |
|
---|
2754 | if (!fSameResolution)
|
---|
2755 | {
|
---|
2756 | LogRel(("VMMDev::SetVideoModeHint: got a video mode hint (%dx%dx%d) at %d\n",
|
---|
2757 | xres, yres, bpp, display));
|
---|
2758 |
|
---|
2759 | /* we could validate the information here but hey, the guest can do that as well! */
|
---|
2760 | pRequest->displayChangeRequest.xres = xres;
|
---|
2761 | pRequest->displayChangeRequest.yres = yres;
|
---|
2762 | pRequest->displayChangeRequest.bpp = bpp;
|
---|
2763 | pRequest->displayChangeRequest.display = display;
|
---|
2764 | pRequest->displayChangeRequest.xOrigin = u32OriginX;
|
---|
2765 | pRequest->displayChangeRequest.yOrigin = u32OriginY;
|
---|
2766 | pRequest->displayChangeRequest.fEnabled = fEnabled;
|
---|
2767 | pRequest->displayChangeRequest.fChangeOrigin = fChangeOrigin;
|
---|
2768 |
|
---|
2769 | pRequest->fPending = true;
|
---|
2770 |
|
---|
2771 | /* IRQ so the guest knows what's going on */
|
---|
2772 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST);
|
---|
2773 | }
|
---|
2774 |
|
---|
2775 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2776 | return VINF_SUCCESS;
|
---|
2777 | }
|
---|
2778 |
|
---|
2779 | static DECLCALLBACK(int) vmmdevRequestSeamlessChange(PPDMIVMMDEVPORT pInterface, bool fEnabled)
|
---|
2780 | {
|
---|
2781 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2782 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
2783 |
|
---|
2784 | /* Verify that the new resolution is different and that guest does not yet know about it. */
|
---|
2785 | bool fSameMode = (pThis->fLastSeamlessEnabled == fEnabled);
|
---|
2786 |
|
---|
2787 | Log(("vmmdevRequestSeamlessChange: same=%d. new=%d\n", fSameMode, fEnabled));
|
---|
2788 |
|
---|
2789 | if (!fSameMode)
|
---|
2790 | {
|
---|
2791 | /* we could validate the information here but hey, the guest can do that as well! */
|
---|
2792 | pThis->fSeamlessEnabled = fEnabled;
|
---|
2793 |
|
---|
2794 | /* IRQ so the guest knows what's going on */
|
---|
2795 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_SEAMLESS_MODE_CHANGE_REQUEST);
|
---|
2796 | }
|
---|
2797 |
|
---|
2798 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2799 | return VINF_SUCCESS;
|
---|
2800 | }
|
---|
2801 |
|
---|
2802 | static DECLCALLBACK(int) vmmdevSetMemoryBalloon(PPDMIVMMDEVPORT pInterface, uint32_t ulBalloonSize)
|
---|
2803 | {
|
---|
2804 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2805 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
2806 |
|
---|
2807 | /* Verify that the new resolution is different and that guest does not yet know about it. */
|
---|
2808 | bool fSame = (pThis->u32LastMemoryBalloonSize == ulBalloonSize);
|
---|
2809 |
|
---|
2810 | Log(("vmmdevSetMemoryBalloon: old=%d. new=%d\n", pThis->u32LastMemoryBalloonSize, ulBalloonSize));
|
---|
2811 |
|
---|
2812 | if (!fSame)
|
---|
2813 | {
|
---|
2814 | /* we could validate the information here but hey, the guest can do that as well! */
|
---|
2815 | pThis->u32MemoryBalloonSize = ulBalloonSize;
|
---|
2816 |
|
---|
2817 | /* IRQ so the guest knows what's going on */
|
---|
2818 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_BALLOON_CHANGE_REQUEST);
|
---|
2819 | }
|
---|
2820 |
|
---|
2821 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2822 | return VINF_SUCCESS;
|
---|
2823 | }
|
---|
2824 |
|
---|
2825 | static DECLCALLBACK(int) vmmdevVRDPChange(PPDMIVMMDEVPORT pInterface, bool fVRDPEnabled, uint32_t u32VRDPExperienceLevel)
|
---|
2826 | {
|
---|
2827 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2828 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
2829 |
|
---|
2830 | bool fSame = (pThis->fVRDPEnabled == fVRDPEnabled);
|
---|
2831 |
|
---|
2832 | Log(("vmmdevVRDPChange: old=%d. new=%d\n", pThis->fVRDPEnabled, fVRDPEnabled));
|
---|
2833 |
|
---|
2834 | if (!fSame)
|
---|
2835 | {
|
---|
2836 | pThis->fVRDPEnabled = fVRDPEnabled;
|
---|
2837 | pThis->u32VRDPExperienceLevel = u32VRDPExperienceLevel;
|
---|
2838 |
|
---|
2839 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_VRDP);
|
---|
2840 | }
|
---|
2841 |
|
---|
2842 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2843 | return VINF_SUCCESS;
|
---|
2844 | }
|
---|
2845 |
|
---|
2846 | static DECLCALLBACK(int) vmmdevSetStatisticsInterval(PPDMIVMMDEVPORT pInterface, uint32_t ulStatInterval)
|
---|
2847 | {
|
---|
2848 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2849 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
2850 |
|
---|
2851 | /* Verify that the new resolution is different and that guest does not yet know about it. */
|
---|
2852 | bool fSame = (pThis->u32LastStatIntervalSize == ulStatInterval);
|
---|
2853 |
|
---|
2854 | Log(("vmmdevSetStatisticsInterval: old=%d. new=%d\n", pThis->u32LastStatIntervalSize, ulStatInterval));
|
---|
2855 |
|
---|
2856 | if (!fSame)
|
---|
2857 | {
|
---|
2858 | /* we could validate the information here but hey, the guest can do that as well! */
|
---|
2859 | pThis->u32StatIntervalSize = ulStatInterval;
|
---|
2860 |
|
---|
2861 | /* IRQ so the guest knows what's going on */
|
---|
2862 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_STATISTICS_INTERVAL_CHANGE_REQUEST);
|
---|
2863 | }
|
---|
2864 |
|
---|
2865 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2866 | return VINF_SUCCESS;
|
---|
2867 | }
|
---|
2868 |
|
---|
2869 |
|
---|
2870 | static DECLCALLBACK(int) vmmdevSetCredentials(PPDMIVMMDEVPORT pInterface, const char *pszUsername,
|
---|
2871 | const char *pszPassword, const char *pszDomain,
|
---|
2872 | uint32_t u32Flags)
|
---|
2873 | {
|
---|
2874 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2875 | int rc = VINF_SUCCESS;
|
---|
2876 |
|
---|
2877 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
2878 |
|
---|
2879 | /* logon mode? */
|
---|
2880 | if (u32Flags & VMMDEV_SETCREDENTIALS_GUESTLOGON)
|
---|
2881 | {
|
---|
2882 | /* memorize the data */
|
---|
2883 | strcpy(pThis->pCredentials->Logon.szUserName, pszUsername);
|
---|
2884 | strcpy(pThis->pCredentials->Logon.szPassword, pszPassword);
|
---|
2885 | strcpy(pThis->pCredentials->Logon.szDomain, pszDomain);
|
---|
2886 | pThis->pCredentials->Logon.fAllowInteractiveLogon = !(u32Flags & VMMDEV_SETCREDENTIALS_NOLOCALLOGON);
|
---|
2887 | }
|
---|
2888 | /* credentials verification mode? */
|
---|
2889 | else if (u32Flags & VMMDEV_SETCREDENTIALS_JUDGE)
|
---|
2890 | {
|
---|
2891 | /* memorize the data */
|
---|
2892 | strcpy(pThis->pCredentials->Judge.szUserName, pszUsername);
|
---|
2893 | strcpy(pThis->pCredentials->Judge.szPassword, pszPassword);
|
---|
2894 | strcpy(pThis->pCredentials->Judge.szDomain, pszDomain);
|
---|
2895 |
|
---|
2896 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_JUDGE_CREDENTIALS);
|
---|
2897 | }
|
---|
2898 | else
|
---|
2899 | rc = VERR_INVALID_PARAMETER;
|
---|
2900 |
|
---|
2901 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2902 | return rc;
|
---|
2903 | }
|
---|
2904 |
|
---|
2905 | /**
|
---|
2906 | * Notification from the Display. Especially useful when
|
---|
2907 | * acceleration is disabled after a video mode change.
|
---|
2908 | *
|
---|
2909 | * @param fEnable Current acceleration status.
|
---|
2910 | */
|
---|
2911 | static DECLCALLBACK(void) vmmdevVBVAChange(PPDMIVMMDEVPORT pInterface, bool fEnabled)
|
---|
2912 | {
|
---|
2913 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2914 |
|
---|
2915 | Log(("vmmdevVBVAChange: fEnabled = %d\n", fEnabled));
|
---|
2916 |
|
---|
2917 | if (pThis)
|
---|
2918 | {
|
---|
2919 | pThis->u32VideoAccelEnabled = fEnabled;
|
---|
2920 | }
|
---|
2921 | return;
|
---|
2922 | }
|
---|
2923 |
|
---|
2924 | /**
|
---|
2925 | * Notification that a CPU is about to be unplugged from the VM.
|
---|
2926 | * The guest has to eject the CPU.
|
---|
2927 | *
|
---|
2928 | * @returns VBox status code.
|
---|
2929 | * @param idCpu The id of the CPU.
|
---|
2930 | * @param idCpuCore The core id of the CPU to remove.
|
---|
2931 | * @param idCpuPackage The package id of the CPU to remove.
|
---|
2932 | */
|
---|
2933 | static DECLCALLBACK(int) vmmdevCpuHotUnplug(PPDMIVMMDEVPORT pInterface, uint32_t idCpuCore, uint32_t idCpuPackage)
|
---|
2934 | {
|
---|
2935 | int rc = VINF_SUCCESS;
|
---|
2936 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2937 |
|
---|
2938 | Log(("vmmdevCpuHotUnplug: idCpuCore=%u idCpuPackage=%u\n", idCpuCore, idCpuPackage));
|
---|
2939 |
|
---|
2940 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
2941 |
|
---|
2942 | if (pThis->fCpuHotPlugEventsEnabled)
|
---|
2943 | {
|
---|
2944 | pThis->enmCpuHotPlugEvent = VMMDevCpuEventType_Unplug;
|
---|
2945 | pThis->idCpuCore = idCpuCore;
|
---|
2946 | pThis->idCpuPackage = idCpuPackage;
|
---|
2947 | VMMDevNotifyGuest (pThis, VMMDEV_EVENT_CPU_HOTPLUG);
|
---|
2948 | }
|
---|
2949 | else
|
---|
2950 | rc = VERR_CPU_HOTPLUG_NOT_MONITORED_BY_GUEST;
|
---|
2951 |
|
---|
2952 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2953 | return rc;
|
---|
2954 | }
|
---|
2955 |
|
---|
2956 | /**
|
---|
2957 | * Notification that a CPU was attached to the VM
|
---|
2958 | * The guest may use it now.
|
---|
2959 | *
|
---|
2960 | * @returns VBox status code.
|
---|
2961 | * @param idCpuCore The core id of the CPU to add.
|
---|
2962 | * @param idCpuPackage The package id of the CPU to add.
|
---|
2963 | */
|
---|
2964 | static DECLCALLBACK(int) vmmdevCpuHotPlug(PPDMIVMMDEVPORT pInterface, uint32_t idCpuCore, uint32_t idCpuPackage)
|
---|
2965 | {
|
---|
2966 | int rc = VINF_SUCCESS;
|
---|
2967 | VMMDevState *pThis = IVMMDEVPORT_2_VMMDEVSTATE(pInterface);
|
---|
2968 |
|
---|
2969 | Log(("vmmdevCpuPlug: idCpuCore=%u idCpuPackage=%u\n", idCpuCore, idCpuPackage));
|
---|
2970 |
|
---|
2971 | PDMCritSectEnter(&pThis->CritSect, VERR_SEM_BUSY);
|
---|
2972 |
|
---|
2973 | if (pThis->fCpuHotPlugEventsEnabled)
|
---|
2974 | {
|
---|
2975 | pThis->enmCpuHotPlugEvent = VMMDevCpuEventType_Plug;
|
---|
2976 | pThis->idCpuCore = idCpuCore;
|
---|
2977 | pThis->idCpuPackage = idCpuPackage;
|
---|
2978 | VMMDevNotifyGuest(pThis, VMMDEV_EVENT_CPU_HOTPLUG);
|
---|
2979 | }
|
---|
2980 | else
|
---|
2981 | rc = VERR_CPU_HOTPLUG_NOT_MONITORED_BY_GUEST;
|
---|
2982 |
|
---|
2983 | PDMCritSectLeave(&pThis->CritSect);
|
---|
2984 | return rc;
|
---|
2985 | }
|
---|
2986 |
|
---|
2987 | /* -=-=-=-=-=- Saved State -=-=-=-=-=- */
|
---|
2988 |
|
---|
2989 | /**
|
---|
2990 | * @copydoc FNSSMDEVLIVEEXEC
|
---|
2991 | */
|
---|
2992 | static DECLCALLBACK(int) vmmdevLiveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uPass)
|
---|
2993 | {
|
---|
2994 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState*);
|
---|
2995 |
|
---|
2996 | SSMR3PutBool(pSSM, pThis->fGetHostTimeDisabled);
|
---|
2997 | SSMR3PutBool(pSSM, pThis->fBackdoorLogDisabled);
|
---|
2998 | SSMR3PutBool(pSSM, pThis->fKeepCredentials);
|
---|
2999 | SSMR3PutBool(pSSM, pThis->fHeapEnabled);
|
---|
3000 |
|
---|
3001 | return VINF_SSM_DONT_CALL_AGAIN;
|
---|
3002 | }
|
---|
3003 |
|
---|
3004 |
|
---|
3005 | /**
|
---|
3006 | * @copydoc FNSSMDEVSAVEEXEC
|
---|
3007 | *
|
---|
3008 | */
|
---|
3009 | static DECLCALLBACK(int) vmmdevSaveExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
|
---|
3010 | {
|
---|
3011 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState*);
|
---|
3012 |
|
---|
3013 | vmmdevLiveExec(pDevIns, pSSM, SSM_PASS_FINAL);
|
---|
3014 |
|
---|
3015 | SSMR3PutU32(pSSM, pThis->hypervisorSize);
|
---|
3016 | SSMR3PutU32(pSSM, pThis->mouseCapabilities);
|
---|
3017 | SSMR3PutS32(pSSM, pThis->mouseXAbs);
|
---|
3018 | SSMR3PutS32(pSSM, pThis->mouseYAbs);
|
---|
3019 |
|
---|
3020 | SSMR3PutBool(pSSM, pThis->fNewGuestFilterMask);
|
---|
3021 | SSMR3PutU32(pSSM, pThis->u32NewGuestFilterMask);
|
---|
3022 | SSMR3PutU32(pSSM, pThis->u32GuestFilterMask);
|
---|
3023 | SSMR3PutU32(pSSM, pThis->u32HostEventFlags);
|
---|
3024 | /* The following is not strictly necessary as PGM restores MMIO2, keeping it for historical reasons. */
|
---|
3025 | SSMR3PutMem(pSSM, &pThis->pVMMDevRAMR3->V, sizeof(pThis->pVMMDevRAMR3->V));
|
---|
3026 |
|
---|
3027 | SSMR3PutMem(pSSM, &pThis->guestInfo, sizeof(pThis->guestInfo));
|
---|
3028 | SSMR3PutU32(pSSM, pThis->fu32AdditionsOk);
|
---|
3029 | SSMR3PutU32(pSSM, pThis->u32VideoAccelEnabled);
|
---|
3030 | SSMR3PutBool(pSSM, pThis->displayChangeData.fGuestSentChangeEventAck);
|
---|
3031 |
|
---|
3032 | SSMR3PutU32(pSSM, pThis->guestCaps);
|
---|
3033 |
|
---|
3034 | #ifdef VBOX_WITH_HGCM
|
---|
3035 | vmmdevHGCMSaveState(pThis, pSSM);
|
---|
3036 | #endif /* VBOX_WITH_HGCM */
|
---|
3037 |
|
---|
3038 | SSMR3PutU32(pSSM, pThis->fHostCursorRequested);
|
---|
3039 |
|
---|
3040 | SSMR3PutU32(pSSM, pThis->guestInfo2.uFullVersion);
|
---|
3041 | SSMR3PutU32(pSSM, pThis->guestInfo2.uRevision);
|
---|
3042 | SSMR3PutU32(pSSM, pThis->guestInfo2.fFeatures);
|
---|
3043 | SSMR3PutStrZ(pSSM, pThis->guestInfo2.szName);
|
---|
3044 | SSMR3PutU32(pSSM, pThis->cFacilityStatuses);
|
---|
3045 | for (uint32_t i = 0; i < pThis->cFacilityStatuses; i++)
|
---|
3046 | {
|
---|
3047 | SSMR3PutU32(pSSM, pThis->aFacilityStatuses[i].uFacility);
|
---|
3048 | SSMR3PutU32(pSSM, pThis->aFacilityStatuses[i].fFlags);
|
---|
3049 | SSMR3PutU16(pSSM, pThis->aFacilityStatuses[i].uStatus);
|
---|
3050 | SSMR3PutS64(pSSM, RTTimeSpecGetNano(&pThis->aFacilityStatuses[i].TimeSpecTS));
|
---|
3051 | }
|
---|
3052 |
|
---|
3053 | return VINF_SUCCESS;
|
---|
3054 | }
|
---|
3055 |
|
---|
3056 | /**
|
---|
3057 | * @copydoc FNSSMDEVLOADEXEC
|
---|
3058 | */
|
---|
3059 | static DECLCALLBACK(int) vmmdevLoadExec(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass)
|
---|
3060 | {
|
---|
3061 | /** @todo The code load code is assuming we're always loaded into a freshly
|
---|
3062 | * constructed VM. */
|
---|
3063 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState*);
|
---|
3064 | int rc;
|
---|
3065 |
|
---|
3066 | if ( uVersion > VMMDEV_SAVED_STATE_VERSION
|
---|
3067 | || uVersion < 6)
|
---|
3068 | return VERR_SSM_UNSUPPORTED_DATA_UNIT_VERSION;
|
---|
3069 |
|
---|
3070 | /* config */
|
---|
3071 | if (uVersion > VMMDEV_SAVED_STATE_VERSION_VBOX_30)
|
---|
3072 | {
|
---|
3073 | bool f;
|
---|
3074 | rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);
|
---|
3075 | if (pThis->fGetHostTimeDisabled != f)
|
---|
3076 | LogRel(("VMMDev: Config mismatch - fGetHostTimeDisabled: config=%RTbool saved=%RTbool\n", pThis->fGetHostTimeDisabled, f));
|
---|
3077 |
|
---|
3078 | rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);
|
---|
3079 | if (pThis->fBackdoorLogDisabled != f)
|
---|
3080 | LogRel(("VMMDev: Config mismatch - fBackdoorLogDisabled: config=%RTbool saved=%RTbool\n", pThis->fBackdoorLogDisabled, f));
|
---|
3081 |
|
---|
3082 | rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);
|
---|
3083 | if (pThis->fKeepCredentials != f)
|
---|
3084 | return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch - fKeepCredentials: config=%RTbool saved=%RTbool"),
|
---|
3085 | pThis->fKeepCredentials, f);
|
---|
3086 | rc = SSMR3GetBool(pSSM, &f); AssertRCReturn(rc, rc);
|
---|
3087 | if (pThis->fHeapEnabled != f)
|
---|
3088 | return SSMR3SetCfgError(pSSM, RT_SRC_POS, N_("Config mismatch - fHeapEnabled: config=%RTbool saved=%RTbool"),
|
---|
3089 | pThis->fHeapEnabled, f);
|
---|
3090 | }
|
---|
3091 |
|
---|
3092 | if (uPass != SSM_PASS_FINAL)
|
---|
3093 | return VINF_SUCCESS;
|
---|
3094 |
|
---|
3095 | /* state */
|
---|
3096 | SSMR3GetU32(pSSM, &pThis->hypervisorSize);
|
---|
3097 | SSMR3GetU32(pSSM, &pThis->mouseCapabilities);
|
---|
3098 | SSMR3GetS32(pSSM, &pThis->mouseXAbs);
|
---|
3099 | SSMR3GetS32(pSSM, &pThis->mouseYAbs);
|
---|
3100 |
|
---|
3101 | SSMR3GetBool(pSSM, &pThis->fNewGuestFilterMask);
|
---|
3102 | SSMR3GetU32(pSSM, &pThis->u32NewGuestFilterMask);
|
---|
3103 | SSMR3GetU32(pSSM, &pThis->u32GuestFilterMask);
|
---|
3104 | SSMR3GetU32(pSSM, &pThis->u32HostEventFlags);
|
---|
3105 |
|
---|
3106 | // SSMR3GetBool(pSSM, &pThis->pVMMDevRAMR3->fHaveEvents);
|
---|
3107 | // here be dragons (probably)
|
---|
3108 | SSMR3GetMem(pSSM, &pThis->pVMMDevRAMR3->V, sizeof (pThis->pVMMDevRAMR3->V));
|
---|
3109 |
|
---|
3110 | SSMR3GetMem(pSSM, &pThis->guestInfo, sizeof (pThis->guestInfo));
|
---|
3111 | SSMR3GetU32(pSSM, &pThis->fu32AdditionsOk);
|
---|
3112 | SSMR3GetU32(pSSM, &pThis->u32VideoAccelEnabled);
|
---|
3113 | if (uVersion > 10)
|
---|
3114 | SSMR3GetBool(pSSM, &pThis->displayChangeData.fGuestSentChangeEventAck);
|
---|
3115 |
|
---|
3116 | rc = SSMR3GetU32(pSSM, &pThis->guestCaps);
|
---|
3117 |
|
---|
3118 | /* Attributes which were temporarily introduced in r30072 */
|
---|
3119 | if (uVersion == 7)
|
---|
3120 | {
|
---|
3121 | uint32_t temp;
|
---|
3122 | SSMR3GetU32(pSSM, &temp);
|
---|
3123 | rc = SSMR3GetU32(pSSM, &temp);
|
---|
3124 | }
|
---|
3125 | AssertRCReturn(rc, rc);
|
---|
3126 |
|
---|
3127 | #ifdef VBOX_WITH_HGCM
|
---|
3128 | rc = vmmdevHGCMLoadState(pThis, pSSM, uVersion);
|
---|
3129 | AssertRCReturn(rc, rc);
|
---|
3130 | #endif /* VBOX_WITH_HGCM */
|
---|
3131 |
|
---|
3132 | if (uVersion >= 10)
|
---|
3133 | rc = SSMR3GetU32(pSSM, &pThis->fHostCursorRequested);
|
---|
3134 | AssertRCReturn(rc, rc);
|
---|
3135 |
|
---|
3136 | if (uVersion > VMMDEV_SAVED_STATE_VERSION_MISSING_GUEST_INFO_2)
|
---|
3137 | {
|
---|
3138 | SSMR3GetU32(pSSM, &pThis->guestInfo2.uFullVersion);
|
---|
3139 | SSMR3GetU32(pSSM, &pThis->guestInfo2.uRevision);
|
---|
3140 | SSMR3GetU32(pSSM, &pThis->guestInfo2.fFeatures);
|
---|
3141 | rc = SSMR3GetStrZ(pSSM, &pThis->guestInfo2.szName[0], sizeof(pThis->guestInfo2.szName));
|
---|
3142 | AssertRCReturn(rc, rc);
|
---|
3143 | }
|
---|
3144 |
|
---|
3145 | if (uVersion > VMMDEV_SAVED_STATE_VERSION_MISSING_FACILITY_STATUSES)
|
---|
3146 | {
|
---|
3147 | uint32_t cFacilityStatuses;
|
---|
3148 | rc = SSMR3GetU32(pSSM, &cFacilityStatuses);
|
---|
3149 | AssertRCReturn(rc, rc);
|
---|
3150 |
|
---|
3151 | for (uint32_t i = 0; i < cFacilityStatuses; i++)
|
---|
3152 | {
|
---|
3153 | uint32_t uFacility, fFlags;
|
---|
3154 | uint16_t uStatus;
|
---|
3155 | int64_t iTimeStampNano;
|
---|
3156 |
|
---|
3157 | SSMR3GetU32(pSSM, &uFacility);
|
---|
3158 | SSMR3GetU32(pSSM, &fFlags);
|
---|
3159 | SSMR3GetU16(pSSM, &uStatus);
|
---|
3160 | rc = SSMR3GetS64(pSSM, &iTimeStampNano);
|
---|
3161 | AssertRCReturn(rc, rc);
|
---|
3162 |
|
---|
3163 | PVMMDEVFACILITYSTATUSENTRY pEntry = vmmdevGetFacilityStatusEntry(pThis, uFacility);
|
---|
3164 | AssertLogRelMsgReturn(pEntry,
|
---|
3165 | ("VMMDev: Ran out of entries restoring the guest facility statuses. Saved state has %u.\n", cFacilityStatuses),
|
---|
3166 | VERR_OUT_OF_RESOURCES);
|
---|
3167 | pEntry->uStatus = uStatus;
|
---|
3168 | pEntry->fFlags = fFlags;
|
---|
3169 | RTTimeSpecSetNano(&pEntry->TimeSpecTS, iTimeStampNano);
|
---|
3170 | }
|
---|
3171 | }
|
---|
3172 |
|
---|
3173 |
|
---|
3174 | /*
|
---|
3175 | * On a resume, we send the capabilities changed message so
|
---|
3176 | * that listeners can sync their state again
|
---|
3177 | */
|
---|
3178 | Log(("vmmdevLoadState: capabilities changed (%x), informing connector\n", pThis->mouseCapabilities));
|
---|
3179 | if (pThis->pDrv)
|
---|
3180 | {
|
---|
3181 | pThis->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->mouseCapabilities);
|
---|
3182 | if (uVersion >= 10)
|
---|
3183 | pThis->pDrv->pfnUpdatePointerShape(pThis->pDrv,
|
---|
3184 | /*fVisible=*/!!pThis->fHostCursorRequested,
|
---|
3185 | /*fAlpha=*/false,
|
---|
3186 | /*xHot=*/0, /*yHot=*/0,
|
---|
3187 | /*cx=*/0, /*cy=*/0,
|
---|
3188 | /*pvShape=*/NULL);
|
---|
3189 | }
|
---|
3190 |
|
---|
3191 | /* Reestablish the acceleration status. */
|
---|
3192 | if ( pThis->u32VideoAccelEnabled
|
---|
3193 | && pThis->pDrv)
|
---|
3194 | {
|
---|
3195 | pThis->pDrv->pfnVideoAccelEnable(pThis->pDrv, !!pThis->u32VideoAccelEnabled, &pThis->pVMMDevRAMR3->vbvaMemory);
|
---|
3196 | }
|
---|
3197 |
|
---|
3198 | if (pThis->fu32AdditionsOk)
|
---|
3199 | {
|
---|
3200 | LogRel(("Guest Additions information report: additionsVersion = 0x%08X, osType = 0x%08X\n",
|
---|
3201 | pThis->guestInfo.interfaceVersion,
|
---|
3202 | pThis->guestInfo.osType));
|
---|
3203 | if (pThis->pDrv)
|
---|
3204 | {
|
---|
3205 | if (pThis->guestInfo2.uFullVersion && pThis->pDrv->pfnUpdateGuestInfo2)
|
---|
3206 | pThis->pDrv->pfnUpdateGuestInfo2(pThis->pDrv, pThis->guestInfo2.uFullVersion, pThis->guestInfo2.szName,
|
---|
3207 | pThis->guestInfo2.uRevision, pThis->guestInfo2.fFeatures);
|
---|
3208 | if (pThis->pDrv->pfnUpdateGuestInfo)
|
---|
3209 | pThis->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);
|
---|
3210 |
|
---|
3211 | if (pThis->pDrv->pfnUpdateGuestStatus)
|
---|
3212 | {
|
---|
3213 | for (uint32_t i = 0; i < pThis->cFacilityStatuses; i++) /* ascending order! */
|
---|
3214 | if ( pThis->aFacilityStatuses[i].uStatus != VBoxGuestFacilityStatus_Inactive
|
---|
3215 | || !pThis->aFacilityStatuses[i].fFixed)
|
---|
3216 | pThis->pDrv->pfnUpdateGuestStatus(pThis->pDrv,
|
---|
3217 | pThis->aFacilityStatuses[i].uFacility,
|
---|
3218 | pThis->aFacilityStatuses[i].uStatus,
|
---|
3219 | pThis->aFacilityStatuses[i].fFlags,
|
---|
3220 | &pThis->aFacilityStatuses[i].TimeSpecTS);
|
---|
3221 | }
|
---|
3222 | }
|
---|
3223 | }
|
---|
3224 | if (pThis->pDrv && pThis->pDrv->pfnUpdateGuestCapabilities)
|
---|
3225 | pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, pThis->guestCaps);
|
---|
3226 |
|
---|
3227 | return VINF_SUCCESS;
|
---|
3228 | }
|
---|
3229 |
|
---|
3230 | /**
|
---|
3231 | * Load state done callback. Notify guest of restore event.
|
---|
3232 | *
|
---|
3233 | * @returns VBox status code.
|
---|
3234 | * @param pDevIns The device instance.
|
---|
3235 | * @param pSSM The handle to the saved state.
|
---|
3236 | */
|
---|
3237 | static DECLCALLBACK(int) vmmdevLoadStateDone(PPDMDEVINS pDevIns, PSSMHANDLE pSSM)
|
---|
3238 | {
|
---|
3239 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState*);
|
---|
3240 |
|
---|
3241 | #ifdef VBOX_WITH_HGCM
|
---|
3242 | int rc = vmmdevHGCMLoadStateDone(pThis, pSSM);
|
---|
3243 | AssertLogRelRCReturn(rc, rc);
|
---|
3244 | #endif /* VBOX_WITH_HGCM */
|
---|
3245 |
|
---|
3246 | VMMDevNotifyGuest(pThis, VMMDEV_EVENT_RESTORED);
|
---|
3247 |
|
---|
3248 | return VINF_SUCCESS;
|
---|
3249 | }
|
---|
3250 |
|
---|
3251 | /* -=-=-=-=- PDMDEVREG -=-=-=-=- */
|
---|
3252 |
|
---|
3253 | /**
|
---|
3254 | * (Re-)initializes the MMIO2 data.
|
---|
3255 | *
|
---|
3256 | * @param pThis Pointer to the VMMDev instance data.
|
---|
3257 | */
|
---|
3258 | static void vmmdevInitRam(VMMDevState *pThis)
|
---|
3259 | {
|
---|
3260 | memset(pThis->pVMMDevRAMR3, 0, sizeof(VMMDevMemory));
|
---|
3261 | pThis->pVMMDevRAMR3->u32Size = sizeof(VMMDevMemory);
|
---|
3262 | pThis->pVMMDevRAMR3->u32Version = VMMDEV_MEMORY_VERSION;
|
---|
3263 | }
|
---|
3264 |
|
---|
3265 | /**
|
---|
3266 | * Reset notification.
|
---|
3267 | *
|
---|
3268 | * @returns VBox status.
|
---|
3269 | * @param pDrvIns The driver instance data.
|
---|
3270 | */
|
---|
3271 | static DECLCALLBACK(void) vmmdevReset(PPDMDEVINS pDevIns)
|
---|
3272 | {
|
---|
3273 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState*);
|
---|
3274 |
|
---|
3275 | /*
|
---|
3276 | * Reset the mouse integration feature bits
|
---|
3277 | */
|
---|
3278 | if (pThis->mouseCapabilities & VMMDEV_MOUSE_GUEST_MASK)
|
---|
3279 | {
|
---|
3280 | pThis->mouseCapabilities &= ~VMMDEV_MOUSE_GUEST_MASK;
|
---|
3281 | /* notify the connector */
|
---|
3282 | Log(("vmmdevReset: capabilities changed (%x), informing connector\n", pThis->mouseCapabilities));
|
---|
3283 | pThis->pDrv->pfnUpdateMouseCapabilities(pThis->pDrv, pThis->mouseCapabilities);
|
---|
3284 | }
|
---|
3285 | pThis->fHostCursorRequested = false;
|
---|
3286 |
|
---|
3287 | pThis->hypervisorSize = 0;
|
---|
3288 |
|
---|
3289 | /* re-initialize the VMMDev memory */
|
---|
3290 | if (pThis->pVMMDevRAMR3)
|
---|
3291 | vmmdevInitRam(pThis);
|
---|
3292 |
|
---|
3293 | /* credentials have to go away (by default) */
|
---|
3294 | if (!pThis->fKeepCredentials)
|
---|
3295 | {
|
---|
3296 | memset(pThis->pCredentials->Logon.szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
3297 | memset(pThis->pCredentials->Logon.szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
3298 | memset(pThis->pCredentials->Logon.szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
3299 | }
|
---|
3300 | memset(pThis->pCredentials->Judge.szUserName, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
3301 | memset(pThis->pCredentials->Judge.szPassword, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
3302 | memset(pThis->pCredentials->Judge.szDomain, '\0', VMMDEV_CREDENTIALS_SZ_SIZE);
|
---|
3303 |
|
---|
3304 | /* Reset means that additions will report again. */
|
---|
3305 | const bool fVersionChanged = pThis->fu32AdditionsOk
|
---|
3306 | || pThis->guestInfo.interfaceVersion
|
---|
3307 | || pThis->guestInfo.osType != VBOXOSTYPE_Unknown;
|
---|
3308 | if (fVersionChanged)
|
---|
3309 | Log(("vmmdevReset: fu32AdditionsOk=%d additionsVersion=%x osType=%#x\n",
|
---|
3310 | pThis->fu32AdditionsOk, pThis->guestInfo.interfaceVersion, pThis->guestInfo.osType));
|
---|
3311 | pThis->fu32AdditionsOk = false;
|
---|
3312 | memset (&pThis->guestInfo, 0, sizeof (pThis->guestInfo));
|
---|
3313 | RT_ZERO(pThis->guestInfo2);
|
---|
3314 |
|
---|
3315 | /* Clear facilities. No need to tell Main as it will get a
|
---|
3316 | pfnUpdateGuestInfo callback. */
|
---|
3317 | RTTIMESPEC TimeStampNow;
|
---|
3318 | RTTimeNow(&TimeStampNow);
|
---|
3319 | uint32_t iFacility = pThis->cFacilityStatuses;
|
---|
3320 | while (iFacility-- > 0)
|
---|
3321 | {
|
---|
3322 | pThis->aFacilityStatuses[iFacility].uStatus = VBoxGuestFacilityStatus_Inactive;
|
---|
3323 | pThis->aFacilityStatuses[iFacility].TimeSpecTS = TimeStampNow;
|
---|
3324 | }
|
---|
3325 |
|
---|
3326 | /* clear pending display change request. */
|
---|
3327 | for (unsigned i = 0; i < RT_ELEMENTS(pThis->displayChangeData.aRequests); i++)
|
---|
3328 | {
|
---|
3329 | DISPLAYCHANGEREQUEST *pRequest = &pThis->displayChangeData.aRequests[i];
|
---|
3330 | memset (&pRequest->lastReadDisplayChangeRequest, 0, sizeof (pRequest->lastReadDisplayChangeRequest));
|
---|
3331 | }
|
---|
3332 | pThis->displayChangeData.iCurrentMonitor = 0;
|
---|
3333 | pThis->displayChangeData.fGuestSentChangeEventAck = false;
|
---|
3334 |
|
---|
3335 | /* disable seamless mode */
|
---|
3336 | pThis->fLastSeamlessEnabled = false;
|
---|
3337 |
|
---|
3338 | /* disabled memory ballooning */
|
---|
3339 | pThis->u32LastMemoryBalloonSize = 0;
|
---|
3340 |
|
---|
3341 | /* disabled statistics updating */
|
---|
3342 | pThis->u32LastStatIntervalSize = 0;
|
---|
3343 |
|
---|
3344 | /* Clear the "HGCM event enabled" flag so the event can be automatically reenabled. */
|
---|
3345 | pThis->u32HGCMEnabled = 0;
|
---|
3346 |
|
---|
3347 | /*
|
---|
3348 | * Clear the event variables.
|
---|
3349 | *
|
---|
3350 | * XXX By design we should NOT clear pThis->u32HostEventFlags because it is designed
|
---|
3351 | * that way so host events do not depend on guest resets. However, the pending
|
---|
3352 | * event flags actually _were_ cleared since ages so we mask out events from
|
---|
3353 | * clearing which we really need to survive the reset. See xtracker 5767.
|
---|
3354 | */
|
---|
3355 | pThis->u32HostEventFlags &= VMMDEV_EVENT_DISPLAY_CHANGE_REQUEST;
|
---|
3356 | pThis->u32GuestFilterMask = 0;
|
---|
3357 | pThis->u32NewGuestFilterMask = 0;
|
---|
3358 | pThis->fNewGuestFilterMask = 0;
|
---|
3359 |
|
---|
3360 | /* This is the default, as Windows and OS/2 guests take this for granted. (Actually, neither does...) */
|
---|
3361 | /** @todo change this when we next bump the interface version */
|
---|
3362 | const bool fCapsChanged = pThis->guestCaps != VMMDEV_GUEST_SUPPORTS_GRAPHICS;
|
---|
3363 | if (fCapsChanged)
|
---|
3364 | Log(("vmmdevReset: fCapsChanged=%#x -> %#x\n", pThis->guestCaps, VMMDEV_GUEST_SUPPORTS_GRAPHICS));
|
---|
3365 | pThis->guestCaps = VMMDEV_GUEST_SUPPORTS_GRAPHICS; /** @todo r=bird: why? I cannot see this being done at construction?*/
|
---|
3366 |
|
---|
3367 | /*
|
---|
3368 | * Call the update functions as required.
|
---|
3369 | */
|
---|
3370 | if (fVersionChanged && pThis->pDrv && pThis->pDrv->pfnUpdateGuestInfo)
|
---|
3371 | pThis->pDrv->pfnUpdateGuestInfo(pThis->pDrv, &pThis->guestInfo);
|
---|
3372 | if (fCapsChanged && pThis->pDrv && pThis->pDrv->pfnUpdateGuestCapabilities)
|
---|
3373 | pThis->pDrv->pfnUpdateGuestCapabilities(pThis->pDrv, pThis->guestCaps);
|
---|
3374 |
|
---|
3375 | /* Generate a unique session id for this VM; it will be changed for each start, reset or restore.
|
---|
3376 | * This can be used for restore detection inside the guest.
|
---|
3377 | */
|
---|
3378 | pThis->idSession = ASMReadTSC();
|
---|
3379 | }
|
---|
3380 |
|
---|
3381 |
|
---|
3382 | /**
|
---|
3383 | * @interface_method_impl{PDMDEVREG,pfnRelocate}
|
---|
3384 | */
|
---|
3385 | static DECLCALLBACK(void) vmmdevRelocate(PPDMDEVINS pDevIns, RTGCINTPTR offDelta)
|
---|
3386 | {
|
---|
3387 | NOREF(pDevIns);
|
---|
3388 | NOREF(offDelta);
|
---|
3389 | }
|
---|
3390 |
|
---|
3391 |
|
---|
3392 | /**
|
---|
3393 | * @interface_method_impl{PDMDEVREG,pfnDestruct}
|
---|
3394 | */
|
---|
3395 | static DECLCALLBACK(int) vmmdevDestroy(PPDMDEVINS pDevIns)
|
---|
3396 | {
|
---|
3397 | PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
|
---|
3398 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState *);
|
---|
3399 |
|
---|
3400 | /*
|
---|
3401 | * Wipe and free the credentials.
|
---|
3402 | */
|
---|
3403 | if (pThis->pCredentials)
|
---|
3404 | {
|
---|
3405 | RTMemWipeThoroughly(pThis->pCredentials, sizeof(*pThis->pCredentials), 10);
|
---|
3406 | RTMemFree(pThis->pCredentials);
|
---|
3407 | pThis->pCredentials = NULL;
|
---|
3408 | }
|
---|
3409 |
|
---|
3410 | return VINF_SUCCESS;
|
---|
3411 | }
|
---|
3412 |
|
---|
3413 |
|
---|
3414 | /**
|
---|
3415 | * @interface_method_impl{PDMDEVREG,pfnConstruct}
|
---|
3416 | */
|
---|
3417 | static DECLCALLBACK(int) vmmdevConstruct(PPDMDEVINS pDevIns, int iInstance, PCFGMNODE pCfg)
|
---|
3418 | {
|
---|
3419 | int rc;
|
---|
3420 | VMMDevState *pThis = PDMINS_2_DATA(pDevIns, VMMDevState *);
|
---|
3421 |
|
---|
3422 | Assert(iInstance == 0);
|
---|
3423 | PDMDEV_CHECK_VERSIONS_RETURN(pDevIns);
|
---|
3424 |
|
---|
3425 | /*
|
---|
3426 | * Initialize data (most of it anyway).
|
---|
3427 | */
|
---|
3428 | /* Save PDM device instance data for future reference. */
|
---|
3429 | pThis->pDevIns = pDevIns;
|
---|
3430 |
|
---|
3431 | /* PCI vendor, just a free bogus value */
|
---|
3432 | PCIDevSetVendorId(&pThis->dev, 0x80ee);
|
---|
3433 | /* device ID */
|
---|
3434 | PCIDevSetDeviceId(&pThis->dev, 0xcafe);
|
---|
3435 | /* class sub code (other type of system peripheral) */
|
---|
3436 | PCIDevSetClassSub(&pThis->dev, 0x80);
|
---|
3437 | /* class base code (base system peripheral) */
|
---|
3438 | PCIDevSetClassBase(&pThis->dev, 0x08);
|
---|
3439 | /* header type */
|
---|
3440 | PCIDevSetHeaderType(&pThis->dev, 0x00);
|
---|
3441 | /* interrupt on pin 0 */
|
---|
3442 | PCIDevSetInterruptPin(&pThis->dev, 0x01);
|
---|
3443 |
|
---|
3444 | RTTIMESPEC TimeStampNow;
|
---|
3445 | RTTimeNow(&TimeStampNow);
|
---|
3446 | vmmdevAllocFacilityStatusEntry(pThis, VBoxGuestFacilityType_VBoxGuestDriver, true /*fFixed*/, &TimeStampNow);
|
---|
3447 | vmmdevAllocFacilityStatusEntry(pThis, VBoxGuestFacilityType_VBoxService, true /*fFixed*/, &TimeStampNow);
|
---|
3448 | vmmdevAllocFacilityStatusEntry(pThis, VBoxGuestFacilityType_VBoxTrayClient, true /*fFixed*/, &TimeStampNow);
|
---|
3449 | vmmdevAllocFacilityStatusEntry(pThis, VBoxGuestFacilityType_Seamless, true /*fFixed*/, &TimeStampNow);
|
---|
3450 | vmmdevAllocFacilityStatusEntry(pThis, VBoxGuestFacilityType_Graphics, true /*fFixed*/, &TimeStampNow);
|
---|
3451 | Assert(pThis->cFacilityStatuses == 5);
|
---|
3452 |
|
---|
3453 | /*
|
---|
3454 | * Interfaces
|
---|
3455 | */
|
---|
3456 | /* IBase */
|
---|
3457 | pThis->IBase.pfnQueryInterface = vmmdevPortQueryInterface;
|
---|
3458 |
|
---|
3459 | /* VMMDev port */
|
---|
3460 | pThis->IPort.pfnQueryAbsoluteMouse = vmmdevQueryAbsoluteMouse;
|
---|
3461 | pThis->IPort.pfnSetAbsoluteMouse = vmmdevSetAbsoluteMouse;
|
---|
3462 | pThis->IPort.pfnQueryMouseCapabilities = vmmdevQueryMouseCapabilities;
|
---|
3463 | pThis->IPort.pfnUpdateMouseCapabilities = vmmdevUpdateMouseCapabilities;
|
---|
3464 | pThis->IPort.pfnRequestDisplayChange = vmmdevRequestDisplayChange;
|
---|
3465 | pThis->IPort.pfnSetCredentials = vmmdevSetCredentials;
|
---|
3466 | pThis->IPort.pfnVBVAChange = vmmdevVBVAChange;
|
---|
3467 | pThis->IPort.pfnRequestSeamlessChange = vmmdevRequestSeamlessChange;
|
---|
3468 | pThis->IPort.pfnSetMemoryBalloon = vmmdevSetMemoryBalloon;
|
---|
3469 | pThis->IPort.pfnSetStatisticsInterval = vmmdevSetStatisticsInterval;
|
---|
3470 | pThis->IPort.pfnVRDPChange = vmmdevVRDPChange;
|
---|
3471 | pThis->IPort.pfnCpuHotUnplug = vmmdevCpuHotUnplug;
|
---|
3472 | pThis->IPort.pfnCpuHotPlug = vmmdevCpuHotPlug;
|
---|
3473 |
|
---|
3474 | /* Shared folder LED */
|
---|
3475 | pThis->SharedFolders.Led.u32Magic = PDMLED_MAGIC;
|
---|
3476 | pThis->SharedFolders.ILeds.pfnQueryStatusLed = vmmdevQueryStatusLed;
|
---|
3477 |
|
---|
3478 | #ifdef VBOX_WITH_HGCM
|
---|
3479 | /* HGCM port */
|
---|
3480 | pThis->IHGCMPort.pfnCompleted = hgcmCompleted;
|
---|
3481 | #endif
|
---|
3482 |
|
---|
3483 | pThis->pCredentials = (VMMDEVCREDS *)RTMemAllocZ(sizeof(*pThis->pCredentials));
|
---|
3484 | if (!pThis->pCredentials)
|
---|
3485 | return VERR_NO_MEMORY;
|
---|
3486 |
|
---|
3487 |
|
---|
3488 | /*
|
---|
3489 | * Validate and read the configuration.
|
---|
3490 | */
|
---|
3491 | PDMDEV_VALIDATE_CONFIG_RETURN(pDevIns,
|
---|
3492 | "GetHostTimeDisabled|"
|
---|
3493 | "BackdoorLogDisabled|"
|
---|
3494 | "KeepCredentials|"
|
---|
3495 | "HeapEnabled|"
|
---|
3496 | "RamSize|"
|
---|
3497 | "RZEnabled|"
|
---|
3498 | "GuestCoreDumpEnabled|"
|
---|
3499 | "GuestCoreDumpDir|"
|
---|
3500 | "GuestCoreDumpCount|"
|
---|
3501 | "TestingEnabled"
|
---|
3502 | ,
|
---|
3503 | "");
|
---|
3504 |
|
---|
3505 | rc = CFGMR3QueryU64(pCfg, "RamSize", &pThis->cbGuestRAM);
|
---|
3506 | if (RT_FAILURE(rc))
|
---|
3507 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
3508 | N_("Configuration error: Failed querying \"RamSize\" as a 64-bit unsigned integer"));
|
---|
3509 |
|
---|
3510 | rc = CFGMR3QueryBoolDef(pCfg, "GetHostTimeDisabled", &pThis->fGetHostTimeDisabled, false);
|
---|
3511 | if (RT_FAILURE(rc))
|
---|
3512 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
3513 | N_("Configuration error: Failed querying \"GetHostTimeDisabled\" as a boolean"));
|
---|
3514 |
|
---|
3515 | rc = CFGMR3QueryBoolDef(pCfg, "BackdoorLogDisabled", &pThis->fBackdoorLogDisabled, false);
|
---|
3516 | if (RT_FAILURE(rc))
|
---|
3517 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
3518 | N_("Configuration error: Failed querying \"BackdoorLogDisabled\" as a boolean"));
|
---|
3519 |
|
---|
3520 | rc = CFGMR3QueryBoolDef(pCfg, "KeepCredentials", &pThis->fKeepCredentials, false);
|
---|
3521 | if (RT_FAILURE(rc))
|
---|
3522 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
3523 | N_("Configuration error: Failed querying \"KeepCredentials\" as a boolean"));
|
---|
3524 |
|
---|
3525 | rc = CFGMR3QueryBoolDef(pCfg, "HeapEnabled", &pThis->fHeapEnabled, true);
|
---|
3526 | if (RT_FAILURE(rc))
|
---|
3527 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
3528 | N_("Configuration error: Failed querying \"HeapEnabled\" as a boolean"));
|
---|
3529 |
|
---|
3530 | rc = CFGMR3QueryBoolDef(pCfg, "RZEnabled", &pThis->fRZEnabled, true);
|
---|
3531 | if (RT_FAILURE(rc))
|
---|
3532 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
3533 | N_("Configuration error: Failed querying \"RZEnabled\" as a boolean"));
|
---|
3534 |
|
---|
3535 | rc = CFGMR3QueryBoolDef(pCfg, "GuestCoreDumpEnabled", &pThis->fGuestCoreDumpEnabled, false);
|
---|
3536 | if (RT_FAILURE(rc))
|
---|
3537 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
3538 | N_("Configuration error: Failed querying \"GuestCoreDumpEnabled\" as a boolean"));
|
---|
3539 |
|
---|
3540 | char *pszGuestCoreDumpDir = NULL;
|
---|
3541 | rc = CFGMR3QueryStringAllocDef(pCfg, "GuestCoreDumpDir", &pszGuestCoreDumpDir, "");
|
---|
3542 | if (RT_FAILURE(rc))
|
---|
3543 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
3544 | N_("Configuration error: Failed querying \"GuestCoreDumpDir\" as a string"));
|
---|
3545 |
|
---|
3546 | RTStrCopy(pThis->szGuestCoreDumpDir, sizeof(pThis->szGuestCoreDumpDir), pszGuestCoreDumpDir);
|
---|
3547 | MMR3HeapFree(pszGuestCoreDumpDir);
|
---|
3548 |
|
---|
3549 | rc = CFGMR3QueryU32Def(pCfg, "GuestCoreDumpCount", &pThis->cGuestCoreDumps, 3);
|
---|
3550 | if (RT_FAILURE(rc))
|
---|
3551 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
3552 | N_("Configuration error: Failed querying \"GuestCoreDumpCount\" as a 32-bit unsigned integer"));
|
---|
3553 |
|
---|
3554 | #ifndef VBOX_WITHOUT_TESTING_FEATURES
|
---|
3555 | rc = CFGMR3QueryBoolDef(pCfg, "TestingEnabled", &pThis->fTestingEnabled, false);
|
---|
3556 | if (RT_FAILURE(rc))
|
---|
3557 | return PDMDEV_SET_ERROR(pDevIns, rc,
|
---|
3558 | N_("Configuration error: Failed querying \"TestingEnabled\" as a boolean"));
|
---|
3559 | /** @todo image-to-load-filename? */
|
---|
3560 | #endif
|
---|
3561 |
|
---|
3562 | /*
|
---|
3563 | * Create the critical section for the device.
|
---|
3564 | */
|
---|
3565 | rc = PDMDevHlpCritSectInit(pDevIns, &pThis->CritSect, RT_SRC_POS, "VMMDev#%u", iInstance);
|
---|
3566 | AssertRCReturn(rc, rc);
|
---|
3567 | /* Later: pDevIns->pCritSectR3 = &pThis->CritSect; */
|
---|
3568 |
|
---|
3569 | /*
|
---|
3570 | * Register the backdoor logging port
|
---|
3571 | */
|
---|
3572 | rc = PDMDevHlpIOPortRegister(pDevIns, RTLOG_DEBUG_PORT, 1, NULL, vmmdevBackdoorLog, NULL, NULL, NULL, "VMMDev backdoor logging");
|
---|
3573 | AssertRCReturn(rc, rc);
|
---|
3574 |
|
---|
3575 | #ifdef TIMESYNC_BACKDOOR
|
---|
3576 | /*
|
---|
3577 | * Alternative timesync source (temporary!)
|
---|
3578 | */
|
---|
3579 | rc = PDMDevHlpIOPortRegister(pDevIns, 0x505, 1, NULL, vmmdevTimesyncBackdoorWrite, vmmdevTimesyncBackdoorRead, NULL, NULL, "VMMDev timesync backdoor");
|
---|
3580 | AssertRCReturn(rc, rc);
|
---|
3581 | #endif
|
---|
3582 |
|
---|
3583 | /*
|
---|
3584 | * Allocate and initialize the MMIO2 memory.
|
---|
3585 | */
|
---|
3586 | rc = PDMDevHlpMMIO2Register(pDevIns, 1 /*iRegion*/, VMMDEV_RAM_SIZE, 0 /*fFlags*/, (void **)&pThis->pVMMDevRAMR3, "VMMDev");
|
---|
3587 | if (RT_FAILURE(rc))
|
---|
3588 | return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
|
---|
3589 | N_("Failed to allocate %u bytes of memory for the VMM device"), VMMDEV_RAM_SIZE);
|
---|
3590 | vmmdevInitRam(pThis);
|
---|
3591 |
|
---|
3592 | if (pThis->fHeapEnabled)
|
---|
3593 | {
|
---|
3594 | rc = PDMDevHlpMMIO2Register(pDevIns, 2 /*iRegion*/, VMMDEV_HEAP_SIZE, 0 /*fFlags*/, (void **)&pThis->pVMMDevHeapR3, "VMMDev Heap");
|
---|
3595 | if (RT_FAILURE(rc))
|
---|
3596 | return PDMDevHlpVMSetError(pDevIns, rc, RT_SRC_POS,
|
---|
3597 | N_("Failed to allocate %u bytes of memory for the VMM device heap"), PAGE_SIZE);
|
---|
3598 | }
|
---|
3599 |
|
---|
3600 | /*
|
---|
3601 | * Register the PCI device.
|
---|
3602 | */
|
---|
3603 | rc = PDMDevHlpPCIRegister(pDevIns, &pThis->dev);
|
---|
3604 | if (RT_FAILURE(rc))
|
---|
3605 | return rc;
|
---|
3606 | if (pThis->dev.devfn != 32 || iInstance != 0)
|
---|
3607 | Log(("!!WARNING!!: pThis->dev.devfn=%d (ignore if testcase or no started by Main)\n", pThis->dev.devfn));
|
---|
3608 | rc = PDMDevHlpPCIIORegionRegister(pDevIns, 0, 0x20, PCI_ADDRESS_SPACE_IO, vmmdevIOPortRegionMap);
|
---|
3609 | if (RT_FAILURE(rc))
|
---|
3610 | return rc;
|
---|
3611 | rc = PDMDevHlpPCIIORegionRegister(pDevIns, 1, VMMDEV_RAM_SIZE, PCI_ADDRESS_SPACE_MEM, vmmdevIORAMRegionMap);
|
---|
3612 | if (RT_FAILURE(rc))
|
---|
3613 | return rc;
|
---|
3614 | if (pThis->fHeapEnabled)
|
---|
3615 | {
|
---|
3616 | rc = PDMDevHlpPCIIORegionRegister(pDevIns, 2, VMMDEV_HEAP_SIZE, PCI_ADDRESS_SPACE_MEM_PREFETCH, vmmdevIORAMRegionMap);
|
---|
3617 | if (RT_FAILURE(rc))
|
---|
3618 | return rc;
|
---|
3619 | }
|
---|
3620 |
|
---|
3621 | #ifndef VBOX_WITHOUT_TESTING_FEATURES
|
---|
3622 | /*
|
---|
3623 | * Initialize testing.
|
---|
3624 | */
|
---|
3625 | rc = vmmdevTestingInitialize(pDevIns);
|
---|
3626 | if (RT_FAILURE(rc))
|
---|
3627 | return rc;
|
---|
3628 | #endif
|
---|
3629 |
|
---|
3630 | /*
|
---|
3631 | * Get the corresponding connector interface
|
---|
3632 | */
|
---|
3633 | rc = PDMDevHlpDriverAttach(pDevIns, 0, &pThis->IBase, &pThis->pDrvBase, "VMM Driver Port");
|
---|
3634 | if (RT_SUCCESS(rc))
|
---|
3635 | {
|
---|
3636 | pThis->pDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIVMMDEVCONNECTOR);
|
---|
3637 | AssertMsgReturn(pThis->pDrv, ("LUN #0 doesn't have a VMMDev connector interface!\n"), VERR_PDM_MISSING_INTERFACE);
|
---|
3638 | #ifdef VBOX_WITH_HGCM
|
---|
3639 | pThis->pHGCMDrv = PDMIBASE_QUERY_INTERFACE(pThis->pDrvBase, PDMIHGCMCONNECTOR);
|
---|
3640 | if (!pThis->pHGCMDrv)
|
---|
3641 | {
|
---|
3642 | Log(("LUN #0 doesn't have a HGCM connector interface, HGCM is not supported. rc=%Rrc\n", rc));
|
---|
3643 | /* this is not actually an error, just means that there is no support for HGCM */
|
---|
3644 | }
|
---|
3645 | #endif
|
---|
3646 | /* Query the initial balloon size. */
|
---|
3647 | AssertPtr(pThis->pDrv->pfnQueryBalloonSize);
|
---|
3648 | rc = pThis->pDrv->pfnQueryBalloonSize(pThis->pDrv, &pThis->u32MemoryBalloonSize);
|
---|
3649 | AssertRC(rc);
|
---|
3650 |
|
---|
3651 | Log(("Initial balloon size %x\n", pThis->u32MemoryBalloonSize));
|
---|
3652 | }
|
---|
3653 | else if (rc == VERR_PDM_NO_ATTACHED_DRIVER)
|
---|
3654 | {
|
---|
3655 | Log(("%s/%d: warning: no driver attached to LUN #0!\n", pDevIns->pReg->szName, pDevIns->iInstance));
|
---|
3656 | rc = VINF_SUCCESS;
|
---|
3657 | }
|
---|
3658 | else
|
---|
3659 | AssertMsgFailedReturn(("Failed to attach LUN #0! rc=%Rrc\n", rc), rc);
|
---|
3660 |
|
---|
3661 | /*
|
---|
3662 | * Attach status driver for shared folders (optional).
|
---|
3663 | */
|
---|
3664 | PPDMIBASE pBase;
|
---|
3665 | rc = PDMDevHlpDriverAttach(pDevIns, PDM_STATUS_LUN, &pThis->IBase, &pBase, "Status Port");
|
---|
3666 | if (RT_SUCCESS(rc))
|
---|
3667 | pThis->SharedFolders.pLedsConnector = PDMIBASE_QUERY_INTERFACE(pBase, PDMILEDCONNECTORS);
|
---|
3668 | else if (rc != VERR_PDM_NO_ATTACHED_DRIVER)
|
---|
3669 | {
|
---|
3670 | AssertMsgFailed(("Failed to attach to status driver. rc=%Rrc\n", rc));
|
---|
3671 | return rc;
|
---|
3672 | }
|
---|
3673 |
|
---|
3674 | /*
|
---|
3675 | * Register saved state and init the HGCM CmdList critsect.
|
---|
3676 | */
|
---|
3677 | rc = PDMDevHlpSSMRegisterEx(pDevIns, VMMDEV_SAVED_STATE_VERSION, sizeof(*pThis), NULL,
|
---|
3678 | NULL, vmmdevLiveExec, NULL,
|
---|
3679 | NULL, vmmdevSaveExec, NULL,
|
---|
3680 | NULL, vmmdevLoadExec, vmmdevLoadStateDone);
|
---|
3681 | AssertRCReturn(rc, rc);
|
---|
3682 |
|
---|
3683 | #ifdef VBOX_WITH_HGCM
|
---|
3684 | pThis->pHGCMCmdList = NULL;
|
---|
3685 | rc = RTCritSectInit(&pThis->critsectHGCMCmdList);
|
---|
3686 | AssertRCReturn(rc, rc);
|
---|
3687 | pThis->u32HGCMEnabled = 0;
|
---|
3688 | #endif /* VBOX_WITH_HGCM */
|
---|
3689 |
|
---|
3690 | /* In this version of VirtualBox the GUI checks whether "needs host cursor"
|
---|
3691 | * changes. */
|
---|
3692 | pThis->mouseCapabilities |= VMMDEV_MOUSE_HOST_RECHECKS_NEEDS_HOST_CURSOR;
|
---|
3693 |
|
---|
3694 | PDMDevHlpSTAMRegisterF(pDevIns, &pThis->StatMemBalloonChunks, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, STAMUNIT_COUNT, "Memory balloon size", "/Devices/VMMDev/BalloonChunks");
|
---|
3695 |
|
---|
3696 | /* Generate a unique session id for this VM; it will be changed for each start, reset or restore.
|
---|
3697 | * This can be used for restore detection inside the guest.
|
---|
3698 | */
|
---|
3699 | pThis->idSession = ASMReadTSC();
|
---|
3700 | return rc;
|
---|
3701 | }
|
---|
3702 |
|
---|
3703 | /**
|
---|
3704 | * The device registration structure.
|
---|
3705 | */
|
---|
3706 | extern "C" const PDMDEVREG g_DeviceVMMDev =
|
---|
3707 | {
|
---|
3708 | /* u32Version */
|
---|
3709 | PDM_DEVREG_VERSION,
|
---|
3710 | /* szName */
|
---|
3711 | "VMMDev",
|
---|
3712 | /* szRCMod */
|
---|
3713 | "VBoxDDGC.gc",
|
---|
3714 | /* szR0Mod */
|
---|
3715 | "VBoxDDR0.r0",
|
---|
3716 | /* pszDescription */
|
---|
3717 | "VirtualBox VMM Device\n",
|
---|
3718 | /* fFlags */
|
---|
3719 | PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT | PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT | PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_R0,
|
---|
3720 | /* fClass */
|
---|
3721 | PDM_DEVREG_CLASS_VMM_DEV,
|
---|
3722 | /* cMaxInstances */
|
---|
3723 | 1,
|
---|
3724 | /* cbInstance */
|
---|
3725 | sizeof(VMMDevState),
|
---|
3726 | /* pfnConstruct */
|
---|
3727 | vmmdevConstruct,
|
---|
3728 | /* pfnDestruct */
|
---|
3729 | NULL,
|
---|
3730 | /* pfnRelocate */
|
---|
3731 | vmmdevRelocate,
|
---|
3732 | /* pfnIOCtl */
|
---|
3733 | NULL,
|
---|
3734 | /* pfnPowerOn */
|
---|
3735 | NULL,
|
---|
3736 | /* pfnReset */
|
---|
3737 | vmmdevReset,
|
---|
3738 | /* pfnSuspend */
|
---|
3739 | NULL,
|
---|
3740 | /* pfnResume */
|
---|
3741 | NULL,
|
---|
3742 | /* pfnAttach */
|
---|
3743 | NULL,
|
---|
3744 | /* pfnDetach */
|
---|
3745 | NULL,
|
---|
3746 | /* pfnQueryInterface. */
|
---|
3747 | NULL,
|
---|
3748 | /* pfnInitComplete */
|
---|
3749 | NULL,
|
---|
3750 | /* pfnPowerOff */
|
---|
3751 | NULL,
|
---|
3752 | /* pfnSoftReset */
|
---|
3753 | NULL,
|
---|
3754 | /* u32VersionEnd */
|
---|
3755 | PDM_DEVREG_VERSION
|
---|
3756 | };
|
---|
3757 | #endif /* !VBOX_DEVICE_STRUCT_TESTCASE */
|
---|