Changeset 16095 in vbox for trunk/src/VBox
- Timestamp:
- Jan 20, 2009 5:24:02 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/linux/module/vboxmod.c
r16062 r16095 365 365 } 366 366 367 /** Jumpbuffer structure for hcgm guest-host data copies. */368 typedef struct hgcm_ jump_buffer367 /** Bounce buffer structure for hcgm guest-host data copies. */ 368 typedef struct hgcm_bounce_buffer 369 369 { 370 370 /** Kernel memory address. */ … … 374 374 /** Buffer size. */ 375 375 size_t cb; 376 } hgcm_ jump_buffer;377 378 /** Create a jumpbuffer in kernel space for user space memory. */379 static int vboxadd_hgcm_alloc_buffer(hgcm_ jump_buffer **ppBuf, void *pUser,380 size_t cb )381 { 382 hgcm_ jump_buffer *pBuf = NULL;376 } hgcm_bounce_buffer; 377 378 /** Create a bounce buffer in kernel space for user space memory. */ 379 static int vboxadd_hgcm_alloc_buffer(hgcm_bounce_buffer **ppBuf, void *pUser, 380 size_t cb, bool copy) 381 { 382 hgcm_bounce_buffer *pBuf = NULL; 383 383 void *pKernel = NULL; 384 384 int rc = 0; … … 394 394 } 395 395 if ( rc >= 0 396 && copy 396 397 && copy_from_user(pKernel, pUser, cb) != 0) 397 398 rc = -EFAULT; … … 410 411 } 411 412 412 /** Free a kernel space jumpbuffer for user space memory. */413 static int vboxadd_hgcm_free_buffer(hgcm_ jump_buffer *pBuf)413 /** Free a kernel space bounce buffer for user space memory. */ 414 static int vboxadd_hgcm_free_buffer(hgcm_bounce_buffer *pBuf, bool copy) 414 415 { 415 416 int rc = 0; 416 417 AssertPtrReturn(pBuf, -EINVAL); 417 if (copy _to_user(pBuf->pUser, pBuf->pKernel, pBuf->cb) != 0) /** @todo r=bird: This isn't entirely correct for LinAddr_In buffers. */418 if (copy && copy_to_user(pBuf->pUser, pBuf->pKernel, pBuf->cb) != 0) 418 419 rc = -EFAULT; 419 420 kfree(pBuf->pKernel); /* We want to do this whatever the outcome. */ … … 458 459 void *pv = (void *) pParm->u.Pointer.u.linearAddr; 459 460 uint32_t u32Size = pParm->u.Pointer.size; 460 hgcm_jump_buffer *MemObj = NULL; 461 rc = vboxadd_hgcm_alloc_buffer(&MemObj, pv, u32Size); 461 hgcm_bounce_buffer *MemObj = NULL; 462 rc = vboxadd_hgcm_alloc_buffer(&MemObj, pv, u32Size, 463 pParm->type != VMMDevHGCMParmType_LinAddr_Out /* copy */); 462 464 if (rc >= 0) { 463 465 ppvCtx[iParm] = MemObj; … … 495 497 if (ppvCtx[iParm] != NULL) 496 498 { 497 hgcm_jump_buffer *MemObj = (hgcm_jump_buffer *)ppvCtx[iParm]; 498 int rc2 = vboxadd_hgcm_free_buffer(MemObj); 499 hgcm_bounce_buffer *MemObj = (hgcm_bounce_buffer *)ppvCtx[iParm]; 500 int rc2 = vboxadd_hgcm_free_buffer(MemObj, 501 pParm->type != VMMDevHGCMParmType_LinAddr_In /* copy */); 499 502 if (rc >= 0 && rc2 < 0) 500 503 rc = rc2; /* Report the first error. */
Note:
See TracChangeset
for help on using the changeset viewer.