From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web08.28505.1655718963287040833 for ; Mon, 20 Jun 2022 02:56:06 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=NMutNHLO; spf=pass (domain: intel.com, ip: 134.134.136.31, 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=1655718965; x=1687254965; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=ia2lU0v0o99Tt6lhqnfC/0mJrKifhYPz2a4Yo9JE3wk=; b=NMutNHLOPNeNT2gJjAJUgcZUBTdNHa22DZBJSH2YWjf1dsjsn0AXWN5i NsrTxIesFCIx9iAaNmXhdh8SfFDtklNBGkX/Deh+TvEZGpwwJReXdJTBf pPo2sFsqBhmJ6tNODyhEZ3Bz2Vckj2v+D3cXzY2+QpPIQByMK8Ab6a7vv +Y2r0PFUK2t+YLpIhhJ1ZYMbg+8Q9GFvHjHfjVcGEWrbCTArGJMVj6Yu5 C+MumqLSf4Tw7XW8Y+7lNxI4BNm28PsofBzJ+B5h31ZIgFQhrhflsog/8 9IdPvZyX8zOgluLmyYX2gTktyEf+YX/54YUIY2xnwvddl1OHq+PqJivBq w==; X-IronPort-AV: E=McAfee;i="6400,9594,10380"; a="341536231" X-IronPort-AV: E=Sophos;i="5.92,306,1650956400"; d="scan'208";a="341536231" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Jun 2022 02:56:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,306,1650956400"; d="scan'208";a="643043363" Received: from sep081ff3625096.sh.intel.com (HELO win_li.ccr.corp.intel.com) ([10.239.157.34]) by fmsmga008.fm.intel.com with ESMTP; 20 Jun 2022 02:56:04 -0700 From: "Li, Zhihao" To: devel@edk2.groups.io Cc: Jiewen Yao , Jian J Wang Subject: [PATCH 1/1] MdeModulePkg: Use SmmWaitForAllProcessor() in VariableSmm driver. Date: Mon, 20 Jun 2022 17:55:54 +0800 Message-Id: <20220620095555.1625-6-zhihao.li@intel.com> X-Mailer: git-send-email 2.26.2.windows.1 In-Reply-To: <20220620095555.1625-1-zhihao.li@intel.com> References: <20220620095555.1625-1-zhihao.li@intel.com> 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: Jiewen Yao =0D Cc: Jian J Wang Signed-off-by: Zhihao Li --- .../Universal/Variable/RuntimeDxe/VariableSmm.c | 10 +++++++++- .../Universal/Variable/RuntimeDxe/VariableSmm.inf | 3 ++- .../Variable/RuntimeDxe/VariableStandaloneMm.inf | 3 ++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c b/Mde= ModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.c index 5253c328dcd9..265934c56a11 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/Universal/Variable/RuntimeDxe/VariableSmm.inf b/M= deModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf index 8c552b87e080..e2a59d90586b 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 @@ -84,6 +84,7 @@ [LibraryClasses] VariablePolicyLib=0D VariablePolicyHelperLib=0D SafeIntLib=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 f09bed40cf51..e473a12cd80e 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 @@ -80,6 +80,7 @@ [LibraryClasses] VariableFlashInfoLib=0D VariablePolicyLib=0D VariablePolicyHelperLib=0D + SmmCpuRendezvousLib=0D =0D [Protocols]=0D gEfiSmmFirmwareVolumeBlockProtocolGuid ## CONSUMES=0D --=20 2.26.2.windows.1