Today's behavior is to always restrict access to non-SMRAM regardless
the value of PcdCpuSmmRestrictedMemoryAccess.
Because RAS components require to access all non-SMRAM memory, the
patch changes the code logic to honor PcdCpuSmmRestrictedMemoryAccess
so that only when the PCD is true, the restriction takes affect and
page table memory is also protected.
Because IA32 build doesn't reference this PCD, such restriction
always takes affect in IA32 build.
Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
{\r
return ;\r
}\r
+\r
+/**\r
+ Return whether access to non-SMRAM is restricted.\r
+\r
+ @retval TRUE Access to non-SMRAM is restricted.\r
+ @retval FALSE Access to non-SMRAM is not restricted.\r
+*/\r
+BOOLEAN\r
+IsRestrictedMemoryAccess (\r
+ VOID\r
+ )\r
+{\r
+ return TRUE;\r
+}\r
//\r
SetMemMapAttributes ();\r
\r
- //\r
- // For outside SMRAM, we only map SMM communication buffer or MMIO.\r
- //\r
- SetUefiMemMapAttributes ();\r
+ if (IsRestrictedMemoryAccess ()) {\r
+ //\r
+ // For outside SMRAM, we only map SMM communication buffer or MMIO.\r
+ //\r
+ SetUefiMemMapAttributes ();\r
\r
- //\r
- // Set page table itself to be read-only\r
- //\r
- SetPageTableAttributes ();\r
+ //\r
+ // Set page table itself to be read-only\r
+ //\r
+ SetPageTableAttributes ();\r
+ }\r
\r
//\r
// Configure SMM Code Access Check feature if available.\r
VOID\r
);\r
\r
+/**\r
+ Return whether access to non-SMRAM is restricted.\r
+\r
+ @retval TRUE Access to non-SMRAM is restricted.\r
+ @retval FALSE Access to non-SMRAM is not restricted.\r
+*/\r
+BOOLEAN\r
+IsRestrictedMemoryAccess (\r
+ VOID\r
+ );\r
+\r
#endif\r
AsmWriteCr2 (Cr2);\r
}\r
}\r
+\r
+/**\r
+ Return whether access to non-SMRAM is restricted.\r
+\r
+ @retval TRUE Access to non-SMRAM is restricted.\r
+ @retval FALSE Access to non-SMRAM is not restricted.\r
+*/\r
+BOOLEAN\r
+IsRestrictedMemoryAccess (\r
+ VOID\r
+ )\r
+{\r
+ return mCpuSmmRestrictedMemoryAccess;\r
+}\r