Changeset 71224 in vbox for trunk/src/VBox/VMM/VMMAll
- Timestamp:
- Mar 6, 2018 1:08:53 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/NEMAllNativeTemplate-win.cpp.h
r71223 r71224 29 29 (a_Dst).fFlags = CPUMSELREG_FLAGS_VALID; \ 30 30 } while (0) 31 32 /** The CPUMCTX_EXTRN_XXX mask for IEM. */33 #define NEM_WIN_CPUMCTX_EXTRN_MASK_FOR_IEM CPUMCTX_EXTRN_ALL34 31 35 32 … … 1178 1175 } 1179 1176 1180 #ifdef IN_RING0 1177 1178 #ifdef NEM_WIN_USE_OUR_OWN_RUN_API 1179 1180 # ifdef IN_RING0 1181 1181 /** 1182 1182 * Wrapper around nemR0WinImportState that converts VERR_NEM_CHANGE_PGM_MODE and … … 1207 1207 AssertMsgFailedReturn(("%s/%u: nemR0WinImportState failed: %Rrc\n", pszCaller, pGVCpu->idCpu, rc), rc); 1208 1208 } 1209 # endif /* IN_RING0 */1209 # endif /* IN_RING0 */ 1210 1210 1211 1211 /** … … 1290 1290 nemHCWinCopyStateFromX64Header(pCtx, &pMsg->Header); 1291 1291 VBOXSTRICTRC rcStrict; 1292 # ifdef IN_RING01292 # ifdef IN_RING0 1293 1293 rcStrict = nemR0WinImportStateStrict(pGVCpu->pGVM, pGVCpu, pCtx, NEM_WIN_CPUMCTX_EXTRN_MASK_FOR_IEM, "MemExit"); 1294 1294 if (rcStrict != VINF_SUCCESS) 1295 1295 return rcStrict; 1296 # else1296 # else 1297 1297 rc = nemHCWinCopyStateFromHyperV(pVM, pVCpu, pCtx, NEM_WIN_CPUMCTX_EXTRN_MASK_FOR_IEM); 1298 1298 AssertRCReturn(rc, rc); 1299 1299 NOREF(pGVCpu); 1300 # endif1300 # endif 1301 1301 1302 1302 if (pMsg->InstructionByteCount > 0) … … 1400 1400 pCtx->rdi = pMsg->Rdi; 1401 1401 pCtx->rsi = pMsg->Rsi; 1402 # ifdef IN_RING01402 # ifdef IN_RING0 1403 1403 rcStrict = nemR0WinImportStateStrict(pGVCpu->pGVM, pGVCpu, pCtx, NEM_WIN_CPUMCTX_EXTRN_MASK_FOR_IEM, "IOExit"); 1404 1404 if (rcStrict != VINF_SUCCESS) 1405 1405 return rcStrict; 1406 # else1406 # else 1407 1407 int rc = nemHCWinCopyStateFromHyperV(pVM, pVCpu, pCtx, NEM_WIN_CPUMCTX_EXTRN_MASK_FOR_IEM); 1408 1408 AssertRCReturn(rc, rc); 1409 1409 RT_NOREF(pGVCpu); 1410 # endif1410 # endif 1411 1411 1412 1412 Log4(("IOExit/%u: %04x:%08RX64: %s%s %#x LB %u (emulating)\n", … … 1528 1528 * does another VM exit. 1529 1529 */ 1530 # ifdef IN_RING01530 # ifdef IN_RING0 1531 1531 pVCpu->nem.s.uIoCtlBuf.idCpu = pGVCpu->idCpu; 1532 1532 NTSTATUS rcNt = nemR0NtPerformIoControl(pGVM, pGVM->nem.s.IoCtlStopVirtualProcessor.uFunction, … … 1538 1538 return rcStrict; 1539 1539 } 1540 # else1540 # else 1541 1541 BOOL fRet = VidStopVirtualProcessor(pVM->nem.s.hPartitionDevice, pVCpu->idCpu); 1542 1542 if (fRet) … … 1546 1546 } 1547 1547 RT_NOREF(pGVM, pGVCpu); 1548 # endif1548 # endif 1549 1549 1550 1550 /* 1551 1551 * Dang. The CPU stopped by itself and we got a couple of message to deal with. 1552 1552 */ 1553 # ifdef IN_RING01553 # ifdef IN_RING0 1554 1554 AssertLogRelMsgReturn(rcNt == ERROR_VID_STOP_PENDING, ("rcNt=%#x\n", rcNt), 1555 1555 RT_SUCCESS(rcStrict) ? VERR_INTERNAL_ERROR_3 : rcStrict); 1556 # else1556 # else 1557 1557 DWORD dwErr = RTNtLastErrorValue(); 1558 1558 AssertLogRelMsgReturn(dwErr == ERROR_VID_STOP_PENDING, ("dwErr=%#u (%#x)\n", dwErr, dwErr), 1559 1559 RT_SUCCESS(rcStrict) ? VERR_INTERNAL_ERROR_3 : rcStrict); 1560 # endif1560 # endif 1561 1561 Log8(("nemHCWinStopCpu: Stopping CPU pending...\n")); 1562 1562 … … 1565 1565 * Note! We can safely ASSUME that rcStrict isn't an important information one. 1566 1566 */ 1567 # ifdef IN_RING01567 # ifdef IN_RING0 1568 1568 pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.iCpu = pGVCpu->idCpu; 1569 1569 pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.fFlags = VID_MSHAGN_F_GET_NEXT_MESSAGE; … … 1575 1575 AssertLogRelMsgReturn(NT_SUCCESS(rcNt), ("1st VidMessageSlotHandleAndGetNext after ERROR_VID_STOP_PENDING failed: %#x\n", rcNt), 1576 1576 RT_SUCCESS(rcStrict) ? VERR_INTERNAL_ERROR_3 : rcStrict); 1577 # else1577 # else 1578 1578 BOOL fWait = g_pfnVidMessageSlotHandleAndGetNext(pVM->nem.s.hPartitionDevice, pVCpu->idCpu, 1579 1579 VID_MSHAGN_F_GET_NEXT_MESSAGE, 30000 /*ms*/); 1580 1580 AssertLogRelMsgReturn(fWait, ("1st VidMessageSlotHandleAndGetNext after ERROR_VID_STOP_PENDING failed: %u\n", RTNtLastErrorValue()), 1581 1581 RT_SUCCESS(rcStrict) ? VERR_INTERNAL_ERROR_3 : rcStrict); 1582 # endif1582 # endif 1583 1583 1584 1584 /* It should be a hypervisor message and definitely not a stop request completed message. */ … … 1597 1597 * that as handled too. CPU is back into fully stopped stated then. 1598 1598 */ 1599 # ifdef IN_RING01599 # ifdef IN_RING0 1600 1600 pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.iCpu = pGVCpu->idCpu; 1601 1601 pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.fFlags = VID_MSHAGN_F_HANDLE_MESSAGE | VID_MSHAGN_F_GET_NEXT_MESSAGE; … … 1607 1607 AssertLogRelMsgReturn(NT_SUCCESS(rcNt), ("2st VidMessageSlotHandleAndGetNext after ERROR_VID_STOP_PENDING failed: %#x\n", rcNt), 1608 1608 RT_SUCCESS(rcStrict) ? VERR_INTERNAL_ERROR_3 : rcStrict); 1609 # else1609 # else 1610 1610 fWait = g_pfnVidMessageSlotHandleAndGetNext(pVM->nem.s.hPartitionDevice, pVCpu->idCpu, 1611 1611 VID_MSHAGN_F_HANDLE_MESSAGE | VID_MSHAGN_F_GET_NEXT_MESSAGE, 30000 /*ms*/); 1612 1612 AssertLogRelMsgReturn(fWait, ("2nd VidMessageSlotHandleAndGetNext after ERROR_VID_STOP_PENDING failed: %u\n", RTNtLastErrorValue()), 1613 1613 RT_SUCCESS(rcStrict) ? VERR_INTERNAL_ERROR_3 : rcStrict); 1614 # endif1614 # endif 1615 1615 1616 1616 /* It should be a stop request completed message. */ … … 1622 1622 1623 1623 /* Mark this as handled. */ 1624 # ifdef IN_RING01624 # ifdef IN_RING0 1625 1625 pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.iCpu = pGVCpu->idCpu; 1626 1626 pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.fFlags = VID_MSHAGN_F_HANDLE_MESSAGE; … … 1632 1632 AssertLogRelMsgReturn(NT_SUCCESS(rcNt), ("3rd VidMessageSlotHandleAndGetNext after ERROR_VID_STOP_PENDING failed: %#x\n", rcNt), 1633 1633 RT_SUCCESS(rcStrict) ? VERR_INTERNAL_ERROR_3 : rcStrict); 1634 # else1634 # else 1635 1635 fWait = g_pfnVidMessageSlotHandleAndGetNext(pVM->nem.s.hPartitionDevice, pVCpu->idCpu, VID_MSHAGN_F_HANDLE_MESSAGE, 30000 /*ms*/); 1636 1636 AssertLogRelMsgReturn(fWait, ("3rd VidMessageSlotHandleAndGetNext after ERROR_VID_STOP_PENDING failed: %u\n", RTNtLastErrorValue()), 1637 1637 RT_SUCCESS(rcStrict) ? VERR_INTERNAL_ERROR_3 : rcStrict); 1638 # endif1638 # endif 1639 1639 Log8(("nemHCWinStopCpu: Stopped the CPU (rcStrict=%Rrc)\n", VBOXSTRICTRC_VAL(rcStrict) )); 1640 1640 return rcStrict; … … 1646 1646 PCPUMCTX pCtx = CPUMQueryGuestCtxPtr(pVCpu); 1647 1647 LogFlow(("NEM/%u: %04x:%08RX64 efl=%#08RX64 <=\n", pVCpu->idCpu, pCtx->cs.Sel, pCtx->rip, pCtx->rflags)); 1648 # ifdef LOG_ENABLED1648 # ifdef LOG_ENABLED 1649 1649 if (LogIs3Enabled()) 1650 1650 nemHCWinLogState(pVM, pVCpu); 1651 # endif1651 # endif 1652 1652 1653 1653 /* … … 1668 1668 if ((pCtx->fExtrn & (CPUMCTX_EXTRN_ALL | CPUMCTX_EXTRN_NEM_WIN_MASK)) != (CPUMCTX_EXTRN_ALL | CPUMCTX_EXTRN_NEM_WIN_MASK)) 1669 1669 { 1670 # ifdef IN_RING01670 # ifdef IN_RING0 1671 1671 int rc2 = nemR0WinExportState(pGVM, pGVCpu, pCtx); 1672 # else1672 # else 1673 1673 int rc2 = nemHCWinCopyStateToHyperV(pVM, pVCpu, pCtx); 1674 1674 RT_NOREF(pGVM, pGVCpu); 1675 # endif1675 # endif 1676 1676 AssertRCReturn(rc2, rc2); 1677 1677 } … … 1687 1687 else 1688 1688 { 1689 # ifdef IN_RING01689 # ifdef IN_RING0 1690 1690 pVCpu->nem.s.uIoCtlBuf.idCpu = pGVCpu->idCpu; 1691 1691 NTSTATUS rcNt = nemR0NtPerformIoControl(pGVM, pGVM->nem.s.IoCtlStartVirtualProcessor.uFunction, … … 1695 1695 AssertLogRelMsgReturn(NT_SUCCESS(rcNt), ("VidStartVirtualProcessor failed for CPU #%u: %#x\n", pGVCpu->idCpu, rcNt), 1696 1696 VERR_INTERNAL_ERROR_3); 1697 # else1697 # else 1698 1698 AssertLogRelMsgReturn(g_pfnVidStartVirtualProcessor(pVM->nem.s.hPartitionDevice, pVCpu->idCpu), 1699 1699 ("VidStartVirtualProcessor failed for CPU #%u: %u (%#x, rcNt=%#x)\n", 1700 1700 pVCpu->idCpu, RTNtLastErrorValue(), RTNtLastErrorValue(), RTNtLastStatusValue()), 1701 1701 VERR_INTERNAL_ERROR_3); 1702 # endif1702 # endif 1703 1703 pVCpu->nem.s.fHandleAndGetFlags = VID_MSHAGN_F_GET_NEXT_MESSAGE; 1704 1704 } … … 1706 1706 if (VMCPU_CMPXCHG_STATE(pVCpu, VMCPUSTATE_STARTED_EXEC_NEM_WAIT, VMCPUSTATE_STARTED)) 1707 1707 { 1708 # ifdef IN_RING01708 # ifdef IN_RING0 1709 1709 pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.iCpu = pGVCpu->idCpu; 1710 1710 pVCpu->nem.s.uIoCtlBuf.MsgSlotHandleAndGetNext.fFlags = pVCpu->nem.s.fHandleAndGetFlags; … … 1716 1716 VMCPU_CMPXCHG_STATE(pVCpu, VMCPUSTATE_STARTED, VMCPUSTATE_STARTED_EXEC_NEM_WAIT); 1717 1717 if (rcNt == STATUS_SUCCESS) 1718 # else1718 # else 1719 1719 BOOL fRet = VidMessageSlotHandleAndGetNext(pVM->nem.s.hPartitionDevice, pVCpu->idCpu, 1720 1720 pVCpu->nem.s.fHandleAndGetFlags, cMillies); 1721 1721 VMCPU_CMPXCHG_STATE(pVCpu, VMCPUSTATE_STARTED, VMCPUSTATE_STARTED_EXEC_NEM_WAIT); 1722 1722 if (fRet) 1723 # endif1723 # endif 1724 1724 { 1725 1725 /* … … 1741 1741 so after NtAlertThread we end up here with a STATUS_TIMEOUT. And yeah, 1742 1742 the error code conversion is into WAIT_XXX, i.e. NT status codes. */ 1743 # ifndef IN_RING01743 # ifndef IN_RING0 1744 1744 DWORD rcNt = GetLastError(); 1745 # endif1745 # endif 1746 1746 LogFlow(("NEM/%u: VidMessageSlotHandleAndGetNext -> %#x\n", pVCpu->idCpu, rcNt)); 1747 1747 AssertLogRelMsgReturn( rcNt == STATUS_TIMEOUT … … 1788 1788 if (pCtx->fExtrn & (CPUMCTX_EXTRN_ALL | (CPUMCTX_EXTRN_NEM_WIN_MASK & ~CPUMCTX_EXTRN_NEM_WIN_EVENT_INJECT))) 1789 1789 { 1790 # ifdef IN_RING01790 # ifdef IN_RING0 1791 1791 int rc2 = nemR0WinImportState(pGVM, pGVCpu, pCtx, CPUMCTX_EXTRN_ALL | CPUMCTX_EXTRN_NEM_WIN_MASK); 1792 1792 if (RT_SUCCESS(rc2)) … … 1803 1803 } 1804 1804 } 1805 # else1805 # else 1806 1806 int rc2 = nemHCWinCopyStateFromHyperV(pVM, pVCpu, pCtx, CPUMCTX_EXTRN_ALL | CPUMCTX_EXTRN_NEM_WIN_MASK); 1807 1807 if (RT_SUCCESS(rc2)) 1808 1808 pCtx->fExtrn = 0; 1809 # endif1809 # endif 1810 1810 else if (RT_SUCCESS(rcStrict)) 1811 1811 rcStrict = rc2; … … 1819 1819 } 1820 1820 1821 #endif /* NEM_WIN_USE_OUR_OWN_RUN_API */ 1821 1822 1822 1823
Note:
See TracChangeset
for help on using the changeset viewer.