From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by mx.groups.io with SMTP id smtpd.web10.5248.1682507633627273656 for ; Wed, 26 Apr 2023 04:13:53 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=Nwy8jmE+; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: zhihao.li@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1682507633; x=1714043633; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=WsGol0zNeyY4OYU6wOtDY4mSR6qWa/LTDekKUEjErjU=; b=Nwy8jmE+ZPAXbCSEQX2ZG3IFMhGhhRwqauTK4Z92wHB2BnwjEHqxF+7k atlIk0KkC8MlSQfGUlqnEMDPn3qTxNN4cscYxjAe/LuSIPEEtiWmi3fM2 MIe+0s8MRsHP0BuLg2MhwQ8AAg+qGfrzL3UYR+gj7RmGtM74G9I0LjJvm tQ+5rSNDpz1sPXPxDVUmD0dEa3KPEqwM4LUjvmPJDCEwuN2/ezpEFX6P5 SpYtGnekf98iAkYz52uc29yzcCu6qgBqawtn0iqhW8SzKxmMgKhZwoiyM 7kWyjCsxhqgDmIu5yPoiX51CT6cbuO5LyvHKGWdgVtHp/9bZ7ZzD0thl9 Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10691"; a="345830705" X-IronPort-AV: E=Sophos;i="5.99,227,1677571200"; d="scan'208";a="345830705" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Apr 2023 04:13:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10691"; a="687901119" X-IronPort-AV: E=Sophos;i="5.99,227,1677571200"; d="scan'208";a="687901119" Received: from win_li.ccr.corp.intel.com ([10.239.55.212]) by orsmga007.jf.intel.com with ESMTP; 26 Apr 2023 04:13:51 -0700 From: "Li, Zhihao" To: devel@edk2.groups.io Cc: Eric Dong , Ray Ni Subject: [PATCH v1 1/1] UefiCpuPkg/PiSmmCpuDxeSmm:add Ap Rendezvous check in PerformRemainingTasks. Date: Wed, 26 Apr 2023 19:13:50 +0800 Message-Id: <20230426111350.1543-1-zhihao.li@intel.com> X-Mailer: git-send-email 2.26.2.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4424 In Relaxed-AP Sync Mode, BSP will not wait for all Aps arrive. However, SmmReadyToLock needs all Aps to arrive to set memory map Attributes and check config Smm code access in PerformRemainingTasks. Cc: Eric Dong Cc: Ray Ni Signed-off-by: Zhihao Li --- UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c | 19 +++++++++++++------ UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 10 +++++++++- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h | 3 ++- UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf | 3 ++- 4 files changed, 26 insertions(+), 9 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c b/UefiCpuPkg/PiSmmCpuDx= eSmm/CpuService.c index 2ebf4543c3ed..391b64e9f222 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/CpuService.c @@ -1,7 +1,7 @@ /** @file=0D Implementation of SMM CPU Services Protocol.=0D =0D -Copyright (c) 2011 - 2022, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2011 - 2023, Intel Corporation. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D **/=0D @@ -421,11 +421,18 @@ SmmCpuRendezvous ( goto ON_EXIT;=0D }=0D =0D - //=0D - // There are some APs outside SMM, Wait for all avaiable APs to arrive.= =0D - //=0D - SmmWaitForApArrival ();=0D - Status =3D mSmmMpSyncData->AllApArrivedWithException ? EFI_SUCCESS : EFI= _TIMEOUT;=0D + if ((mSmmMpSyncData->EffectiveSyncMode !=3D SmmCpuSyncModeTradition) && = !SmmCpuFeaturesNeedConfigureMtrrs ()) {=0D + //=0D + // There are some APs outside SMM, Wait for all avaiable APs to arrive= .=0D + //=0D + SmmWaitForApArrival ();=0D + Status =3D mSmmMpSyncData->AllApArrivedWithException ? EFI_SUCCESS : E= FI_TIMEOUT;=0D + } else {=0D + //=0D + // BSP has already waitted for APs to arrive SMM if SmmCpuSyncMode sel= ected or need config MTRR.=0D + //=0D + Status =3D EFI_TIMEOUT;=0D + }=0D =0D ON_EXIT:=0D if (!mSmmMpSyncData->AllApArrivedWithException) {=0D diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmC= puDxeSmm/PiSmmCpuDxeSmm.c index 655175a2c6db..71c143069e41 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -1,7 +1,7 @@ /** @file=0D Agent Module to load other modules to deploy SMM Entry Vector for X86 CPU.= =0D =0D -Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.
=0D Copyright (c) 2017, AMD Incorporated. All rights reserved.
=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D @@ -1441,6 +1441,14 @@ PerformRemainingTasks ( )=0D {=0D if (mSmmReadyToLock) {=0D + //=0D + // Check if all Aps enter SMM. In Relaxed-AP Sync Mode, BSP will not w= ait for=0D + // all Aps arrive. Howawever, SmmReadyToLock needs all Aps to arrive.= =0D + //=0D + if (EFI_ERROR (SmmWaitForAllProcessor (TRUE))) {=0D + DEBUG ((DEBUG_ERROR, "PerformRemainingTasks: fail to wait for all AP= check in SMM!\n"));=0D + }=0D +=0D //=0D // Start SMM Profile feature=0D //=0D diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h b/UefiCpuPkg/PiSmmC= puDxeSmm/PiSmmCpuDxeSmm.h index 5f0a38e4002d..cc1b42661bda 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h @@ -1,7 +1,7 @@ /** @file=0D Agent Module to load other modules to deploy SMM Entry Vector for X86 CPU.= =0D =0D -Copyright (c) 2009 - 2022, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.
=0D Copyright (c) 2017, AMD Incorporated. All rights reserved.
=0D =0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D @@ -50,6 +50,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include =0D #include =0D #include =0D +#include =0D =0D #include =0D #include =0D diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf b/UefiCpuPkg/PiSm= mCpuDxeSmm/PiSmmCpuDxeSmm.inf index b4b327f60c81..c0bdb931bfac 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf @@ -4,7 +4,7 @@ # This SMM driver performs SMM initialization, deploy SMM Entry Vector,=0D # provides CPU specific services in SMM.=0D #=0D -# Copyright (c) 2009 - 2022, Intel Corporation. All rights reserved.
=0D +# Copyright (c) 2009 - 2023, Intel Corporation. All rights reserved.
=0D # Copyright (c) 2017, AMD Incorporated. All rights reserved.
=0D #=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D @@ -98,6 +98,7 @@ ReportStatusCodeLib=0D SmmCpuFeaturesLib=0D PeCoffGetEntryPointLib=0D + SmmCpuRendezvousLib=0D =0D [Protocols]=0D gEfiSmmAccess2ProtocolGuid ## CONSUMES=0D --=20 2.26.2.windows.1