Changeset 80118 in vbox for trunk/src/VBox/VMM/VMMR3/MMHyper.cpp
- Timestamp:
- Aug 4, 2019 2:39:54 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/MMHyper.cpp
r76553 r80118 38 38 * Internal Functions * 39 39 *********************************************************************************************************************************/ 40 #ifndef PGM_WITHOUT_MAPPINGS 40 41 static DECLCALLBACK(bool) mmR3HyperRelocateCallback(PVM pVM, RTGCPTR GCPtrOld, RTGCPTR GCPtrNew, PGMRELOCATECALL enmMode, 41 42 void *pvUser); 43 #endif 42 44 static int mmR3HyperMap(PVM pVM, const size_t cb, const char *pszDesc, PRTGCPTR pGCPtr, PMMLOOKUPHYPER *ppLookup); 43 45 static int mmR3HyperHeapCreate(PVM pVM, const size_t cb, PMMHYPERHEAP *ppHeap, PRTR0PTR pR0PtrHeap); … … 54 56 static uint32_t mmR3HyperComputeHeapSize(PVM pVM) 55 57 { 58 /** @todo Redo after moving allocations off the hyper heap. */ 59 56 60 /* 57 61 * Gather parameters. 58 62 */ 59 bool fCanUseLargerHeap; 60 int rc = CFGMR3QueryBoolDef(CFGMR3GetChild(CFGMR3GetRoot(pVM), "MM"), "CanUseLargerHeap", &fCanUseLargerHeap, false); 61 AssertStmt(RT_SUCCESS(rc), fCanUseLargerHeap = false); 63 bool fCanUseLargerHeap = true; 64 //bool fCanUseLargerHeap; 65 //int rc = CFGMR3QueryBoolDef(CFGMR3GetChild(CFGMR3GetRoot(pVM), "MM"), "CanUseLargerHeap", &fCanUseLargerHeap, false); 66 //AssertStmt(RT_SUCCESS(rc), fCanUseLargerHeap = false); 62 67 63 68 uint64_t cbRam; 64 rc = CFGMR3QueryU64(CFGMR3GetRoot(pVM), "RamSize", &cbRam);69 int rc = CFGMR3QueryU64(CFGMR3GetRoot(pVM), "RamSize", &cbRam); 65 70 AssertStmt(RT_SUCCESS(rc), cbRam = _1G); 66 71 … … 142 147 * Make a small head fence to fend of accidental sequential access. 143 148 */ 144 MMR3HyperReserve (pVM, PAGE_SIZE, "fence", NULL);149 MMR3HyperReserveFence(pVM); 145 150 146 151 /* … … 158 163 159 164 /* Reserve a page for fencing. */ 160 MMR3HyperReserve (pVM, PAGE_SIZE, "fence", NULL);165 MMR3HyperReserveFence(pVM); 161 166 162 167 /* … … 218 223 AssertRC(rc); 219 224 225 #ifndef PGM_WITHOUT_MAPPINGS 220 226 /* 221 227 * Adjust and create the HMA mapping. … … 227 233 if (RT_FAILURE(rc)) 228 234 return rc; 235 #endif 229 236 pVM->mm.s.fPGMInitialized = true; 230 237 238 #ifndef PGM_WITHOUT_MAPPINGS 231 239 /* 232 240 * Do all the delayed mappings. … … 309 317 pLookup = (PMMLOOKUPHYPER)((uintptr_t)pLookup + pLookup->offNext); 310 318 } 319 #endif /* !PGM_WITHOUT_MAPPINGS */ 311 320 312 321 LogFlow(("MMR3HyperInitFinalize: returns VINF_SUCCESS\n")); … … 315 324 316 325 326 #ifndef PGM_WITHOUT_MAPPINGS 317 327 /** 318 328 * Callback function which will be called when PGM is trying to find a new … … 385 395 return false; 386 396 } 397 #endif /* !PGM_WITHOUT_MAPPINGS */ 398 387 399 388 400 /** … … 400 412 return rc; 401 413 } 414 415 416 #ifndef PGM_WITHOUT_MAPPINGS 402 417 403 418 /** … … 607 622 } 608 623 624 #endif /* !PGM_WITHOUT_MAPPINGS */ 609 625 610 626 /** … … 662 678 } 663 679 680 #ifndef PGM_WITHOUT_MAPPINGS 664 681 if (pVM->mm.s.fPGMInitialized) 665 682 { … … 670 687 } 671 688 } 689 #endif 672 690 if (RT_SUCCESS(rc)) 673 691 { … … 689 707 690 708 709 #ifndef PGM_WITHOUT_MAPPINGS 691 710 /** 692 711 * Reserves a hypervisor memory area. … … 729 748 } 730 749 return rc; 750 } 751 #endif /* !PGM_WITHOUT_MAPPINGS */ 752 753 754 /** 755 * Reserves an electric fence page. 756 * 757 * @returns VBox status code. 758 * @param pVM The cross context VM structure. 759 */ 760 VMMR3DECL(int) MMR3HyperReserveFence(PVM pVM) 761 { 762 #ifndef PGM_WITHOUT_MAPPINGS 763 return MMR3HyperReserve(pVM, cb, "fence", NULL); 764 #else 765 RT_NOREF(pVM); 766 return VINF_SUCCESS; 767 #endif 731 768 } 732 769 … … 818 855 0 /*fFlags*/, 819 856 &pv, 820 #if defined(VBOX_WITH_2X_4GB_ADDR_SPACE) || defined(VBOX_WITH_MORE_RING0_MEM_MAPPINGS)821 857 &pvR0, 822 #else823 NULL,824 #endif825 858 paPages); 826 859 if (RT_SUCCESS(rc)) 827 860 { 828 #if !defined(VBOX_WITH_2X_4GB_ADDR_SPACE) && !defined(VBOX_WITH_MORE_RING0_MEM_MAPPINGS) 829 pvR0 = (uintptr_t)pv; 830 #endif 861 Assert(pvR0 != NIL_RTR0PTR && !(PAGE_OFFSET_MASK & pvR0)); 831 862 memset(pv, 0, cbAligned); 832 863 … … 837 868 pHeap->u32Magic = MMHYPERHEAP_MAGIC; 838 869 pHeap->pbHeapR3 = (uint8_t *)pHeap + MMYPERHEAP_HDR_SIZE; 839 pHeap->pbHeapR0 = pvR0 != NIL_RTR0PTR ? pvR0 + MMYPERHEAP_HDR_SIZE : NIL_RTR0PTR;870 pHeap->pbHeapR0 = pvR0 + MMYPERHEAP_HDR_SIZE; 840 871 //pHeap->pbHeapRC = 0; // set by mmR3HyperHeapMap() 841 872 pHeap->pVMR3 = pVM; … … 871 902 } 872 903 904 873 905 /** 874 906 * Allocates a new heap. … … 877 909 { 878 910 Assert(RT_ALIGN_Z(pHeap->cbHeap + MMYPERHEAP_HDR_SIZE, PAGE_SIZE) == pHeap->cbHeap + MMYPERHEAP_HDR_SIZE); 911 Assert(pHeap->pbHeapR0); 879 912 Assert(pHeap->paPages); 880 913 int rc = MMR3HyperMapPages(pVM, 881 914 pHeap, 882 pHeap->pbHeapR0 != NIL_RTR0PTR ? pHeap->pbHeapR0 - MMYPERHEAP_HDR_SIZE : NIL_RTR0PTR,915 pHeap->pbHeapR0 - MMYPERHEAP_HDR_SIZE, 883 916 (pHeap->cbHeap + MMYPERHEAP_HDR_SIZE) >> PAGE_SHIFT, 884 917 pHeap->paPages, … … 889 922 pHeap->pbHeapRC = *ppHeapGC + MMYPERHEAP_HDR_SIZE; 890 923 /* Reserve a page for fencing. */ 891 MMR3HyperReserve (pVM, PAGE_SIZE, "fence", NULL);924 MMR3HyperReserveFence(pVM); 892 925 893 926 /* We won't need these any more. */ … … 1014 1047 0 /*fFlags*/, 1015 1048 &pvPages, 1016 #ifdef VBOX_WITH_MORE_RING0_MEM_MAPPINGS1017 1049 &pvR0, 1018 #else1019 fFlags & MMHYPER_AONR_FLAGS_KERNEL_MAPPING ? &pvR0 : NULL,1020 #endif1021 1050 paPages); 1022 1051 if (RT_SUCCESS(rc)) 1023 1052 { 1024 #ifdef VBOX_WITH_MORE_RING0_MEM_MAPPINGS1025 1053 Assert(pvR0 != NIL_RTR0PTR); 1026 #else1027 if (!(fFlags & MMHYPER_AONR_FLAGS_KERNEL_MAPPING))1028 # ifdef VBOX_WITH_2X_4GB_ADDR_SPACE1029 pvR0 = NIL_RTR0PTR;1030 # else1031 pvR0 = (RTR0PTR)pvPages;1032 # endif1033 #endif1034 1035 1054 memset(pvPages, 0, cbAligned); 1036 1055 … … 1050 1069 Log2(("MMR3HyperAllocOnceNoRel: cbAligned=%#x uAlignment=%#x returns VINF_SUCCESS and *ppv=%p\n", 1051 1070 cbAligned, uAlignment, *ppv)); 1052 MMR3HyperReserve (pVM, PAGE_SIZE, "fence", NULL);1071 MMR3HyperReserveFence(pVM); 1053 1072 return rc; 1054 1073 } … … 1165 1184 if (fSet) 1166 1185 { 1186 #ifndef PGM_WITHOUT_MAPPINGS 1167 1187 rc = PGMMapSetPage(pVM, MMHyperR3ToRC(pVM, pvStart), cb, 0); 1188 #else 1189 rc = VINF_SUCCESS; 1190 #endif 1168 1191 SUPR3PageProtect(pbR3, R0Ptr, off, (uint32_t)cb, RTMEM_PROT_NONE); 1169 1192 } 1170 1193 else 1171 1194 { 1195 #ifndef PGM_WITHOUT_MAPPINGS 1172 1196 rc = PGMMapSetPage(pVM, MMHyperR3ToRC(pVM, pvStart), cb, X86_PTE_P | X86_PTE_A | X86_PTE_D | X86_PTE_RW); 1197 #else 1198 rc = VINF_SUCCESS; 1199 #endif 1173 1200 SUPR3PageProtect(pbR3, R0Ptr, off, (uint32_t)cb, RTMEM_PROT_READ | RTMEM_PROT_WRITE); 1174 1201 } … … 1228 1255 } 1229 1256 1257 #ifndef PGM_WITHOUT_MAPPINGS 1230 1258 1231 1259 /** … … 1314 1342 1315 1343 1316 #if 0 /* unused, not implemented */1317 /**1318 * Convert hypervisor HC physical address to HC virtual address.1319 *1320 * @returns HC virtual address.1321 * @param pVM The cross context VM structure.1322 * @param HCPhys Host context physical address.1323 */1324 VMMR3DECL(void *) MMR3HyperHCPhys2HCVirt(PVM pVM, RTHCPHYS HCPhys)1325 {1326 void *pv;1327 int rc = MMR3HyperHCPhys2HCVirtEx(pVM, HCPhys, &pv);1328 if (RT_SUCCESS(rc))1329 return pv;1330 AssertMsgFailed(("Invalid address HCPhys=%x rc=%d\n", HCPhys, rc));1331 return NULL;1332 }1333 1334 1335 /**1336 * Convert hypervisor HC physical address to HC virtual address.1337 *1338 * @returns VBox status code.1339 * @param pVM The cross context VM structure.1340 * @param HCPhys Host context physical address.1341 * @param ppv Where to store the HC virtual address.1342 */1343 VMMR3DECL(int) MMR3HyperHCPhys2HCVirtEx(PVM pVM, RTHCPHYS HCPhys, void **ppv)1344 {1345 /*1346 * Linear search.1347 */1348 /** @todo implement when actually used. */1349 return VERR_INVALID_POINTER;1350 }1351 #endif /* unused, not implemented */1352 1353 1354 1344 /** 1355 1345 * Read hypervisor memory from GC virtual address. … … 1370 1360 } 1371 1361 1362 #endif /* !PGM_WITHOUT_MAPPINGS */ 1372 1363 1373 1364 /**
Note:
See TracChangeset
for help on using the changeset viewer.