VirtualBox

source: vbox/trunk/src/VBox/Additions/common/VBoxGuestLib/HGCMInternal.cpp@ 58029

Last change on this file since 58029 was 57358, checked in by vboxsync, 9 years ago

*: scm cleanup run.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 44.5 KB
Line 
1/* $Id: HGCMInternal.cpp 57358 2015-08-14 15:16:38Z vboxsync $ */
2/** @file
3 * VBoxGuestLib - Host-Guest Communication Manager internal functions, implemented by VBoxGuest
4 */
5
6/*
7 * Copyright (C) 2006-2015 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 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27/* Entire file is ifdef'ed with VBGL_VBOXGUEST */
28#ifdef VBGL_VBOXGUEST
29
30
31/*********************************************************************************************************************************
32* Header Files *
33*********************************************************************************************************************************/
34#define LOG_GROUP LOG_GROUP_HGCM
35
36#include "VBGLInternal.h"
37#include <iprt/alloca.h>
38#include <iprt/asm.h>
39#include <iprt/assert.h>
40#include <iprt/mem.h>
41#include <iprt/memobj.h>
42#include <iprt/string.h>
43#include <iprt/thread.h>
44#include <iprt/time.h>
45
46
47/*********************************************************************************************************************************
48* Defined Constants And Macros *
49*********************************************************************************************************************************/
50/** The max parameter buffer size for a user request. */
51#define VBGLR0_MAX_HGCM_USER_PARM (24*_1M)
52/** The max parameter buffer size for a kernel request. */
53#define VBGLR0_MAX_HGCM_KERNEL_PARM (16*_1M)
54#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN)
55/** Linux needs to use bounce buffers since RTR0MemObjLockUser has unwanted
56 * side effects.
57 * Darwin 32bit & 64bit also needs this because of 4GB/4GB user/kernel space. */
58# define USE_BOUNCE_BUFFERS
59#endif
60
61
62/*********************************************************************************************************************************
63* Structures and Typedefs *
64*********************************************************************************************************************************/
65/**
66 * Lock info structure used by VbglR0HGCMInternalCall and its helpers.
67 */
68struct VbglR0ParmInfo
69{
70 uint32_t cLockBufs;
71 struct
72 {
73 uint32_t iParm;
74 RTR0MEMOBJ hObj;
75#ifdef USE_BOUNCE_BUFFERS
76 void *pvSmallBuf;
77#endif
78 } aLockBufs[10];
79};
80
81
82
83/* These functions can be only used by VBoxGuest. */
84
85DECLVBGL(int) VbglR0HGCMInternalConnect (VBoxGuestHGCMConnectInfo *pConnectInfo,
86 PFNVBGLHGCMCALLBACK pfnAsyncCallback, void *pvAsyncData, uint32_t u32AsyncData)
87{
88 VMMDevHGCMConnect *pHGCMConnect;
89 int rc;
90
91 if (!pConnectInfo || !pfnAsyncCallback)
92 return VERR_INVALID_PARAMETER;
93
94 pHGCMConnect = NULL;
95
96 /* Allocate request */
97 rc = VbglGRAlloc ((VMMDevRequestHeader **)&pHGCMConnect, sizeof (VMMDevHGCMConnect), VMMDevReq_HGCMConnect);
98
99 if (RT_SUCCESS(rc))
100 {
101 /* Initialize request memory */
102 pHGCMConnect->header.fu32Flags = 0;
103
104 memcpy (&pHGCMConnect->loc, &pConnectInfo->Loc, sizeof (HGCMServiceLocation));
105 pHGCMConnect->u32ClientID = 0;
106
107 /* Issue request */
108 rc = VbglGRPerform (&pHGCMConnect->header.header);
109
110 if (RT_SUCCESS(rc))
111 {
112 /* Check if host decides to process the request asynchronously. */
113 if (rc == VINF_HGCM_ASYNC_EXECUTE)
114 {
115 /* Wait for request completion interrupt notification from host */
116 pfnAsyncCallback (&pHGCMConnect->header, pvAsyncData, u32AsyncData);
117 }
118
119 pConnectInfo->result = pHGCMConnect->header.result;
120
121 if (RT_SUCCESS (pConnectInfo->result))
122 pConnectInfo->u32ClientID = pHGCMConnect->u32ClientID;
123 }
124
125 VbglGRFree (&pHGCMConnect->header.header);
126 }
127
128 return rc;
129}
130
131
132DECLR0VBGL(int) VbglR0HGCMInternalDisconnect (VBoxGuestHGCMDisconnectInfo *pDisconnectInfo,
133 PFNVBGLHGCMCALLBACK pfnAsyncCallback, void *pvAsyncData, uint32_t u32AsyncData)
134{
135 VMMDevHGCMDisconnect *pHGCMDisconnect;
136 int rc;
137
138 if (!pDisconnectInfo || !pfnAsyncCallback)
139 return VERR_INVALID_PARAMETER;
140
141 pHGCMDisconnect = NULL;
142
143 /* Allocate request */
144 rc = VbglGRAlloc ((VMMDevRequestHeader **)&pHGCMDisconnect, sizeof (VMMDevHGCMDisconnect), VMMDevReq_HGCMDisconnect);
145
146 if (RT_SUCCESS(rc))
147 {
148 /* Initialize request memory */
149 pHGCMDisconnect->header.fu32Flags = 0;
150
151 pHGCMDisconnect->u32ClientID = pDisconnectInfo->u32ClientID;
152
153 /* Issue request */
154 rc = VbglGRPerform (&pHGCMDisconnect->header.header);
155
156 if (RT_SUCCESS(rc))
157 {
158 /* Check if host decides to process the request asynchronously. */
159 if (rc == VINF_HGCM_ASYNC_EXECUTE)
160 {
161 /* Wait for request completion interrupt notification from host */
162 pfnAsyncCallback (&pHGCMDisconnect->header, pvAsyncData, u32AsyncData);
163 }
164
165 pDisconnectInfo->result = pHGCMDisconnect->header.result;
166 }
167
168 VbglGRFree (&pHGCMDisconnect->header.header);
169 }
170
171 return rc;
172}
173
174
175/**
176 * Preprocesses the HGCM call, validating and locking/buffering parameters.
177 *
178 * @returns VBox status code.
179 *
180 * @param pCallInfo The call info.
181 * @param cbCallInfo The size of the call info structure.
182 * @param fIsUser Is it a user request or kernel request.
183 * @param pcbExtra Where to return the extra request space needed for
184 * physical page lists.
185 */
186static int vbglR0HGCMInternalPreprocessCall(VBoxGuestHGCMCallInfo const *pCallInfo, uint32_t cbCallInfo,
187 bool fIsUser, struct VbglR0ParmInfo *pParmInfo, size_t *pcbExtra)
188{
189 HGCMFunctionParameter const *pSrcParm = VBOXGUEST_HGCM_CALL_PARMS(pCallInfo);
190 uint32_t cParms = pCallInfo->cParms;
191 uint32_t iParm;
192 uint32_t cb;
193
194 /*
195 * Lock down the any linear buffers so we can get their addresses
196 * and figure out how much extra storage we need for page lists.
197 *
198 * Note! With kernel mode users we can be assertive. For user mode users
199 * we should just (debug) log it and fail without any fanfare.
200 */
201 *pcbExtra = 0;
202 pParmInfo->cLockBufs = 0;
203 for (iParm = 0; iParm < cParms; iParm++, pSrcParm++)
204 {
205 switch (pSrcParm->type)
206 {
207 case VMMDevHGCMParmType_32bit:
208 Log4(("GstHGCMCall: parm=%u type=32bit: %#010x\n", iParm, pSrcParm->u.value32));
209 break;
210
211 case VMMDevHGCMParmType_64bit:
212 Log4(("GstHGCMCall: parm=%u type=64bit: %#018RX64\n", iParm, pSrcParm->u.value64));
213 break;
214
215 case VMMDevHGCMParmType_PageList:
216 if (fIsUser)
217 return VERR_INVALID_PARAMETER;
218 cb = pSrcParm->u.PageList.size;
219 if (cb)
220 {
221 uint32_t off = pSrcParm->u.PageList.offset;
222 HGCMPageListInfo *pPgLst;
223 uint32_t cPages;
224 uint32_t u32;
225
226 AssertMsgReturn(cb <= VBGLR0_MAX_HGCM_KERNEL_PARM, ("%#x > %#x\n", cb, VBGLR0_MAX_HGCM_KERNEL_PARM),
227 VERR_OUT_OF_RANGE);
228 AssertMsgReturn( off >= pCallInfo->cParms * sizeof(HGCMFunctionParameter)
229 && off <= cbCallInfo - sizeof(HGCMPageListInfo),
230 ("offset=%#x cParms=%#x cbCallInfo=%#x\n", off, pCallInfo->cParms, cbCallInfo),
231 VERR_INVALID_PARAMETER);
232
233 pPgLst = (HGCMPageListInfo *)((uint8_t *)pCallInfo + off);
234 cPages = pPgLst->cPages;
235 u32 = RT_OFFSETOF(HGCMPageListInfo, aPages[cPages]) + off;
236 AssertMsgReturn(u32 <= cbCallInfo,
237 ("u32=%#x (cPages=%#x offset=%#x) cbCallInfo=%#x\n", u32, cPages, off, cbCallInfo),
238 VERR_INVALID_PARAMETER);
239 AssertMsgReturn(pPgLst->offFirstPage < PAGE_SIZE, ("#x\n", pPgLst->offFirstPage), VERR_INVALID_PARAMETER);
240 u32 = RT_ALIGN_32(pPgLst->offFirstPage + cb, PAGE_SIZE) >> PAGE_SHIFT;
241 AssertMsgReturn(cPages == u32, ("cPages=%#x u32=%#x\n", cPages, u32), VERR_INVALID_PARAMETER);
242 AssertMsgReturn(VBOX_HGCM_F_PARM_ARE_VALID(pPgLst->flags), ("%#x\n", pPgLst->flags), VERR_INVALID_PARAMETER);
243 Log4(("GstHGCMCall: parm=%u type=pglst: cb=%#010x cPgs=%u offPg0=%#x flags=%#x\n",
244 iParm, cb, cPages, pPgLst->offFirstPage, pPgLst->flags));
245 u32 = cPages;
246 while (u32-- > 0)
247 {
248 Log4(("GstHGCMCall: pg#%u=%RHp\n", u32, pPgLst->aPages[u32]));
249 AssertMsgReturn(!(pPgLst->aPages[u32] & (PAGE_OFFSET_MASK | UINT64_C(0xfff0000000000000))),
250 ("pg#%u=%RHp\n", u32, pPgLst->aPages[u32]),
251 VERR_INVALID_PARAMETER);
252 }
253
254 *pcbExtra += RT_OFFSETOF(HGCMPageListInfo, aPages[pPgLst->cPages]);
255 }
256 else
257 Log4(("GstHGCMCall: parm=%u type=pglst: cb=0\n", iParm));
258 break;
259
260 case VMMDevHGCMParmType_LinAddr_Locked_In:
261 case VMMDevHGCMParmType_LinAddr_Locked_Out:
262 case VMMDevHGCMParmType_LinAddr_Locked:
263 if (fIsUser)
264 return VERR_INVALID_PARAMETER;
265 if (!VBGLR0_CAN_USE_PHYS_PAGE_LIST(/*a_fLocked =*/ true))
266 {
267 cb = pSrcParm->u.Pointer.size;
268 AssertMsgReturn(cb <= VBGLR0_MAX_HGCM_KERNEL_PARM, ("%#x > %#x\n", cb, VBGLR0_MAX_HGCM_KERNEL_PARM),
269 VERR_OUT_OF_RANGE);
270 if (cb != 0)
271 Log4(("GstHGCMCall: parm=%u type=%#x: cb=%#010x pv=%p\n",
272 iParm, pSrcParm->type, cb, pSrcParm->u.Pointer.u.linearAddr));
273 else
274 Log4(("GstHGCMCall: parm=%u type=%#x: cb=0\n", iParm, pSrcParm->type));
275 break;
276 }
277 /* fall thru */
278
279 case VMMDevHGCMParmType_LinAddr_In:
280 case VMMDevHGCMParmType_LinAddr_Out:
281 case VMMDevHGCMParmType_LinAddr:
282 cb = pSrcParm->u.Pointer.size;
283 if (cb != 0)
284 {
285#ifdef USE_BOUNCE_BUFFERS
286 void *pvSmallBuf = NULL;
287#endif
288 uint32_t iLockBuf = pParmInfo->cLockBufs;
289 RTR0MEMOBJ hObj;
290 int rc;
291 uint32_t fAccess = pSrcParm->type == VMMDevHGCMParmType_LinAddr_In
292 || pSrcParm->type == VMMDevHGCMParmType_LinAddr_Locked_In
293 ? RTMEM_PROT_READ
294 : RTMEM_PROT_READ | RTMEM_PROT_WRITE;
295
296 AssertReturn(iLockBuf < RT_ELEMENTS(pParmInfo->aLockBufs), VERR_INVALID_PARAMETER);
297 if (!fIsUser)
298 {
299 AssertMsgReturn(cb <= VBGLR0_MAX_HGCM_KERNEL_PARM, ("%#x > %#x\n", cb, VBGLR0_MAX_HGCM_KERNEL_PARM),
300 VERR_OUT_OF_RANGE);
301 rc = RTR0MemObjLockKernel(&hObj, (void *)pSrcParm->u.Pointer.u.linearAddr, cb, fAccess);
302 if (RT_FAILURE(rc))
303 {
304 Log(("GstHGCMCall: id=%#x fn=%u parm=%u RTR0MemObjLockKernel(,%p,%#x) -> %Rrc\n",
305 pCallInfo->u32ClientID, pCallInfo->u32Function, iParm, pSrcParm->u.Pointer.u.linearAddr, cb, rc));
306 return rc;
307 }
308 Log3(("GstHGCMCall: parm=%u type=%#x: cb=%#010x pv=%p locked kernel -> %p\n",
309 iParm, pSrcParm->type, cb, pSrcParm->u.Pointer.u.linearAddr, hObj));
310 }
311 else if (cb > VBGLR0_MAX_HGCM_USER_PARM)
312 {
313 Log(("GstHGCMCall: id=%#x fn=%u parm=%u pv=%p cb=%#x > %#x -> out of range\n",
314 pCallInfo->u32ClientID, pCallInfo->u32Function, iParm, pSrcParm->u.Pointer.u.linearAddr,
315 cb, VBGLR0_MAX_HGCM_USER_PARM));
316 return VERR_OUT_OF_RANGE;
317 }
318 else
319 {
320#ifndef USE_BOUNCE_BUFFERS
321 rc = RTR0MemObjLockUser(&hObj, (RTR3PTR)pSrcParm->u.Pointer.u.linearAddr, cb, fAccess, NIL_RTR0PROCESS);
322 if (RT_FAILURE(rc))
323 {
324 Log(("GstHGCMCall: id=%#x fn=%u parm=%u RTR0MemObjLockUser(,%p,%#x,nil) -> %Rrc\n",
325 pCallInfo->u32ClientID, pCallInfo->u32Function, iParm, pSrcParm->u.Pointer.u.linearAddr, cb, rc));
326 return rc;
327 }
328 Log3(("GstHGCMCall: parm=%u type=%#x: cb=%#010x pv=%p locked user -> %p\n",
329 iParm, pSrcParm->type, cb, pSrcParm->u.Pointer.u.linearAddr, hObj));
330
331#else /* USE_BOUNCE_BUFFERS */
332 /*
333 * This is a bit massive, but we don't want to waste a
334 * whole page for a 3 byte string buffer (guest props).
335 *
336 * The threshold is ASSUMING sizeof(RTMEMHDR) == 16 and
337 * the system is using some power of two allocator.
338 */
339 /** @todo A more efficient strategy would be to combine buffers. However it
340 * is probably going to be more massive than the current code, so
341 * it can wait till later. */
342 bool fCopyIn = pSrcParm->type != VMMDevHGCMParmType_LinAddr_Out
343 && pSrcParm->type != VMMDevHGCMParmType_LinAddr_Locked_Out;
344 if (cb <= PAGE_SIZE / 2 - 16)
345 {
346 pvSmallBuf = fCopyIn ? RTMemTmpAlloc(cb) : RTMemTmpAllocZ(cb);
347 if (RT_UNLIKELY(!pvSmallBuf))
348 return VERR_NO_MEMORY;
349 if (fCopyIn)
350 {
351 rc = RTR0MemUserCopyFrom(pvSmallBuf, pSrcParm->u.Pointer.u.linearAddr, cb);
352 if (RT_FAILURE(rc))
353 {
354 RTMemTmpFree(pvSmallBuf);
355 Log(("GstHGCMCall: id=%#x fn=%u parm=%u RTR0MemUserCopyFrom(,%p,%#x) -> %Rrc\n",
356 pCallInfo->u32ClientID, pCallInfo->u32Function, iParm,
357 pSrcParm->u.Pointer.u.linearAddr, cb, rc));
358 return rc;
359 }
360 }
361 rc = RTR0MemObjLockKernel(&hObj, pvSmallBuf, cb, fAccess);
362 if (RT_FAILURE(rc))
363 {
364 RTMemTmpFree(pvSmallBuf);
365 Log(("GstHGCMCall: RTR0MemObjLockKernel failed for small buffer: rc=%Rrc pvSmallBuf=%p cb=%#x\n",
366 rc, pvSmallBuf, cb));
367 return rc;
368 }
369 Log3(("GstHGCMCall: parm=%u type=%#x: cb=%#010x pv=%p small buffer %p -> %p\n",
370 iParm, pSrcParm->type, cb, pSrcParm->u.Pointer.u.linearAddr, pvSmallBuf, hObj));
371 }
372 else
373 {
374 rc = RTR0MemObjAllocPage(&hObj, cb, false /*fExecutable*/);
375 if (RT_FAILURE(rc))
376 return rc;
377 if (!fCopyIn)
378 memset(RTR0MemObjAddress(hObj), '\0', cb);
379 else
380 {
381 rc = RTR0MemUserCopyFrom(RTR0MemObjAddress(hObj), pSrcParm->u.Pointer.u.linearAddr, cb);
382 if (RT_FAILURE(rc))
383 {
384 RTR0MemObjFree(hObj, false /*fFreeMappings*/);
385 Log(("GstHGCMCall: id=%#x fn=%u parm=%u RTR0MemUserCopyFrom(,%p,%#x) -> %Rrc\n",
386 pCallInfo->u32ClientID, pCallInfo->u32Function, iParm,
387 pSrcParm->u.Pointer.u.linearAddr, cb, rc));
388 return rc;
389 }
390 }
391 Log3(("GstHGCMCall: parm=%u type=%#x: cb=%#010x pv=%p big buffer -> %p\n",
392 iParm, pSrcParm->type, cb, pSrcParm->u.Pointer.u.linearAddr, hObj));
393 }
394#endif /* USE_BOUNCE_BUFFERS */
395 }
396
397 pParmInfo->aLockBufs[iLockBuf].iParm = iParm;
398 pParmInfo->aLockBufs[iLockBuf].hObj = hObj;
399#ifdef USE_BOUNCE_BUFFERS
400 pParmInfo->aLockBufs[iLockBuf].pvSmallBuf = pvSmallBuf;
401#endif
402 pParmInfo->cLockBufs = iLockBuf + 1;
403
404 if (VBGLR0_CAN_USE_PHYS_PAGE_LIST(/*a_fLocked =*/ false))
405 {
406 size_t const cPages = RTR0MemObjSize(hObj) >> PAGE_SHIFT;
407 *pcbExtra += RT_OFFSETOF(HGCMPageListInfo, aPages[cPages]);
408 }
409 }
410 else
411 Log4(("GstHGCMCall: parm=%u type=%#x: cb=0\n", iParm, pSrcParm->type));
412 break;
413
414 default:
415 return VERR_INVALID_PARAMETER;
416 }
417 }
418
419 return VINF_SUCCESS;
420}
421
422
423/**
424 * Translates locked linear address to the normal type.
425 * The locked types are only for the guest side and not handled by the host.
426 *
427 * @returns normal linear address type.
428 * @param enmType The type.
429 */
430static HGCMFunctionParameterType vbglR0HGCMInternalConvertLinAddrType(HGCMFunctionParameterType enmType)
431{
432 switch (enmType)
433 {
434 case VMMDevHGCMParmType_LinAddr_Locked_In:
435 return VMMDevHGCMParmType_LinAddr_In;
436 case VMMDevHGCMParmType_LinAddr_Locked_Out:
437 return VMMDevHGCMParmType_LinAddr_Out;
438 case VMMDevHGCMParmType_LinAddr_Locked:
439 return VMMDevHGCMParmType_LinAddr;
440 default:
441 return enmType;
442 }
443}
444
445
446/**
447 * Translates linear address types to page list direction flags.
448 *
449 * @returns page list flags.
450 * @param enmType The type.
451 */
452static uint32_t vbglR0HGCMInternalLinAddrTypeToPageListFlags(HGCMFunctionParameterType enmType)
453{
454 switch (enmType)
455 {
456 case VMMDevHGCMParmType_LinAddr_In:
457 case VMMDevHGCMParmType_LinAddr_Locked_In:
458 return VBOX_HGCM_F_PARM_DIRECTION_TO_HOST;
459
460 case VMMDevHGCMParmType_LinAddr_Out:
461 case VMMDevHGCMParmType_LinAddr_Locked_Out:
462 return VBOX_HGCM_F_PARM_DIRECTION_FROM_HOST;
463
464 default: AssertFailed();
465 case VMMDevHGCMParmType_LinAddr:
466 case VMMDevHGCMParmType_LinAddr_Locked:
467 return VBOX_HGCM_F_PARM_DIRECTION_BOTH;
468 }
469}
470
471
472/**
473 * Initializes the call request that we're sending to the host.
474 *
475 * @returns VBox status code.
476 *
477 * @param pCallInfo The call info.
478 * @param cbCallInfo The size of the call info structure.
479 * @param fIsUser Is it a user request or kernel request.
480 * @param pcbExtra Where to return the extra request space needed for
481 * physical page lists.
482 */
483static void vbglR0HGCMInternalInitCall(VMMDevHGCMCall *pHGCMCall, VBoxGuestHGCMCallInfo const *pCallInfo,
484 uint32_t cbCallInfo, bool fIsUser, struct VbglR0ParmInfo *pParmInfo)
485{
486 HGCMFunctionParameter const *pSrcParm = VBOXGUEST_HGCM_CALL_PARMS(pCallInfo);
487 HGCMFunctionParameter *pDstParm = VMMDEV_HGCM_CALL_PARMS(pHGCMCall);
488 uint32_t cParms = pCallInfo->cParms;
489 uint32_t offExtra = (uintptr_t)(pDstParm + cParms) - (uintptr_t)pHGCMCall;
490 uint32_t iLockBuf = 0;
491 uint32_t iParm;
492
493
494 /*
495 * The call request headers.
496 */
497 pHGCMCall->header.fu32Flags = 0;
498 pHGCMCall->header.result = VINF_SUCCESS;
499
500 pHGCMCall->u32ClientID = pCallInfo->u32ClientID;
501 pHGCMCall->u32Function = pCallInfo->u32Function;
502 pHGCMCall->cParms = cParms;
503
504 /*
505 * The parameters.
506 */
507 for (iParm = 0; iParm < pCallInfo->cParms; iParm++, pSrcParm++, pDstParm++)
508 {
509 switch (pSrcParm->type)
510 {
511 case VMMDevHGCMParmType_32bit:
512 case VMMDevHGCMParmType_64bit:
513 *pDstParm = *pSrcParm;
514 break;
515
516 case VMMDevHGCMParmType_PageList:
517 pDstParm->type = VMMDevHGCMParmType_PageList;
518 pDstParm->u.PageList.size = pSrcParm->u.PageList.size;
519 if (pSrcParm->u.PageList.size)
520 {
521 HGCMPageListInfo const *pSrcPgLst = (HGCMPageListInfo *)((uint8_t *)pCallInfo + pSrcParm->u.PageList.offset);
522 HGCMPageListInfo *pDstPgLst = (HGCMPageListInfo *)((uint8_t *)pHGCMCall + offExtra);
523 uint32_t const cPages = pSrcPgLst->cPages;
524 uint32_t iPage;
525
526 pDstParm->u.PageList.offset = offExtra;
527 pDstPgLst->flags = pSrcPgLst->flags;
528 pDstPgLst->offFirstPage = pSrcPgLst->offFirstPage;
529 pDstPgLst->cPages = cPages;
530 for (iPage = 0; iPage < cPages; iPage++)
531 pDstPgLst->aPages[iPage] = pSrcPgLst->aPages[iPage];
532
533 offExtra += RT_OFFSETOF(HGCMPageListInfo, aPages[cPages]);
534 }
535 else
536 pDstParm->u.PageList.offset = 0;
537 break;
538
539 case VMMDevHGCMParmType_LinAddr_Locked_In:
540 case VMMDevHGCMParmType_LinAddr_Locked_Out:
541 case VMMDevHGCMParmType_LinAddr_Locked:
542 if (!VBGLR0_CAN_USE_PHYS_PAGE_LIST(/*a_fLocked =*/ true))
543 {
544 *pDstParm = *pSrcParm;
545 pDstParm->type = vbglR0HGCMInternalConvertLinAddrType(pSrcParm->type);
546 break;
547 }
548 /* fall thru */
549
550 case VMMDevHGCMParmType_LinAddr_In:
551 case VMMDevHGCMParmType_LinAddr_Out:
552 case VMMDevHGCMParmType_LinAddr:
553 if (pSrcParm->u.Pointer.size != 0)
554 {
555#ifdef USE_BOUNCE_BUFFERS
556 void *pvSmallBuf = pParmInfo->aLockBufs[iLockBuf].pvSmallBuf;
557#endif
558 RTR0MEMOBJ hObj = pParmInfo->aLockBufs[iLockBuf].hObj;
559 Assert(iParm == pParmInfo->aLockBufs[iLockBuf].iParm);
560
561 if (VBGLR0_CAN_USE_PHYS_PAGE_LIST(/*a_fLocked =*/ false))
562 {
563 HGCMPageListInfo *pDstPgLst = (HGCMPageListInfo *)((uint8_t *)pHGCMCall + offExtra);
564 size_t const cPages = RTR0MemObjSize(hObj) >> PAGE_SHIFT;
565 size_t iPage;
566
567 pDstParm->type = VMMDevHGCMParmType_PageList;
568 pDstParm->u.PageList.size = pSrcParm->u.Pointer.size;
569 pDstParm->u.PageList.offset = offExtra;
570 pDstPgLst->flags = vbglR0HGCMInternalLinAddrTypeToPageListFlags(pSrcParm->type);
571#ifdef USE_BOUNCE_BUFFERS
572 if (fIsUser)
573 pDstPgLst->offFirstPage = (uintptr_t)pvSmallBuf & PAGE_OFFSET_MASK;
574 else
575#endif
576 pDstPgLst->offFirstPage = pSrcParm->u.Pointer.u.linearAddr & PAGE_OFFSET_MASK;
577 pDstPgLst->cPages = cPages; Assert(pDstPgLst->cPages == cPages);
578 for (iPage = 0; iPage < cPages; iPage++)
579 {
580 pDstPgLst->aPages[iPage] = RTR0MemObjGetPagePhysAddr(hObj, iPage);
581 Assert(pDstPgLst->aPages[iPage] != NIL_RTHCPHYS);
582 }
583
584 offExtra += RT_OFFSETOF(HGCMPageListInfo, aPages[cPages]);
585 }
586 else
587 {
588 pDstParm->type = vbglR0HGCMInternalConvertLinAddrType(pSrcParm->type);
589 pDstParm->u.Pointer.size = pSrcParm->u.Pointer.size;
590#ifdef USE_BOUNCE_BUFFERS
591 if (fIsUser)
592 pDstParm->u.Pointer.u.linearAddr = pvSmallBuf
593 ? (uintptr_t)pvSmallBuf
594 : (uintptr_t)RTR0MemObjAddress(hObj);
595 else
596#endif
597 pDstParm->u.Pointer.u.linearAddr = pSrcParm->u.Pointer.u.linearAddr;
598 }
599 iLockBuf++;
600 }
601 else
602 {
603 pDstParm->type = vbglR0HGCMInternalConvertLinAddrType(pSrcParm->type);
604 pDstParm->u.Pointer.size = 0;
605 pDstParm->u.Pointer.u.linearAddr = 0;
606 }
607 break;
608
609 default:
610 AssertFailed();
611 pDstParm->type = VMMDevHGCMParmType_Invalid;
612 break;
613 }
614 }
615}
616
617
618/**
619 * Performs the call and completion wait.
620 *
621 * @returns VBox status code of this operation, not necessarily the call.
622 *
623 * @param pHGCMCall The HGCM call info.
624 * @param pfnAsyncCallback The async callback that will wait for the call
625 * to complete.
626 * @param pvAsyncData Argument for the callback.
627 * @param u32AsyncData Argument for the callback.
628 * @param pfLeakIt Where to return the leak it / free it,
629 * indicator. Cancellation fun.
630 */
631static int vbglR0HGCMInternalDoCall(VMMDevHGCMCall *pHGCMCall, PFNVBGLHGCMCALLBACK pfnAsyncCallback,
632 void *pvAsyncData, uint32_t u32AsyncData, bool *pfLeakIt)
633{
634 int rc;
635
636 Log(("calling VbglGRPerform\n"));
637 rc = VbglGRPerform(&pHGCMCall->header.header);
638 Log(("VbglGRPerform rc = %Rrc (header rc=%d)\n", rc, pHGCMCall->header.result));
639
640 /*
641 * If the call failed, but as a result of the request itself, then pretend
642 * success. Upper layers will interpret the result code in the packet.
643 */
644 if ( RT_FAILURE(rc)
645 && rc == pHGCMCall->header.result)
646 {
647 Assert(pHGCMCall->header.fu32Flags & VBOX_HGCM_REQ_DONE);
648 rc = VINF_SUCCESS;
649 }
650
651 /*
652 * Check if host decides to process the request asynchronously,
653 * if so, we wait for it to complete using the caller supplied callback.
654 */
655 *pfLeakIt = false;
656 if (rc == VINF_HGCM_ASYNC_EXECUTE)
657 {
658 Log(("Processing HGCM call asynchronously\n"));
659 rc = pfnAsyncCallback(&pHGCMCall->header, pvAsyncData, u32AsyncData);
660 if (pHGCMCall->header.fu32Flags & VBOX_HGCM_REQ_DONE)
661 {
662 Assert(!(pHGCMCall->header.fu32Flags & VBOX_HGCM_REQ_CANCELLED));
663 rc = VINF_SUCCESS;
664 }
665 else
666 {
667 /*
668 * The request didn't complete in time or the call was interrupted,
669 * the RC from the callback indicates which. Try cancel the request.
670 *
671 * This is a bit messy because we're racing request completion. Sorry.
672 */
673 /** @todo It would be nice if we could use the waiter callback to do further
674 * waiting in case of a completion race. If it wasn't for WINNT having its own
675 * version of all that stuff, I would've done it already. */
676 VMMDevHGCMCancel2 *pCancelReq;
677 int rc2 = VbglGRAlloc((VMMDevRequestHeader **)&pCancelReq, sizeof(*pCancelReq), VMMDevReq_HGCMCancel2);
678 if (RT_SUCCESS(rc2))
679 {
680 pCancelReq->physReqToCancel = VbglPhysHeapGetPhysAddr(pHGCMCall);
681 rc2 = VbglGRPerform(&pCancelReq->header);
682 VbglGRFree(&pCancelReq->header);
683 }
684#if 1 /** @todo ADDVER: Remove this on next minor version change. */
685 if (rc2 == VERR_NOT_IMPLEMENTED)
686 {
687 /* host is too old, or we're out of heap. */
688 pHGCMCall->header.fu32Flags |= VBOX_HGCM_REQ_CANCELLED;
689 pHGCMCall->header.header.requestType = VMMDevReq_HGCMCancel;
690 rc2 = VbglGRPerform(&pHGCMCall->header.header);
691 if (rc2 == VERR_INVALID_PARAMETER)
692 rc2 = VERR_NOT_FOUND;
693 else if (RT_SUCCESS(rc))
694 RTThreadSleep(1);
695 }
696#endif
697 if (RT_SUCCESS(rc)) rc = VERR_INTERRUPTED; /** @todo weed this out from the WINNT VBoxGuest code. */
698 if (RT_SUCCESS(rc2))
699 {
700 Log(("vbglR0HGCMInternalDoCall: successfully cancelled\n"));
701 pHGCMCall->header.fu32Flags |= VBOX_HGCM_REQ_CANCELLED;
702 }
703 else
704 {
705 /*
706 * Wait for a bit while the host (hopefully) completes it.
707 */
708 uint64_t u64Start = RTTimeSystemMilliTS();
709 uint32_t cMilliesToWait = rc2 == VERR_NOT_FOUND || rc2 == VERR_SEM_DESTROYED ? 500 : 2000;
710 uint64_t cElapsed = 0;
711 if (rc2 != VERR_NOT_FOUND)
712 {
713 static unsigned s_cErrors = 0;
714 if (s_cErrors++ < 32)
715 LogRel(("vbglR0HGCMInternalDoCall: Failed to cancel the HGCM call on %Rrc: rc2=%Rrc\n", rc, rc2));
716 }
717 else
718 Log(("vbglR0HGCMInternalDoCall: Cancel race rc=%Rrc rc2=%Rrc\n", rc, rc2));
719
720 do
721 {
722 ASMCompilerBarrier(); /* paranoia */
723 if (pHGCMCall->header.fu32Flags & VBOX_HGCM_REQ_DONE)
724 break;
725 RTThreadSleep(1);
726 cElapsed = RTTimeSystemMilliTS() - u64Start;
727 } while (cElapsed < cMilliesToWait);
728
729 ASMCompilerBarrier(); /* paranoia^2 */
730 if (pHGCMCall->header.fu32Flags & VBOX_HGCM_REQ_DONE)
731 rc = VINF_SUCCESS;
732 else
733 {
734 LogRel(("vbglR0HGCMInternalDoCall: Leaking %u bytes. Pending call to %u with %u parms. (rc2=%Rrc)\n",
735 pHGCMCall->header.header.size, pHGCMCall->u32Function, pHGCMCall->cParms, rc2));
736 *pfLeakIt = true;
737 }
738 Log(("vbglR0HGCMInternalDoCall: Cancel race ended with rc=%Rrc (rc2=%Rrc) after %llu ms\n", rc, rc2, cElapsed));
739 }
740 }
741 }
742
743 Log(("GstHGCMCall: rc=%Rrc result=%Rrc fu32Flags=%#x fLeakIt=%d\n",
744 rc, pHGCMCall->header.result, pHGCMCall->header.fu32Flags, *pfLeakIt));
745 return rc;
746}
747
748
749/**
750 * Copies the result of the call back to the caller info structure and user
751 * buffers (if using bounce buffers).
752 *
753 * @returns rc, unless RTR0MemUserCopyTo fails.
754 * @param pCallInfo Call info structure to update.
755 * @param pHGCMCall HGCM call request.
756 * @param pParmInfo Parameter locking/buffering info.
757 * @param fIsUser Is it a user (true) or kernel request.
758 * @param rc The current result code. Passed along to
759 * preserve informational status codes.
760 */
761static int vbglR0HGCMInternalCopyBackResult(VBoxGuestHGCMCallInfo *pCallInfo, VMMDevHGCMCall const *pHGCMCall,
762 struct VbglR0ParmInfo *pParmInfo, bool fIsUser, int rc)
763{
764 HGCMFunctionParameter const *pSrcParm = VMMDEV_HGCM_CALL_PARMS(pHGCMCall);
765 HGCMFunctionParameter *pDstParm = VBOXGUEST_HGCM_CALL_PARMS(pCallInfo);
766 uint32_t cParms = pCallInfo->cParms;
767#ifdef USE_BOUNCE_BUFFERS
768 uint32_t iLockBuf = 0;
769#endif
770 uint32_t iParm;
771
772 /*
773 * The call result.
774 */
775 pCallInfo->result = pHGCMCall->header.result;
776
777 /*
778 * Copy back parameters.
779 */
780 for (iParm = 0; iParm < cParms; iParm++, pSrcParm++, pDstParm++)
781 {
782 switch (pDstParm->type)
783 {
784 case VMMDevHGCMParmType_32bit:
785 case VMMDevHGCMParmType_64bit:
786 *pDstParm = *pSrcParm;
787 break;
788
789 case VMMDevHGCMParmType_PageList:
790 pDstParm->u.PageList.size = pSrcParm->u.PageList.size;
791 break;
792
793 case VMMDevHGCMParmType_LinAddr_Locked_In:
794 case VMMDevHGCMParmType_LinAddr_In:
795#ifdef USE_BOUNCE_BUFFERS
796 if ( fIsUser
797 && iLockBuf < pParmInfo->cLockBufs
798 && iParm == pParmInfo->aLockBufs[iLockBuf].iParm)
799 iLockBuf++;
800#endif
801 pDstParm->u.Pointer.size = pSrcParm->u.Pointer.size;
802 break;
803
804 case VMMDevHGCMParmType_LinAddr_Locked_Out:
805 case VMMDevHGCMParmType_LinAddr_Locked:
806 if (!VBGLR0_CAN_USE_PHYS_PAGE_LIST(/*a_fLocked =*/ true))
807 {
808 pDstParm->u.Pointer.size = pSrcParm->u.Pointer.size;
809 break;
810 }
811 /* fall thru */
812
813 case VMMDevHGCMParmType_LinAddr_Out:
814 case VMMDevHGCMParmType_LinAddr:
815 {
816#ifdef USE_BOUNCE_BUFFERS
817 if (fIsUser)
818 {
819 size_t cbOut = RT_MIN(pSrcParm->u.Pointer.size, pDstParm->u.Pointer.size);
820 if (cbOut)
821 {
822 int rc2;
823 Assert(pParmInfo->aLockBufs[iLockBuf].iParm == iParm);
824 rc2 = RTR0MemUserCopyTo((RTR3PTR)pDstParm->u.Pointer.u.linearAddr,
825 pParmInfo->aLockBufs[iLockBuf].pvSmallBuf
826 ? pParmInfo->aLockBufs[iLockBuf].pvSmallBuf
827 : RTR0MemObjAddress(pParmInfo->aLockBufs[iLockBuf].hObj),
828 cbOut);
829 if (RT_FAILURE(rc2))
830 return rc2;
831 iLockBuf++;
832 }
833 else if ( iLockBuf < pParmInfo->cLockBufs
834 && iParm == pParmInfo->aLockBufs[iLockBuf].iParm)
835 iLockBuf++;
836 }
837#endif
838 pDstParm->u.Pointer.size = pSrcParm->u.Pointer.size;
839 break;
840 }
841
842 default:
843 AssertFailed();
844 rc = VERR_INTERNAL_ERROR_4;
845 break;
846 }
847 }
848
849#ifdef USE_BOUNCE_BUFFERS
850 Assert(!fIsUser || pParmInfo->cLockBufs == iLockBuf);
851#endif
852 return rc;
853}
854
855
856DECLR0VBGL(int) VbglR0HGCMInternalCall(VBoxGuestHGCMCallInfo *pCallInfo, uint32_t cbCallInfo, uint32_t fFlags,
857 PFNVBGLHGCMCALLBACK pfnAsyncCallback, void *pvAsyncData, uint32_t u32AsyncData)
858{
859 bool fIsUser = (fFlags & VBGLR0_HGCMCALL_F_MODE_MASK) == VBGLR0_HGCMCALL_F_USER;
860 struct VbglR0ParmInfo ParmInfo;
861 size_t cbExtra;
862 int rc;
863
864 /*
865 * Basic validation.
866 */
867 AssertMsgReturn( !pCallInfo
868 || !pfnAsyncCallback
869 || pCallInfo->cParms > VBOX_HGCM_MAX_PARMS
870 || !(fFlags & ~VBGLR0_HGCMCALL_F_MODE_MASK),
871 ("pCallInfo=%p pfnAsyncCallback=%p fFlags=%#x\n", pCallInfo, pfnAsyncCallback, fFlags),
872 VERR_INVALID_PARAMETER);
873 AssertReturn( cbCallInfo >= sizeof(VBoxGuestHGCMCallInfo)
874 || cbCallInfo >= pCallInfo->cParms * sizeof(HGCMFunctionParameter),
875 VERR_INVALID_PARAMETER);
876
877 Log(("GstHGCMCall: u32ClientID=%#x u32Function=%u cParms=%u cbCallInfo=%#x fFlags=%#x\n",
878 pCallInfo->u32ClientID, pCallInfo->u32ClientID, pCallInfo->u32Function, pCallInfo->cParms, cbCallInfo, fFlags));
879
880 /*
881 * Validate, lock and buffer the parameters for the call.
882 * This will calculate the amount of extra space for physical page list.
883 */
884 rc = vbglR0HGCMInternalPreprocessCall(pCallInfo, cbCallInfo, fIsUser, &ParmInfo, &cbExtra);
885 if (RT_SUCCESS(rc))
886 {
887 /*
888 * Allocate the request buffer and recreate the call request.
889 */
890 VMMDevHGCMCall *pHGCMCall;
891 rc = VbglGRAlloc((VMMDevRequestHeader **)&pHGCMCall,
892 sizeof(VMMDevHGCMCall) + pCallInfo->cParms * sizeof(HGCMFunctionParameter) + cbExtra,
893 VMMDevReq_HGCMCall);
894 if (RT_SUCCESS(rc))
895 {
896 bool fLeakIt;
897 vbglR0HGCMInternalInitCall(pHGCMCall, pCallInfo, cbCallInfo, fIsUser, &ParmInfo);
898
899 /*
900 * Perform the call.
901 */
902 rc = vbglR0HGCMInternalDoCall(pHGCMCall, pfnAsyncCallback, pvAsyncData, u32AsyncData, &fLeakIt);
903 if (RT_SUCCESS(rc))
904 {
905 /*
906 * Copy back the result (parameters and buffers that changed).
907 */
908 rc = vbglR0HGCMInternalCopyBackResult(pCallInfo, pHGCMCall, &ParmInfo, fIsUser, rc);
909 }
910 else
911 {
912 if ( rc != VERR_INTERRUPTED
913 && rc != VERR_TIMEOUT)
914 {
915 static unsigned s_cErrors = 0;
916 if (s_cErrors++ < 32)
917 LogRel(("VbglR0HGCMInternalCall: vbglR0HGCMInternalDoCall failed. rc=%Rrc\n", rc));
918 }
919 }
920
921 if (!fLeakIt)
922 VbglGRFree(&pHGCMCall->header.header);
923 }
924 }
925 else
926 LogRel(("VbglR0HGCMInternalCall: vbglR0HGCMInternalPreprocessCall failed. rc=%Rrc\n", rc));
927
928 /*
929 * Release locks and free bounce buffers.
930 */
931 if (ParmInfo.cLockBufs)
932 while (ParmInfo.cLockBufs-- > 0)
933 {
934 RTR0MemObjFree(ParmInfo.aLockBufs[ParmInfo.cLockBufs].hObj, false /*fFreeMappings*/);
935#ifdef USE_BOUNCE_BUFFERS
936 RTMemTmpFree(ParmInfo.aLockBufs[ParmInfo.cLockBufs].pvSmallBuf);
937#endif
938 }
939
940 return rc;
941}
942
943
944#if ARCH_BITS == 64
945DECLR0VBGL(int) VbglR0HGCMInternalCall32(VBoxGuestHGCMCallInfo *pCallInfo, uint32_t cbCallInfo, uint32_t fFlags,
946 PFNVBGLHGCMCALLBACK pfnAsyncCallback, void *pvAsyncData, uint32_t u32AsyncData)
947{
948 VBoxGuestHGCMCallInfo *pCallInfo64 = NULL;
949 HGCMFunctionParameter *pParm64 = NULL;
950 HGCMFunctionParameter32 *pParm32 = NULL;
951 uint32_t cParms = 0;
952 uint32_t iParm = 0;
953 int rc = VINF_SUCCESS;
954
955 /*
956 * Input validation.
957 */
958 AssertMsgReturn( !pCallInfo
959 || !pfnAsyncCallback
960 || pCallInfo->cParms > VBOX_HGCM_MAX_PARMS
961 || !(fFlags & ~VBGLR0_HGCMCALL_F_MODE_MASK),
962 ("pCallInfo=%p pfnAsyncCallback=%p fFlags=%#x\n", pCallInfo, pfnAsyncCallback, fFlags),
963 VERR_INVALID_PARAMETER);
964 AssertReturn( cbCallInfo >= sizeof(VBoxGuestHGCMCallInfo)
965 || cbCallInfo >= pCallInfo->cParms * sizeof(HGCMFunctionParameter32),
966 VERR_INVALID_PARAMETER);
967
968 /* This Assert does not work on Solaris/Windows 64/32 mixed mode, not sure why, skipping for now */
969#if !defined(RT_OS_SOLARIS) && !defined(RT_OS_WINDOWS)
970 AssertReturn((fFlags & VBGLR0_HGCMCALL_F_MODE_MASK) == VBGLR0_HGCMCALL_F_KERNEL, VERR_WRONG_ORDER);
971#endif
972
973 cParms = pCallInfo->cParms;
974 Log(("VbglR0HGCMInternalCall32: cParms=%d, u32Function=%d, fFlags=%#x\n", cParms, pCallInfo->u32Function, fFlags));
975
976 /*
977 * The simple approach, allocate a temporary request and convert the parameters.
978 */
979 pCallInfo64 = (VBoxGuestHGCMCallInfo *)RTMemTmpAllocZ(sizeof(*pCallInfo64) + cParms * sizeof(HGCMFunctionParameter));
980 if (!pCallInfo64)
981 return VERR_NO_TMP_MEMORY;
982
983 *pCallInfo64 = *pCallInfo;
984 pParm32 = VBOXGUEST_HGCM_CALL_PARMS32(pCallInfo);
985 pParm64 = VBOXGUEST_HGCM_CALL_PARMS(pCallInfo64);
986 for (iParm = 0; iParm < cParms; iParm++, pParm32++, pParm64++)
987 {
988 switch (pParm32->type)
989 {
990 case VMMDevHGCMParmType_32bit:
991 pParm64->type = VMMDevHGCMParmType_32bit;
992 pParm64->u.value32 = pParm32->u.value32;
993 break;
994
995 case VMMDevHGCMParmType_64bit:
996 pParm64->type = VMMDevHGCMParmType_64bit;
997 pParm64->u.value64 = pParm32->u.value64;
998 break;
999
1000 case VMMDevHGCMParmType_LinAddr_Out:
1001 case VMMDevHGCMParmType_LinAddr:
1002 case VMMDevHGCMParmType_LinAddr_In:
1003 pParm64->type = pParm32->type;
1004 pParm64->u.Pointer.size = pParm32->u.Pointer.size;
1005 pParm64->u.Pointer.u.linearAddr = pParm32->u.Pointer.u.linearAddr;
1006 break;
1007
1008 default:
1009 rc = VERR_INVALID_PARAMETER;
1010 LogRel(("VbglR0HGCMInternalCall32: pParm32 type %#x invalid.\n", pParm32->type));
1011 break;
1012 }
1013 if (RT_FAILURE(rc))
1014 break;
1015 }
1016 if (RT_SUCCESS(rc))
1017 {
1018 rc = VbglR0HGCMInternalCall(pCallInfo64, sizeof(*pCallInfo64) + cParms * sizeof(HGCMFunctionParameter), fFlags,
1019 pfnAsyncCallback, pvAsyncData, u32AsyncData);
1020
1021 if (RT_SUCCESS(rc))
1022 {
1023 *pCallInfo = *pCallInfo64;
1024
1025 /*
1026 * Copy back.
1027 */
1028 pParm32 = VBOXGUEST_HGCM_CALL_PARMS32(pCallInfo);
1029 pParm64 = VBOXGUEST_HGCM_CALL_PARMS(pCallInfo64);
1030 for (iParm = 0; iParm < cParms; iParm++, pParm32++, pParm64++)
1031 {
1032 switch (pParm64->type)
1033 {
1034 case VMMDevHGCMParmType_32bit:
1035 pParm32->u.value32 = pParm64->u.value32;
1036 break;
1037
1038 case VMMDevHGCMParmType_64bit:
1039 pParm32->u.value64 = pParm64->u.value64;
1040 break;
1041
1042 case VMMDevHGCMParmType_LinAddr_Out:
1043 case VMMDevHGCMParmType_LinAddr:
1044 case VMMDevHGCMParmType_LinAddr_In:
1045 pParm32->u.Pointer.size = pParm64->u.Pointer.size;
1046 break;
1047
1048 default:
1049 LogRel(("VbglR0HGCMInternalCall32: failed invalid pParm32 type %d\n", pParm32->type));
1050 rc = VERR_INTERNAL_ERROR_3;
1051 break;
1052 }
1053 }
1054 }
1055 else
1056 {
1057 static unsigned s_cErrors = 0;
1058 if (s_cErrors++ < 32)
1059 LogRel(("VbglR0HGCMInternalCall32: VbglR0HGCMInternalCall failed. rc=%Rrc\n", rc));
1060 }
1061 }
1062 else
1063 {
1064 static unsigned s_cErrors = 0;
1065 if (s_cErrors++ < 32)
1066 LogRel(("VbglR0HGCMInternalCall32: failed. rc=%Rrc\n", rc));
1067 }
1068
1069 RTMemTmpFree(pCallInfo64);
1070 return rc;
1071}
1072#endif /* ARCH_BITS == 64 */
1073
1074#endif /* VBGL_VBOXGUEST */
1075
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette