]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/PiSmmCpu: Allow SMM access-out when static paging is OFF
authorNi, Ray <ray.ni@intel.com>
Thu, 18 Jul 2019 06:58:07 +0000 (14:58 +0800)
committerRay Ni <ray.ni@intel.com>
Fri, 26 Jul 2019 06:55:47 +0000 (14:55 +0800)
Commit c60d36b4d1ee1f69b7cca897d3621dfa951895c2
* UefiCpuPkg/SmmCpu: Block access-out only when static paging is used

updated page fault handler to treat SMM access-out as allowed
address when static paging is not used.

But that commit is not complete because the page table is still
updated in SetUefiMemMapAttributes() for non-SMRAM memory. When SMM
code accesses non-SMRAM memory, page fault is still generated.

This patch skips to update page table for non-SMRAM memory and
page table itself.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Acked-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c

index 69a04dfb2311b65699ff51efffc643bd1ba4767d..50614f32c364b8e8e0caa3a969997ee6ff377e9b 100644 (file)
@@ -1121,6 +1121,9 @@ FindSmramInfo (
   *SmrrBase = (UINT32)CurrentSmramRange->CpuStart;\r
   *SmrrSize = (UINT32)CurrentSmramRange->PhysicalSize;\r
 \r
+  //\r
+  // Extend *SmrrBase/*SmrrSize to include adjacent SMRAM ranges\r
+  //\r
   do {\r
     Found = FALSE;\r
     for (Index = 0; Index < mSmmCpuSmramRangeCount; Index++) {\r
@@ -1432,14 +1435,20 @@ PerformRemainingTasks (
     SetMemMapAttributes ();\r
 \r
     //\r
-    // For outside SMRAM, we only map SMM communication buffer or MMIO.\r
+    // Do not protect memory outside SMRAM when SMM static page table is not enabled.\r
     //\r
-    SetUefiMemMapAttributes ();\r
+    if (mCpuSmmStaticPageTable) {\r
 \r
-    //\r
-    // Set page table itself to be read-only\r
-    //\r
-    SetPageTableAttributes ();\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
 \r
     //\r
     // Configure SMM Code Access Check feature if available.\r