Changeset 91702 in vbox
- Timestamp:
- Oct 12, 2021 9:15:19 PM (3 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
-
include/VBox/vmm/vm.h (modified) (2 diffs)
-
include/VBox/vmm/vm.mac (modified) (1 diff)
-
src/VBox/VMM/VMMAll/NEMAllNativeTemplate-win.cpp.h (modified) (29 diffs)
-
src/VBox/VMM/VMMR3/NEMR3Native-win.cpp (modified) (4 diffs)
-
src/VBox/VMM/include/NEMInternal.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/vm.h
r91580 r91702 1346 1346 struct NEM s; 1347 1347 #endif 1348 uint8_t padding[ 128]; /* multiple of 64 */1348 uint8_t padding[256]; /* multiple of 64 */ 1349 1349 } nem; 1350 1350 … … 1454 1454 1455 1455 /** Padding for aligning the structure size on a page boundrary. */ 1456 uint8_t abAlignment2[2 136- sizeof(PVMCPUR3) * VMM_MAX_CPU_COUNT];1456 uint8_t abAlignment2[2008 - sizeof(PVMCPUR3) * VMM_MAX_CPU_COUNT]; 1457 1457 1458 1458 /* ---- end small stuff ---- */ -
trunk/include/VBox/vmm/vm.mac
r91345 r91702 149 149 .em resb 256 150 150 alignb 64 151 .nem resb 128151 .nem resb 256 152 152 alignb 64 153 153 .tm resb 10112 -
trunk/src/VBox/VMM/VMMAll/NEMAllNativeTemplate-win.cpp.h
r91692 r91702 1607 1607 Log5(("NEM GPA unmap all: %RGp (cMappedPages=%u)\n", GCPhys, pVM->nem.s.cMappedPages - 1)); 1608 1608 *pu2NemState = NEM_WIN_PAGE_STATE_UNMAPPED; 1609 STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage); 1609 1610 } 1610 1611 else … … 1618 1619 # endif 1619 1620 *pu2NemState = NEM_WIN_PAGE_STATE_NOT_SET; 1621 STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed); 1620 1622 } 1621 1623 if (pVM->nem.s.cMappedPages > 0) … … 1737 1739 if (RT_SUCCESS(rc)) 1738 1740 { 1741 STAM_REL_COUNTER_INC(&pVM->nem.s.StatRemapPage); 1739 1742 pInfo->u2NemState = NEM_WIN_PAGE_STATE_WRITABLE; 1740 1743 pState->fDidSomething = true; … … 1743 1746 GCPhys, g_apszPageStates[u2State], pVM->nem.s.cMappedPages)); 1744 1747 } 1748 else 1749 STAM_REL_COUNTER_INC(&pVM->nem.s.StatRemapPageFailed); 1745 1750 } 1746 1751 else … … 1794 1799 pState->fCanResume = true; 1795 1800 pInfo->u2NemState = NEM_WIN_PAGE_STATE_UNMAPPED; 1801 STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage); 1796 1802 uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages); 1797 1803 Log5(("NEM GPA unmapped/exit: %RGp (was %s, cMappedPages=%u)\n", GCPhys, g_apszPageStates[u2State], cMappedPages)); 1798 1804 return VINF_SUCCESS; 1799 1805 } 1806 STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed); 1800 1807 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 1801 1808 LogRel(("nemHCWinHandleMemoryAccessPageCheckerCallback/unmap: GCPhysDst=%RGp rc=%Rrc\n", GCPhys, rc)); … … 1808 1815 PGMPhysNemEnumPagesByState(pVM, pVCpu, NEM_WIN_PAGE_STATE_READABLE, nemHCWinUnmapOnePageCallback, NULL); 1809 1816 Log(("nemHCWinHandleMemoryAccessPageCheckerCallback: Unmapped all (cMappedPages=%u)\n", pVM->nem.s.cMappedPages)); 1817 STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapAllPages); 1810 1818 1811 1819 pState->fDidSomething = true; … … 4206 4214 */ 4207 4215 uint32_t const cMappedPages = pVM->nem.s.cMappedPages; 4208 if (cMappedPages >= 4000) 4216 if (cMappedPages < pVM->nem.s.cMaxMappedPages) 4217 { /* likely*/ } 4218 else 4209 4219 { 4210 4220 PGMPhysNemEnumPagesByState(pVM, pVCpu, NEM_WIN_PAGE_STATE_READABLE, nemHCWinUnmapOnePageCallback, NULL); 4211 4221 Log(("nemHCWinRunGC: Unmapped all; cMappedPages=%u -> %u\n", cMappedPages, pVM->nem.s.cMappedPages)); 4222 STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapAllPages); 4212 4223 } 4213 4224 # endif … … 4534 4545 # endif 4535 4546 { 4547 STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage); 4536 4548 uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages); 4537 4549 Log5(("NEM GPA unmapped/A20: %RGp (was %s, cMappedPages=%u)\n", GCPhys, g_apszPageStates[pInfo->u2NemState], cMappedPages)); … … 4540 4552 else 4541 4553 { 4554 STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed); 4542 4555 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 4543 4556 LogRel(("nemHCWinUnsetForA20CheckerCallback/unmap: GCPhys=%RGp rc=%Rrc\n", GCPhys, rc)); … … 4636 4649 { 4637 4650 *pu2State = NEM_WIN_PAGE_STATE_UNMAPPED; 4651 STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage); 4638 4652 uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages); 4639 4653 Log5(("NEM GPA unmapped/set: %RGp (was %s, cMappedPages=%u)\n", GCPhysDst, g_apszPageStates[u2OldState], cMappedPages)); 4640 4654 } 4641 4655 else 4656 { 4657 STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed); 4642 4658 AssertLogRelMsgFailed(("nemHCNativeSetPhysPage/unmap: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc)); 4659 } 4643 4660 } 4644 4661 else … … 4655 4672 { 4656 4673 *pu2State = NEM_WIN_PAGE_STATE_WRITABLE; 4674 STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPage); 4657 4675 uint32_t cMappedPages = u2OldState <= NEM_WIN_PAGE_STATE_UNMAPPED 4658 4676 ? ASMAtomicIncU32(&pVM->nem.s.cMappedPages) : pVM->nem.s.cMappedPages; … … 4661 4679 } 4662 4680 else 4681 { 4682 STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPageFailed); 4663 4683 AssertLogRelMsgFailed(("nemHCNativeSetPhysPage/writable: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc)); 4684 } 4664 4685 } 4665 4686 else … … 4675 4696 { 4676 4697 *pu2State = NEM_WIN_PAGE_STATE_READABLE; 4698 STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPage); 4677 4699 uint32_t cMappedPages = u2OldState <= NEM_WIN_PAGE_STATE_UNMAPPED 4678 4700 ? ASMAtomicIncU32(&pVM->nem.s.cMappedPages) : pVM->nem.s.cMappedPages; … … 4681 4703 } 4682 4704 else 4705 { 4706 STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPageFailed); 4683 4707 AssertLogRelMsgFailed(("nemHCNativeSetPhysPage/writable: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc)); 4708 } 4684 4709 } 4685 4710 else … … 4710 4735 { 4711 4736 *pu2State = NEM_WIN_PAGE_STATE_UNMAPPED; 4737 STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage); 4712 4738 uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages); 4713 4739 if (u2NewState == NEM_WIN_PAGE_STATE_UNMAPPED) … … 4720 4746 else 4721 4747 { 4748 STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed); 4722 4749 LogRel(("nemHCNativeSetPhysPage/unmap: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc)); 4723 4750 return rc; … … 4728 4755 { 4729 4756 *pu2State = NEM_WIN_PAGE_STATE_UNMAPPED; 4757 STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage); 4730 4758 uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages); 4731 4759 if (u2NewState == NEM_WIN_PAGE_STATE_UNMAPPED) … … 4738 4766 else 4739 4767 { 4768 STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed); 4740 4769 LogRel(("nemHCNativeSetPhysPage/unmap: GCPhysDst=%RGp hrc=%Rhrc (%#x) Last=%#x/%u\n", 4741 4770 GCPhysDst, hrc, hrc, RTNtLastStatusValue(), RTNtLastErrorValue())); … … 4759 4788 { 4760 4789 *pu2State = NEM_WIN_PAGE_STATE_WRITABLE; 4790 STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPage); 4761 4791 uint32_t cMappedPages = ASMAtomicIncU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages); 4762 4792 Log5(("NEM GPA mapped/set: %RGp %s (was %s, cMappedPages=%u)\n", … … 4764 4794 return VINF_SUCCESS; 4765 4795 } 4796 STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPageFailed); 4766 4797 LogRel(("nemHCNativeSetPhysPage/writable: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc)); 4767 4798 return rc; … … 4776 4807 { 4777 4808 *pu2State = NEM_WIN_PAGE_STATE_WRITABLE; 4809 STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPage); 4778 4810 uint32_t cMappedPages = ASMAtomicIncU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages); 4779 4811 Log5(("NEM GPA mapped/set: %RGp %s (was %s, cMappedPages=%u)\n", … … 4781 4813 return VINF_SUCCESS; 4782 4814 } 4815 STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPageFailed); 4783 4816 LogRel(("nemHCNativeSetPhysPage/writable: GCPhysDst=%RGp hrc=%Rhrc (%#x) Last=%#x/%u\n", 4784 4817 GCPhysDst, hrc, hrc, RTNtLastStatusValue(), RTNtLastErrorValue())); … … 4799 4832 { 4800 4833 *pu2State = NEM_WIN_PAGE_STATE_READABLE; 4834 STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPage); 4801 4835 uint32_t cMappedPages = ASMAtomicIncU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages); 4802 4836 Log5(("NEM GPA mapped/set: %RGp %s (was %s, cMappedPages=%u)\n", … … 4804 4838 return VINF_SUCCESS; 4805 4839 } 4840 STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPageFailed); 4806 4841 LogRel(("nemHCNativeSetPhysPage/readonly: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc)); 4807 4842 return rc; … … 4816 4851 { 4817 4852 *pu2State = NEM_WIN_PAGE_STATE_READABLE; 4853 STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPage); 4818 4854 uint32_t cMappedPages = ASMAtomicIncU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages); 4819 4855 Log5(("NEM GPA mapped/set: %RGp %s (was %s, cMappedPages=%u)\n", … … 4821 4857 return VINF_SUCCESS; 4822 4858 } 4859 STAM_REL_COUNTER_INC(&pVM->nem.s.StatMapPageFailed); 4823 4860 LogRel(("nemHCNativeSetPhysPage/readonly: GCPhysDst=%RGp hrc=%Rhrc (%#x) Last=%#x/%u\n", 4824 4861 GCPhysDst, hrc, hrc, RTNtLastStatusValue(), RTNtLastErrorValue())); … … 4853 4890 if (RT_SUCCESS(rc)) 4854 4891 { 4892 STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage); 4855 4893 uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages); 4856 4894 Log5(("NEM GPA unmapped/just: %RGp (was %s, cMappedPages=%u)\n", GCPhysDst, g_apszPageStates[*pu2State], cMappedPages)); … … 4858 4896 return VINF_SUCCESS; 4859 4897 } 4898 STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed); 4860 4899 LogRel(("nemHCJustUnmapPageFromHyperV/unmap: GCPhysDst=%RGp rc=%Rrc\n", GCPhysDst, rc)); 4861 4900 return rc; 4901 4862 4902 #elif defined(IN_RING3) 4863 4903 HRESULT hrc = WHvUnmapGpaRange(pVM->nem.s.hPartition, GCPhysDst & ~(RTGCPHYS)X86_PAGE_OFFSET_MASK, X86_PAGE_SIZE); 4864 4904 if (SUCCEEDED(hrc)) 4865 4905 { 4906 STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage); 4866 4907 uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages); 4867 4908 *pu2State = NEM_WIN_PAGE_STATE_UNMAPPED; … … 4869 4910 return VINF_SUCCESS; 4870 4911 } 4912 STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed); 4871 4913 LogRel(("nemHCJustUnmapPageFromHyperV(%RGp): failed! hrc=%Rhrc (%#x) Last=%#x/%u\n", 4872 4914 GCPhysDst, hrc, hrc, RTNtLastStatusValue(), RTNtLastErrorValue())); -
trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp
r91692 r91702 1287 1287 #endif 1288 1288 1289 #ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 1290 /** Some guess working here. */ 1291 pVM->nem.s.cMaxMappedPages = 4000; 1292 if (g_uBuildNo >= 22000) 1293 pVM->nem.s.cMaxMappedPages = _64K; /* seems it can do lots more even */ 1294 #endif 1295 1289 1296 /* 1290 1297 * Error state. … … 1334 1341 1335 1342 /* Register release statistics */ 1343 STAMR3Register(pVM, (void *)&pVM->nem.s.cMappedPages, STAMTYPE_U32, STAMVISIBILITY_ALWAYS, 1344 "/NEM/PagesCurrentlyMapped", STAMUNIT_PAGES, "Number guest pages currently mapped by the VM"); 1345 STAMR3Register(pVM, (void *)&pVM->nem.s.StatMapPage, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, 1346 "/NEM/PagesMapCalls", STAMUNIT_PAGES, "Calls to WHvMapGpaRange/HvCallMapGpaPages"); 1347 STAMR3Register(pVM, (void *)&pVM->nem.s.StatMapPageFailed, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, 1348 "/NEM/PagesMapFails", STAMUNIT_PAGES, "Calls to WHvMapGpaRange/HvCallMapGpaPages that failed"); 1349 STAMR3Register(pVM, (void *)&pVM->nem.s.StatUnmapPage, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, 1350 "/NEM/PagesUnmapCalls", STAMUNIT_PAGES, "Calls to WHvUnmapGpaRange/HvCallUnmapGpaPages"); 1351 STAMR3Register(pVM, (void *)&pVM->nem.s.StatUnmapPageFailed, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, 1352 "/NEM/PagesUnmapFails", STAMUNIT_PAGES, "Calls to WHvUnmapGpaRange/HvCallUnmapGpaPages that failed"); 1353 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 1354 STAMR3Register(pVM, (void *)&pVM->nem.s.StatRemapPage, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, 1355 "/NEM/PagesRemapCalls", STAMUNIT_PAGES, "Calls to HvCallMapGpaPages for changing page protection"); 1356 STAMR3Register(pVM, (void *)&pVM->nem.s.StatRemapPage, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, 1357 "/NEM/PagesRemapFails", STAMUNIT_PAGES, "Calls to HvCallMapGpaPages for changing page protection failed"); 1358 #else 1359 STAMR3Register(pVM, (void *)&pVM->nem.s.StatUnmapAllPages, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, 1360 "/NEM/PagesUnmapAll", STAMUNIT_PAGES, "Times we had to unmap all the pages"); 1361 #endif 1362 1336 1363 for (VMCPUID idCpu = 0; idCpu < pVM->cCpus; idCpu++) 1337 1364 { … … 2026 2053 #endif 2027 2054 { 2055 STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPage); 2028 2056 uint32_t cMappedPages = ASMAtomicDecU32(&pVM->nem.s.cMappedPages); NOREF(cMappedPages); 2029 2057 Log5(("NEM GPA unmapped/A20: %RGp (was %s, cMappedPages=%u)\n", GCPhys, g_apszPageStates[pInfo->u2NemState], cMappedPages)); … … 2032 2060 else 2033 2061 { 2062 STAM_REL_COUNTER_INC(&pVM->nem.s.StatUnmapPageFailed); 2034 2063 #ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 2035 2064 LogRel(("nemR3WinUnsetForA20CheckerCallback/unmap: GCPhys=%RGp rc=%Rrc\n", GCPhys, rc)); -
trunk/src/VBox/VMM/include/NEMInternal.h
r91692 r91702 192 192 /** Number of currently mapped pages. */ 193 193 uint32_t volatile cMappedPages; 194 # ifndef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 195 /** Max number of pages we dare map at once. */ 196 uint32_t cMaxMappedPages; 197 # endif 198 STAMCOUNTER StatMapPage; 199 STAMCOUNTER StatUnmapPage; 200 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES 201 STAMCOUNTER StatRemapPage; 202 STAMCOUNTER StatRemapPageFailed; 203 # else 204 STAMCOUNTER StatUnmapAllPages; 205 # endif 206 STAMCOUNTER StatMapPageFailed; 207 STAMCOUNTER StatUnmapPageFailed; 194 208 195 209 # ifdef NEM_WIN_USE_HYPERCALLS_FOR_PAGES
Note:
See TracChangeset
for help on using the changeset viewer.

