Changeset 18125 in vbox for trunk/src/VBox/VMM/VMMAll
- Timestamp:
- Mar 22, 2009 4:52:36 PM (16 years ago)
- Location:
- trunk/src/VBox/VMM/VMMAll
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/PGMAll.cpp
r17667 r18125 1310 1310 } 1311 1311 1312 #ifdef VBOX_WITH_NEW_PHYS_CODE 1313 #ifdef IN_RING3 1314 1315 /** 1316 * Performs the lazy mapping of the 32-bit guest PD. 1317 * 1318 * @returns Pointer to the mapping. 1319 * @param pPGM The PGM instance data. 1320 */ 1321 PX86PD pgmGstLazyMap32BitPD(PPGM pPGM) 1322 { 1323 Assert(!pPGM->CTX_SUFF(pGst32BitPd)); 1324 PVM pVM = PGM2VM(pPGM); 1325 pgmLock(pVM); 1326 1327 PPGMPAGE pPage = pgmPhysGetPage(pPGM, pPGM->GCPhysCR3); 1328 AssertReturn(pPage, NULL); 1329 1330 RTHCPTR HCPtrGuestCR3; 1331 int rc = pgmPhysGCPhys2CCPtrInternal(pVM, pPage, pPGM->GCPhysCR3 & X86_CR3_PAGE_MASK, (void **)&HCPtrGuestCR3); 1332 AssertRCReturn(rc, NULL); 1333 1334 pPGM->pGst32BitPdR3 = (R3PTRTYPE(PX86PD))HCPtrGuestCR3; 1335 # ifndef VBOX_WITH_2X_4GB_ADDR_SPACE 1336 pPGM->pGst32BitPdR0 = (R0PTRTYPE(PX86PD))HCPtrGuestCR3; 1337 # endif 1338 1339 pgmUnlock(pVM); 1340 return pPGM->CTX_SUFF(pGst32BitPd); 1341 } 1342 1343 1344 /** 1345 * Performs the lazy mapping of the PAE guest PDPT. 1346 * 1347 * @returns Pointer to the mapping. 1348 * @param pPGM The PGM instance data. 1349 */ 1350 PX86PDPT pgmGstLazyMapPaePDPT(PPGM pPGM) 1351 { 1352 Assert(!pPGM->CTX_SUFF(pGstPaePdpt)); 1353 PVM pVM = PGM2VM(pPGM); 1354 pgmLock(pVM); 1355 1356 PPGMPAGE pPage = pgmPhysGetPage(pPGM, pPGM->GCPhysCR3); 1357 AssertReturn(pPage, NULL); 1358 1359 RTHCPTR HCPtrGuestCR3; 1360 int rc = pgmPhysGCPhys2CCPtrInternal(pVM, pPage, pPGM->GCPhysCR3 & X86_CR3_PAE_PAGE_MASK, (void **)&HCPtrGuestCR3); 1361 AssertRCReturn(rc, NULL); 1362 1363 pPGM->pGstPaePdptR3 = (R3PTRTYPE(PX86PDPT))HCPtrGuestCR3; 1364 # ifndef VBOX_WITH_2X_4GB_ADDR_SPACE 1365 pPGM->pGstPaePdptR0 = (R0PTRTYPE(PX86PDPT))HCPtrGuestCR3; 1366 # endif 1367 1368 pgmUnlock(pVM); 1369 return pPGM->CTX_SUFF(pGstPaePdpt); 1370 } 1371 1372 #endif /* IN_RING3 */ 1373 1374 /** 1375 * Performs the lazy mapping / updating of a PAE guest PD. 1376 * 1377 * @returns Pointer to the mapping. 1378 * @param pPGM The PGM instance data. 1379 * @param iPdpt Which PD entry to map (0..3). 1380 */ 1381 PX86PDPAE pgmGstLazyMapPaePD(PPGM pPGM, uint32_t iPdpt) 1382 { 1383 PVM pVM = PGM2VM(pPGM); 1384 pgmLock(pVM); 1385 1386 PX86PDPT pGuestPDPT = pPGM->CTX_SUFF(pGstPaePdpt); 1387 Assert(pGuestPDPT); 1388 Assert(pGuestPDPT->a[iPdpt].n.u1Present); 1389 RTGCPHYS GCPhys = pGuestPDPT->a[iPdpt].u & X86_PDPE_PG_MASK; 1390 bool const fChanged = pPGM->aGCPhysGstPaePDs[iPdpt] != GCPhys; 1391 1392 PPGMPAGE pPage = pgmPhysGetPage(pPGM, GCPhys); 1393 if (RT_LIKELY(pPage)) 1394 { 1395 int rc = VINF_SUCCESS; 1396 RTRCPTR RCPtr = NIL_RTRCPTR; 1397 RTHCPTR HCPtr = NIL_RTHCPTR; 1398 #if !defined(IN_RC) && !defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) 1399 rc = pgmPhysGCPhys2CCPtrInternal(pVM, pPage, GCPhys, &HCPtr); 1400 AssertRC(rc); 1401 #endif 1402 if (RT_SUCCESS(rc) && fChanged) 1403 { 1404 RCPtr = (RTRCPTR)(RTRCUINTPTR)(pPGM->GCPtrCR3Mapping + (1 + iPdpt) * PAGE_SIZE); 1405 rc = PGMMap(pVM, (RTRCUINTPTR)RCPtr, PGM_PAGE_GET_HCPHYS(pPage), PAGE_SIZE, 0); 1406 } 1407 if (RT_SUCCESS(rc)) 1408 { 1409 pPGM->apGstPaePDsR3[iPdpt] = (R3PTRTYPE(PX86PDPAE))HCPtr; 1410 # ifndef VBOX_WITH_2X_4GB_ADDR_SPACE 1411 pPGM->apGstPaePDsR0[iPdpt] = (R0PTRTYPE(PX86PDPAE))HCPtr; 1412 # endif 1413 if (fChanged) 1414 { 1415 pPGM->aGCPhysGstPaePDs[iPdpt] = GCPhys; 1416 pPGM->apGstPaePDsRC[iPdpt] = (RCPTRTYPE(PX86PDPAE))RCPtr; 1417 } 1418 1419 pgmUnlock(pVM); 1420 return pPGM->CTX_SUFF(apGstPaePDs)[iPdpt]; 1421 } 1422 } 1423 1424 /* Invalid page or some failure, invalidate the entry. */ 1425 pPGM->aGCPhysGstPaePDs[iPdpt] = NIL_RTGCPHYS; 1426 pPGM->apGstPaePDsR3[iPdpt] = 0; 1427 # ifndef VBOX_WITH_2X_4GB_ADDR_SPACE 1428 pPGM->apGstPaePDsR0[iPdpt] = 0; 1429 # endif 1430 pPGM->apGstPaePDsRC[iPdpt] = 0; 1431 1432 pgmUnlock(pVM); 1433 return NULL; 1434 } 1435 1436 1437 #ifdef VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R3 1438 /** 1439 * Performs the lazy mapping of the 32-bit guest PD. 1440 * 1441 * @returns Pointer to the mapping. 1442 * @param pPGM The PGM instance data. 1443 */ 1444 PX86PML4 pgmGstLazyMapPml4(PPGM pPGM) 1445 { 1446 Assert(!pPGM->CTX_SUFF(pGstAmd64Pml4)); 1447 PVM pVM = PGM2VM(pPGM); 1448 pgmLock(pVM); 1449 1450 PPGMPAGE pPage = pgmPhysGetPage(pPGM, pPGM->GCPhysCR3); 1451 AssertReturn(pPage, NULL); 1452 1453 RTHCPTR HCPtrGuestCR3; 1454 int rc = pgmPhysGCPhys2CCPtrInternal(pVM, pPage, pPGM->GCPhysCR3 & X86_CR3_AMD64_PAGE_MASK, (void **)&HCPtrGuestCR3); 1455 AssertRCReturn(rc, NULL); 1456 1457 pPGM->pGstAmd64Pml4R3 = (R3PTRTYPE(PX86PML4))HCPtrGuestCR3; 1458 # ifndef VBOX_WITH_2X_4GB_ADDR_SPACE 1459 pPGM->pGstAmd64Pml4R0 = (R0PTRTYPE(PX86PML4))HCPtrGuestCR3; 1460 # endif 1461 1462 pgmUnlock(pVM); 1463 return pPGM->CTX_SUFF(pGstAmd64Pml4); 1464 } 1465 #endif /* VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R3 */ 1466 1467 #endif /* VBOX_WITH_NEW_PHYS_CODE */ 1312 1468 1313 1469 /** -
trunk/src/VBox/VMM/VMMAll/PGMAllBth.h
r18093 r18125 3416 3416 AssertMsgReturn(HCPhys == HCPhysShw, ("HCPhys=%RHp HCPhyswShw=%RHp (cr3)\n", HCPhys, HCPhysShw), false); 3417 3417 # if PGM_GST_TYPE == PGM_TYPE_32BIT && defined(IN_RING3) 3418 pgmGstGet32bitPDPtr(pPGM); 3418 3419 RTGCPHYS GCPhys; 3419 3420 rc = PGMR3DbgR3Ptr2GCPhys(pVM, pPGM->pGst32BitPdR3, &GCPhys); … … 4139 4140 RTHCPHYS HCPhysGuestCR3; 4140 4141 # ifdef VBOX_WITH_NEW_PHYS_CODE 4141 /** @todo this needs some reworking. current code is just a big hack. */ 4142 pgmLock(pVM); 4143 PPGMPAGE pPage = pgmPhysGetPage(&pVM->pgm.s, GCPhysCR3); 4144 AssertReturn(pPage, VERR_INTERNAL_ERROR); 4145 HCPhysGuestCR3 = PGM_PAGE_GET_HCPHYS(pPage); 4146 /** @todo this needs some reworking wrt. locking. */ 4142 4147 # if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) 4143 # if 1 /* temp hack */ 4144 VM_FF_SET(pVM, VM_FF_PGM_SYNC_CR3); 4145 return VINF_PGM_SYNC_CR3; 4146 # else 4147 AssertFailedReturn(VERR_INTERNAL_ERROR); 4148 # endif 4149 int rc = VERR_INTERNAL_ERROR; 4148 HCPtrGuestCR3 = NIL_RTHCPTR; 4149 int rc = VINF_SUCCESS; 4150 4150 # else 4151 pgmLock(pVM);4152 PPGMPAGE pPage = pgmPhysGetPage(&pVM->pgm.s, GCPhysCR3);4153 AssertReturn(pPage, VERR_INTERNAL_ERROR);4154 4151 int rc = pgmPhysGCPhys2CCPtrInternal(pVM, pPage, GCPhysCR3 & GST_CR3_PAGE_MASK, (void **)&HCPtrGuestCR3); 4155 HCPhysGuestCR3 = PGM_PAGE_GET_HCPHYS(pPage); 4152 # endif 4156 4153 pgmUnlock(pVM); 4157 # endif4158 4154 # else /* !VBOX_WITH_NEW_PHYS_CODE */ 4159 4155 int rc = pgmRamGCPhys2HCPtrAndHCPhys(&pVM->pgm.s, GCPhysCR3 & GST_CR3_PAGE_MASK, &HCPtrGuestCR3, &HCPhysGuestCR3); … … 4187 4183 */ 4188 4184 PX86PDPT pGuestPDPT = pgmGstGetPaePDPTPtr(&pVM->pgm.s); 4189 RTGCPTR GCPtr= pVM->pgm.s.GCPtrCR3Mapping + PAGE_SIZE;4185 RTGCPTR GCPtr = pVM->pgm.s.GCPtrCR3Mapping + PAGE_SIZE; 4190 4186 for (unsigned i = 0; i < X86_PG_PAE_PDPE_ENTRIES; i++, GCPtr += PAGE_SIZE) 4191 4187 { … … 4196 4192 RTGCPHYS GCPhys = pGuestPDPT->a[i].u & X86_PDPE_PG_MASK; 4197 4193 # ifdef VBOX_WITH_NEW_PHYS_CODE 4194 pgmLock(pVM); 4195 PPGMPAGE pPage = pgmPhysGetPage(&pVM->pgm.s, GCPhys); 4196 AssertReturn(pPage, VERR_INTERNAL_ERROR); 4197 HCPhys = PGM_PAGE_GET_HCPHYS(pPage); 4198 4198 # if defined(IN_RC) || defined(VBOX_WITH_2X_4GB_ADDR_SPACE_IN_R0) 4199 AssertFailedReturn(VERR_INTERNAL_ERROR);4200 int rc2 = V ERR_INTERNAL_ERROR;4199 HCPtr = NIL_RTHCPTR; 4200 int rc2 = VINF_SUCCESS; 4201 4201 # else 4202 pgmLock(pVM);4203 PPGMPAGE pPage = pgmPhysGetPage(&pVM->pgm.s, GCPhys);4204 AssertReturn(pPage, VERR_INTERNAL_ERROR);4205 4202 int rc2 = pgmPhysGCPhys2CCPtrInternal(pVM, pPage, GCPhys, (void **)&HCPtr); 4206 HCPhys = PGM_PAGE_GET_HCPHYS(pPage); 4203 # endif 4207 4204 pgmUnlock(pVM); 4208 # endif4209 4205 # else /* !VBOX_WITH_NEW_PHYS_CODE */ 4210 4206 int rc2 = pgmRamGCPhys2HCPtrAndHCPhys(&pVM->pgm.s, GCPhys, &HCPtr, &HCPhys); … … 4299 4295 4300 4296 # ifndef PGM_WITHOUT_MAPPINGS 4301 /* Apply all hypervisor mappings to the new CR3. 4297 /* 4298 * Apply all hypervisor mappings to the new CR3. 4302 4299 * Note that SyncCR3 will be executed in case CR3 is changed in a guest paging mode; this will 4303 4300 * make sure we check for conflicts in the new CR3 root. -
trunk/src/VBox/VMM/VMMAll/PGMAllPhys.cpp
r18101 r18125 1007 1007 */ 1008 1008 PPGMPAGEMAP pMap = pTlbe->pMap; 1009 pMap->cRefs++; 1009 if (pMap) 1010 pMap->cRefs++; 1010 1011 #if 0 /** @todo implement locking properly */ 1011 1012 if (RT_LIKELY(pPage->cLocks != PGM_PAGE_MAX_LOCKS)) … … 1013 1014 { 1014 1015 AssertMsgFailed(("%RGp is entering permanent locked state!\n", GCPhys)); 1015 pMap->cRefs++; /* Extra ref to prevent it from going away. */ 1016 if (pMap) 1017 pMap->cRefs++; /* Extra ref to prevent it from going away. */ 1016 1018 } 1017 1019 #endif … … 1113 1115 */ 1114 1116 PPGMPAGEMAP pMap = pTlbe->pMap; 1115 pMap->cRefs++; 1117 if (pMap) 1118 pMap->cRefs++; 1116 1119 #if 0 /** @todo implement locking properly */ 1117 1120 if (RT_LIKELY(pPage->cLocks != PGM_PAGE_MAX_LOCKS)) … … 1119 1122 { 1120 1123 AssertMsgFailed(("%RGp is entering permanent locked state!\n", GCPhys)); 1121 pMap->cRefs++; /* Extra ref to prevent it from going away. */ 1124 if (pMap) 1125 pMap->cRefs++; /* Extra ref to prevent it from going away. */ 1122 1126 } 1123 1127 #endif
Note:
See TracChangeset
for help on using the changeset viewer.