From: "Yuanhao Xie" <yuanhao.xie@intel.com>
To: devel@edk2.groups.io
Cc: xieyuanh <yuanhao.xie@intel.com>, Zhihao Li <zhihao.li@intel.com>,
Ray Ni <ray.ni@intel.com>, Rahul Kumar <rahul1.kumar@intel.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Jiaxin Wu <jiaxin.wu@intel.com>
Subject: [edk2-devel] [Patch V3] UefiCpuPkg/PiSmmCpuDxeSmm: SmmCpuRendezvous ensure all Aps in Present.
Date: Fri, 15 Dec 2023 17:29:53 +0800 [thread overview]
Message-ID: <20231215092953.2395-1-yuanhao.xie@intel.com> (raw)
SMM read save state requires AP must be present.
This patch aim to avoid the AP not ready for save state check.
Furthermore, SmmWaitForApArrival has two callers: SmmCpuRendezvous and
BSPHandler, the behavior of the two callers can be consistent by add
the while loop to check the present of the APs to SmmCpuRendezvous.
Signed-off-by: Zhihao Li <zhihao.li@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
---
UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c | 27 +++++++++++++++++++++++++++
UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 13 +++++++++++++
2 files changed, 40 insertions(+)
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c
index c0485b0519..3e98955319 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c
@@ -416,8 +416,15 @@ SmmCpuRendezvous (
IN BOOLEAN BlockingMode
)
{
+ UINTN Index;
+ UINTN PresentCount;
+ UINT32 BlockedCount;
+ UINT32 DisabledCount;
EFI_STATUS Status;
+ BlockedCount = 0;
+ DisabledCount = 0;
+
//
// Return success immediately if all CPUs are already synchronized.
//
@@ -436,6 +443,26 @@ SmmCpuRendezvous (
// There are some APs outside SMM, Wait for all avaiable APs to arrive.
//
SmmWaitForApArrival ();
+
+ //
+ // Make sure all APs have their Present flag set
+ //
+ while (TRUE) {
+ PresentCount = 0;
+ for (Index = 0; Index < mMaxNumberOfCpus; Index++) {
+ if (*(mSmmMpSyncData->CpuData[Index].Present)) {
+ PresentCount++;
+ }
+ }
+
+ GetSmmDelayedBlockedDisabledCount (NULL, &BlockedCount, &DisabledCount);
+ if (PresentCount == mMaxNumberOfCpus - BlockedCount - DisabledCount ) {
+ break;
+ }
+
+ CpuPause ();
+ }
+
Status = mSmmMpSyncData->AllApArrivedWithException ? EFI_SUCCESS : EFI_TIMEOUT;
} else {
//
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
index f18345881b..e3538957fb 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
@@ -1552,6 +1552,19 @@ SmmWaitForApArrival (
VOID
);
+/**
+ Returns the Number of SMM Delayed & Blocked & Disabled Thread Count.
+ @param[in,out] DelayedCount The Number of SMM Delayed Thread Count.
+ @param[in,out] BlockedCount The Number of SMM Blocked Thread Count.
+ @param[in,out] DisabledCount The Number of SMM Disabled Thread Count.
+**/
+VOID
+GetSmmDelayedBlockedDisabledCount (
+ IN OUT UINT32 *DelayedCount,
+ IN OUT UINT32 *BlockedCount,
+ IN OUT UINT32 *DisabledCount
+ );
+
/**
Write unprotect read-only pages if Cr0.Bits.WP is 1.
--
2.39.1.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#112589): https://edk2.groups.io/g/devel/message/112589
Mute This Topic: https://groups.io/mt/103187773/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next reply other threads:[~2023-12-15 9:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-15 9:29 Yuanhao Xie [this message]
2023-12-19 4:01 ` [edk2-devel] [Patch V3] UefiCpuPkg/PiSmmCpuDxeSmm: SmmCpuRendezvous ensure all Aps in Present Ni, Ray
2023-12-19 5:12 ` Yuanhao Xie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231215092953.2395-1-yuanhao.xie@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox