summaryrefslogtreecommitdiff
path: root/src/VBox/VMM/VMMAll/PGMAllMap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/VBox/VMM/VMMAll/PGMAllMap.cpp')
-rw-r--r--src/VBox/VMM/VMMAll/PGMAllMap.cpp66
1 files changed, 36 insertions, 30 deletions
diff --git a/src/VBox/VMM/VMMAll/PGMAllMap.cpp b/src/VBox/VMM/VMMAll/PGMAllMap.cpp
index 188e7ac3..8edb607c 100644
--- a/src/VBox/VMM/VMMAll/PGMAllMap.cpp
+++ b/src/VBox/VMM/VMMAll/PGMAllMap.cpp
@@ -258,11 +258,13 @@ VMMDECL(int) PGMMapGetPage(PVM pVM, RTGCPTR GCPtr, uint64_t *pfFlags, PRTHCPHYS
return VERR_NOT_FOUND;
}
+#ifndef PGM_WITHOUT_MAPPINGS
-#ifdef VBOX_WITH_RAW_MODE_NOT_R0
/**
* Sets all PDEs involved with the mapping in the shadow page table.
*
+ * Ignored if mappings are disabled (i.e. if HM is enabled).
+ *
* @param pVM Pointer to the VM.
* @param pMap Pointer to the mapping in question.
* @param iNewPDE The index of the 32-bit PDE corresponding to the base of the mapping.
@@ -271,8 +273,7 @@ void pgmMapSetShadowPDEs(PVM pVM, PPGMMAPPING pMap, unsigned iNewPDE)
{
Log4(("pgmMapSetShadowPDEs new pde %x (mappings enabled %d)\n", iNewPDE, pgmMapAreMappingsEnabled(pVM)));
- if ( !pgmMapAreMappingsEnabled(pVM)
- || pVM->cCpus > 1)
+ if (!pgmMapAreMappingsEnabled(pVM))
return;
/* This only applies to raw mode where we only support 1 VCPU. */
@@ -355,7 +356,7 @@ void pgmMapSetShadowPDEs(PVM pVM, PPGMMAPPING pMap, unsigned iNewPDE)
AssertFatal(pPoolPagePd);
if (!pgmPoolIsPageLocked(pPoolPagePd))
pgmPoolLockPage(pPool, pPoolPagePd);
-#ifdef VBOX_STRICT
+# ifdef VBOX_STRICT
else if (pShwPaePd->a[iPaePde].u & PGM_PDFLAGS_MAPPING)
{
Assert(PGMGetGuestMode(pVCpu) >= PGMMODE_PAE); /** @todo We may hit this during reset, will fix later. */
@@ -367,7 +368,7 @@ void pgmMapSetShadowPDEs(PVM pVM, PPGMMAPPING pMap, unsigned iNewPDE)
|| !PGMMODE_WITH_PAGING(PGMGetGuestMode(pVCpu)),
("%RX64 vs %RX64\n", pShwPaePd->a[iPaePde+1].u & X86_PDE_PAE_PG_MASK, pMap->aPTs[i].HCPhysPaePT1));
}
-#endif
+# endif
/*
* Insert our first PT, freeing anything we might be replacing unless it's a mapping (i.e. us).
@@ -415,6 +416,8 @@ void pgmMapSetShadowPDEs(PVM pVM, PPGMMAPPING pMap, unsigned iNewPDE)
/**
* Clears all PDEs involved with the mapping in the shadow page table.
*
+ * Ignored if mappings are disabled (i.e. if HM is enabled).
+ *
* @param pVM Pointer to the VM.
* @param pShwPageCR3 CR3 root page
* @param pMap Pointer to the mapping in question.
@@ -426,10 +429,9 @@ void pgmMapClearShadowPDEs(PVM pVM, PPGMPOOLPAGE pShwPageCR3, PPGMMAPPING pMap,
Log(("pgmMapClearShadowPDEs: old pde %x (cPTs=%x) (mappings enabled %d) fDeactivateCR3=%RTbool\n", iOldPDE, pMap->cPTs, pgmMapAreMappingsEnabled(pVM), fDeactivateCR3));
/*
- * Skip this if disabled or if it doesn't apply.
+ * Skip this if it doesn't apply.
*/
- if ( !pgmMapAreMappingsEnabled(pVM)
- || pVM->cCpus > 1)
+ if (!pgmMapAreMappingsEnabled(pVM))
return;
Assert(pShwPageCR3);
@@ -539,9 +541,10 @@ void pgmMapClearShadowPDEs(PVM pVM, PPGMPOOLPAGE pShwPageCR3, PPGMMAPPING pMap,
PGM_DYNMAP_UNUSED_HINT_VM(pVM, pCurrentShwPdpt);
}
-#endif /* VBOX_WITH_RAW_MODE_NOT_R0 */
+#endif /* PGM_WITHOUT_MAPPINGS */
#if defined(VBOX_STRICT) && !defined(IN_RING0)
+
/**
* Clears all PDEs involved with the mapping in the shadow page table.
*
@@ -622,6 +625,8 @@ static void pgmMapCheckShadowPDEs(PVM pVM, PVMCPU pVCpu, PPGMPOOLPAGE pShwPageCR
/**
* Check the hypervisor mappings in the active CR3.
*
+ * Ignored if mappings are disabled (i.e. if HM is enabled).
+ *
* @param pVM The virtual machine.
*/
VMMDECL(void) PGMMapCheck(PVM pVM)
@@ -648,13 +653,15 @@ VMMDECL(void) PGMMapCheck(PVM pVM)
}
pgmUnlock(pVM);
}
-#endif /* defined(VBOX_STRICT) && !defined(IN_RING0) */
-#ifdef VBOX_WITH_RAW_MODE_NOT_R0
+#endif /* defined(VBOX_STRICT) && !defined(IN_RING0) */
+#ifndef PGM_WITHOUT_MAPPINGS
/**
* Apply the hypervisor mappings to the active CR3.
*
+ * Ignored if mappings are disabled (i.e. if HM is enabled).
+ *
* @returns VBox status.
* @param pVM The virtual machine.
* @param pShwPageCR3 CR3 root page
@@ -662,10 +669,9 @@ VMMDECL(void) PGMMapCheck(PVM pVM)
int pgmMapActivateCR3(PVM pVM, PPGMPOOLPAGE pShwPageCR3)
{
/*
- * Skip this if disabled or if it doesn't apply.
+ * Skip this if it doesn't apply.
*/
- if ( !pgmMapAreMappingsEnabled(pVM)
- || pVM->cCpus > 1)
+ if (!pgmMapAreMappingsEnabled(pVM))
return VINF_SUCCESS;
/* Note! This might not be logged successfully in RC because we usually
@@ -692,6 +698,8 @@ int pgmMapActivateCR3(PVM pVM, PPGMPOOLPAGE pShwPageCR3)
/**
* Remove the hypervisor mappings from the specified CR3
*
+ * Ignored if mappings are disabled (i.e. if HM is enabled).
+ *
* @returns VBox status.
* @param pVM The virtual machine.
* @param pShwPageCR3 CR3 root page
@@ -699,10 +707,9 @@ int pgmMapActivateCR3(PVM pVM, PPGMPOOLPAGE pShwPageCR3)
int pgmMapDeactivateCR3(PVM pVM, PPGMPOOLPAGE pShwPageCR3)
{
/*
- * Skip this if disabled or if it doesn't apply.
+ * Skip this if it doesn't apply.
*/
- if ( !pgmMapAreMappingsEnabled(pVM)
- || pVM->cCpus > 1)
+ if (!pgmMapAreMappingsEnabled(pVM))
return VINF_SUCCESS;
Assert(pShwPageCR3);
@@ -734,8 +741,7 @@ VMMDECL(bool) PGMMapHasConflicts(PVM pVM)
*/
if (!pgmMapAreMappingsFloating(pVM))
return false;
-
- Assert(pVM->cCpus == 1);
+ AssertReturn(pgmMapAreMappingsEnabled(pVM), false);
/* This only applies to raw mode where we only support 1 VCPU. */
PVMCPU pVCpu = &pVM->aCpus[0];
@@ -764,17 +770,17 @@ VMMDECL(bool) PGMMapHasConflicts(PVM pVM)
{
STAM_COUNTER_INC(&pVM->pgm.s.CTX_SUFF(pStats)->StatR3DetectedConflicts);
-#ifdef IN_RING3
+# ifdef IN_RING3
Log(("PGMHasMappingConflicts: Conflict was detected at %08RX32 for mapping %s (32 bits)\n"
" iPDE=%#x iPT=%#x PDE=%RGp.\n",
(iPT + iPDE) << X86_PD_SHIFT, pCur->pszDesc,
iPDE, iPT, pPD->a[iPDE + iPT].au32[0]));
-#else
+# else
Log(("PGMHasMappingConflicts: Conflict was detected at %08RX32 for mapping (32 bits)\n"
" iPDE=%#x iPT=%#x PDE=%RGp.\n",
(iPT + iPDE) << X86_PD_SHIFT,
iPDE, iPT, pPD->a[iPDE + iPT].au32[0]));
-#endif
+# endif
return true;
}
}
@@ -795,15 +801,15 @@ VMMDECL(bool) PGMMapHasConflicts(PVM pVM)
&& (EMIsRawRing0Enabled(pVM) || Pde.n.u1User))
{
STAM_COUNTER_INC(&pVM->pgm.s.CTX_SUFF(pStats)->StatR3DetectedConflicts);
-#ifdef IN_RING3
+# ifdef IN_RING3
Log(("PGMHasMappingConflicts: Conflict was detected at %RGv for mapping %s (PAE)\n"
" PDE=%016RX64.\n",
GCPtr, pCur->pszDesc, Pde.u));
-#else
+# else
Log(("PGMHasMappingConflicts: Conflict was detected at %RGv for mapping (PAE)\n"
" PDE=%016RX64.\n",
GCPtr, Pde.u));
-#endif
+# endif
return true;
}
GCPtr += (1 << X86_PD_PAE_SHIFT);
@@ -827,7 +833,7 @@ int pgmMapResolveConflicts(PVM pVM)
{
/* The caller is expected to check these two conditions. */
Assert(!pVM->pgm.s.fMappingsFixed);
- Assert(!pVM->pgm.s.fMappingsDisabled);
+ Assert(pgmMapAreMappingsEnabled(pVM));
/* This only applies to raw mode where we only support 1 VCPU. */
Assert(pVM->cCpus == 1);
@@ -859,7 +865,7 @@ int pgmMapResolveConflicts(PVM pVM)
{
STAM_COUNTER_INC(&pVM->pgm.s.CTX_SUFF(pStats)->StatR3DetectedConflicts);
-#ifdef IN_RING3
+# ifdef IN_RING3
Log(("PGMHasMappingConflicts: Conflict was detected at %08RX32 for mapping %s (32 bits)\n"
" iPDE=%#x iPT=%#x PDE=%RGp.\n",
(iPT + iPDE) << X86_PD_SHIFT, pCur->pszDesc,
@@ -867,13 +873,13 @@ int pgmMapResolveConflicts(PVM pVM)
int rc = pgmR3SyncPTResolveConflict(pVM, pCur, pPD, iPDE << X86_PD_SHIFT);
AssertRCReturn(rc, rc);
break;
-#else
+# else
Log(("PGMHasMappingConflicts: Conflict was detected at %08RX32 for mapping (32 bits)\n"
" iPDE=%#x iPT=%#x PDE=%RGp.\n",
(iPT + iPDE) << X86_PD_SHIFT,
iPDE, iPT, pPD->a[iPDE + iPT].au32[0]));
return VINF_PGM_SYNC_CR3;
-#endif
+# endif
}
}
pCur = pNext;
@@ -924,5 +930,5 @@ int pgmMapResolveConflicts(PVM pVM)
return VINF_SUCCESS;
}
-#endif /* VBOX_WITH_RAW_MODE_NOT_R0 */
+#endif /* PGM_WITHOUT_MAPPINGS */