]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Revert "UefiCpuPkg/PiSmmCpu: Allow SMM access-out when static paging is OFF"
authorLaszlo Ersek <lersek@redhat.com>
Fri, 26 Jul 2019 09:59:56 +0000 (11:59 +0200)
committerLaszlo Ersek <lersek@redhat.com>
Fri, 26 Jul 2019 09:59:56 +0000 (11:59 +0200)
This reverts commit 30f6148546c7092650ab4886fc6d95d5065c3188.

Commit 30f6148546c7 causes a build failure, when building for IA32:

> UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c: In function
> 'PerformRemainingTasks':
> UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c:1440:9: error:
> 'mCpuSmmStaticPageTable' undeclared (first use in this function)
>      if (mCpuSmmStaticPageTable) {

"mCpuSmmStaticPageTable" is an X64-only variable. It is defined in
"X64/PageTbl.c", which is not linked into the IA32 binary. We must not
reference the variable in such code that is linked into both IA32 and X64
builds, such as "PiSmmCpuDxeSmm.c".

We have encountered the same challenge at least once in the past:

- https://bugzilla.tianocore.org/show_bug.cgi?id=1593
- commit 37f9fea5b88d ("UefiCpuPkg\CpuSmm: Save & restore CR2 on-demand
  paging in SMM", 2019-04-04)

The right approach is to declare a new function in "PiSmmCpuDxeSmm.h", and
to provide two definitions for the function, one in "Ia32/PageTbl.c", and
another in "X64/PageTbl.c". The IA32 implementation should return a
constant value. The X64 implementation should return
"mCpuSmmStaticPageTable". (In the example named above, the functions were
SaveCr2() and RestoreCr2().)

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
[lersek@redhat.com: push revert immediately, due to build breakage that
 would have been easy to catch before submitting the patch]

UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c

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