This patch skips to update page table for non-SMRAM memory when PcdCpuSmmAccessOut is TRUE. So that when SMM accesses out, no page fault is triggered at all.
Signed-off-by: Ray Ni <[email protected]> Cc: Eric Dong <[email protected]> Cc: Jiewen Yao <[email protected]> Cc: Jian J Wang <[email protected]> Cc: Laszlo Ersek <[email protected]> --- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 21 +++++++++++++++++---- UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c index 69a04dfb23..427c33fb01 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -130,6 +130,11 @@ UINT8 mPhysicalAddressBits; UINT32 mSmmCr0; UINT32 mSmmCr4; +// +// Cache of PcdCpuSmmAccessOut +// +BOOLEAN mSmmAccessOut; + /** Initialize IDT to setup exception handlers for SMM. @@ -610,6 +615,12 @@ PiCpuSmmEntry ( mSmmCodeAccessCheckEnable = PcdGetBool (PcdCpuSmmCodeAccessCheckEnable); DEBUG ((EFI_D_INFO, "PcdCpuSmmCodeAccessCheckEnable = %d\n", mSmmCodeAccessCheckEnable)); + // + // Save the PcdCpuSmmAccessOut value into a global variable. + // + mSmmAccessOut = PcdGetBool (PcdCpuSmmAccessOut); + DEBUG ((DEBUG_INFO, "PcdCpuSmmAccessOut = %d\n", mSmmAccessOut)); + // // Save the PcdPteMemoryEncryptionAddressOrMask value into a global variable. // Make sure AddressEncMask is contained to smallest supported address field. @@ -1431,10 +1442,12 @@ PerformRemainingTasks ( // SetMemMapAttributes (); - // - // For outside SMRAM, we only map SMM communication buffer or MMIO. - // - SetUefiMemMapAttributes (); + if (!mSmmAccessOut) { + // + // For outside SMRAM, we only map SMM communication buffer or MMIO. + // + SetUefiMemMapAttributes (); + } // // Set page table itself to be read-only diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c index a3b62f7787..6699aac65d 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/X64/PageTbl.c @@ -1029,7 +1029,7 @@ SmiPFHandler ( goto Exit; } - if (mCpuSmmStaticPageTable && IsSmmCommBufferForbiddenAddress (PFAddress)) { + if (IsSmmCommBufferForbiddenAddress (PFAddress)) { DumpCpuContext (InterruptType, SystemContext); DEBUG ((DEBUG_ERROR, "Access SMM communication forbidden address (0x%lx)!\n", PFAddress)); DEBUG_CODE ( -- 2.21.0.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#44688): https://edk2.groups.io/g/devel/message/44688 Mute This Topic: https://groups.io/mt/32668874/21656 Group Owner: [email protected] Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
