From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by mx.groups.io with SMTP id smtpd.web11.26682.1649660795361457757 for ; Mon, 11 Apr 2022 00:06:35 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=gl2eqZow; spf=pass (domain: intel.com, ip: 192.55.52.93, 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=1649660795; x=1681196795; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=I9LnF09/Rc5ylLktmdqd1oQBA1B9jk8ifrg7JK3G844=; b=gl2eqZowqEOULrTwbfCTY+p1iCHNoPeY0xAcf+Kdaz7IsO+F6tB1rVDF YK7yXnecA+BeqI58su8ObdEJTVsshMxyVjuKZLPcXU5iJs9yEGZOH/O8F ot+bG6/H6VG5qGoMBoJgGTn/ViTpCIfzVh6j+7HwVCmG+wPw1pYBWAKEy /M3NnS3/K28BxAyilB1feJQRx3nt77tqE/grLXRRKGhWOd/EI6G2r8c95 Ei5efYKxlpI55HitQ1kCIMgECm8a6Oiel/pzovq73iNsh5kCytyEbiXTt oI15yiw9VXEDjTHntIMXWckbJTWwAIEl7pfoImxCZdS7jIpba89W2B2Br Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10313"; a="259645083" X-IronPort-AV: E=Sophos;i="5.90,251,1643702400"; d="scan'208";a="259645083" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Apr 2022 00:06:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.90,251,1643702400"; d="scan'208";a="571997244" Received: from win_li.ccr.corp.intel.com ([10.239.157.34]) by orsmga008.jf.intel.com with ESMTP; 11 Apr 2022 00:06:32 -0700 From: "Li, Zhihao" To: devel@edk2.groups.io Cc: Jian J Wang , Liming Gao , Siyuan Fu , Ni Ray , Michael D Kinney Subject: [PATCH v1 1/1] MdeModulePkg: Use SmmWaitForAllProcessor() in VariableSmm driver. Date: Mon, 11 Apr 2022 15:06:31 +0800 Message-Id: <20220411070631.1266-1-zhihao.li@intel.com> X-Mailer: git-send-email 2.26.2.windows.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable REF=EF=BC=9A https://bugzilla.tianocore.org/show_bug.cgi?id=3D3854 In UefiCpuPkg, there are a new Protocol with the new service SmmWaitForAllProcessor(), which can be used by SMI handler to optionally wait for other APs to complete SMM rendezvous in relaxed AP mode. This patch use the new service to let VariableSmm driver work normally in relaxed AP mode. Cc: Jian J Wang Cc: Liming Gao Cc: Siyuan Fu Cc: Ni Ray Cc: Michael D Kinney Signed-off-by: Zhihao Li --- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c | 10 += ++++++- MdeModulePkg/Include/Library/SmmCpuRendezvousLib.h | 27 += +++++++++++++++++++ MdeModulePkg/MdeModulePkg.dec | 5 += ++- MdeModulePkg/MdeModulePkg.dsc | 4 += +- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf | 3 += +- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf | 3 += +- 6 files changed, 47 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c b/Mde= ModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c index 517cae7b00f8..52a9b0e6b202 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c @@ -14,7 +14,7 @@ VariableServiceSetVariable(), VariableServiceQueryVariableInfo(), Reclai= mForOS(),=0D SmmVariableGetStatistics() should also do validation based on its own kn= owledge.=0D =0D -Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
=0D +Copyright (c) 2010 - 2022, Intel Corporation. All rights reserved.
=0D Copyright (c) 2018, Linaro, Ltd. All rights reserved.
=0D SPDX-License-Identifier: BSD-2-Clause-Patent=0D =0D @@ -28,6 +28,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =0D #include =0D #include =0D +#include =0D =0D #include =0D #include "Variable.h"=0D @@ -656,6 +657,13 @@ SmmVariableHandler ( goto EXIT;=0D }=0D =0D + if ((SmmVariableHeader->Attributes & EFI_VARIABLE_NON_VOLATILE) !=3D= 0) {=0D + if (EFI_ERROR (SmmWaitForAllProcessor (TRUE))) {=0D + DEBUG ((DEBUG_ERROR, "SetVariable: fail to wait for all AP check= in SMM!\n"));=0D + goto EXIT;=0D + }=0D + }=0D +=0D Status =3D VariableServiceSetVariable (=0D SmmVariableHeader->Name,=0D &SmmVariableHeader->Guid,=0D diff --git a/MdeModulePkg/Include/Library/SmmCpuRendezvousLib.h b/MdeModule= Pkg/Include/Library/SmmCpuRendezvousLib.h new file mode 100644 index 000000000000..82e459e9106e --- /dev/null +++ b/MdeModulePkg/Include/Library/SmmCpuRendezvousLib.h @@ -0,0 +1,27 @@ +/** @file=0D + SMM CPU Rendezvous library header file.=0D +=0D + Copyright (c) 2022, Intel Corporation. All rights reserved.
=0D + SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef SMM_CPU_RENDEZVOUS_H_=0D +#define SMM_CPU_RENDEZVOUS_H_=0D +=0D +/**=0D + This routine wait for all AP processors to arrive in SMM.=0D +=0D + @param[in] BlockingMode Blocking mode or non-blocking mode.=0D +=0D + @retval EFI_SUCCESS All processors checked in to SMM.=0D + @retval EFI_TIMEOUT Wait for all APs until timeout.=0D +=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +SmmWaitForAllProcessor (=0D + IN BOOLEAN BlockingMode=0D + );=0D +=0D +#endif=0D diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 463e889e9a68..06ada41b7344 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -4,7 +4,7 @@ # and libraries instances, which are used for those modules.=0D #=0D # Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.=0D -# Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.
=0D +# Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.
=0D # Copyright (c) 2016, Linaro Ltd. All rights reserved.
=0D # (C) Copyright 2016 - 2019 Hewlett Packard Enterprise Development LP
= =0D # Copyright (c) 2017, AMD Incorporated. All rights reserved.
=0D @@ -154,6 +154,9 @@ #=0D VariablePolicyHelperLib|Include/Library/VariablePolicyHelperLib.h=0D =0D + ## @libraryclass Provides function for SMM CPU Rendezvous Library.=0D + SmmCpuRendezvousLib|Include/Library/SmmCpuRendezvousLib.h=0D +=0D [Guids]=0D ## MdeModule package token space guid=0D # Include/Guid/MdeModulePkgTokenSpace.h=0D diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index b1d83461865e..a15dd5d7b23d 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -2,7 +2,7 @@ # EFI/PI Reference Module Package for All Architectures=0D #=0D # (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
=0D -# Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.
=0D +# Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.
=0D # Copyright (c) Microsoft Corporation.=0D #=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D @@ -152,6 +152,7 @@ SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableL= ib.inf=0D LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf=0D SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf=0D + SmmCpuRendezvousLib|UefiCpuPkg/Library/SmmCpuRendezvousLib/SmmCpuRendezv= ousLib.inf=0D =0D [LibraryClasses.common.UEFI_DRIVER]=0D HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf=0D @@ -172,6 +173,7 @@ MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/Standalon= eMmServicesTableLib.inf=0D LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.= inf=0D MemLib|StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf= =0D + SmmCpuRendezvousLib|UefiCpuPkg/Library/SmmCpuRendezvousLib/SmmCpuRendezv= ousLib.inf=0D =0D [LibraryClasses.ARM, LibraryClasses.AARCH64]=0D ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf=0D diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf b/M= deModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf index eaa97a01c6e5..0bebd92b1626 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf @@ -18,7 +18,7 @@ # may not be modified without authorization. If platform fails to protect= these resources,=0D # the authentication service provided in this driver will be broken, and = the behavior is undefined.=0D #=0D -# Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
=0D +# Copyright (c) 2010 - 2022, Intel Corporation. All rights reserved.
=0D # Copyright (c) Microsoft Corporation.=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D #=0D @@ -82,6 +82,7 @@ UefiBootServicesTableLib=0D VariablePolicyLib=0D VariablePolicyHelperLib=0D + SmmCpuRendezvousLib=0D =0D [Protocols]=0D gEfiSmmFirmwareVolumeBlockProtocolGuid ## CONSUMES=0D diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneM= m.inf b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf index d8c4f77e7f1f..595baaf70164 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf @@ -18,7 +18,7 @@ # may not be modified without authorization. If platform fails to protect= these resources,=0D # the authentication service provided in this driver will be broken, and = the behavior is undefined.=0D #=0D -# Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
=0D +# Copyright (c) 2010 - 2022, Intel Corporation. All rights reserved.
=0D # Copyright (c) 2018, Linaro, Ltd. All rights reserved.
=0D # Copyright (c) Microsoft Corporation.=0D # SPDX-License-Identifier: BSD-2-Clause-Patent=0D @@ -78,6 +78,7 @@ VarCheckLib=0D VariablePolicyLib=0D VariablePolicyHelperLib=0D + SmmCpuRendezvousLib=0D =0D [Protocols]=0D gEfiSmmFirmwareVolumeBlockProtocolGuid ## CONSUMES=0D --=20 2.26.2.windows.1