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>
}\r
\r
/**\r
- This function reads CR2 register when on-demand paging is enabled.\r
+ This function reads CR2 register.\r
\r
@param[out] *Cr2 Pointer to variable to hold CR2 register value.\r
**/\r
OUT UINTN *Cr2\r
)\r
{\r
- if (!mCpuSmmRestrictedMemoryAccess) {\r
- //\r
- // On-demand paging is enabled when access to non-SMRAM is not restricted.\r
- //\r
- *Cr2 = AsmReadCr2 ();\r
- }\r
+ *Cr2 = AsmReadCr2 ();\r
}\r
\r
/**\r
- This function restores CR2 register when on-demand paging is enabled.\r
+ This function restores CR2 register.\r
\r
@param[in] Cr2 Value to write into CR2 register.\r
**/\r
IN UINTN Cr2\r
)\r
{\r
- if (!mCpuSmmRestrictedMemoryAccess) {\r
- //\r
- // On-demand paging is enabled when access to non-SMRAM is not restricted.\r
- //\r
- AsmWriteCr2 (Cr2);\r
- }\r
+ AsmWriteCr2 (Cr2);\r
}\r
\r
/**\r