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 025A2740032 for ; Mon, 13 Nov 2023 05:47:31 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=o+lf9GCQg/vTWiXv8UkCP33HBmPkYfPqZsov+U+rhv0=; 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=1699854450; v=1; b=cLRNT2Dq4yjxsFVOFf8cA2pFXFMcic2JvBFVy8p03XZ94Kz2jvQV7AhE6RLvMoAMW7PWu2Mw Hy3Yhe8Ieek2tTNC8OMiTqny6hJMEVVKa+zVsxojRfpzKhkq4JmYh2qb4epcLxDazCeEU6/WDzY ItL46pbGLflBYJxB8FOVwUf8= X-Received: by 127.0.0.2 with SMTP id e7HAYY7687511x9hjo4soZhy; Sun, 12 Nov 2023 21:47:30 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web10.31440.1699854449747059978 for ; Sun, 12 Nov 2023 21:47:30 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10892"; a="380771425" X-IronPort-AV: E=Sophos;i="6.03,298,1694761200"; d="scan'208";a="380771425" X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Nov 2023 21:47:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10892"; a="740669564" X-IronPort-AV: E=Sophos;i="6.03,298,1694761200"; d="scan'208";a="740669564" X-Received: from shwdeopenlab813.ccr.corp.intel.com ([10.239.55.230]) by orsmga006.jf.intel.com with ESMTP; 12 Nov 2023 21:47:27 -0800 From: "Yuanhao Xie" To: devel@edk2.groups.io Cc: xieyuanh , Zhihao Li , Ray Ni , Rahul Kumar , Gerd Hoffmann Subject: [edk2-devel] [Patch V2] UefiCpuPkg/PiSmmCpuDxeSmm: SmmCpuRendezvous ensure all Aps in Present. Date: Mon, 13 Nov 2023 13:47:14 +0800 Message-Id: <20231113054714.1729-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: ydoFGSHZqX8imkhL6TA6avipx7686176AA= 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=cLRNT2Dq; 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. Signed-off-by: Zhihao Li Cc: Ray Ni Cc: Rahul Kumar Cc: Gerd Hoffmann --- UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c | 25 +++++++++++++++++++++++++ UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 13 +++++++++++++ 2 files changed, 38 insertions(+) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c index 391b64e9f2..cdc7021ee9 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c @@ -406,8 +406,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. // @@ -426,6 +433,24 @@ 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; + } + } + Status = mSmmMpSyncData->AllApArrivedWithException ? EFI_SUCCESS : EFI_TIMEOUT; } else { // diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h index 20ada465c2..b5aa5f99d7 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 (#111119): https://edk2.groups.io/g/devel/message/111119 Mute This Topic: https://groups.io/mt/102556528/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-