From 0593183d764e63ffd07807213300bbfe1702d079 Mon Sep 17 00:00:00 2001 From: Jiaxin Wu Date: Wed, 26 Jun 2024 15:54:22 +0800 Subject: [PATCH] UefiCpuPkg/PiSmmCpuDxeSmm: Start SMM Profile early for MM SMM Profile start can be started early in SMM CPU EntryPoint since page table for SMM profile is ready. No need wait smm ready to lock. Signed-off-by: Jiaxin Wu Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann Cc: Star Zeng Cc: Dun Tan Cc: Hongbin1 Zhang Cc: Wei6 Xu Cc: Yuanhao Xie --- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 5 +++++ UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuStandaloneMm.c | 10 ++++++++++ UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c | 5 ----- UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h | 9 +++++++++ 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c index 959e993bda..93bb67ce7a 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -163,6 +163,11 @@ SmmReadyToLockEventNotify ( // Get Software SMI from FADT // GetSmiCommandPort (); + + // + // Initialize protected memory range for patching page table later. + // + InitProtectedMemRange (); } // diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuStandaloneMm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuStandaloneMm.c index 005fbcd968..d8aaff811c 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuStandaloneMm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuStandaloneMm.c @@ -221,6 +221,16 @@ PiCpuStandaloneMmEntry ( // Get Software SMI // GetSmiCommandPort (); + + // + // Initialize protected memory range for patching page table later. + // + InitProtectedMemRange (); + + // + // Start SMM Profile feature + // + SmmProfileStart (); } // diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c index bbac6064e2..0e95fc0eb3 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.c @@ -738,11 +738,6 @@ InitSmmProfileCallBack ( &mSmmProfileBase ); - // - // Initialize protected memory range for patching page table later. - // - InitProtectedMemRange (); - return EFI_SUCCESS; } diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h index b34aab41ef..fc4c2731a0 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/SmmProfile.h @@ -90,6 +90,15 @@ CheckFeatureSupported ( IN UINTN CpuIndex ); +/** + Initialize the protected memory ranges and the 4KB-page mapped memory ranges. + +**/ +VOID +InitProtectedMemRange ( + VOID + ); + /** Update page table according to protected memory ranges and the 4KB-page mapped memory ranges.