- Timestamp:
- Oct 12, 2021 1:31:34 PM (3 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/NEMAllNativeTemplate-win.cpp.h
r91688 r91692 1589 1589 #endif /* IN_RING3 && !NEM_WIN_TEMPLATE_MODE_OWN_RUN_API */ 1590 1590 1591 1591 #if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3) 1592 1592 1593 1593 NEM_TMPL_STATIC DECLCALLBACK(int) … … 1595 1595 { 1596 1596 RT_NOREF_PV(pvUser); 1597 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES1597 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 1598 1598 int rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhys); 1599 1599 AssertRC(rc); 1600 1600 if (RT_SUCCESS(rc)) 1601 # else1601 # else 1602 1602 RT_NOREF_PV(pVCpu); 1603 1603 HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhys, X86_PAGE_SIZE); 1604 1604 if (SUCCEEDED(hrc)) 1605 # endif1605 # endif 1606 1606 { 1607 1607 Log5(("NEM GPA unmap all: %RGp (cMappedPages=%u)\n", GCPhys, pVM->nem.s.cMappedPages - 1)); … … 1610 1610 else 1611 1611 { 1612 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES1613 LogRel(("nem R3WinUnmapOnePageCallback: GCPhys=%RGp rc=%Rrc\n", GCPhys, rc));1614 # else1615 LogRel(("nem R3WinUnmapOnePageCallback: GCPhys=%RGp %s hrc=%Rhrc (%#x) Last=%#x/%u (cMappedPages=%u)\n",1612 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 1613 LogRel(("nemHCWinUnmapOnePageCallback: GCPhys=%RGp rc=%Rrc\n", GCPhys, rc)); 1614 # else 1615 LogRel(("nemHCWinUnmapOnePageCallback: GCPhys=%RGp %s hrc=%Rhrc (%#x) Last=%#x/%u (cMappedPages=%u)\n", 1616 1616 GCPhys, g_apszPageStates[*pu2NemState], hrc, hrc, RTNtLastStatusValue(), 1617 1617 RTNtLastErrorValue(), pVM->nem.s.cMappedPages)); 1618 # endif1618 # endif 1619 1619 *pu2NemState = NEM_WIN_PAGE_STATE_NOT_SET; 1620 1620 } … … 1673 1673 * We don't really consider downgrades here, as they shouldn't happen. 1674 1674 */ 1675 # ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES1675 # ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 1676 1676 /** @todo Someone at microsoft please explain: 1677 1677 * I'm not sure WTF was going on, but I ended up in a loop if I remapped a … … 1682 1682 * with new protection or backing. 1683 1683 */ 1684 # endif1684 # endif 1685 1685 int rc; 1686 1686 switch (u2State) … … 1725 1725 } 1726 1726 1727 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES1727 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 1728 1728 /* Upgrade page to writable. */ 1729 1729 /** @todo test this*/ … … 1751 1751 } 1752 1752 return rc; 1753 # else1753 # else 1754 1754 break; 1755 # endif1755 # endif 1756 1756 1757 1757 case NEM_WIN_PAGE_STATE_WRITABLE: … … 1768 1768 return VINF_SUCCESS; 1769 1769 } 1770 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES1770 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 1771 1771 AssertFailed(); /* There should be no downgrades. */ 1772 # endif1772 # endif 1773 1773 break; 1774 1774 … … 1781 1781 * If this fails, which it does every so often, just unmap everything for now. 1782 1782 */ 1783 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES1783 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 1784 1784 rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhys); 1785 1785 AssertRC(rc); 1786 1786 if (RT_SUCCESS(rc)) 1787 # else1787 # else 1788 1788 /** @todo figure out whether we mess up the state or if it's WHv. */ 1789 1789 HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhys, X86_PAGE_SIZE); 1790 1790 if (SUCCEEDED(hrc)) 1791 # endif1791 # endif 1792 1792 { 1793 1793 pState->fDidSomething = true; … … 1798 1798 return VINF_SUCCESS; 1799 1799 } 1800 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES1800 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 1801 1801 LogRel(("nemHCWinHandleMemoryAccessPageCheckerCallback/unmap: GCPhysDst=%RGp rc=%Rrc\n", GCPhys, rc)); 1802 1802 return rc; 1803 # else1803 # else 1804 1804 LogRel(("nemHCWinHandleMemoryAccessPageCheckerCallback/unmap: GCPhysDst=%RGp %s hrc=%Rhrc (%#x) Last=%#x/%u (cMappedPages=%u)\n", 1805 1805 GCPhys, g_apszPageStates[u2State], hrc, hrc, RTNtLastStatusValue(), RTNtLastErrorValue(), 1806 1806 pVM->nem.s.cMappedPages)); 1807 1807 1808 PGMPhysNemEnumPagesByState(pVM, pVCpu, NEM_WIN_PAGE_STATE_READABLE, nem R3WinUnmapOnePageCallback, NULL);1808 PGMPhysNemEnumPagesByState(pVM, pVCpu, NEM_WIN_PAGE_STATE_READABLE, nemHCWinUnmapOnePageCallback, NULL); 1809 1809 Log(("nemHCWinHandleMemoryAccessPageCheckerCallback: Unmapped all (cMappedPages=%u)\n", pVM->nem.s.cMappedPages)); 1810 1810 … … 1813 1813 pInfo->u2NemState = NEM_WIN_PAGE_STATE_UNMAPPED; 1814 1814 return VINF_SUCCESS; 1815 #endif 1816 } 1817 1815 # endif 1816 } 1817 1818 #endif /* defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3) */ 1818 1819 1819 1820 … … 4513 4514 4514 4515 #endif /* defined(NEM_WIN_TEMPLATE_MODE_OWN_RUN_API) || defined(IN_RING3) */ 4516 #if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3) 4515 4517 4516 4518 /** … … 4523 4525 if (pInfo->u2NemState > NEM_WIN_PAGE_STATE_UNMAPPED) 4524 4526 { 4525 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES4527 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 4526 4528 int rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhys); 4527 4529 AssertRC(rc); 4528 4530 if (RT_SUCCESS(rc)) 4529 # else4531 # else 4530 4532 HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhys, X86_PAGE_SIZE); 4531 4533 if (SUCCEEDED(hrc)) 4532 # endif4534 # endif 4533 4535 { 4534 4536 uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages); … … 4538 4540 else 4539 4541 { 4540 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES4542 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 4541 4543 LogRel(("nemHCWinUnsetForA20CheckerCallback/unmap: GCPhys=%RGp rc=%Rrc\n", GCPhys, rc)); 4542 4544 return rc; 4543 # else4545 # else 4544 4546 LogRel(("nemHCWinUnsetForA20CheckerCallback/unmap: GCPhys=%RGp hrc=%Rhrc (%#x) Last=%#x/%u\n", 4545 4547 GCPhys, hrc, hrc, RTNtLastStatusValue(), RTNtLastErrorValue())); 4546 4548 return VERR_NEM_IPE_2; 4547 # endif4549 # endif 4548 4550 } 4549 4551 } … … 4568 4570 } 4569 4571 4572 #endif /* defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3) */ 4570 4573 4571 4574 void nemHCNativeNotifyHandlerPhysicalRegister(PVMCC pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb) … … 4594 4597 4595 4598 4599 #if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3) 4596 4600 /** 4597 4601 * Worker that maps pages into Hyper-V. … … 4615 4619 uint32_t fPageProt, uint8_t *pu2State, bool fBackingChanged) 4616 4620 { 4617 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES4621 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 4618 4622 /* 4619 4623 * When using the hypercalls instead of the ring-3 APIs, we don't need to … … 4685 4689 return VINF_SUCCESS; 4686 4690 4687 # else4691 # else /* !NEM_WIN_USE_HYPERCALLS_FOR_PAGES */ 4688 4692 /* 4689 4693 * Looks like we need to unmap a page before we can change the backing … … 4691 4695 * PGM lends us two bits to keep track of the state here. 4692 4696 */ 4697 RT_NOREF(pVCpu); 4693 4698 uint8_t const u2OldState = *pu2State; 4694 4699 uint8_t const u2NewState = fPageProt & NEM_PAGE_PROT_WRITE ? NEM_WIN_PAGE_STATE_WRITABLE … … 4699 4704 if (u2OldState > NEM_WIN_PAGE_STATE_UNMAPPED) 4700 4705 { 4701 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES4706 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 4702 4707 int rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhysDst); 4703 4708 AssertRC(rc); … … 4718 4723 return rc; 4719 4724 } 4720 # else4725 # else 4721 4726 HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhysDst, X86_PAGE_SIZE); 4722 4727 if (SUCCEEDED(hrc)) … … 4737 4742 return VERR_NEM_INIT_FAILED; 4738 4743 } 4739 # endif4744 # endif 4740 4745 } 4741 4746 } … … 4746 4751 if (fPageProt & NEM_PAGE_PROT_WRITE) 4747 4752 { 4748 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES4753 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 4749 4754 int rc = nemHCWinHypercallMapPage(pVM, pVCpu, GCPhysSrc, GCPhysDst, 4750 4755 HV_MAP_GPA_READABLE | HV_MAP_GPA_WRITABLE … … 4761 4766 LogRel(("nemHCNativeSetPhysPage/writable: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc)); 4762 4767 return rc; 4763 # else4768 # else 4764 4769 void *pvPage; 4765 4770 int rc = nemR3NativeGCPhys2R3PtrWriteable(pVM, GCPhysSrc, &pvPage); … … 4782 4787 LogRel(("nemHCNativeSetPhysPage/writable: GCPhysSrc=%RGp rc=%Rrc\n", GCPhysSrc, rc)); 4783 4788 return rc; 4784 # endif4789 # endif 4785 4790 } 4786 4791 4787 4792 if (fPageProt & NEM_PAGE_PROT_READ) 4788 4793 { 4789 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES4794 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 4790 4795 int rc = nemHCWinHypercallMapPage(pVM, pVCpu, GCPhysSrc, GCPhysDst, 4791 4796 HV_MAP_GPA_READABLE | HV_MAP_GPA_EXECUTABLE | HV_MAP_GPA_EXECUTABLE_AGAIN); … … 4801 4806 LogRel(("nemHCNativeSetPhysPage/readonly: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc)); 4802 4807 return rc; 4803 # else4808 # else 4804 4809 const void *pvPage; 4805 4810 int rc = nemR3NativeGCPhys2R3PtrReadOnly(pVM, GCPhysSrc, &pvPage); … … 4822 4827 LogRel(("nemHCNativeSetPhysPage/readonly: GCPhysSrc=%RGp rc=%Rrc\n", GCPhysSrc, rc)); 4823 4828 return rc; 4824 # endif4829 # endif 4825 4830 } 4826 4831 … … 4828 4833 *pu2State = NEM_WIN_PAGE_STATE_UNMAPPED; 4829 4834 return VINF_SUCCESS; 4830 #endif /* !NEM_WIN_USE_HYPERCALLS_FOR_PAGES */ 4831 } 4835 # endif /* !NEM_WIN_USE_HYPERCALLS_FOR_PAGES */ 4836 } 4837 #endif /* defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING3) */ 4832 4838 4833 4839 … … 4841 4847 } 4842 4848 4843 #if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING0)4849 #if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) 4844 4850 PVMCPUCC pVCpu = VMMGetCpu(pVM); 4845 4851 int rc = nemHCWinHypercallUnmapPage(pVM, pVCpu, GCPhysDst); … … 4854 4860 LogRel(("nemHCJustUnmapPageFromHyperV/unmap: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc)); 4855 4861 return rc; 4856 #el se4862 #elif defined(IN_RING3) 4857 4863 HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhysDst & ~(RTGCPHYS)X86_PAGE_OFFSET_MASK, X86_PAGE_SIZE); 4858 4864 if (SUCCEEDED(hrc)) … … 4866 4872 GCPhysDst, hrc, hrc, RTNtLastStatusValue(), RTNtLastErrorValue())); 4867 4873 return VERR_NEM_IPE_6; 4874 #else 4875 RT_NOREF(pVM, GCPhysDst, pu2State); 4876 LogRel(("nemHCJustUnmapPageFromHyperV(%RGp): Why are we here?!?\n", GCPhysDst)); 4877 return VERR_NEM_IPE_6; 4868 4878 #endif 4869 4879 } … … 4878 4888 4879 4889 int rc; 4880 #if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING0)4890 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 4881 4891 PVMCPUCC pVCpu = VMMGetCpu(pVM); 4882 4892 if ( pVM->nem.s.fA20Enabled … … 4895 4905 if ( pVM->nem.s.fA20Enabled 4896 4906 || !NEM_WIN_IS_RELEVANT_TO_A20(GCPhys)) 4897 rc = nem R3JustUnmapPageFromHyperV(pVM, GCPhys, pu2State);4907 rc = nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State); 4898 4908 else if (!NEM_WIN_IS_SUBJECT_TO_A20(GCPhys)) 4899 rc = nem R3JustUnmapPageFromHyperV(pVM, GCPhys, pu2State);4909 rc = nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State); 4900 4910 else 4901 4911 rc = VINF_SUCCESS; /* ignore since we've got the alias page at this address. */ … … 4912 4922 RT_NOREF_PV(HCPhys); RT_NOREF_PV(enmType); 4913 4923 4914 #if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING0)4924 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 4915 4925 PVMCPUCC pVCpu = VMMGetCpu(pVM); 4916 4926 if ( pVM->nem.s.fA20Enabled … … 4928 4938 if ( pVM->nem.s.fA20Enabled 4929 4939 || !NEM_WIN_IS_RELEVANT_TO_A20(GCPhys)) 4930 nem R3JustUnmapPageFromHyperV(pVM, GCPhys, pu2State);4940 nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State); 4931 4941 else if (!NEM_WIN_IS_SUBJECT_TO_A20(GCPhys)) 4932 nem R3JustUnmapPageFromHyperV(pVM, GCPhys, pu2State);4942 nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State); 4933 4943 /* else: ignore since we've got the alias page at this address. */ 4934 4944 #endif … … 4943 4953 RT_NOREF_PV(HCPhysPrev); RT_NOREF_PV(HCPhysNew); RT_NOREF_PV(enmType); 4944 4954 4945 #if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(IN_RING0)4955 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 4946 4956 PVMCPUCC pVCpu = VMMGetCpu(pVM); 4947 4957 if ( pVM->nem.s.fA20Enabled … … 4959 4969 if ( pVM->nem.s.fA20Enabled 4960 4970 || !NEM_WIN_IS_RELEVANT_TO_A20(GCPhys)) 4961 nem R3JustUnmapPageFromHyperV(pVM, GCPhys, pu2State);4971 nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State); 4962 4972 else if (!NEM_WIN_IS_SUBJECT_TO_A20(GCPhys)) 4963 nem R3JustUnmapPageFromHyperV(pVM, GCPhys, pu2State);4973 nemHCJustUnmapPageFromHyperV(pVM, GCPhys, pu2State); 4964 4974 /* else: ignore since we've got the alias page at this address. */ 4965 4975 #endif -
trunk/src/VBox/VMM/VMMR0/NEMR0Native-win.cpp
r91688 r91692 68 68 * Global Variables * 69 69 *********************************************************************************************************************************/ 70 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 70 71 static uint64_t (*g_pfnHvlInvokeHypercall)(uint64_t uCallInfo, uint64_t HCPhysInput, uint64_t HCPhysOutput); 71 72 … … 91 92 decltype(WinHvGetPartitionProperty) *g_pfnWinHvGetPartitionProperty; 92 93 RT_C_DECLS_END 94 #endif 93 95 94 96 /** @name VID.SYS image details. 95 97 * @{ */ 98 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 96 99 static uint8_t *g_pbVidSys = NULL; 97 100 static uintptr_t g_cbVidSys = 0; … … 102 105 /** Critical section protecting the WinHvGetPartitionProperty hacking. */ 103 106 static RTCRITSECT g_VidSysCritSect; 107 #endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */ 104 108 RT_C_DECLS_BEGIN 105 109 /** The partition ID passed to WinHvGetPartitionProperty by VID.SYS. */ … … 392 396 AssertRCReturn(rc, rc); 393 397 398 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 394 399 /* 395 400 * We want to perform hypercalls here. The NT kernel started to expose a very low … … 464 469 } 465 470 } 471 #endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */ 466 472 467 473 return rc; 468 474 } 469 475 476 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 470 477 471 478 /** … … 490 497 void *pvOutput, uint32_t cbOutput) 491 498 { 492 # ifdef RT_STRICT499 # ifdef RT_STRICT 493 500 /* 494 501 * Input and output parameters are part of the VM CPU structure. … … 499 506 if (pvOutput) 500 507 AssertReturn(((uintptr_t)pvOutput + cbOutput) - (uintptr_t)pGVCpu <= sizeof(*pGVCpu), VERR_INVALID_PARAMETER); 501 # endif508 # endif 502 509 503 510 int32_t rcNt = STATUS_UNSUCCESSFUL; … … 795 802 } 796 803 804 #endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */ 797 805 798 806 /** … … 808 816 AssertRCReturn(rc, rc); 809 817 SUPR0Printf("NEMR0InitVMPart2\n"); LogRel(("2: NEMR0InitVMPart2\n")); 810 #ifdef NEM_WIN_WITH_RING0_RUNLOOP 818 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 819 # ifdef NEM_WIN_WITH_RING0_RUNLOOP 811 820 Assert(pGVM->nemr0.s.fMayUseRing0Runloop == false); 812 # endif821 # endif 813 822 814 823 /* … … 827 836 pGVM->nemr0.s.IoCtlGetPartitionProperty = Copy; 828 837 829 # ifdef NEM_WIN_WITH_RING0_RUNLOOP838 # ifdef NEM_WIN_WITH_RING0_RUNLOOP 830 839 pGVM->nemr0.s.fMayUseRing0Runloop = pGVM->nem.s.fUseRing0Runloop; 831 840 … … 858 867 if (RT_SUCCESS(rc)) 859 868 pGVM->nemr0.s.IoCtlMessageSlotHandleAndGetNext = Copy; 860 # endif869 # endif 861 870 862 871 if ( RT_SUCCESS(rc) … … 880 889 NTSTATUS rcNt = nemR0NtPerformIoControl(pGVM, pVCpu0, pGVM->nemr0.s.IoCtlGetHvPartitionId.uFunction, NULL, 0, 881 890 &pVCpu0->nem.s.uIoCtlBuf.idPartition, sizeof(pVCpu0->nem.s.uIoCtlBuf.idPartition)); 882 # if 0891 # if 0 883 892 AssertLogRelMsgReturn(NT_SUCCESS(rcNt), ("IoCtlGetHvPartitionId failed: %#x\n", rcNt), VERR_NEM_INIT_FAILED); 884 893 pGVM->nemr0.s.idHvPartition = pVCpu0->nem.s.uIoCtlBuf.idPartition; 885 # else894 # else 886 895 /* 887 896 * Since 2021 (Win11) the above I/O control doesn't work on exo-partitions … … 903 912 if (pGVM->nem.s.idHvPartition == HV_PARTITION_ID_INVALID) 904 913 pGVM->nem.s.idHvPartition = pGVM->nemr0.s.idHvPartition; 905 # endif914 # endif 906 915 AssertLogRelMsgReturn(pGVM->nemr0.s.idHvPartition == pGVM->nem.s.idHvPartition, 907 916 ("idHvPartition mismatch: r0=%#RX64, r3=%#RX64\n", pGVM->nemr0.s.idHvPartition, pGVM->nem.s.idHvPartition), … … 910 919 rc = VERR_NEM_INIT_FAILED; 911 920 } 921 #endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */ 912 922 913 923 return rc; … … 925 935 VMMR0_INT_DECL(void) NEMR0CleanupVM(PGVM pGVM) 926 936 { 937 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 927 938 pGVM->nemr0.s.idHvPartition = HV_PARTITION_ID_INVALID; 928 939 … … 944 955 RTCritSectDelete(&pGVM->nemr0.s.HypercallDataCritSect); 945 956 nemR0DeleteHypercallData(&pGVM->nemr0.s.HypercallData); 957 #else 958 RT_NOREF(pGVM); 959 #endif 946 960 } 947 961 … … 970 984 971 985 986 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 972 987 /** 973 988 * Worker for NEMR0MapPages and others. … … 1042 1057 } 1043 1058 } 1059 #endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */ 1044 1060 1045 1061 … … 1058 1074 VMMR0_INT_DECL(int) NEMR0MapPages(PGVM pGVM, VMCPUID idCpu) 1059 1075 { 1076 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 1060 1077 /* 1061 1078 * Unpack the call. … … 1077 1094 } 1078 1095 return rc; 1096 #else 1097 RT_NOREF(pGVM, idCpu); 1098 return VERR_NOT_IMPLEMENTED; 1099 #endif 1079 1100 } 1080 1101 1081 1102 1103 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 1082 1104 /** 1083 1105 * Worker for NEMR0UnmapPages and others. … … 1109 1131 if (uResult == ((uint64_t)cPages << 32)) 1110 1132 { 1111 # if 1 /* Do we need to do this? Hopefully not... */1133 # if 1 /* Do we need to do this? Hopefully not... */ 1112 1134 uint64_t volatile uR = g_pfnHvlInvokeHypercall(HvCallUncommitGpaPages | ((uint64_t)cPages << 32), 1113 1135 pGVCpu->nemr0.s.HypercallData.HCPhysPage, 0); 1114 1136 AssertMsg(uR == ((uint64_t)cPages << 32), ("uR=%#RX64\n", uR)); NOREF(uR); 1115 # endif1137 # endif 1116 1138 return VINF_SUCCESS; 1117 1139 } … … 1120 1142 return VERR_NEM_UNMAP_PAGES_FAILED; 1121 1143 } 1144 #endif /* NEM_WIN_USE_HYPERCALLS_FOR_PAGES */ 1122 1145 1123 1146 … … 1136 1159 VMMR0_INT_DECL(int) NEMR0UnmapPages(PGVM pGVM, VMCPUID idCpu) 1137 1160 { 1161 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 1138 1162 /* 1139 1163 * Unpack the call. … … 1153 1177 } 1154 1178 return rc; 1179 #else 1180 RT_NOREF(pGVM, idCpu); 1181 return VERR_NOT_IMPLEMENTED; 1182 #endif 1155 1183 } 1156 1184 … … 3006 3034 VMMR0_INT_DECL(int) NEMR0UpdateStatistics(PGVM pGVM, VMCPUID idCpu) 3007 3035 { 3036 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 3008 3037 /* 3009 3038 * Validate the call. … … 3065 3094 } 3066 3095 return rc; 3096 #else 3097 RT_NOREF(pGVM, idCpu); 3098 return VINF_SUCCESS; 3099 #endif 3067 3100 } 3068 3101 3069 3102 3070 #if 1 && defined(DEBUG_bird)3071 3103 /** 3072 3104 * Debug only interface for poking around and exploring Hyper-V stuff. … … 3078 3110 VMMR0_INT_DECL(int) NEMR0DoExperiment(PGVM pGVM, VMCPUID idCpu, uint64_t u64Arg) 3079 3111 { 3112 #if defined(DEBUG_bird) && defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) 3080 3113 /* 3081 3114 * Resolve CPU structures. … … 3164 3197 } 3165 3198 return rc; 3199 #else /* !DEBUG_bird */ 3200 RT_NOREF(pGVM, idCpu, u64Arg); 3201 return VERR_NOT_SUPPORTED; 3202 #endif /* !DEBUG_bird */ 3166 3203 } 3167 #endif /* DEBUG_bird */ 3168 3204 -
trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp
r91688 r91692 174 174 /** Pointer to the NtDeviceIoControlFile import table entry. */ 175 175 static decltype(NtDeviceIoControlFile) **g_ppfnVidNtDeviceIoControlFile; 176 #if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(LOG_ENABLED) 176 177 /** Info about the VidGetHvPartitionId I/O control interface. */ 177 178 static NEMWINIOCTL g_IoCtlGetHvPartitionId; 178 179 /** Info about the VidGetPartitionProperty I/O control interface. */ 179 180 static NEMWINIOCTL g_IoCtlGetPartitionProperty; 181 #endif 180 182 #if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(LOG_ENABLED) 181 183 /** Info about the VidStartVirtualProcessor I/O control interface. */ … … 241 243 * Internal Functions * 242 244 *********************************************************************************************************************************/ 245 DECLINLINE(int) nemR3NativeGCPhys2R3PtrReadOnly(PVM pVM, RTGCPHYS GCPhys, const void **ppv); 246 DECLINLINE(int) nemR3NativeGCPhys2R3PtrWriteable(PVM pVM, RTGCPHYS GCPhys, void **ppv); 243 247 244 248 /* … … 791 795 } 792 796 797 #if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(LOG_ENABLED) 793 798 794 799 /** … … 845 850 } 846 851 852 #endif /* defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(LOG_ENABLED) */ 847 853 #if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(LOG_ENABLED) 848 854 … … 985 991 static int nemR3WinInitDiscoverIoControlProperties(PVM pVM, PRTERRINFO pErrInfo) 986 992 { 993 RT_NOREF(pVM, pErrInfo); 994 987 995 /* 988 996 * Probe the I/O control information for select VID APIs so we can use … … 990 998 * 991 999 */ 1000 #if defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) || defined(LOG_ENABLED) 992 1001 decltype(NtDeviceIoControlFile) * const pfnOrg = *g_ppfnVidNtDeviceIoControlFile; 993 1002 … … 1019 1028 g_IoCtlGetPartitionProperty.uFunction, g_IoCtlGetPartitionProperty.cbInput, g_IoCtlGetPartitionProperty.cbOutput)); 1020 1029 1030 #endif 1021 1031 int rcRet = VINF_SUCCESS; 1022 1032 #if defined(NEM_WIN_WITH_RING0_RUNLOOP) || defined(LOG_ENABLED) … … 1103 1113 1104 1114 /* Done. */ 1115 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 1105 1116 pVM->nem.s.IoCtlGetHvPartitionId = g_IoCtlGetHvPartitionId; 1106 1117 pVM->nem.s.IoCtlGetPartitionProperty = g_IoCtlGetPartitionProperty; 1118 #endif 1107 1119 #ifdef NEM_WIN_WITH_RING0_RUNLOOP 1108 1120 pVM->nem.s.IoCtlStartVirtualProcessor = g_IoCtlStartVirtualProcessor; -
trunk/src/VBox/VMM/include/NEMInternal.h
r91688 r91692 48 48 */ 49 49 # define NEM_WIN_USE_HYPERCALLS_FOR_PAGES 50 //# define NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS /**< Applies to ring-3 code only. Useful for testing VID API. */51 //# define NEM_WIN_USE_OUR_OWN_RUN_API /**< Applies to ring-3 code only. Useful for testing VID API. */50 //# define NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS /**< Applies to ring-3 code only. Useful for testing VID API. */ 51 //# define NEM_WIN_USE_OUR_OWN_RUN_API /**< Applies to ring-3 code only. Useful for testing VID API. */ 52 52 //# define NEM_WIN_WITH_RING0_RUNLOOP /**< Enables the ring-0 runloop. */ 53 53 //# define NEM_WIN_USE_RING0_RUNLOOP_BY_DEFAULT /**< For quickly testing ring-3 API without messing with CFGM. */ … … 193 193 uint32_t volatile cMappedPages; 194 194 195 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 195 196 /** Info about the VidGetHvPartitionId I/O control interface. */ 196 197 NEMWINIOCTL IoCtlGetHvPartitionId; 197 198 /** Info about the VidGetPartitionProperty I/O control interface. */ 198 199 NEMWINIOCTL IoCtlGetPartitionProperty; 200 # endif 199 201 # ifdef NEM_WIN_WITH_RING0_RUNLOOP 200 202 /** Info about the VidStartVirtualProcessor I/O control interface. */ … … 371 373 typedef struct NEMR0PERVCPU 372 374 { 373 # if def RT_OS_WINDOWS375 # if defined(RT_OS_WINDOWS) && defined(NEM_WIN_USE_HYPERCALLS_FOR_PAGES) 374 376 /** Hypercall input/ouput page. */ 375 377 NEMR0HYPERCALLDATA HypercallData; … … 387 389 { 388 390 # ifdef RT_OS_WINDOWS 391 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 389 392 /** The partition ID. */ 390 393 uint64_t idHvPartition; … … 395 398 /** Info about the VidGetPartitionProperty I/O control interface. */ 396 399 NEMWINIOCTL IoCtlGetPartitionProperty; 400 # endif 397 401 # ifdef NEM_WIN_WITH_RING0_RUNLOOP 398 402 /** Info about the VidStartVirtualProcessor I/O control interface. */ … … 406 410 # endif 407 411 412 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 408 413 /** Hypercall input/ouput page for non-EMT. */ 409 414 NEMR0HYPERCALLDATA HypercallData; 410 415 /** Critical section protecting use of HypercallData. */ 411 416 RTCRITSECT HypercallDataCritSect; 417 # endif 412 418 413 419 # else
Note:
See TracChangeset
for help on using the changeset viewer.