vbox的更動 67955 路徑 trunk/src/VBox/HostDrivers
- 時間撮記:
- 2017-7-13 下午09:13:23 (7 年 以前)
- 位置:
- trunk/src/VBox/HostDrivers/Support
- 檔案:
-
- 修改 4 筆資料
圖例:
- 未更動
- 新增
- 刪除
-
trunk/src/VBox/HostDrivers/Support/SUPDrv.cpp
r67823 r67955 218 218 { "SUPR0PageFree", (void *)(uintptr_t)SUPR0PageFree }, 219 219 { "SUPR0Printf", (void *)(uintptr_t)SUPR0Printf }, 220 { "SUPR0GetSessionGVM", (void *)(uintptr_t)SUPR0GetSessionGVM }, 221 { "SUPR0GetSessionVM", (void *)(uintptr_t)SUPR0GetSessionVM }, 222 { "SUPR0SetSessionVM", (void *)(uintptr_t)SUPR0SetSessionVM }, 220 223 { "SUPR0TscDeltaMeasureBySetIndex", (void *)(uintptr_t)SUPR0TscDeltaMeasureBySetIndex }, 221 224 { "SUPR0TracerDeregisterDrv", (void *)(uintptr_t)SUPR0TracerDeregisterDrv }, … … 924 927 925 928 /* 929 * Make sure the associated VM pointers are NULL. 930 */ 931 if (pSession->pSessionGVM || pSession->pSessionVM || pSession->pFastIoCtrlVM) 932 { 933 SUPR0Printf("supdrvCleanupSession: VM not disassociated! pSessionGVM=%p pSessionVM=%p pFastIoCtrlVM=%p\n", 934 pSession->pSessionGVM, pSession->pSessionVM, pSession->pFastIoCtrlVM); 935 pSession->pSessionGVM = NULL; 936 pSession->pSessionVM = NULL; 937 pSession->pFastIoCtrlVM = NULL; 938 } 939 940 /* 926 941 * Do tracer cleanups related to this session. 927 942 */ … … 1424 1439 { 1425 1440 /* 1426 * We check the two prereqs after doing this only to allow the compiler to optimize things better. 1427 */ 1428 if (RT_LIKELY( RT_VALID_PTR(pSession) 1429 && pSession->pVM 1430 && pDevExt->pfnVMMR0EntryFast)) 1431 { 1432 switch (uIOCtl) 1433 { 1434 case SUP_IOCTL_FAST_DO_RAW_RUN: 1435 pDevExt->pfnVMMR0EntryFast(pSession->pVM, idCpu, SUP_VMMR0_DO_RAW_RUN); 1436 break; 1437 case SUP_IOCTL_FAST_DO_HM_RUN: 1438 pDevExt->pfnVMMR0EntryFast(pSession->pVM, idCpu, SUP_VMMR0_DO_HM_RUN); 1439 break; 1440 case SUP_IOCTL_FAST_DO_NOP: 1441 pDevExt->pfnVMMR0EntryFast(pSession->pVM, idCpu, SUP_VMMR0_DO_NOP); 1442 break; 1443 default: 1444 return VERR_INTERNAL_ERROR; 1445 } 1446 return VINF_SUCCESS; 1447 } 1441 * Validate input and check that the VM has a session. 1442 */ 1443 if (RT_LIKELY(RT_VALID_PTR(pSession))) 1444 { 1445 PVM pVM = pSession->pSessionVM; 1446 PGVM pGVM = pSession->pSessionGVM; 1447 if (RT_LIKELY( pGVM != NULL 1448 && pVM != NULL 1449 && pVM == pSession->pFastIoCtrlVM)) 1450 { 1451 if (RT_LIKELY(pDevExt->pfnVMMR0EntryFast)) 1452 { 1453 /* 1454 * Do the call. 1455 */ 1456 switch (uIOCtl) 1457 { 1458 case SUP_IOCTL_FAST_DO_RAW_RUN: 1459 pDevExt->pfnVMMR0EntryFast(pGVM, pVM, idCpu, SUP_VMMR0_DO_RAW_RUN); 1460 break; 1461 case SUP_IOCTL_FAST_DO_HM_RUN: 1462 pDevExt->pfnVMMR0EntryFast(pGVM, pVM, idCpu, SUP_VMMR0_DO_HM_RUN); 1463 break; 1464 case SUP_IOCTL_FAST_DO_NOP: 1465 pDevExt->pfnVMMR0EntryFast(pGVM, pVM, idCpu, SUP_VMMR0_DO_NOP); 1466 break; 1467 default: 1468 return VERR_INTERNAL_ERROR; 1469 } 1470 return VINF_SUCCESS; 1471 } 1472 1473 SUPR0Printf("supdrvIOCtlFast: pfnVMMR0EntryFast is NULL\n"); 1474 } 1475 else 1476 SUPR0Printf("supdrvIOCtlFast: Misconfig session: pGVM=%p pVM=%p pFastIoCtrlVM=%p\n", 1477 pGVM, pVM, pSession->pFastIoCtrlVM); 1478 } 1479 else 1480 SUPR0Printf("supdrvIOCtlFast: Bad session pointer %p\n", pSession); 1448 1481 return VERR_INTERNAL_ERROR; 1449 1482 } … … 1781 1814 /* execute */ 1782 1815 if (RT_LIKELY(pDevExt->pfnVMMR0EntryEx)) 1783 pReq->Hdr.rc = pDevExt->pfnVMMR0EntryEx(pReq->u.In.pVMR0, pReq->u.In.idCpu, pReq->u.In.uOperation, NULL, pReq->u.In.u64Arg, pSession); 1816 { 1817 if (pReq->u.In.pVMR0 == NULL) 1818 pReq->Hdr.rc = pDevExt->pfnVMMR0EntryEx(NULL, NULL, pReq->u.In.idCpu, 1819 pReq->u.In.uOperation, NULL, pReq->u.In.u64Arg, pSession); 1820 else if (pReq->u.In.pVMR0 == pSession->pSessionVM) 1821 pReq->Hdr.rc = pDevExt->pfnVMMR0EntryEx(pSession->pSessionGVM, pSession->pSessionVM, pReq->u.In.idCpu, 1822 pReq->u.In.uOperation, NULL, pReq->u.In.u64Arg, pSession); 1823 else 1824 pReq->Hdr.rc = VERR_INVALID_VM_HANDLE; 1825 } 1784 1826 else 1785 1827 pReq->Hdr.rc = VERR_WRONG_ORDER; … … 1795 1837 /* execute */ 1796 1838 if (RT_LIKELY(pDevExt->pfnVMMR0EntryEx)) 1797 pReq->Hdr.rc = pDevExt->pfnVMMR0EntryEx(pReq->u.In.pVMR0, pReq->u.In.idCpu, pReq->u.In.uOperation, pVMMReq, pReq->u.In.u64Arg, pSession); 1839 { 1840 if (pReq->u.In.pVMR0 == NULL) 1841 pReq->Hdr.rc = pDevExt->pfnVMMR0EntryEx(NULL, NULL, pReq->u.In.idCpu, 1842 pReq->u.In.uOperation, pVMMReq, pReq->u.In.u64Arg, pSession); 1843 else if (pReq->u.In.pVMR0 == pSession->pSessionVM) 1844 pReq->Hdr.rc = pDevExt->pfnVMMR0EntryEx(pSession->pSessionGVM, pSession->pSessionVM, pReq->u.In.idCpu, 1845 pReq->u.In.uOperation, pVMMReq, pReq->u.In.u64Arg, pSession); 1846 else 1847 pReq->Hdr.rc = VERR_INVALID_VM_HANDLE; 1848 } 1798 1849 else 1799 1850 pReq->Hdr.rc = VERR_WRONG_ORDER; … … 1827 1878 /* execute */ 1828 1879 if (RT_LIKELY(pDevExt->pfnVMMR0EntryEx)) 1829 pReq->Hdr.rc = pDevExt->pfnVMMR0EntryEx(pReq->u.In.pVMR0, pReq->u.In.idCpu, pReq->u.In.uOperation, pVMMReq, pReq->u.In.u64Arg, pSession); 1880 { 1881 if (pReq->u.In.pVMR0 == NULL) 1882 pReq->Hdr.rc = pDevExt->pfnVMMR0EntryEx(NULL, NULL, pReq->u.In.idCpu, pReq->u.In.uOperation, pVMMReq, pReq->u.In.u64Arg, pSession); 1883 else if (pReq->u.In.pVMR0 == pSession->pSessionVM) 1884 pReq->Hdr.rc = pDevExt->pfnVMMR0EntryEx(pSession->pSessionGVM, pSession->pSessionVM, pReq->u.In.idCpu, 1885 pReq->u.In.uOperation, pVMMReq, pReq->u.In.u64Arg, pSession); 1886 else 1887 pReq->Hdr.rc = VERR_INVALID_VM_HANDLE; 1888 } 1830 1889 else 1831 1890 pReq->Hdr.rc = VERR_WRONG_ORDER; … … 1912 1971 && !((uintptr_t)pReq->u.In.pVMR0 & (PAGE_SIZE - 1))), 1913 1972 ("SUP_IOCTL_SET_VM_FOR_FAST: pVMR0=%p!\n", pReq->u.In.pVMR0)); 1973 1914 1974 /* execute */ 1915 pSession->pVM = pReq->u.In.pVMR0; 1916 pReq->Hdr.rc = VINF_SUCCESS; 1975 RTSpinlockAcquire(pDevExt->Spinlock); 1976 if (pSession->pSessionVM == pReq->u.In.pVMR0) 1977 { 1978 if (pSession->pFastIoCtrlVM == NULL) 1979 { 1980 pSession->pFastIoCtrlVM = pSession->pSessionVM; 1981 RTSpinlockRelease(pDevExt->Spinlock); 1982 pReq->Hdr.rc = VINF_SUCCESS; 1983 } 1984 else 1985 { 1986 RTSpinlockRelease(pDevExt->Spinlock); 1987 OSDBGPRINT(("SUP_IOCTL_SET_VM_FOR_FAST: pSession->pFastIoCtrlVM=%p! (pVMR0=%p)\n", 1988 pSession->pFastIoCtrlVM, pReq->u.In.pVMR0)); 1989 pReq->Hdr.rc = VERR_ALREADY_EXISTS; 1990 } 1991 } 1992 else 1993 { 1994 RTSpinlockRelease(pDevExt->Spinlock); 1995 OSDBGPRINT(("SUP_IOCTL_SET_VM_FOR_FAST: pSession->pSessionVM=%p vs pVMR0=%p)\n", 1996 pSession->pSessionVM, pReq->u.In.pVMR0)); 1997 pReq->Hdr.rc = pSession->pSessionVM ? VERR_ACCESS_DENIED : VERR_WRONG_ORDER; 1998 } 1917 1999 return 0; 1918 2000 } … … 3013 3095 3014 3096 /** 3097 * API for the VMMR0 module to get the SUPDRVSESSION::pSessionVM member. 3098 * 3099 * @returns The associated VM pointer. 3100 * @param pSession The session of the current thread. 3101 */ 3102 SUPR0DECL(PVM) SUPR0GetSessionVM(PSUPDRVSESSION pSession) 3103 { 3104 AssertReturn(SUP_IS_SESSION_VALID(pSession), NULL); 3105 return pSession->pSessionVM; 3106 } 3107 3108 3109 /** 3110 * API for the VMMR0 module to get the SUPDRVSESSION::pSessionGVM member. 3111 * 3112 * @returns The associated GVM pointer. 3113 * @param pSession The session of the current thread. 3114 */ 3115 SUPR0DECL(PGVM) SUPR0GetSessionGVM(PSUPDRVSESSION pSession) 3116 { 3117 AssertReturn(SUP_IS_SESSION_VALID(pSession), NULL); 3118 return pSession->pSessionGVM; 3119 } 3120 3121 3122 /** 3123 * API for the VMMR0 module to work the SUPDRVSESSION::pSessionVM member. 3124 * 3125 * This will fail if there is already a VM associated with the session and pVM 3126 * isn't NULL. 3127 * 3128 * @retval VINF_SUCCESS 3129 * @retval VERR_ALREADY_EXISTS if there already is a VM associated with the 3130 * session. 3131 * @retval VERR_INVALID_PARAMETER if only one of the parameters are NULL or if 3132 * the session is invalid. 3133 * 3134 * @param pSession The session of the current thread. 3135 * @param pGVM The GVM to associate with the session. Pass NULL to 3136 * dissassociate. 3137 * @param pVM The VM to associate with the session. Pass NULL to 3138 * dissassociate. 3139 */ 3140 SUPR0DECL(int) SUPR0SetSessionVM(PSUPDRVSESSION pSession, PGVM pGVM, PVM pVM) 3141 { 3142 AssertReturn(SUP_IS_SESSION_VALID(pSession), VERR_INVALID_PARAMETER); 3143 AssertReturn((pGVM != NULL) == (pVM != NULL), VERR_INVALID_PARAMETER); 3144 3145 RTSpinlockAcquire(pSession->pDevExt->Spinlock); 3146 if (pGVM) 3147 { 3148 if (!pSession->pSessionGVM) 3149 { 3150 pSession->pSessionGVM = pGVM; 3151 pSession->pSessionVM = pVM; 3152 pSession->pFastIoCtrlVM = NULL; 3153 } 3154 else 3155 { 3156 RTSpinlockRelease(pSession->pDevExt->Spinlock); 3157 SUPR0Printf("SUPR0SetSessionVM: Unable to associated GVM/VM %p/%p with session %p as it has %p/%p already!\n", 3158 pGVM, pVM, pSession, pSession->pSessionGVM, pSession->pSessionVM); 3159 return VERR_ALREADY_EXISTS; 3160 } 3161 } 3162 else 3163 { 3164 pSession->pSessionGVM = NULL; 3165 pSession->pSessionVM = NULL; 3166 pSession->pFastIoCtrlVM = NULL; 3167 } 3168 RTSpinlockRelease(pSession->pDevExt->Spinlock); 3169 return VINF_SUCCESS; 3170 } 3171 3172 3173 /** 3015 3174 * Lock pages. 3016 3175 * -
trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h
r67821 r67955 215 215 * - nothing. 216 216 */ 217 #define SUPDRV_IOC_VERSION 0x002 80002217 #define SUPDRV_IOC_VERSION 0x00290000 218 218 219 219 /** SUP_IOCTL_COOKIE. */ -
trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h
r67137 r67955 488 488 RTR0PROCESS R0Process; 489 489 490 /** The VM associated with the session. */ 491 PVM pVM; 490 /** The GVM associated with the session. 491 * This is set by VMMR0. */ 492 PGVM pSessionGVM; 493 /** The VM associated with the session. 494 * This is set by VMMR0. */ 495 PVM pSessionVM; 496 /** Set to pSessionVM if fast I/O controlls are enabled. */ 497 PVM pFastIoCtrlVM; 492 498 /** Handle table for IPRT semaphore wrapper APIs. 493 499 * This takes care of its own locking in an IRQ safe manner. */ … … 588 594 void * volatile pvVMMR0; 589 595 /** VMMR0EntryFast() pointer. */ 590 DECLR0CALLBACKMEMBER(void, pfnVMMR0EntryFast, (P VM pVM, VMCPUID idCpu, unsigneduOperation));596 DECLR0CALLBACKMEMBER(void, pfnVMMR0EntryFast, (PGVM pGVM, PVM pVM, VMCPUID idCpu, uint32_t uOperation)); 591 597 /** VMMR0EntryEx() pointer. */ 592 DECLR0CALLBACKMEMBER(int, pfnVMMR0EntryEx, (PVM pVM, VMCPUID idCpu, unsigned uOperation, PSUPVMMR0REQHDR pReq, uint64_t u64Arg, PSUPDRVSESSION pSession)); 598 DECLR0CALLBACKMEMBER(int, pfnVMMR0EntryEx, (PGVM pGVM, PVM pVM, VMCPUID idCpu, uint32_t uOperation, 599 PSUPVMMR0REQHDR pReq, uint64_t u64Arg, PSUPDRVSESSION pSession)); 593 600 594 601 /** Linked list of loaded code. */ -
trunk/src/VBox/HostDrivers/Support/testcase/tstInt.cpp
r62490 r67955 32 32 #include <VBox/vmm/vm.h> 33 33 #include <VBox/vmm/vmm.h> 34 #include <VBox/vmm/gvmm.h> 34 35 #include <VBox/err.h> 35 36 #include <VBox/param.h> … … 80 81 { 81 82 /* 82 * Create a fake 'VM'.83 * Create a tiny dummy VM so we can do NOP calls into it using the fast I/O control path. 83 84 */ 84 PVMR0 pVMR0 = NIL_RTR0PTR;85 PVM pVM = NULL;86 const unsigned cPages = RT_ALIGN_Z(sizeof(*pVM), PAGE_SIZE) >> PAGE_SHIFT;87 PSUPPAGE paPages = (PSUPPAGE)RTMemAllocZ(cPages * sizeof(SUPPAGE));88 if (paPages)89 rc = SUPR3LowAlloc(cPages, (void **)&pVM, &pVMR0, &paPages[0]);90 else91 rc = VERR_NO_MEMORY;85 GVMMCREATEVMREQ CreateVMReq; 86 CreateVMReq.Hdr.u32Magic = SUPVMMR0REQHDR_MAGIC; 87 CreateVMReq.Hdr.cbReq = sizeof(CreateVMReq); 88 CreateVMReq.pSession = pSession; 89 CreateVMReq.pVMR0 = NIL_RTR0PTR; 90 CreateVMReq.pVMR3 = NULL; 91 CreateVMReq.cCpus = 1; 92 rc = SUPR3CallVMMR0Ex(NIL_RTR0PTR, NIL_VMCPUID, VMMR0_DO_GVMM_CREATE_VM, 0, &CreateVMReq.Hdr); 92 93 if (RT_SUCCESS(rc)) 93 94 { 94 pVM->pVMRC = 0; 95 pVM->pVMR3 = pVM; 96 pVM->pVMR0 = pVMR0; 97 pVM->paVMPagesR3 = paPages; 98 pVM->pSession = pSession; 95 PVM pVM = CreateVMReq.pVMR3; 96 AssertRelease(VALID_PTR(pVM)); 97 AssertRelease(pVM->pVMR0 == CreateVMReq.pVMR0); 98 AssertRelease(pVM->pSession == pSession); 99 AssertRelease(pVM->cCpus == 1); 100 AssertRelease(pVM->offVMCPU == RT_UOFFSETOF(VM, aCpus)); 99 101 pVM->enmVMState = VMSTATE_CREATED; 100 101 rc = SUPR3SetVMForFastIOCtl(pVMR0); 102 PVMR0 const pVMR0 = pVM->pVMR0; 103 104 rc = SUPR3SetVMForFastIOCtl(pVM->pVMR0); 102 105 if (!rc) 103 106 { 104 105 107 /* 106 108 * Call VMM code with invalid function. … … 182 184 rcRet++; 183 185 } 186 187 rc = SUPR3CallVMMR0Ex(pVM->pVMR0, 0 /*idCpu*/, VMMR0_DO_GVMM_DESTROY_VM, 0, NULL); 188 if (RT_FAILURE(rc)) 189 { 190 RTPrintf("tstInt: VMMR0_DO_GVMM_DESTROY_VM failed: %Rrc\n", rc); 191 rcRet++; 192 } 184 193 } 185 194 else 186 195 { 187 RTPrintf("tstInt: SUPR3ContAlloc(%#zx,,) failed\n", sizeof(*pVM));196 RTPrintf("tstInt: VMMR0_DO_GVMM_CREATE_VM failed\n"); 188 197 rcRet++; 189 198 }
注意:
瀏覽 TracChangeset
來幫助您使用更動檢視器