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.web08.51643.1654014427488500100 for ; Tue, 31 May 2022 09:27:08 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=TIbBAgq4; 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=1654014427; x=1685550427; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=NQqdgF5+SF2W4LOVyi0/1U4J4ty+XcONswg0ud7Xav8=; b=TIbBAgq4YF3iCqgVLZGpKjj6dHpIualYeNYzMjvrpgh0lRqDeTl4DKLh Aixt6sMqA5/2iNKadHrCR53e+0nD/USqwqiUgOOfDaVGnvJnAnYrXcfjt BrBB91m347XfLxXazSA9Al6dfPZ5lsLvqaujtguQaCEG102XM/LBBmNyV XlA59RvoVtg47kjQ+FSHrZ7c/nZsl0j324XOMsCn9wy1VTxR8pPLTNl/U cUxW0y+cAQsJy5cGYhwp9QBMlUzug9Rp4g4lp4pCOrHGDLdu61uzWenWk lINCinvEKzv21zRinOTqQTdrw8x1aDxRG9uOXXTL4Zjg9p7Yk97U9AEqC A==; X-IronPort-AV: E=McAfee;i="6400,9594,10364"; a="274113494" X-IronPort-AV: E=Sophos;i="5.91,265,1647327600"; d="scan'208";a="274113494" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2022 09:27:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,265,1647327600"; d="scan'208";a="605757470" Received: from win_li.ccr.corp.intel.com ([10.239.157.34]) by orsmga008.jf.intel.com with ESMTP; 31 May 2022 09:27:05 -0700 From: "Li, Zhihao" To: devel@edk2.groups.io Cc: Jian J Wang , Liming Gao , Ni Ray Subject: [PATCH v3 1/1] MdeModulePkg: Use SmmWaitForAllProcessor() in VariableSmm driver. Date: Wed, 1 Jun 2022 00:27:04 +0800 Message-Id: <20220531162704.2202-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 From: Zhihao Li 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. Due to MdeModulePkg can not depend on UefiCpuPkg, use null version implementation in MdePkg. Cc: Jian J Wang Cc: Liming Gao Cc: Ni Ray Signed-off-by: Zhihao Li --- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c | 10 += ++++++++- MdeModulePkg/MdeModulePkg.dsc | 4 += ++- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf | 3 += +- MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.inf | 3 += +- 4 files changed, 16 insertions(+), 4 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/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index b1d83461865e..1a3cf191bb5c 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 @@ [LibraryClasses.common.DXE_SMM_DRIVER] SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableL= ib.inf=0D LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf=0D SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf=0D + SmmCpuRendezvousLib|MdePkg/Library/SmmCpuRendezvousLibNull/SmmCpuRendezv= ousLibNull.inf=0D =0D [LibraryClasses.common.UEFI_DRIVER]=0D HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf=0D @@ -172,6 +173,7 @@ [LibraryClasses.common.MM_STANDALONE] MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/Standalon= eMmServicesTableLib.inf=0D LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.= inf=0D MemLib|StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf= =0D + SmmCpuRendezvousLib|MdePkg/Library/SmmCpuRendezvousLibNull/SmmCpuRendezv= ousLibNull.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 @@ [LibraryClasses] 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 @@ [LibraryClasses] VarCheckLib=0D VariablePolicyLib=0D VariablePolicyHelperLib=0D + SmmCpuRendezvousLib=0D =0D [Protocols]=0D gEfiSmmFirmwareVolumeBlockProtocolGuid ## CONSUMES=0D --=20 2.26.2.windows.1