From 9f12d6b6ecf8ffe9cd4d93fe0976fdbaf2ded4f0 Mon Sep 17 00:00:00 2001 From: Zhihao Li Date: Tue, 25 Apr 2023 14:00:39 +0800 Subject: UefiCpuPkg/PiSmmCpuDxeSmm:add Ap Rendezvous check in PerformRemainingTasks. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4424 In Relaxed-AP Sync Mode, BSP will not wait for all Aps arrive. However, PerformRemainingTasks() needs to wait all Aps arrive before calling SetMemMapAttributes and ConfigSmmCodeAccessCheck() when mSmmReadyToLock is true. In SetMemMapAttributes(), SmmSetMemoryAttributesEx() will call FlushTlbForAll() that need to start up the aps. So it need to let all aps arrive. Same as SetMemMapAttributes(), ConfigSmmCodeAccessCheck() also will start up the aps. Cc: Eric Dong Cc: Ray Ni Signed-off-by: Zhihao Li Reviewed-by: Ray Ni --- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c index c0e368ea94..2144d6ade8 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -1540,6 +1540,19 @@ PerformRemainingTasks ( ) { if (mSmmReadyToLock) { + // + // Check if all Aps enter SMM. In Relaxed-AP Sync Mode, BSP will not wait for + // all Aps arrive. However,PerformRemainingTasks() needs to wait all Aps arrive before calling + // SetMemMapAttributes() and ConfigSmmCodeAccessCheck() when mSmmReadyToLock + // is true. In SetMemMapAttributes(), SmmSetMemoryAttributesEx() will call + // FlushTlbForAll() that need to start up the aps. So it need to let all + // aps arrive. Same as SetMemMapAttributes(), ConfigSmmCodeAccessCheck() + // also will start up the aps. + // + if (EFI_ERROR (SmmCpuRendezvous (NULL, TRUE))) { + DEBUG ((DEBUG_ERROR, "PerformRemainingTasks: fail to wait for all AP check in SMM!\n")); + } + // // Start SMM Profile feature // -- cgit v1.2.3