From nobody Mon May 13 21:53:36 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+111119+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111119+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1699854451; cv=none; d=zohomail.com; s=zohoarc; b=QjC4PGRx4JI+0ZJ6jliO1pKyqqPzL5Lmj6H306T+fh8jNkTa/e8oJPENaELe2PiQyci62IdVxXdehhsTmOPYti0Z7wsn6XObDhNf43YnztSloFH3SeMJLfvx+zi4bpq+FvdBt29mgzNgP0GXMUklFW0sCBdGQJw9OnUiI7CwM0w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1699854451; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:Sender:Subject:Subject:To:To:Message-Id; bh=vhEEK1CWlgz+VsKoXfoViwYTfgywgaX7P27xfupOOiU=; b=NALMkgcr6SHvunH1grkUQncvqgLnz3EYYd0w51UU5krsCsw2o0hLhJnXSdQr2nqcSB3m1k7X0qTgK1/v844iAOvIYJP4iShnXYZ1OxkNHJbCiOzry16DyaCpD6uYd5bmvVawBftE/NslquFY28TqYXxLN8dfDn/CvSzdEVUdn00= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+111119+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1699854451246705.2736570618265; Sun, 12 Nov 2023 21:47:31 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=QWT8vCFZa3queAGCCcHm6KagqB3JSyzk5EkpN/iA9yE=; 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=lToUrVG9XtbX2iyZoFDzqnfTcInCgLs/QxOH17d6FCxvY2RhTN4jkhposx/t9/ixXUmD9Hda BKshq9f0jMh4E8R2ExeULtabTP2OPWj9KCkaF7rDTDcOo1yImq2UynB+lPPmx8v8qmwuS7jyV/e wmjxGi+uK9nRHm2ephcoPbCo= X-Received: by 127.0.0.2 with SMTP id Rt7HYY1788612xmDZBh6QivG; 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: muFC77CsJ2o3fufkoTh9ryBKx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1699854452707100001 Content-Type: text/plain; charset="utf-8" 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/PiSmmCpuDx= eSmm/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; =20 + BlockedCount =3D 0; + DisabledCount =3D 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 =3D 0; + for (Index =3D 0; Index < mMaxNumberOfCpus; Index++) { + if (*(mSmmMpSyncData->CpuData[Index].Present)) { + PresentCount++; + } + } + + GetSmmDelayedBlockedDisabledCount (NULL, &BlockedCount, &DisabledCou= nt); + if (PresentCount =3D=3D mMaxNumberOfCpus - BlockedCount - DisabledCo= unt ) { + break; + } + } + Status =3D mSmmMpSyncData->AllApArrivedWithException ? EFI_SUCCESS : E= FI_TIMEOUT; } else { // diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/UefiCpuPkg/PiSmmC= puDxeSmm/PiSmmCpuDxeSmm.h index 20ada465c2..b5aa5f99d7 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h @@ -1552,6 +1552,19 @@ SmmWaitForApArrival ( VOID ); =20 +/** + 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. =20 --=20 2.39.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- 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/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-