summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg
diff options
context:
space:
mode:
authorJiaxin Wu <jiaxin.wu@intel.com>2024-09-02 12:03:46 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-09-06 08:41:49 +0000
commitc8ce84d06785ee7e7a3e1a8ab7c0af42ccbe3aa8 (patch)
tree191763362127227542297b0c3dfa1ca19ed67989 /UefiCpuPkg
parent897284d47deec28a3f88a7694cfc899856b897b9 (diff)
downloadedk2-c8ce84d06785ee7e7a3e1a8ab7c0af42ccbe3aa8.tar.gz
UefiCpuPkg/PiSmmCpuDxeSmm: Always save and restore CR2
Following the commit 9f29fbd3, full mapping SMM page table is always created regardless the value of the PcdCpuSmmRestrictedMemoryAccess. Consequently, a page fault (#PF) that triggers an update to the page table occurs only when SmiProfile is enabled. Therefore, it is necessary to save and restore the CR2 register when SmiProfile is configured to be enabled. And the operation of saving and restoring CR2 is considered to be not heavy operation compared to the saving and restoring of CR3. As a result, the condition check for SmiProfile has been removed, and CR2 is now saved and restored unconditionally, without the need for additional condition checks. Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Diffstat (limited to 'UefiCpuPkg')
-rw-r--r--UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
index 29b6125dce..d561dc1966 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c
@@ -845,7 +845,7 @@ Exit:
}
/**
- This function reads CR2 register when on-demand paging is enabled.
+ This function reads CR2 register.
@param[out] *Cr2 Pointer to variable to hold CR2 register value.
**/
@@ -854,16 +854,11 @@ SaveCr2 (
OUT UINTN *Cr2
)
{
- if (!mCpuSmmRestrictedMemoryAccess) {
- //
- // On-demand paging is enabled when access to non-SMRAM is not restricted.
- //
- *Cr2 = AsmReadCr2 ();
- }
+ *Cr2 = AsmReadCr2 ();
}
/**
- This function restores CR2 register when on-demand paging is enabled.
+ This function restores CR2 register.
@param[in] Cr2 Value to write into CR2 register.
**/
@@ -872,12 +867,7 @@ RestoreCr2 (
IN UINTN Cr2
)
{
- if (!mCpuSmmRestrictedMemoryAccess) {
- //
- // On-demand paging is enabled when access to non-SMRAM is not restricted.
- //
- AsmWriteCr2 (Cr2);
- }
+ AsmWriteCr2 (Cr2);
}
/**