From: Laszlo Ersek Date: Fri, 26 Jul 2019 09:59:56 +0000 (+0200) Subject: Revert "UefiCpuPkg/PiSmmCpu: Allow SMM access-out when static paging is OFF" X-Git-Tag: edk2-stable201908~201 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=d47b85a621add591212546b12945d7b9873fbabf Revert "UefiCpuPkg/PiSmmCpu: Allow SMM access-out when static paging is OFF" 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: push revert immediately, due to build breakage that would have been easy to catch before submitting the patch] --- diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c index 50614f32c3..69a04dfb23 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -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) { - - // - // For outside SMRAM, we only map SMM communication buffer or MMIO. - // - SetUefiMemMapAttributes (); + 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.