Changeset 13187 in vbox
- Timestamp:
- Oct 10, 2008 11:18:46 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/src/VBox/VMM/PGM.cpp (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/PGM.cpp
r13146 r13187 610 610 * Internal Functions * 611 611 *******************************************************************************/ 612 static int pgmR3InitPaging(PVM pVM);612 static int pgmR3InitPaging(PVM pVM); 613 613 static DECLCALLBACK(void) pgmR3PhysInfo(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs); 614 614 static DECLCALLBACK(void) pgmR3InfoMode(PVM pVM, PCDBGFINFOHLP pHlp, const char *pszArgs); 615 615 static 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);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); 619 619 #ifdef VBOX_STRICT 620 620 static DECLCALLBACK(void) pgmR3ResetNoMorePhysWritesFlag(PVM pVM, VMSTATE enmState, VMSTATE enmOldState, void *pvUser); 621 621 #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);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); 627 627 628 628 #ifdef VBOX_WITH_STATISTICS 629 static void pgmR3InitStats(PVM pVM);629 static void pgmR3InitStats(PVM pVM); 630 630 #endif 631 631 632 632 #ifdef VBOX_WITH_DEBUGGER 633 633 /** @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);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); 638 638 # ifdef VBOX_STRICT 639 static DECLCALLBACK(int) pgmR3CmdAssertCR3(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult);639 static DECLCALLBACK(int) pgmR3CmdAssertCR3(PCDBGCCMD pCmd, PDBGCCMDHLP pCmdHlp, PVM pVM, PCDBGCVAR paArgs, unsigned cArgs, PDBGCVAR pResult); 640 640 # endif 641 641 #endif … … 848 848 #ifdef VBOX_WITH_64_BITS_GUESTS 849 849 /* Guest - AMD64 mode */ 850 # define PGM_GST_TYPEPGM_TYPE_AMD64851 # 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_PTPGMPOOLKIND_PAE_PT_FOR_PAE_PT858 # define BTH_PGMPOOLKIND_PT_FOR_BIGPGMPOOLKIND_PAE_PT_FOR_PAE_2MB859 # include "PGMGst.h"860 # include "PGMBth.h"861 # undef BTH_PGMPOOLKIND_PT_FOR_BIG862 # undef BTH_PGMPOOLKIND_PT_FOR_PT863 # undef PGM_BTH_NAME864 # undef PGM_BTH_NAME_RC_STR865 # undef PGM_BTH_NAME_R0_STR866 # undef PGM_GST_TYPE867 # undef PGM_GST_NAME868 # undef PGM_GST_NAME_RC_STR869 # undef PGM_GST_NAME_R0_STR870 #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 */ 871 871 872 872 #undef PGM_SHW_TYPE … … 874 874 #undef PGM_SHW_NAME_RC_STR 875 875 #undef PGM_SHW_NAME_R0_STR 876 876 877 877 878 /* … … 966 967 #ifdef VBOX_WITH_64_BITS_GUESTS 967 968 /* Guest - AMD64 mode */ 968 # define PGM_GST_TYPEPGM_TYPE_AMD64969 # 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_PTPGMPOOLKIND_PAE_PT_FOR_PAE_PT976 # define BTH_PGMPOOLKIND_PT_FOR_BIGPGMPOOLKIND_PAE_PT_FOR_PAE_2MB977 # include "PGMBth.h"978 # undef BTH_PGMPOOLKIND_PT_FOR_BIG979 # undef BTH_PGMPOOLKIND_PT_FOR_PT980 # undef PGM_BTH_NAME981 # undef PGM_BTH_NAME_RC_STR982 # undef PGM_BTH_NAME_R0_STR983 # undef PGM_GST_TYPE984 # undef PGM_GST_NAME985 # undef PGM_GST_NAME_RC_STR986 # undef PGM_GST_NAME_R0_STR987 #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 */ 988 989 989 990 #undef PGM_SHW_TYPE … … 991 992 #undef PGM_SHW_NAME_RC_STR 992 993 #undef PGM_SHW_NAME_R0_STR 994 993 995 994 996 /* … … 1083 1085 #ifdef VBOX_WITH_64_BITS_GUESTS 1084 1086 /* Guest - AMD64 mode */ 1085 # define PGM_GST_TYPEPGM_TYPE_AMD641086 # 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_PTPGMPOOLKIND_PAE_PT_FOR_PAE_PT1093 # define BTH_PGMPOOLKIND_PT_FOR_BIGPGMPOOLKIND_PAE_PT_FOR_PAE_2MB1094 # include "PGMBth.h"1095 # undef BTH_PGMPOOLKIND_PT_FOR_BIG1096 # undef BTH_PGMPOOLKIND_PT_FOR_PT1097 # undef PGM_BTH_NAME1098 # undef PGM_BTH_NAME_RC_STR1099 # undef PGM_BTH_NAME_R0_STR1100 # undef PGM_GST_TYPE1101 # undef PGM_GST_NAME1102 # undef PGM_GST_NAME_RC_STR1103 # undef PGM_GST_NAME_R0_STR1104 #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 */ 1105 1107 1106 1108 #undef PGM_SHW_TYPE … … 1108 1110 #undef PGM_SHW_NAME_RC_STR 1109 1111 #undef PGM_SHW_NAME_R0_STR 1112 1113 1110 1114 1111 1115 /** … … 1381 1385 /* 1382 1386 * Allocate pages for the three possible guest contexts (AMD64, PAE and plain 32-Bit). 1383 * We allocate pages for all three posibilities toin order to simplify mappings and1387 * We allocate pages for all three posibilities in order to simplify mappings and 1384 1388 * avoid resource failure during mode switches. So, we need to cover all levels of the 1385 1389 * of the first 4GB down to PD level. … … 1473 1477 LogFlow(("pgmR3InitPaging: returns successfully\n")); 1474 1478 #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", 1479 1485 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]), 1482 1488 MMPage2Phys(pVM, pVM->pgm.s.apInterPaePTs[0]), MMPage2Phys(pVM, pVM->pgm.s.apInterPaePTs[1]), 1483 1489 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]), … … 1712 1718 #endif /* VBOX_WITH_STATISTICS */ 1713 1719 1720 1714 1721 /** 1715 1722 * Init the PGM bits that rely on VMMR0 and MM to be fully initialized. … … 1737 1744 * Reserve space for the dynamic mappings. 1738 1745 */ 1739 /** @todo r=bird: Need to verify that the checks for crossing PTs are correct here. They seems to be assuming 4MB PTs.. */1740 1746 rc = MMR3HyperReserve(pVM, MM_HYPER_DYNAMIC_SIZE, "Dynamic mapping", &GCPtr); 1741 1747 if (VBOX_SUCCESS(rc)) … … 1743 1749 1744 1750 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)) 1746 1752 { 1747 1753 rc = MMR3HyperReserve(pVM, MM_HYPER_DYNAMIC_SIZE, "Dynamic mapping not crossing", &GCPtr); … … 1751 1757 if (VBOX_SUCCESS(rc)) 1752 1758 { 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)); 1754 1760 MMR3HyperReserve(pVM, PAGE_SIZE, "fence", NULL); 1755 1761 }
Note:
See TracChangeset
for help on using the changeset viewer.

