Revert "UefiCpuPkg/PiSmmCpu: Allow SMM access-out when static paging is OFF"

This reverts commit 30f6148546.

Commit 30f6148546 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 37f9fea5b8 ("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]
This commit is contained in:
Laszlo Ersek 2019-07-26 11:59:56 +02:00
parent 30f6148546
commit d47b85a621
1 changed files with 6 additions and 15 deletions

View File

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