Changeset 21268 in vbox for trunk/src/VBox/Additions/common/VBoxGuestLib
- Timestamp:
- Jul 6, 2009 6:35:30 PM (15 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxGuestLib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuestLib/HGCMInternal.cpp
r21260 r21268 169 169 switch (pParm->type) 170 170 { 171 case VMMDevHGCMParmType_32bit: 172 case VMMDevHGCMParmType_64bit: 173 break; 174 175 case VMMDevHGCMParmType_PhysAddr: 176 if ((fFlags & VBGLR0_HGCMCALL_F_MODE_MASK) == VBGLR0_HGCMCALL_F_USER) 177 rc = VERR_INVALID_PARAMETER; 178 break; 179 171 180 case VMMDevHGCMParmType_LinAddr_Locked_In: 172 pParm->type = VMMDevHGCMParmType_LinAddr_In; 181 if ((fFlags & VBGLR0_HGCMCALL_F_MODE_MASK) == VBGLR0_HGCMCALL_F_USER) 182 rc = VERR_INVALID_PARAMETER; 183 else 184 pParm->type = VMMDevHGCMParmType_LinAddr_In; 173 185 break; 174 186 case VMMDevHGCMParmType_LinAddr_Locked_Out: 175 pParm->type = VMMDevHGCMParmType_LinAddr_Out; 187 if ((fFlags & VBGLR0_HGCMCALL_F_MODE_MASK) == VBGLR0_HGCMCALL_F_USER) 188 rc = VERR_INVALID_PARAMETER; 189 else 190 pParm->type = VMMDevHGCMParmType_LinAddr_Out; 176 191 break; 177 192 case VMMDevHGCMParmType_LinAddr_Locked: 178 pParm->type = VMMDevHGCMParmType_LinAddr; 193 if ((fFlags & VBGLR0_HGCMCALL_F_MODE_MASK) == VBGLR0_HGCMCALL_F_USER) 194 rc = VERR_INVALID_PARAMETER; 195 else 196 pParm->type = VMMDevHGCMParmType_LinAddr; 179 197 break; 180 198 … … 190 208 These kind of problems actually applies to some patched linux kernels too, including older 191 209 fedora releases. (The patch is the infamous 4G/4G patch, aka 4g4g, by Ingo Molnar.) */ 192 rc = vbglLockLinear (&apvCtx[iParm], (void *)pParm->u.Pointer.u.linearAddr, pParm->u.Pointer.size, (pParm->type == VMMDevHGCMParmType_LinAddr_In) ? false : true /* write access */); 193 break; 210 rc = vbglLockLinear (&apvCtx[iParm], (void *)pParm->u.Pointer.u.linearAddr, pParm->u.Pointer.size, 211 (pParm->type == VMMDevHGCMParmType_LinAddr_In) ? false : true /* write access */, 212 fFlags); 213 break; 214 194 215 default: 195 /* make gcc happy */216 rc = VERR_INVALID_PARAMETER; 196 217 break; 197 218 } … … 333 354 switch (pParm->type) 334 355 { 356 case VMMDevHGCMParmType_32bit: 357 case VMMDevHGCMParmType_64bit: 358 break; 359 360 case VMMDevHGCMParmType_PhysAddr: 361 if ((fFlags & VBGLR0_HGCMCALL_F_MODE_MASK) == VBGLR0_HGCMCALL_F_USER) 362 rc = VERR_INVALID_PARAMETER; 363 break; 364 335 365 case VMMDevHGCMParmType_LinAddr_Locked_In: 336 pParm->type = VMMDevHGCMParmType_LinAddr_In; 366 if ((fFlags & VBGLR0_HGCMCALL_F_MODE_MASK) == VBGLR0_HGCMCALL_F_USER) 367 rc = VERR_INVALID_PARAMETER; 368 else 369 pParm->type = VMMDevHGCMParmType_LinAddr_In; 337 370 break; 338 371 case VMMDevHGCMParmType_LinAddr_Locked_Out: 339 pParm->type = VMMDevHGCMParmType_LinAddr_Out; 372 if ((fFlags & VBGLR0_HGCMCALL_F_MODE_MASK) == VBGLR0_HGCMCALL_F_USER) 373 rc = VERR_INVALID_PARAMETER; 374 else 375 pParm->type = VMMDevHGCMParmType_LinAddr_Out; 340 376 break; 341 377 case VMMDevHGCMParmType_LinAddr_Locked: 342 pParm->type = VMMDevHGCMParmType_LinAddr; 378 if ((fFlags & VBGLR0_HGCMCALL_F_MODE_MASK) == VBGLR0_HGCMCALL_F_USER) 379 rc = VERR_INVALID_PARAMETER; 380 else 381 pParm->type = VMMDevHGCMParmType_LinAddr; 343 382 break; 344 383 … … 354 393 These kind of problems actually applies to some patched linux kernels too, including older 355 394 fedora releases. (The patch is the infamous 4G/4G patch, aka 4g4g, by Ingo Molnar.) */ 356 rc = vbglLockLinear (&apvCtx[iParm], (void *)pParm->u.Pointer.u.linearAddr, pParm->u.Pointer.size, (pParm->type == VMMDevHGCMParmType_LinAddr_In) ? false : true /* write access */); 357 break; 395 rc = vbglLockLinear (&apvCtx[iParm], (void *)pParm->u.Pointer.u.linearAddr, pParm->u.Pointer.size, 396 (pParm->type == VMMDevHGCMParmType_LinAddr_In) ? false : true /* write access */, 397 fFlags); 398 break; 399 358 400 default: 359 /* make gcc happy */401 rc = VERR_INVALID_PARAMETER; 360 402 break; 361 403 } -
trunk/src/VBox/Additions/common/VBoxGuestLib/SysHlp.cpp
r21211 r21268 33 33 34 34 35 int vbglLockLinear (void **ppvCtx, void *pv, uint32_t u32Size, bool fWriteAccess) 35 36 /** 37 * Internal worker for locking a range of linear addresses. 38 * 39 * @returns VBox status code. 40 * @param ppvCtx Where to store context data. 41 * @param pv The start of the range. 42 * @param u32Size The size of the range. 43 * @param fWriteAccess Lock for read-write (true) or readonly (false). 44 * @param fFlags HGCM call flags, VBGLR0_HGCM_F_XXX. 45 */ 46 int vbglLockLinear (void **ppvCtx, void *pv, uint32_t u32Size, bool fWriteAccess, uint32_t fFlags) 36 47 { 37 48 int rc = VINF_SUCCESS; … … 49 60 } 50 61 62 /** @todo just use IPRT here. the extra allocation shouldn't matter much... 63 * Then we can most all this up one level even. */ 51 64 #ifdef RT_OS_WINDOWS 52 65 PMDL pMdl = IoAllocateMdl (pv, u32Size, FALSE, FALSE, NULL); … … 62 75 /* Calls to MmProbeAndLockPages must be enclosed in a try/except block. */ 63 76 MmProbeAndLockPages (pMdl, 77 /** @todo (fFlags & VBGLR0_HGCMCALL_F_MODE_MASK) == VBGLR0_HGCMCALL_F_USER? UserMode: KernelMode */ 64 78 KernelMode, 65 79 (fWriteAccess) ? IoModifyAccess : IoReadAccess); … … 70 84 71 85 IoFreeMdl (pMdl); 86 /** @todo */ 72 87 rc = VERR_INVALID_PARAMETER; 73 88 AssertMsgFailed(("MmProbeAndLockPages %p %x failed!!\n", pv, u32Size)); … … 84 99 * end up calling this API. In practice, Linux R3 does it's own thing 85 100 * before winding up in the R0 path - which calls this stub API. 101 * 102 * bird: this will soon be obsoleted. 86 103 */ 87 104 NOREF(ppvCtx); 88 105 NOREF(pv); 89 106 NOREF(u32Size); 107 NOREF(fFlags); 90 108 91 109 #else 92 /* Default to IPRT - this ASSUMES that it is USER addresses we're locking. */ 93 RTR0MEMOBJ MemObj; 94 rc = RTR0MemObjLockUser(&MemObj, (RTR3PTR)pv, u32Size, NIL_RTR0PROCESS); 110 /* 111 * Lock depending on context. 112 * 113 * Note: We will later use the memory object here to convert the HGCM 114 * linear buffer paramter into a physical page list. This is why 115 * we lock both kernel pages on all systems, even those where we 116 * know they aren't pagable. 117 */ 118 RTR0MEMOBJ MemObj = NIL_RTR0MEMOBJ; 119 if ((fFlags & VBGLR0_HGCMCALL_F_MODE_MASK) == VBGLR0_HGCMCALL_F_USER) 120 rc = RTR0MemObjLockUser(&MemObj, (RTR3PTR)pv, u32Size, NIL_RTR0PROCESS); 121 else 122 rc = RTR0MemObjLockKernel(&MemObj, pv, u32Size); 95 123 if (RT_SUCCESS(rc)) 96 124 *ppvCtx = MemObj; … … 122 150 123 151 #else 124 /* default to IPRT */125 152 RTR0MEMOBJ MemObj = (RTR0MEMOBJ)pvCtx; 126 153 int rc = RTR0MemObjFree(MemObj, false); -
trunk/src/VBox/Additions/common/VBoxGuestLib/SysHlp.h
r21211 r21268 69 69 } VBGLDRIVER; 70 70 71 int vbglLockLinear (void **ppvCtx, void *pv, uint32_t u32Size, bool fWriteAccess );71 int vbglLockLinear (void **ppvCtx, void *pv, uint32_t u32Size, bool fWriteAccess, uint32_t fFlags); 72 72 void vbglUnlockLinear (void *pvCtx, void *pv, uint32_t u32Size); 73 73
Note:
See TracChangeset
for help on using the changeset viewer.