VirtualBox

Changeset 13187 in vbox


Ignore:
Timestamp:
Oct 10, 2008 11:18:46 PM (16 years ago)
Author:
vboxsync
Message:

PGMR3InitDynMap: check that the dynamic mapping area doesn't cross a 2MB (PAE PT) boundrary instead of 4MB (legacy PT). (ancient todo)

File:
1 edited

Legend:

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

    r13146 r13187  
    610610*   Internal Functions                                                         *
    611611*******************************************************************************/
    612 static int pgmR3InitPaging(PVM pVM);
     612static int                pgmR3InitPaging(PVM pVM);
    613613static DECLCALLBACK(void) pgmR3PhysInfo(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
    614614static DECLCALLBACK(void) pgmR3InfoMode(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
    615615static DECLCALLBACK(void) pgmR3InfoCr3(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs);
    616 static DECLCALLBACK(int) pgmR3RelocatePhysHandler(PAVLROGCPHYSNODECORE pNode, void *pvUser);
    617 static DECLCALLBACK(int) pgmR3RelocateVirtHandler(PAVLROGCPTRNODECORE pNode, void *pvUser);
    618 static DECLCALLBACK(int) pgmR3RelocateHyperVirtHandler(PAVLROGCPTRNODECORE pNode, void *pvUser);
     616static DECLCALLBACK(int)  pgmR3RelocatePhysHandler(PAVLROGCPHYSNODECORE pNode, void *pvUser);
     617static DECLCALLBACK(int)  pgmR3RelocateVirtHandler(PAVLROGCPTRNODECORE pNode, void *pvUser);
     618static DECLCALLBACK(int)  pgmR3RelocateHyperVirtHandler(PAVLROGCPTRNODECORE pNode, void *pvUser);
    619619#ifdef VBOX_STRICT
    620620static DECLCALLBACK(void) pgmR3ResetNoMorePhysWritesFlag(PVM pVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser);
    621621#endif
    622 static DECLCALLBACK(int) pgmR3Save(PVM pVM, PSSMHANDLE pSSM);
    623 static DECLCALLBACK(int) pgmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version);
    624 static int               pgmR3ModeDataInit(PVM pVM, bool fResolveGCAndR0);
    625 static void              pgmR3ModeDataSwitch(PVM pVM, PGMMODE enmShw, PGMMODE enmGst);
    626 static PGMMODE           pgmR3CalcShadowMode(PVM pVM, PGMMODE enmGuestMode, SUPPAGINGMODE enmHostMode, PGMMODE enmShadowMode, VMMSWITCHER *penmSwitcher);
     622static DECLCALLBACK(int)  pgmR3Save(PVM pVM, PSSMHANDLE pSSM);
     623static DECLCALLBACK(int)  pgmR3Load(PVM pVM, PSSMHANDLE pSSM, uint32_t u32Version);
     624static int                pgmR3ModeDataInit(PVM pVM, bool fResolveGCAndR0);
     625static void               pgmR3ModeDataSwitch(PVM pVM, PGMMODE enmShw, PGMMODE enmGst);
     626static PGMMODE            pgmR3CalcShadowMode(PVM pVM, PGMMODE enmGuestMode, SUPPAGINGMODE enmHostMode, PGMMODE enmShadowMode, VMMSWITCHER *penmSwitcher);
    627627
    628628#ifdef VBOX_WITH_STATISTICS
    629 static void pgmR3InitStats(PVM pVM);
     629static void               pgmR3InitStats(PVM pVM);
    630630#endif
    631631
    632632#ifdef VBOX_WITH_DEBUGGER
    633633/** @todo all but the two last commands must be converted to 'info'. */
    634 static DECLCALLBACK(int) pgmR3CmdRam(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
    635 static DECLCALLBACK(int) pgmR3CmdMap(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
    636 static DECLCALLBACK(int) pgmR3CmdSync(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
    637 static DECLCALLBACK(int) pgmR3CmdSyncAlways(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
     634static DECLCALLBACK(int)  pgmR3CmdRam(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
     635static DECLCALLBACK(int)  pgmR3CmdMap(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
     636static DECLCALLBACK(int)  pgmR3CmdSync(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
     637static DECLCALLBACK(int)  pgmR3CmdSyncAlways(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
    638638# ifdef VBOX_STRICT
    639 static DECLCALLBACK(int) pgmR3CmdAssertCR3(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
     639static DECLCALLBACK(int)  pgmR3CmdAssertCR3(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);
    640640# endif
    641641#endif
     
    848848#ifdef VBOX_WITH_64_BITS_GUESTS
    849849/* Guest - AMD64 mode */
    850 #define PGM_GST_TYPE                PGM_TYPE_AMD64
    851 #define PGM_GST_NAME(name)          PGM_GST_NAME_AMD64(name)
    852 #define PGM_GST_NAME_RC_STR(name)   PGM_GST_NAME_RC_AMD64_STR(name)
    853 #define PGM_GST_NAME_R0_STR(name)   PGM_GST_NAME_R0_AMD64_STR(name)
    854 #define PGM_BTH_NAME(name)          PGM_BTH_NAME_AMD64_AMD64(name)
    855 #define PGM_BTH_NAME_RC_STR(name)   PGM_BTH_NAME_RC_AMD64_AMD64_STR(name)
    856 #define PGM_BTH_NAME_R0_STR(name)   PGM_BTH_NAME_R0_AMD64_AMD64_STR(name)
    857 #define BTH_PGMPOOLKIND_PT_FOR_PT   PGMPOOLKIND_PAE_PT_FOR_PAE_PT
    858 #define BTH_PGMPOOLKIND_PT_FOR_BIG PGMPOOLKIND_PAE_PT_FOR_PAE_2MB
    859 #include "PGMGst.h"
    860 #include "PGMBth.h"
    861 #undef BTH_PGMPOOLKIND_PT_FOR_BIG
    862 #undef BTH_PGMPOOLKIND_PT_FOR_PT
    863 #undef PGM_BTH_NAME
    864 #undef PGM_BTH_NAME_RC_STR
    865 #undef PGM_BTH_NAME_R0_STR
    866 #undef PGM_GST_TYPE
    867 #undef PGM_GST_NAME
    868 #undef PGM_GST_NAME_RC_STR
    869 #undef PGM_GST_NAME_R0_STR
    870 #endif
     850# define PGM_GST_TYPE               PGM_TYPE_AMD64
     851# define PGM_GST_NAME(name)         PGM_GST_NAME_AMD64(name)
     852# define PGM_GST_NAME_RC_STR(name)  PGM_GST_NAME_RC_AMD64_STR(name)
     853# define PGM_GST_NAME_R0_STR(name)  PGM_GST_NAME_R0_AMD64_STR(name)
     854# define PGM_BTH_NAME(name)         PGM_BTH_NAME_AMD64_AMD64(name)
     855# define PGM_BTH_NAME_RC_STR(name)  PGM_BTH_NAME_RC_AMD64_AMD64_STR(name)
     856# define PGM_BTH_NAME_R0_STR(name)  PGM_BTH_NAME_R0_AMD64_AMD64_STR(name)
     857# define BTH_PGMPOOLKIND_PT_FOR_PT  PGMPOOLKIND_PAE_PT_FOR_PAE_PT
     858# define BTH_PGMPOOLKIND_PT_FOR_BIG PGMPOOLKIND_PAE_PT_FOR_PAE_2MB
     859# include "PGMGst.h"
     860# include "PGMBth.h"
     861# undef BTH_PGMPOOLKIND_PT_FOR_BIG
     862# undef BTH_PGMPOOLKIND_PT_FOR_PT
     863# undef PGM_BTH_NAME
     864# undef PGM_BTH_NAME_RC_STR
     865# undef PGM_BTH_NAME_R0_STR
     866# undef PGM_GST_TYPE
     867# undef PGM_GST_NAME
     868# undef PGM_GST_NAME_RC_STR
     869# undef PGM_GST_NAME_R0_STR
     870#endif /* VBOX_WITH_64_BITS_GUESTS */
    871871
    872872#undef PGM_SHW_TYPE
     
    874874#undef PGM_SHW_NAME_RC_STR
    875875#undef PGM_SHW_NAME_R0_STR
     876
    876877
    877878/*
     
    966967#ifdef VBOX_WITH_64_BITS_GUESTS
    967968/* Guest - AMD64 mode */
    968 #define PGM_GST_TYPE                PGM_TYPE_AMD64
    969 #define PGM_GST_NAME(name)          PGM_GST_NAME_AMD64(name)
    970 #define PGM_GST_NAME_RC_STR(name)   PGM_GST_NAME_RC_AMD64_STR(name)
    971 #define PGM_GST_NAME_R0_STR(name)   PGM_GST_NAME_R0_AMD64_STR(name)
    972 #define PGM_BTH_NAME(name)          PGM_BTH_NAME_NESTED_AMD64(name)
    973 #define PGM_BTH_NAME_RC_STR(name)   PGM_BTH_NAME_RC_NESTED_AMD64_STR(name)
    974 #define PGM_BTH_NAME_R0_STR(name)   PGM_BTH_NAME_R0_NESTED_AMD64_STR(name)
    975 #define BTH_PGMPOOLKIND_PT_FOR_PT   PGMPOOLKIND_PAE_PT_FOR_PAE_PT
    976 #define BTH_PGMPOOLKIND_PT_FOR_BIG PGMPOOLKIND_PAE_PT_FOR_PAE_2MB
    977 #include "PGMBth.h"
    978 #undef BTH_PGMPOOLKIND_PT_FOR_BIG
    979 #undef BTH_PGMPOOLKIND_PT_FOR_PT
    980 #undef PGM_BTH_NAME
    981 #undef PGM_BTH_NAME_RC_STR
    982 #undef PGM_BTH_NAME_R0_STR
    983 #undef PGM_GST_TYPE
    984 #undef PGM_GST_NAME
    985 #undef PGM_GST_NAME_RC_STR
    986 #undef PGM_GST_NAME_R0_STR
    987 #endif
     969# define PGM_GST_TYPE               PGM_TYPE_AMD64
     970# define PGM_GST_NAME(name)         PGM_GST_NAME_AMD64(name)
     971# define PGM_GST_NAME_RC_STR(name)  PGM_GST_NAME_RC_AMD64_STR(name)
     972# define PGM_GST_NAME_R0_STR(name)  PGM_GST_NAME_R0_AMD64_STR(name)
     973# define PGM_BTH_NAME(name)         PGM_BTH_NAME_NESTED_AMD64(name)
     974# define PGM_BTH_NAME_RC_STR(name)  PGM_BTH_NAME_RC_NESTED_AMD64_STR(name)
     975# define PGM_BTH_NAME_R0_STR(name)  PGM_BTH_NAME_R0_NESTED_AMD64_STR(name)
     976# define BTH_PGMPOOLKIND_PT_FOR_PT  PGMPOOLKIND_PAE_PT_FOR_PAE_PT
     977# define BTH_PGMPOOLKIND_PT_FOR_BIG PGMPOOLKIND_PAE_PT_FOR_PAE_2MB
     978# include "PGMBth.h"
     979# undef BTH_PGMPOOLKIND_PT_FOR_BIG
     980# undef BTH_PGMPOOLKIND_PT_FOR_PT
     981# undef PGM_BTH_NAME
     982# undef PGM_BTH_NAME_RC_STR
     983# undef PGM_BTH_NAME_R0_STR
     984# undef PGM_GST_TYPE
     985# undef PGM_GST_NAME
     986# undef PGM_GST_NAME_RC_STR
     987# undef PGM_GST_NAME_R0_STR
     988#endif /* VBOX_WITH_64_BITS_GUESTS */
    988989
    989990#undef PGM_SHW_TYPE
     
    991992#undef PGM_SHW_NAME_RC_STR
    992993#undef PGM_SHW_NAME_R0_STR
     994
    993995
    994996/*
     
    10831085#ifdef VBOX_WITH_64_BITS_GUESTS
    10841086/* Guest - AMD64 mode */
    1085 #define PGM_GST_TYPE                PGM_TYPE_AMD64
    1086 #define PGM_GST_NAME(name)          PGM_GST_NAME_AMD64(name)
    1087 #define PGM_GST_NAME_RC_STR(name)   PGM_GST_NAME_RC_AMD64_STR(name)
    1088 #define PGM_GST_NAME_R0_STR(name)   PGM_GST_NAME_R0_AMD64_STR(name)
    1089 #define PGM_BTH_NAME(name)          PGM_BTH_NAME_EPT_AMD64(name)
    1090 #define PGM_BTH_NAME_RC_STR(name)   PGM_BTH_NAME_RC_EPT_AMD64_STR(name)
    1091 #define PGM_BTH_NAME_R0_STR(name)   PGM_BTH_NAME_R0_EPT_AMD64_STR(name)
    1092 #define BTH_PGMPOOLKIND_PT_FOR_PT   PGMPOOLKIND_PAE_PT_FOR_PAE_PT
    1093 #define BTH_PGMPOOLKIND_PT_FOR_BIG PGMPOOLKIND_PAE_PT_FOR_PAE_2MB
    1094 #include "PGMBth.h"
    1095 #undef BTH_PGMPOOLKIND_PT_FOR_BIG
    1096 #undef BTH_PGMPOOLKIND_PT_FOR_PT
    1097 #undef PGM_BTH_NAME
    1098 #undef PGM_BTH_NAME_RC_STR
    1099 #undef PGM_BTH_NAME_R0_STR
    1100 #undef PGM_GST_TYPE
    1101 #undef PGM_GST_NAME
    1102 #undef PGM_GST_NAME_RC_STR
    1103 #undef PGM_GST_NAME_R0_STR
    1104 #endif
     1087# define PGM_GST_TYPE               PGM_TYPE_AMD64
     1088# define PGM_GST_NAME(name)         PGM_GST_NAME_AMD64(name)
     1089# define PGM_GST_NAME_RC_STR(name)  PGM_GST_NAME_RC_AMD64_STR(name)
     1090# define PGM_GST_NAME_R0_STR(name)  PGM_GST_NAME_R0_AMD64_STR(name)
     1091# define PGM_BTH_NAME(name)         PGM_BTH_NAME_EPT_AMD64(name)
     1092# define PGM_BTH_NAME_RC_STR(name)  PGM_BTH_NAME_RC_EPT_AMD64_STR(name)
     1093# define PGM_BTH_NAME_R0_STR(name)  PGM_BTH_NAME_R0_EPT_AMD64_STR(name)
     1094# define BTH_PGMPOOLKIND_PT_FOR_PT  PGMPOOLKIND_PAE_PT_FOR_PAE_PT
     1095# define BTH_PGMPOOLKIND_PT_FOR_BIG PGMPOOLKIND_PAE_PT_FOR_PAE_2MB
     1096# include "PGMBth.h"
     1097# undef BTH_PGMPOOLKIND_PT_FOR_BIG
     1098# undef BTH_PGMPOOLKIND_PT_FOR_PT
     1099# undef PGM_BTH_NAME
     1100# undef PGM_BTH_NAME_RC_STR
     1101# undef PGM_BTH_NAME_R0_STR
     1102# undef PGM_GST_TYPE
     1103# undef PGM_GST_NAME
     1104# undef PGM_GST_NAME_RC_STR
     1105# undef PGM_GST_NAME_R0_STR
     1106#endif /* VBOX_WITH_64_BITS_GUESTS */
    11051107
    11061108#undef PGM_SHW_TYPE
     
    11081110#undef PGM_SHW_NAME_RC_STR
    11091111#undef PGM_SHW_NAME_R0_STR
     1112
     1113
    11101114
    11111115/**
     
    13811385    /*
    13821386     * Allocate pages for the three possible guest contexts (AMD64, PAE and plain 32-Bit).
    1383      * We allocate pages for all three posibilities to in order to simplify mappings and
     1387     * We allocate pages for all three posibilities in order to simplify mappings and
    13841388     * avoid resource failure during mode switches. So, we need to cover all levels of the
    13851389     * of the first 4GB down to PD level.
     
    14731477        LogFlow(("pgmR3InitPaging: returns successfully\n"));
    14741478#if HC_ARCH_BITS == 64
    1475         LogRel(("Debug: HCPhys32BitPD=%VHp aHCPhysPaePDs={%VHp,%VHp,%VHp,%VHp} HCPhysPaePDPT=%VHp HCPhysPaePML4=%VHp\n",
    1476                 pVM->pgm.s.HCPhys32BitPD, pVM->pgm.s.aHCPhysPaePDs[0], pVM->pgm.s.aHCPhysPaePDs[1], pVM->pgm.s.aHCPhysPaePDs[2], pVM->pgm.s.aHCPhysPaePDs[3],
    1477                 pVM->pgm.s.HCPhysPaePDPT, pVM->pgm.s.HCPhysPaePML4));
    1478         LogRel(("Debug: HCPhysInterPD=%VHp HCPhysInterPaePDPT=%VHp HCPhysInterPaePML4=%VHp\n",
     1479        LogRel(("Debug: HCPhys32BitPD=%VHp aHCPhysPaePDs={%RHp,%RHp,%RHp,%RHp} HCPhysPaePDPT=%RHp HCPhysPaePML4=%RHp\n",
     1480                pVM->pgm.s.HCPhys32BitPD,
     1481                pVM->pgm.s.aHCPhysPaePDs[0], pVM->pgm.s.aHCPhysPaePDs[1], pVM->pgm.s.aHCPhysPaePDs[2], pVM->pgm.s.aHCPhysPaePDs[3],
     1482                pVM->pgm.s.HCPhysPaePDPT,
     1483                pVM->pgm.s.HCPhysPaePML4));
     1484        LogRel(("Debug: HCPhysInterPD=%RHp HCPhysInterPaePDPT=%RHp HCPhysInterPaePML4=%RHp\n",
    14791485                pVM->pgm.s.HCPhysInterPD, pVM->pgm.s.HCPhysInterPaePDPT, pVM->pgm.s.HCPhysInterPaePML4));
    1480         LogRel(("Debug: apInterPTs={%VHp,%VHp} apInterPaePTs={%VHp,%VHp} apInterPaePDs={%VHp,%VHp,%VHp,%VHp} pInterPaePDPT64=%VHp\n",
    1481                 MMPage2Phys(pVM, pVM->pgm.s.apInterPTs[0]), MMPage2Phys(pVM, pVM->pgm.s.apInterPTs[1]),
     1486        LogRel(("Debug: apInterPTs={%RHp,%RHp} apInterPaePTs={%RHp,%RHp} apInterPaePDs={%RHp,%RHp,%RHp,%RHp} pInterPaePDPT64=%RHp\n",
     1487                MMPage2Phys(pVM, pVM->pgm.s.apInterPTs[0]),    MMPage2Phys(pVM, pVM->pgm.s.apInterPTs[1]),
    14821488                MMPage2Phys(pVM, pVM->pgm.s.apInterPaePTs[0]), MMPage2Phys(pVM, pVM->pgm.s.apInterPaePTs[1]),
    14831489                MMPage2Phys(pVM, pVM->pgm.s.apInterPaePDs[0]), MMPage2Phys(pVM, pVM->pgm.s.apInterPaePDs[1]), MMPage2Phys(pVM, pVM->pgm.s.apInterPaePDs[2]), MMPage2Phys(pVM, pVM->pgm.s.apInterPaePDs[3]),
     
    17121718#endif /* VBOX_WITH_STATISTICS */
    17131719
     1720
    17141721/**
    17151722 * Init the PGM bits that rely on VMMR0 and MM to be fully initialized.
     
    17371744     * Reserve space for the dynamic mappings.
    17381745     */
    1739     /** @todo r=bird: Need to verify that the checks for crossing PTs are correct here. They seems to be assuming 4MB PTs.. */
    17401746    rc = MMR3HyperReserve(pVM, MM_HYPER_DYNAMIC_SIZE, "Dynamic mapping", &GCPtr);
    17411747    if (VBOX_SUCCESS(rc))
     
    17431749
    17441750    if (    VBOX_SUCCESS(rc)
    1745         &&  (pVM->pgm.s.pbDynPageMapBaseGC >> X86_PD_SHIFT) != ((pVM->pgm.s.pbDynPageMapBaseGC + MM_HYPER_DYNAMIC_SIZE - 1) >> X86_PD_SHIFT))
     1751        &&  (pVM->pgm.s.pbDynPageMapBaseGC >> X86_PD_PAE_SHIFT) != ((pVM->pgm.s.pbDynPageMapBaseGC + MM_HYPER_DYNAMIC_SIZE - 1) >> X86_PD_PAE_SHIFT))
    17461752    {
    17471753        rc = MMR3HyperReserve(pVM, MM_HYPER_DYNAMIC_SIZE, "Dynamic mapping not crossing", &GCPtr);
     
    17511757    if (VBOX_SUCCESS(rc))
    17521758    {
    1753         AssertRelease((pVM->pgm.s.pbDynPageMapBaseGC >> X86_PD_SHIFT) == ((pVM->pgm.s.pbDynPageMapBaseGC + MM_HYPER_DYNAMIC_SIZE - 1) >> X86_PD_SHIFT));
     1759        AssertRelease((pVM->pgm.s.pbDynPageMapBaseGC >> X86_PD_PAE_SHIFT) == ((pVM->pgm.s.pbDynPageMapBaseGC + MM_HYPER_DYNAMIC_SIZE - 1) >> X86_PD_PAE_SHIFT));
    17541760        MMR3HyperReserve(pVM, PAGE_SIZE, "fence", NULL);
    17551761    }
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