Changeset 58781 in vbox
- Timestamp:
- Nov 19, 2015 10:33:00 PM (9 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMR3/PGM.cpp
r58779 r58781 1253 1253 pVM->pgm.s.offVM = RT_OFFSETOF(VM, pgm.s); 1254 1254 pVM->pgm.s.offVCpuPGM = RT_OFFSETOF(VMCPU, pgm.s); 1255 /*pVM->pgm.s.fRestoreRomPagesAtReset = false;*/ 1255 1256 1256 1257 for (unsigned i = 0; i < RT_ELEMENTS(pVM->pgm.s.aHandyPages); i++) … … 1312 1313 pVM->pgm.s.GCPhys4MBPSEMask = RT_BIT_64(32) - 1; /* default; checked later */ 1313 1314 pVM->pgm.s.GCPtrPrevRamRangeMapping = MM_HYPER_AREA_ADDRESS; 1314 pVM->pgm.s.fRestoreVirginRomPagesDuringReset = false;1315 1315 1316 1316 rc = CFGMR3QueryBoolDef(CFGMR3GetRoot(pVM), "RamPreAlloc", &pVM->pgm.s.fRamPreAlloc, -
trunk/src/VBox/VMM/VMMR3/PGMPhys.cpp
r58779 r58781 3387 3387 pRomNew->idSavedState = UINT8_MAX; 3388 3388 pRomNew->cbOriginal = cbBinary; 3389 #ifdef VBOX_STRICT 3389 pRomNew->pszDesc = pszDesc; 3390 3390 pRomNew->pvOriginal = fFlags & PGMPHYS_ROM_FLAGS_PERMANENT_BINARY 3391 3391 ? pvBinary : RTMemDup(pvBinary, cbBinary); 3392 #else 3393 pRomNew->pvOriginal = fFlags & PGMPHYS_ROM_FLAGS_PERMANENT_BINARY ? pvBinary : NULL; 3394 #endif 3395 pRomNew->pszDesc = pszDesc; 3396 3397 for (unsigned iPage = 0; iPage < cPages; iPage++) 3392 if (pRomNew->pvOriginal) 3398 3393 { 3399 PPGMROMPAGE pPage = &pRomNew->aPages[iPage]; 3400 pPage->enmProt = PGMROMPROT_READ_ROM_WRITE_IGNORE; 3401 PGM_PAGE_INIT_ZERO(&pPage->Shadow, pVM, PGMPAGETYPE_ROM_SHADOW); 3394 for (unsigned iPage = 0; iPage < cPages; iPage++) 3395 { 3396 PPGMROMPAGE pPage = &pRomNew->aPages[iPage]; 3397 pPage->enmProt = PGMROMPROT_READ_ROM_WRITE_IGNORE; 3398 PGM_PAGE_INIT_ZERO(&pPage->Shadow, pVM, PGMPAGETYPE_ROM_SHADOW); 3399 } 3400 3401 /* update the page count stats for the shadow pages. */ 3402 if (fFlags & PGMPHYS_ROM_FLAGS_SHADOWED) 3403 { 3404 pVM->pgm.s.cZeroPages += cPages; 3405 pVM->pgm.s.cAllPages += cPages; 3406 } 3407 3408 /* 3409 * Insert the ROM range, tell REM and return successfully. 3410 */ 3411 pRomNew->pNextR3 = pRom; 3412 pRomNew->pNextR0 = pRom ? MMHyperCCToR0(pVM, pRom) : NIL_RTR0PTR; 3413 pRomNew->pNextRC = pRom ? MMHyperCCToRC(pVM, pRom) : NIL_RTRCPTR; 3414 3415 if (pRomPrev) 3416 { 3417 pRomPrev->pNextR3 = pRomNew; 3418 pRomPrev->pNextR0 = MMHyperCCToR0(pVM, pRomNew); 3419 pRomPrev->pNextRC = MMHyperCCToRC(pVM, pRomNew); 3420 } 3421 else 3422 { 3423 pVM->pgm.s.pRomRangesR3 = pRomNew; 3424 pVM->pgm.s.pRomRangesR0 = MMHyperCCToR0(pVM, pRomNew); 3425 pVM->pgm.s.pRomRangesRC = MMHyperCCToRC(pVM, pRomNew); 3426 } 3427 3428 pgmPhysInvalidatePageMapTLB(pVM); 3429 GMMR3AllocatePagesCleanup(pReq); 3430 return VINF_SUCCESS; 3402 3431 } 3403 3432 3404 /* update the page count stats for the shadow pages. */ 3405 if (fFlags & PGMPHYS_ROM_FLAGS_SHADOWED) 3406 { 3407 pVM->pgm.s.cZeroPages += cPages; 3408 pVM->pgm.s.cAllPages += cPages; 3409 } 3410 3411 /* 3412 * Insert the ROM range, tell REM and return successfully. 3413 */ 3414 pRomNew->pNextR3 = pRom; 3415 pRomNew->pNextR0 = pRom ? MMHyperCCToR0(pVM, pRom) : NIL_RTR0PTR; 3416 pRomNew->pNextRC = pRom ? MMHyperCCToRC(pVM, pRom) : NIL_RTRCPTR; 3417 3418 if (pRomPrev) 3419 { 3420 pRomPrev->pNextR3 = pRomNew; 3421 pRomPrev->pNextR0 = MMHyperCCToR0(pVM, pRomNew); 3422 pRomPrev->pNextRC = MMHyperCCToRC(pVM, pRomNew); 3423 } 3424 else 3425 { 3426 pVM->pgm.s.pRomRangesR3 = pRomNew; 3427 pVM->pgm.s.pRomRangesR0 = MMHyperCCToR0(pVM, pRomNew); 3428 pVM->pgm.s.pRomRangesRC = MMHyperCCToRC(pVM, pRomNew); 3429 } 3430 3431 pgmPhysInvalidatePageMapTLB(pVM); 3432 GMMR3AllocatePagesCleanup(pReq); 3433 return VINF_SUCCESS; 3433 /* bail out */ 3434 rc = VERR_NO_MEMORY; 3434 3435 } 3435 3436 /* bail out */3437 3436 3438 3437 int rc2 = PGMHandlerPhysicalDeregister(pVM, GCPhys); … … 3574 3573 3575 3574 /* 3576 * Restore virgin ROM pages after a saved state load or check that the3577 * virgin pages are unchanged if possible.3575 * Restore the original ROM pages after a saved state load. 3576 * Also, in strict builds check that ROM pages remain unmodified. 3578 3577 */ 3579 if (pRom->pvOriginal) 3578 if ( pRom->pvOriginal 3579 #ifndef VBOX_STRICT 3580 && pVM->pgm.s.fRestoreRomPagesAtReset 3581 #endif 3582 ) 3580 3583 { 3581 3584 size_t cbSrcLeft = pRom->cbOriginal; 3582 3585 uint8_t const *pbSrcPage = (uint8_t const *)pRom->pvOriginal; 3583 bool fChanged = false;3586 uint32_t cRestored = 0; 3584 3587 for (uint32_t iPage = 0; iPage < cPages && cbSrcLeft > 0; iPage++, pbSrcPage += PAGE_SIZE) 3585 3588 { … … 3592 3595 if (memcmp(pvDstPage, pbSrcPage, RT_MIN(cbSrcLeft, PAGE_SIZE))) 3593 3596 { 3594 if (pVM->pgm.s.fRestore VirginRomPagesDuringReset)3597 if (pVM->pgm.s.fRestoreRomPagesAtReset) 3595 3598 { 3596 3599 void *pvDstPageW; … … 3598 3601 AssertLogRelRCReturn(rc, rc); 3599 3602 memcpy(pvDstPageW, pbSrcPage, RT_MIN(cbSrcLeft, PAGE_SIZE)); 3600 fChanged = true;3603 cRestored++; 3601 3604 } 3602 3605 else 3603 { 3604 #ifdef VBOX_STRICT 3605 LogRel(("pgmR3PhysRomReset: %RGp rom page changed (%s)?\n", GCPhys, pRom->pszDesc)); 3606 #endif 3607 } 3606 LogRel(("pgmR3PhysRomReset: %RGp: ROM page changed (%s)\n", GCPhys, pRom->pszDesc)); 3608 3607 } 3609 3608 cbSrcLeft -= RT_MIN(cbSrcLeft, PAGE_SIZE); 3610 3609 } 3611 if (fChanged) 3612 LogRel(("PGM: ROM \"%s\" changed - restored original\n", pRom->pszDesc)); 3613 } 3614 } 3615 3616 pVM->pgm.s.fRestoreVirginRomPagesDuringReset = false; 3610 if (cRestored > 0) 3611 LogRel(("PGM: ROM \"%s\": Reloaded %u of %u pages.\n", pRom->pszDesc, cRestored, cPages)); 3612 } 3613 } 3614 3615 /* Clear the ROM restore flag now as we only need to do this once after 3616 loading saved state. */ 3617 pVM->pgm.s.fRestoreRomPagesAtReset = false; 3618 3617 3619 return VINF_SUCCESS; 3618 3620 } … … 3628 3630 void pgmR3PhysRomTerm(PVM pVM) 3629 3631 { 3630 #ifdef RT_STRICT3631 3632 /* 3632 3633 * Free the heap copy of the original bits. … … 3641 3642 } 3642 3643 } 3643 #endif3644 3644 } 3645 3645 -
trunk/src/VBox/VMM/VMMR3/PGMSavedState.cpp
r58779 r58781 336 336 ("The \"%s\" ROM was not found in the saved state. Probably due to some misconfiguration\n", 337 337 pRom->pszDesc)); 338 339 pVM->pgm.s.fRestoreVirginRomPagesDuringReset = true;340 338 return VINF_SUCCESS; /* the end */ 341 339 } … … 3299 3297 3300 3298 /** 3299 * @callback_method_impl{FNSSMINTLOADDONE} 3300 */ 3301 static DECLCALLBACK(int) pgmR3LoadDone(PVM pVM, PSSMHANDLE pSSM) 3302 { 3303 pVM->pgm.s.fRestoreRomPagesAtReset = true; 3304 NOREF(pSSM); 3305 return VINF_SUCCESS; 3306 } 3307 3308 3309 /** 3301 3310 * Registers the saved state callbacks with SSM. 3302 3311 * … … 3310 3319 pgmR3LivePrep, pgmR3LiveExec, pgmR3LiveVote, 3311 3320 NULL, pgmR3SaveExec, pgmR3SaveDone, 3312 pgmR3LoadPrep, pgmR3Load, NULL);3313 } 3314 3321 pgmR3LoadPrep, pgmR3Load, pgmR3LoadDone); 3322 } 3323 -
trunk/src/VBox/VMM/include/PGMInternal.h
r58779 r58781 3245 3245 /** The number of MMIO2 regions (serves as the next MMIO2 ID). */ 3246 3246 uint8_t cMmio2Regions; 3247 /** Flag indicating that ROM pages should be restored to their original 3248 * during reset. Primary use is for getting firmware updates when the 3249 * VM is reset after a saved state was loaded. */ 3250 bool fRestoreVirginRomPagesDuringReset; 3247 /** Restore original ROM page content when resetting after loading state. 3248 * The flag is set by pgmR3LoadRomRanges and cleared at reset. This 3249 * enables the VM to start using an updated ROM without requiring powering 3250 * down the VM, just rebooting or resetting it. */ 3251 bool fRestoreRomPagesAtReset; 3251 3252 3252 3253 /** Indicates that PGMR3FinalizeMappings has been called and that further -
trunk/src/VBox/VMM/testcase/tstVMStruct.h
r58779 r58781 674 674 GEN_CHECK_OFF(PGM, paDynPageMapPaePTEsGC); 675 675 GEN_CHECK_OFF(PGM, enmHostMode); 676 GEN_CHECK_OFF(PGM, fRestore VirginRomPagesDuringReset);676 GEN_CHECK_OFF(PGM, fRestoreRomPagesAtReset); 677 677 GEN_CHECK_OFF(PGM, GCPhys4MBPSEMask); 678 678 GEN_CHECK_OFF(PGM, pRamRangesXR3);
Note:
See TracChangeset
for help on using the changeset viewer.