- Timestamp:
- Sep 28, 2018 11:24:47 AM (6 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/NEMAllNativeTemplate-win.cpp.h
r73376 r74517 453 453 } 454 454 455 /// @todo WHvRegisterPendingEvent0 456 /// @todo WHvRegisterPendingEvent1 455 /// @todo WHvRegisterPendingEvent 457 456 458 457 /* … … 704 703 /* event injection */ 705 704 aenmNames[iReg++] = WHvRegisterPendingInterruption; 706 aenmNames[iReg++] = WHvRegisterPendingEvent0; 707 aenmNames[iReg++] = WHvRegisterPendingEvent1; 705 aenmNames[iReg++] = WHvRegisterPendingEvent0; /** @todo renamed to WHvRegisterPendingEvent */ 708 706 709 707 size_t const cRegs = iReg; … … 1087 1085 } 1088 1086 1089 /// @todo WHvRegisterPendingEvent0 1090 /// @todo WHvRegisterPendingEvent1 1087 /// @todo WHvRegisterPendingEvent0 (renamed to WHvRegisterPendingEvent). 1091 1088 1092 1089 /* Almost done, just update extrn flags and maybe change PGM mode. */ … … 3749 3746 NTSTATUS rcNt = nemR0NtPerformIoControl(pGVM, pGVM->nem.s.IoCtlMessageSlotHandleAndGetNext.uFunction, 3750 3747 &pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext, 3751 sizeof(pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext),3748 pGVM->nem.s.IoCtlMessageSlotHandleAndGetNext.cbInput, 3752 3749 NULL, 0); 3753 3750 if (rcNt == STATUS_SUCCESS) … … 3773 3770 rcNt = nemR0NtPerformIoControl(pGVM, pGVM->nem.s.IoCtlMessageSlotHandleAndGetNext.uFunction, 3774 3771 &pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext, 3775 sizeof(pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext),3772 pGVM->nem.s.IoCtlMessageSlotHandleAndGetNext.cbInput, 3776 3773 NULL, 0); 3777 3774 DBGFTRACE_CUSTOM(pVCpu->CTX_SUFF(pVM), "IoCtlMessageSlotHandleAndGetNextRestart/2 %#x", rcNt); … … 4240 4237 NTSTATUS rcNt = nemR0NtPerformIoControl(pGVM, pGVM->nem.s.IoCtlMessageSlotHandleAndGetNext.uFunction, 4241 4238 &pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext, 4242 sizeof(pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext),4239 pGVM->nem.s.IoCtlMessageSlotHandleAndGetNext.cbInput, 4243 4240 NULL, 0); 4244 4241 VMCPU_CMPXCHG_STATE(pVCpu, VMCPUSTATE_STARTED_EXEC_NEM, VMCPUSTATE_STARTED_EXEC_NEM_WAIT); -
trunk/src/VBox/VMM/VMMR0/NEMR0Native-win.cpp
r73327 r74517 292 292 AssertRCReturn(rc, rc); 293 293 SUPR0Printf("NEMR0InitVMPart2\n"); LogRel(("2: NEMR0InitVMPart2\n")); 294 Assert(pGVM->nem.s.fMayUseRing0Runloop == false); 294 295 295 296 /* … … 302 303 pGVM->nem.s.IoCtlGetHvPartitionId = Copy; 303 304 305 pGVM->nem.s.fMayUseRing0Runloop = pVM->nem.s.fUseRing0Runloop; 306 304 307 Copy = pVM->nem.s.IoCtlStartVirtualProcessor; 305 AssertLogRelReturn(Copy.uFunction != 0, VERR_NEM_INIT_FAILED); 306 AssertLogRelReturn(Copy.cbInput == sizeof(HV_VP_INDEX), VERR_NEM_INIT_FAILED); 307 AssertLogRelReturn(Copy.cbOutput == 0, VERR_NEM_INIT_FAILED); 308 AssertLogRelReturn(Copy.uFunction != pGVM->nem.s.IoCtlGetHvPartitionId.uFunction, VERR_NEM_INIT_FAILED); 309 pGVM->nem.s.IoCtlStartVirtualProcessor = Copy; 308 AssertLogRelStmt(Copy.uFunction != 0, rc = VERR_NEM_INIT_FAILED); 309 AssertLogRelStmt(Copy.cbInput == sizeof(HV_VP_INDEX), rc = VERR_NEM_INIT_FAILED); 310 AssertLogRelStmt(Copy.cbOutput == 0, rc = VERR_NEM_INIT_FAILED); 311 AssertLogRelStmt(Copy.uFunction != pGVM->nem.s.IoCtlGetHvPartitionId.uFunction, rc = VERR_NEM_INIT_FAILED); 312 if (RT_SUCCESS(rc)) 313 pGVM->nem.s.IoCtlStartVirtualProcessor = Copy; 310 314 311 315 Copy = pVM->nem.s.IoCtlStopVirtualProcessor; 312 AssertLogRelReturn(Copy.uFunction != 0, VERR_NEM_INIT_FAILED); 313 AssertLogRelReturn(Copy.cbInput == sizeof(HV_VP_INDEX), VERR_NEM_INIT_FAILED); 314 AssertLogRelReturn(Copy.cbOutput == 0, VERR_NEM_INIT_FAILED); 315 AssertLogRelReturn(Copy.uFunction != pGVM->nem.s.IoCtlGetHvPartitionId.uFunction, VERR_NEM_INIT_FAILED); 316 AssertLogRelReturn(Copy.uFunction != pGVM->nem.s.IoCtlStartVirtualProcessor.uFunction, VERR_NEM_INIT_FAILED); 317 pGVM->nem.s.IoCtlStopVirtualProcessor = Copy; 316 AssertLogRelStmt(Copy.uFunction != 0, rc = VERR_NEM_INIT_FAILED); 317 AssertLogRelStmt(Copy.cbInput == sizeof(HV_VP_INDEX), rc = VERR_NEM_INIT_FAILED); 318 AssertLogRelStmt(Copy.cbOutput == 0, rc = VERR_NEM_INIT_FAILED); 319 AssertLogRelStmt(Copy.uFunction != pGVM->nem.s.IoCtlGetHvPartitionId.uFunction, rc = VERR_NEM_INIT_FAILED); 320 AssertLogRelStmt(Copy.uFunction != pGVM->nem.s.IoCtlStartVirtualProcessor.uFunction, rc = VERR_NEM_INIT_FAILED); 321 if (RT_SUCCESS(rc)) 322 pGVM->nem.s.IoCtlStopVirtualProcessor = Copy; 318 323 319 324 Copy = pVM->nem.s.IoCtlMessageSlotHandleAndGetNext; 320 AssertLogRelReturn(Copy.uFunction != 0, VERR_NEM_INIT_FAILED); 321 AssertLogRelReturn(Copy.cbInput == sizeof(VID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT), VERR_NEM_INIT_FAILED); 322 AssertLogRelReturn(Copy.cbOutput == 0, VERR_NEM_INIT_FAILED); 323 AssertLogRelReturn(Copy.uFunction != pGVM->nem.s.IoCtlGetHvPartitionId.uFunction, VERR_NEM_INIT_FAILED); 324 AssertLogRelReturn(Copy.uFunction != pGVM->nem.s.IoCtlStartVirtualProcessor.uFunction, VERR_NEM_INIT_FAILED); 325 AssertLogRelReturn(Copy.uFunction != pGVM->nem.s.IoCtlStopVirtualProcessor.uFunction, VERR_NEM_INIT_FAILED); 326 pGVM->nem.s.IoCtlMessageSlotHandleAndGetNext = Copy; 327 328 /* 329 * Setup of an I/O control context for the partition handle for later use. 330 */ 331 rc = SUPR0IoCtlSetupForHandle(pGVM->pSession, pVM->nem.s.hPartitionDevice, 0, &pGVM->nem.s.pIoCtlCtx); 332 AssertLogRelRCReturn(rc, rc); 333 pGVM->nem.s.offRing3ConversionDelta = (uintptr_t)pVM->pVMR3 - (uintptr_t)pGVM->pVM; 334 335 /* 336 * Get the partition ID. 337 */ 338 PVMCPU pVCpu = &pGVM->pVM->aCpus[0]; 339 NTSTATUS rcNt = nemR0NtPerformIoControl(pGVM, pGVM->nem.s.IoCtlGetHvPartitionId.uFunction, NULL, 0, 340 &pVCpu->nem.s.uIoCtlBuf.idPartition, sizeof(pVCpu->nem.s.uIoCtlBuf.idPartition)); 341 AssertLogRelMsgReturn(NT_SUCCESS(rcNt), ("IoCtlGetHvPartitionId failed: %#x\n", rcNt), VERR_NEM_INIT_FAILED); 342 pGVM->nem.s.idHvPartition = pVCpu->nem.s.uIoCtlBuf.idPartition; 343 AssertLogRelMsgReturn(pGVM->nem.s.idHvPartition == pVM->nem.s.idHvPartition, 344 ("idHvPartition mismatch: r0=%#RX64, r3=%#RX64\n", pGVM->nem.s.idHvPartition, pVM->nem.s.idHvPartition), 345 VERR_NEM_INIT_FAILED); 325 AssertLogRelStmt(Copy.uFunction != 0, rc = VERR_NEM_INIT_FAILED); 326 AssertLogRelStmt( Copy.cbInput == sizeof(VID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT) 327 || Copy.cbInput == RT_OFFSETOF(VID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT, cMillies), 328 rc = VERR_NEM_INIT_FAILED); 329 AssertLogRelStmt(Copy.cbOutput == 0, VERR_NEM_INIT_FAILED); 330 AssertLogRelStmt(Copy.uFunction != pGVM->nem.s.IoCtlGetHvPartitionId.uFunction, rc = VERR_NEM_INIT_FAILED); 331 AssertLogRelStmt(Copy.uFunction != pGVM->nem.s.IoCtlStartVirtualProcessor.uFunction, rc = VERR_NEM_INIT_FAILED); 332 AssertLogRelStmt(Copy.uFunction != pGVM->nem.s.IoCtlStopVirtualProcessor.uFunction, rc = VERR_NEM_INIT_FAILED); 333 if (RT_SUCCESS(rc)) 334 pGVM->nem.s.IoCtlMessageSlotHandleAndGetNext = Copy; 335 336 if ( RT_SUCCESS(rc) 337 || !pVM->nem.s.fUseRing0Runloop) 338 { 339 /* 340 * Setup of an I/O control context for the partition handle for later use. 341 */ 342 rc = SUPR0IoCtlSetupForHandle(pGVM->pSession, pVM->nem.s.hPartitionDevice, 0, &pGVM->nem.s.pIoCtlCtx); 343 AssertLogRelRCReturn(rc, rc); 344 pGVM->nem.s.offRing3ConversionDelta = (uintptr_t)pVM->pVMR3 - (uintptr_t)pGVM->pVM; 345 346 /* 347 * Get the partition ID. 348 */ 349 PVMCPU pVCpu = &pGVM->pVM->aCpus[0]; 350 NTSTATUS rcNt = nemR0NtPerformIoControl(pGVM, pGVM->nem.s.IoCtlGetHvPartitionId.uFunction, NULL, 0, 351 &pVCpu->nem.s.uIoCtlBuf.idPartition, sizeof(pVCpu->nem.s.uIoCtlBuf.idPartition)); 352 AssertLogRelMsgReturn(NT_SUCCESS(rcNt), ("IoCtlGetHvPartitionId failed: %#x\n", rcNt), VERR_NEM_INIT_FAILED); 353 pGVM->nem.s.idHvPartition = pVCpu->nem.s.uIoCtlBuf.idPartition; 354 AssertLogRelMsgReturn(pGVM->nem.s.idHvPartition == pVM->nem.s.idHvPartition, 355 ("idHvPartition mismatch: r0=%#RX64, r3=%#RX64\n", pGVM->nem.s.idHvPartition, pVM->nem.s.idHvPartition), 356 VERR_NEM_INIT_FAILED); 357 } 346 358 347 359 return rc; … … 2428 2440 { 2429 2441 #ifdef NEM_WIN_WITH_RING0_RUNLOOP 2430 PVM pVM = pGVM->pVM; 2431 return nemHCWinRunGC(pVM, &pVM->aCpus[idCpu], pGVM, &pGVM->aCpus[idCpu]); 2442 if (pGVM->nem.s.fMayUseRing0Runloop) 2443 { 2444 PVM pVM = pGVM->pVM; 2445 return nemHCWinRunGC(pVM, &pVM->aCpus[idCpu], pGVM, &pGVM->aCpus[idCpu]); 2446 } 2447 return VERR_NEM_RING3_ONLY; 2432 2448 #else 2433 2449 RT_NOREF(pGVM, idCpu); -
trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp
r73282 r74517 855 855 AssertLogRelMsgReturn(RT_VALID_PTR(pIos), ("pIos=%p\n", pIos), STATUS_INVALID_PARAMETER_5); 856 856 857 AssertLogRelMsgReturn(cbInput == sizeof(VID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT), ("cbInput=%#x\n", cbInput), 858 STATUS_INVALID_PARAMETER_8); 859 AssertLogRelMsgReturn(RT_VALID_PTR(pvInput), ("pvInput=%p\n", pvInput), STATUS_INVALID_PARAMETER_9); 860 PCVID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT pVidIn = (PCVID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT)pvInput; 861 AssertLogRelMsgReturn( pVidIn->iCpu == NEM_WIN_IOCTL_DETECTOR_FAKE_VP_INDEX 862 && pVidIn->fFlags == VID_MSHAGN_F_HANDLE_MESSAGE 863 && pVidIn->cMillies == NEM_WIN_IOCTL_DETECTOR_FAKE_TIMEOUT, 864 ("iCpu=%u fFlags=%#x cMillies=%#x\n", pVidIn->iCpu, pVidIn->fFlags, pVidIn->cMillies), 865 STATUS_INVALID_PARAMETER_9); 866 AssertLogRelMsgReturn(cbOutput == 0, ("cbInput=%#x\n", cbInput), STATUS_INVALID_PARAMETER_10); 867 RT_NOREF(pvOutput); 857 if (g_uBuildNo >= 17758) 858 { 859 /* No timeout since about build 17758, it's now always an infinite wait. So, a somewhat compatible change. */ 860 AssertLogRelMsgReturn(cbInput == RT_UOFFSETOF(VID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT, cMillies), 861 ("cbInput=%#x\n", cbInput), 862 STATUS_INVALID_PARAMETER_8); 863 AssertLogRelMsgReturn(RT_VALID_PTR(pvInput), ("pvInput=%p\n", pvInput), STATUS_INVALID_PARAMETER_9); 864 PCVID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT pVidIn = (PCVID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT)pvInput; 865 AssertLogRelMsgReturn( pVidIn->iCpu == NEM_WIN_IOCTL_DETECTOR_FAKE_VP_INDEX 866 && pVidIn->fFlags == VID_MSHAGN_F_HANDLE_MESSAGE, 867 ("iCpu=%u fFlags=%#x cMillies=%#x\n", pVidIn->iCpu, pVidIn->fFlags, pVidIn->cMillies), 868 STATUS_INVALID_PARAMETER_9); 869 AssertLogRelMsgReturn(cbOutput == 0, ("cbInput=%#x\n", cbInput), STATUS_INVALID_PARAMETER_10); 870 } 871 else 872 { 873 AssertLogRelMsgReturn(cbInput == sizeof(VID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT), ("cbInput=%#x\n", cbInput), 874 STATUS_INVALID_PARAMETER_8); 875 AssertLogRelMsgReturn(RT_VALID_PTR(pvInput), ("pvInput=%p\n", pvInput), STATUS_INVALID_PARAMETER_9); 876 PCVID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT pVidIn = (PCVID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT)pvInput; 877 AssertLogRelMsgReturn( pVidIn->iCpu == NEM_WIN_IOCTL_DETECTOR_FAKE_VP_INDEX 878 && pVidIn->fFlags == VID_MSHAGN_F_HANDLE_MESSAGE 879 && pVidIn->cMillies == NEM_WIN_IOCTL_DETECTOR_FAKE_TIMEOUT, 880 ("iCpu=%u fFlags=%#x cMillies=%#x\n", pVidIn->iCpu, pVidIn->fFlags, pVidIn->cMillies), 881 STATUS_INVALID_PARAMETER_9); 882 AssertLogRelMsgReturn(cbOutput == 0, ("cbInput=%#x\n", cbInput), STATUS_INVALID_PARAMETER_10); 883 RT_NOREF(pvOutput); 884 } 868 885 869 886 g_IoCtlMessageSlotHandleAndGetNext.cbInput = cbInput; … … 918 935 decltype(NtDeviceIoControlFile) * const pfnOrg = *g_ppfnVidNtDeviceIoControlFile; 919 936 920 /* VidGetHvPartitionId */937 /* VidGetHvPartitionId - must work due to memory. */ 921 938 *g_ppfnVidNtDeviceIoControlFile = nemR3WinIoctlDetector_GetHvPartitionId; 922 939 HV_PARTITION_ID idHvPartition = HV_PARTITION_ID_INVALID; … … 930 947 g_IoCtlGetHvPartitionId.uFunction, g_IoCtlGetHvPartitionId.cbInput, g_IoCtlGetHvPartitionId.cbOutput)); 931 948 949 int rcRet = VINF_SUCCESS; 932 950 /* VidStartVirtualProcessor */ 933 951 *g_ppfnVidNtDeviceIoControlFile = nemR3WinIoctlDetector_StartVirtualProcessor; 934 952 fRet = g_pfnVidStartVirtualProcessor(NEM_WIN_IOCTL_DETECTOR_FAKE_HANDLE, NEM_WIN_IOCTL_DETECTOR_FAKE_VP_INDEX); 935 953 *g_ppfnVidNtDeviceIoControlFile = pfnOrg; 936 Assert Return(fRet && g_IoCtlStartVirtualProcessor.uFunction != 0,937 RTErrInfoSetF(pErrInfo, VERR_NEM_INIT_FAILED,938 "Problem figuring out VidStartVirtualProcessor: fRet=%u dwErr=%u",939 fRet, GetLastError()) );954 AssertStmt(fRet && g_IoCtlStartVirtualProcessor.uFunction != 0, 955 rcRet = RTERRINFO_LOG_REL_SET_F(pErrInfo, VERR_NEM_RING3_ONLY, 956 "Problem figuring out VidStartVirtualProcessor: fRet=%u dwErr=%u", 957 fRet, GetLastError()) ); 940 958 LogRel(("NEM: VidStartVirtualProcessor -> fun:%#x in:%#x out:%#x\n", g_IoCtlStartVirtualProcessor.uFunction, 941 959 g_IoCtlStartVirtualProcessor.cbInput, g_IoCtlStartVirtualProcessor.cbOutput)); … … 945 963 fRet = g_pfnVidStopVirtualProcessor(NEM_WIN_IOCTL_DETECTOR_FAKE_HANDLE, NEM_WIN_IOCTL_DETECTOR_FAKE_VP_INDEX); 946 964 *g_ppfnVidNtDeviceIoControlFile = pfnOrg; 947 Assert Return(fRet && g_IoCtlStopVirtualProcessor.uFunction != 0,948 RTErrInfoSetF(pErrInfo, VERR_NEM_INIT_FAILED,949 "Problem figuring out VidStopVirtualProcessor: fRet=%u dwErr=%u",950 fRet, GetLastError()) );965 AssertStmt(fRet && g_IoCtlStopVirtualProcessor.uFunction != 0, 966 rcRet = RTERRINFO_LOG_REL_SET_F(pErrInfo, VERR_NEM_RING3_ONLY, 967 "Problem figuring out VidStopVirtualProcessor: fRet=%u dwErr=%u", 968 fRet, GetLastError()) ); 951 969 LogRel(("NEM: VidStopVirtualProcessor -> fun:%#x in:%#x out:%#x\n", g_IoCtlStopVirtualProcessor.uFunction, 952 970 g_IoCtlStopVirtualProcessor.cbInput, g_IoCtlStopVirtualProcessor.cbOutput)); … … 958 976 NEM_WIN_IOCTL_DETECTOR_FAKE_TIMEOUT); 959 977 *g_ppfnVidNtDeviceIoControlFile = pfnOrg; 960 Assert Return(fRet && g_IoCtlMessageSlotHandleAndGetNext.uFunction != 0,961 RTErrInfoSetF(pErrInfo, VERR_NEM_INIT_FAILED,962 "Problem figuring out VidMessageSlotHandleAndGetNext: fRet=%u dwErr=%u",963 fRet, GetLastError()) );978 AssertStmt(fRet && g_IoCtlMessageSlotHandleAndGetNext.uFunction != 0, 979 rcRet = RTERRINFO_LOG_REL_SET_F(pErrInfo, VERR_NEM_RING3_ONLY, 980 "Problem figuring out VidMessageSlotHandleAndGetNext: fRet=%u dwErr=%u", 981 fRet, GetLastError()) ); 964 982 LogRel(("NEM: VidMessageSlotHandleAndGetNext -> fun:%#x in:%#x out:%#x\n", 965 983 g_IoCtlMessageSlotHandleAndGetNext.uFunction, g_IoCtlMessageSlotHandleAndGetNext.cbInput, … … 1014 1032 pVM->nem.s.IoCtlStopVirtualProcessor = g_IoCtlStopVirtualProcessor; 1015 1033 pVM->nem.s.IoCtlMessageSlotHandleAndGetNext = g_IoCtlMessageSlotHandleAndGetNext; 1016 return VINF_SUCCESS;1034 return rcRet; 1017 1035 } 1018 1036 … … 1198 1216 */ 1199 1217 rc = nemR3WinInitDiscoverIoControlProperties(pVM, pErrInfo); 1218 if (rc == VERR_NEM_RING3_ONLY) 1219 { 1220 if (pVM->nem.s.fUseRing0Runloop) 1221 { 1222 LogRel(("NEM: Disabling UseRing0Runloop.\n")); 1223 pVM->nem.s.fUseRing0Runloop = false; 1224 } 1225 rc = VINF_SUCCESS; 1226 } 1200 1227 if (RT_SUCCESS(rc)) 1201 1228 { -
trunk/src/VBox/VMM/include/NEMInternal.h
r73282 r74517 383 383 /** Info about the VidStopVirtualProcessor I/O control interface. */ 384 384 NEMWINIOCTL IoCtlMessageSlotHandleAndGetNext; 385 /** Whether we may use the ring-0 runloop or not. */ 386 bool fMayUseRing0Runloop; 385 387 386 388 /** Hypercall input/ouput page for non-EMT. */
Note:
See TracChangeset
for help on using the changeset viewer.