* [PATCH v3 1/1] MdeModulePkg: Use SmmWaitForAllProcessor() in VariableSmm driver.
@ 2022-05-31 16:27 Li, Zhihao
2022-06-02 2:16 ` 回复: " gaoliming
0 siblings, 1 reply; 2+ messages in thread
From: Li, Zhihao @ 2022-05-31 16:27 UTC (permalink / raw)
To: devel; +Cc: Jian J Wang, Liming Gao, Ni Ray
From: Zhihao Li <zhihao.li@intel.com>
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3854
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 <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Ni Ray <ray.ni@intel.com>
Signed-off-by: Zhihao Li <zhihao.li@intel.com>
---
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/MdeModulePkg/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(), ReclaimForOS(),
SmmVariableGetStatistics() should also do validation based on its own knowledge.
-Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2010 - 2022, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -28,6 +28,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/MmServicesTableLib.h>
#include <Library/VariablePolicyLib.h>
+#include <Library/SmmCpuRendezvousLib.h>
#include <Guid/SmmVariableCommon.h>
#include "Variable.h"
@@ -656,6 +657,13 @@ SmmVariableHandler (
goto EXIT;
}
+ if ((SmmVariableHeader->Attributes & EFI_VARIABLE_NON_VOLATILE) != 0) {
+ if (EFI_ERROR (SmmWaitForAllProcessor (TRUE))) {
+ DEBUG ((DEBUG_ERROR, "SetVariable: fail to wait for all AP check in SMM!\n"));
+ goto EXIT;
+ }
+ }
+
Status = VariableServiceSetVariable (
SmmVariableHeader->Name,
&SmmVariableHeader->Guid,
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
#
# (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
-# Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.<BR>
# Copyright (c) Microsoft Corporation.
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -152,6 +152,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf
SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
+ SmmCpuRendezvousLib|MdePkg/Library/SmmCpuRendezvousLibNull/SmmCpuRendezvousLibNull.inf
[LibraryClasses.common.UEFI_DRIVER]
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
@@ -172,6 +173,7 @@ [LibraryClasses.common.MM_STANDALONE]
MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.inf
MemLib|StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf
+ SmmCpuRendezvousLib|MdePkg/Library/SmmCpuRendezvousLibNull/SmmCpuRendezvousLibNull.inf
[LibraryClasses.ARM, LibraryClasses.AARCH64]
ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf b/MdeModulePkg/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,
# the authentication service provided in this driver will be broken, and the behavior is undefined.
#
-# Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2010 - 2022, Intel Corporation. All rights reserved.<BR>
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -82,6 +82,7 @@ [LibraryClasses]
UefiBootServicesTableLib
VariablePolicyLib
VariablePolicyHelperLib
+ SmmCpuRendezvousLib
[Protocols]
gEfiSmmFirmwareVolumeBlockProtocolGuid ## CONSUMES
diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.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,
# the authentication service provided in this driver will be broken, and the behavior is undefined.
#
-# Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2010 - 2022, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -78,6 +78,7 @@ [LibraryClasses]
VarCheckLib
VariablePolicyLib
VariablePolicyHelperLib
+ SmmCpuRendezvousLib
[Protocols]
gEfiSmmFirmwareVolumeBlockProtocolGuid ## CONSUMES
--
2.26.2.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* 回复: [PATCH v3 1/1] MdeModulePkg: Use SmmWaitForAllProcessor() in VariableSmm driver.
2022-05-31 16:27 [PATCH v3 1/1] MdeModulePkg: Use SmmWaitForAllProcessor() in VariableSmm driver Li, Zhihao
@ 2022-06-02 2:16 ` gaoliming
0 siblings, 0 replies; 2+ messages in thread
From: gaoliming @ 2022-06-02 2:16 UTC (permalink / raw)
To: 'zhihaoli', devel; +Cc: 'Jian J Wang', 'Ni Ray'
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
One minor comment: the change in MdeModulePkg is not required, because this library instance has been specified in MdeLibs.dsc.inc
Thanks
Liming
> -----邮件原件-----
> 发件人: zhihaoli <zhihao.li@intel.com>
> 发送时间: 2022年6月1日 0:27
> 收件人: devel@edk2.groups.io
> 抄送: Jian J Wang <jian.j.wang@intel.com>; Liming Gao
> <gaoliming@byosoft.com.cn>; Ni Ray <ray.ni@intel.com>
> 主题: [PATCH v3 1/1] MdeModulePkg: Use SmmWaitForAllProcessor() in
> VariableSmm driver.
>
> From: Zhihao Li <zhihao.li@intel.com>
>
> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3854
>
> 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 <jian.j.wang@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
> Cc: Ni Ray <ray.ni@intel.com>
>
> Signed-off-by: Zhihao Li <zhihao.li@intel.com>
> ---
> 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/MdeModulePkg/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(),
> ReclaimForOS(),
>
> SmmVariableGetStatistics() should also do validation based on its own
> knowledge.
>
>
>
> -Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
>
> +Copyright (c) 2010 - 2022, Intel Corporation. All rights reserved.<BR>
>
> Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
>
> SPDX-License-Identifier: BSD-2-Clause-Patent
>
>
>
> @@ -28,6 +28,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
>
>
> #include <Library/MmServicesTableLib.h>
>
> #include <Library/VariablePolicyLib.h>
>
> +#include <Library/SmmCpuRendezvousLib.h>
>
>
>
> #include <Guid/SmmVariableCommon.h>
>
> #include "Variable.h"
>
> @@ -656,6 +657,13 @@ SmmVariableHandler (
> goto EXIT;
>
> }
>
>
>
> + if ((SmmVariableHeader->Attributes &
> EFI_VARIABLE_NON_VOLATILE) != 0) {
>
> + if (EFI_ERROR (SmmWaitForAllProcessor (TRUE))) {
>
> + DEBUG ((DEBUG_ERROR, "SetVariable: fail to wait for all AP
> check in SMM!\n"));
>
> + goto EXIT;
>
> + }
>
> + }
>
> +
>
> Status = VariableServiceSetVariable (
>
> SmmVariableHeader->Name,
>
> &SmmVariableHeader->Guid,
>
> 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
>
> #
>
> # (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>
>
> -# Copyright (c) 2007 - 2021, Intel Corporation. All rights reserved.<BR>
>
> +# Copyright (c) 2007 - 2022, Intel Corporation. All rights reserved.<BR>
>
> # Copyright (c) Microsoft Corporation.
>
> #
>
> # SPDX-License-Identifier: BSD-2-Clause-Patent
>
> @@ -152,6 +152,7 @@ [LibraryClasses.common.DXE_SMM_DRIVER]
>
> SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTa
> bleLib.inf
>
>
> LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.i
> nf
>
> SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf
>
> +
> SmmCpuRendezvousLib|MdePkg/Library/SmmCpuRendezvousLibNull/SmmC
> puRendezvousLibNull.inf
>
>
>
> [LibraryClasses.common.UEFI_DRIVER]
>
> HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
>
> @@ -172,6 +173,7 @@ [LibraryClasses.common.MM_STANDALONE]
>
> MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/Stand
> aloneMmServicesTableLib.inf
>
>
> LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandalon
> eMmLib.inf
>
>
> MemLib|StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMm
> MemLib.inf
>
> +
> SmmCpuRendezvousLib|MdePkg/Library/SmmCpuRendezvousLibNull/SmmC
> puRendezvousLibNull.inf
>
>
>
> [LibraryClasses.ARM, LibraryClasses.AARCH64]
>
> ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
>
> diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf
> b/MdeModulePkg/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,
>
> # the authentication service provided in this driver will be broken, and the
> behavior is undefined.
>
> #
>
> -# Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
>
> +# Copyright (c) 2010 - 2022, Intel Corporation. All rights reserved.<BR>
>
> # Copyright (c) Microsoft Corporation.
>
> # SPDX-License-Identifier: BSD-2-Clause-Patent
>
> #
>
> @@ -82,6 +82,7 @@ [LibraryClasses]
> UefiBootServicesTableLib
>
> VariablePolicyLib
>
> VariablePolicyHelperLib
>
> + SmmCpuRendezvousLib
>
>
>
> [Protocols]
>
> gEfiSmmFirmwareVolumeBlockProtocolGuid ## CONSUMES
>
> diff --git
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.in
> f
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.in
> f
> index d8c4f77e7f1f..595baaf70164 100644
> ---
> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.in
> f
> +++
> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableStandaloneMm.in
> f
> @@ -18,7 +18,7 @@
> # may not be modified without authorization. If platform fails to protect
> these resources,
>
> # the authentication service provided in this driver will be broken, and the
> behavior is undefined.
>
> #
>
> -# Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
>
> +# Copyright (c) 2010 - 2022, Intel Corporation. All rights reserved.<BR>
>
> # Copyright (c) 2018, Linaro, Ltd. All rights reserved.<BR>
>
> # Copyright (c) Microsoft Corporation.
>
> # SPDX-License-Identifier: BSD-2-Clause-Patent
>
> @@ -78,6 +78,7 @@ [LibraryClasses]
> VarCheckLib
>
> VariablePolicyLib
>
> VariablePolicyHelperLib
>
> + SmmCpuRendezvousLib
>
>
>
> [Protocols]
>
> gEfiSmmFirmwareVolumeBlockProtocolGuid ## CONSUMES
>
> --
> 2.26.2.windows.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-02 2:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-05-31 16:27 [PATCH v3 1/1] MdeModulePkg: Use SmmWaitForAllProcessor() in VariableSmm driver Li, Zhihao
2022-06-02 2:16 ` 回复: " gaoliming
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox