VirtualBox

Changeset 58779 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Nov 19, 2015 10:01:22 PM (9 years ago)
Author:
vboxsync
Message:

VMM: Restore virgin ROM pages during a reset after a saved state was loaded if they differ. Makes it possible to upgrade our firmware without risking inconsistencies causing guest crashes after a reset (one example is increasing the EFI firmware size from 1MB to 2MB which triggers a Guru Meditation otherwise).

Location:
trunk/src/VBox/VMM
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/PGM.cpp

    r58397 r58779  
    13121312    pVM->pgm.s.GCPhys4MBPSEMask = RT_BIT_64(32) - 1; /* default; checked later */
    13131313    pVM->pgm.s.GCPtrPrevRamRangeMapping = MM_HYPER_AREA_ADDRESS;
     1314    pVM->pgm.s.fRestoreVirginRomPagesDuringReset = false;
    13141315
    13151316    rc = CFGMR3QueryBoolDef(CFGMR3GetRoot(pVM), "RamPreAlloc", &pVM->pgm.s.fRamPreAlloc,
  • trunk/src/VBox/VMM/VMMR3/PGMPhys.cpp

    r58170 r58779  
    35733573        }
    35743574
    3575 #ifdef VBOX_STRICT
    35763575        /*
    3577          * Verify that the virgin page is unchanged if possible.
     3576         * Restore virgin ROM pages after a saved state load or check that the
     3577         * virgin pages are unchanged if possible.
    35783578         */
    35793579        if (pRom->pvOriginal)
     
    35813581            size_t         cbSrcLeft = pRom->cbOriginal;
    35823582            uint8_t const *pbSrcPage = (uint8_t const *)pRom->pvOriginal;
     3583            bool           fChanged = false;
    35833584            for (uint32_t iPage = 0; iPage < cPages && cbSrcLeft > 0; iPage++, pbSrcPage += PAGE_SIZE)
    35843585            {
     
    35913592                if (memcmp(pvDstPage, pbSrcPage, RT_MIN(cbSrcLeft, PAGE_SIZE)))
    35923593                {
    3593 # ifdef DEBUG_bird /* This is darn handy for EFI debugging w/ snapshots, should be made default later. */
    3594                     void *pvDstPageW;
    3595                     rc = pgmPhysPageMap(pVM, &pRom->aPages[iPage].Virgin, GCPhys, &pvDstPageW);
    3596                     AssertRCReturn(rc, rc);
    3597                     memcpy(pvDstPageW, pbSrcPage, RT_MIN(cbSrcLeft, PAGE_SIZE));
    3598 # else
    3599                     LogRel(("pgmR3PhysRomReset: %RGp rom page changed (%s) - loaded saved state?\n",
    3600                             GCPhys, pRom->pszDesc));
    3601 # endif
     3594                    if (pVM->pgm.s.fRestoreVirginRomPagesDuringReset)
     3595                    {
     3596                        void *pvDstPageW;
     3597                        rc = pgmPhysPageMap(pVM, &pRom->aPages[iPage].Virgin, GCPhys, &pvDstPageW);
     3598                        AssertLogRelRCReturn(rc, rc);
     3599                        memcpy(pvDstPageW, pbSrcPage, RT_MIN(cbSrcLeft, PAGE_SIZE));
     3600                        fChanged = true;
     3601                    }
     3602                    else
     3603                    {
     3604#ifdef VBOX_STRICT
     3605                        LogRel(("pgmR3PhysRomReset: %RGp rom page changed (%s)?\n", GCPhys, pRom->pszDesc));
     3606#endif
     3607                    }
    36023608                }
    36033609                cbSrcLeft -= RT_MIN(cbSrcLeft, PAGE_SIZE);
    36043610            }
    3605         }
    3606 #endif
    3607     }
    3608 
     3611            if (fChanged)
     3612                LogRel(("PGM: ROM \"%s\" changed - restored original\n", pRom->pszDesc));
     3613        }
     3614    }
     3615
     3616    pVM->pgm.s.fRestoreVirginRomPagesDuringReset = false;
    36093617    return VINF_SUCCESS;
    36103618}
  • trunk/src/VBox/VMM/VMMR3/PGMSavedState.cpp

    r58126 r58779  
    336336                                ("The \"%s\" ROM was not found in the saved state. Probably due to some misconfiguration\n",
    337337                                 pRom->pszDesc));
     338
     339            pVM->pgm.s.fRestoreVirginRomPagesDuringReset = true;
    338340            return VINF_SUCCESS;        /* the end */
    339341        }
  • trunk/src/VBox/VMM/include/PGMInternal.h

    r58123 r58779  
    32453245    /** The number of MMIO2 regions (serves as the next MMIO2 ID). */
    32463246    uint8_t                         cMmio2Regions;
    3247     /** Alignment padding that makes the next member start on a 8 byte boundary. */
    3248     bool                            afAlignment1[1];
     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;
    32493251
    32503252    /** Indicates that PGMR3FinalizeMappings has been called and that further
  • trunk/src/VBox/VMM/testcase/tstVMStruct.h

    r57429 r58779  
    674674    GEN_CHECK_OFF(PGM, paDynPageMapPaePTEsGC);
    675675    GEN_CHECK_OFF(PGM, enmHostMode);
     676    GEN_CHECK_OFF(PGM, fRestoreVirginRomPagesDuringReset);
    676677    GEN_CHECK_OFF(PGM, GCPhys4MBPSEMask);
    677678    GEN_CHECK_OFF(PGM, pRamRangesXR3);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette