From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id D51D67803D2 for ; Fri, 15 Dec 2023 09:30:19 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=FmTEzgro3LWVZiPrAIy6IkVG7ZOgVOiQcuwDgMNlkLw=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1702632618; v=1; b=hdoCau0ILhjaare38AWKRI7hsYMGFukBGt6reqSRPlMg8ZNQBzn0IWKBH58L1OQGGgV3F2LR Kl5n7p0IlcRIeB6AH6+wxuN/6y+1KaQbOh7yHXDo8PnHVn7QQ6DRiLd41oXJ3ppphS5xBq7WuK6 udIAO1vLg1tw57ZxocsrHVDE= X-Received: by 127.0.0.2 with SMTP id VlA3YY7687511xUo0kyK3y3z; Fri, 15 Dec 2023 01:30:18 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web11.59296.1702632617923067104 for ; Fri, 15 Dec 2023 01:30:18 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="392428720" X-IronPort-AV: E=Sophos;i="6.04,278,1695711600"; d="scan'208";a="392428720" X-Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Dec 2023 01:29:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10924"; a="724402260" X-IronPort-AV: E=Sophos;i="6.04,278,1695711600"; d="scan'208";a="724402260" X-Received: from shwdeopenlab813.ccr.corp.intel.com ([10.239.55.230]) by orsmga003.jf.intel.com with ESMTP; 15 Dec 2023 01:29:57 -0800 From: "Yuanhao Xie" To: devel@edk2.groups.io Cc: xieyuanh , Zhihao Li , Ray Ni , Rahul Kumar , Gerd Hoffmann , Jiaxin Wu Subject: [edk2-devel] [Patch V3] UefiCpuPkg/PiSmmCpuDxeSmm: SmmCpuRendezvous ensure all Aps in Present. Date: Fri, 15 Dec 2023 17:29:53 +0800 Message-Id: <20231215092953.2395-1-yuanhao.xie@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,yuanhao.xie@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 8bQzmHYdSTGjYnBCuSKgF2nLx7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=hdoCau0I; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io 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 Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann Cc: Jiaxin Wu --- 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] -=-=-=-=-=-=-=-=-=-=-=-