From 4f6614fc180c3f24a72ac3234daba8575f13cbad Mon Sep 17 00:00:00 2001 From: Jiaxin Wu Date: Mon, 2 Sep 2024 12:22:41 +0800 Subject: [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Correct SetPageTableAttributes func usage SetPageTableAttributes() will use the IfReadOnlyPageTableNeeded() to determine whether it is necessary to set the page table itself to read-only. And IfReadOnlyPageTableNeeded() has already token into account the status of IsRestrictedMemoryAccess(). Therefore, there is no need for an additional call to IsRestrictedMemoryAccess() before calling the SetPageTableAttributes(). Signed-off-by: Jiaxin Wu --- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 10 ++++------ UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuStandaloneMm.c | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c index 50aeefb948..0ecdd2d891 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -95,12 +95,10 @@ PerformRemainingTasks ( SetMemMapAttributes (MemoryAttributesTable); } - if (IsRestrictedMemoryAccess ()) { - // - // 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. diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuStandaloneMm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuStandaloneMm.c index f81389463f..6f59b49305 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuStandaloneMm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuStandaloneMm.c @@ -70,12 +70,10 @@ PerformRemainingTasks ( SetMemMapAttributes (MemoryAttributesTable); } - if (IsRestrictedMemoryAccess ()) { - // - // Set page table itself to be read-only - // - SetPageTableAttributes (); - } + // + // Set page table itself to be read-only + // + SetPageTableAttributes (); // // Measure performance of SmmCpuFeaturesCompleteSmmReadyToLock() from caller side