[`edk2-devel][PATCH V3 0/8] Add SMM variable support for UEFI payload


Guo Dong
 

From: Guo Dong <guo.dong@intel.com>

V3: Add SMM communication region EFI_ALLOCATED check
in UefiPayloadPkg/BlSupportSmm/BlSupportSmm.c
V2: Added SMM communication region size check
Fixed ECC reported issues and other minor update.

https://bugzilla.tianocore.org/show_bug.cgi?id=3084

Currently UEFI payload uses emulated variable driver. So it could
not support secureboot and measured boot since both need NV variable
support.

EDKII already has SMM modules and variable modules. And modern Intel
platform supports SPI flash hardware sequence to operate flash. So it
is possible to have a common SPI module for Intel platforms.

This patch enhances UEFI payload to support SMM variable with a
common SPI library for Intel platforms. To avoid impact existing
usage, all the new modules are included under SMM_ENABLE and
VARIABLE_SUPPORT and by default SMM variable is not be enabled.

SMM variable could be enabled only when UNIVERSAL_PAYLOAD is set
since non-universal payload need update ParseLib to provide SMM
variable related infromation which is not in the plan.

Signed-off-by: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Benjamin You <benjamin.you@intel.com

Guo Dong (8):
UefiPayloadPkg: Add a common SmmAccessDxe module
UefiPayloadPkg: Add a common SMM control Runtime DXE module
UefiPayloadPkg: Add bootloader SMM support module
UefiPayloadPkg: Add SpiFlashLib
UefiPayloadPkg: Add FlashDeviceLib
UefiPayloadPkg: Add a common FVB SMM module
UefiPayloadPkg: Add a SMM dispatch module
UefiPayloadPkg: Add SMM support and SMM variable support

UefiPayloadPkg/BlSupportSmm/BlSupportSmm.c | 431 +++++++
UefiPayloadPkg/BlSupportSmm/BlSupportSmm.h | 41 +
UefiPayloadPkg/BlSupportSmm/BlSupportSmm.inf | 49 +
UefiPayloadPkg/FvbRuntimeDxe/FvbInfo.c | 151 +++
UefiPayloadPkg/FvbRuntimeDxe/FvbService.c | 1088 +++++++++++++++++
UefiPayloadPkg/FvbRuntimeDxe/FvbService.h | 187 +++
UefiPayloadPkg/FvbRuntimeDxe/FvbServiceSmm.c | 139 +++
UefiPayloadPkg/FvbRuntimeDxe/FvbSmm.inf | 71 ++
UefiPayloadPkg/FvbRuntimeDxe/FvbSmmCommon.h | 69 ++
.../Include/Guid/NvVariableInfoGuid.h | 24 +
.../Include/Guid/SmmRegisterInfoGuid.h | 48 +
.../Include/Guid/SmmS3CommunicationInfoGuid.h | 54 +
.../Include/Guid/SpiFlashInfoGuid.h | 38 +
.../Include/Library/FlashDeviceLib.h | 108 ++
UefiPayloadPkg/Include/Library/SpiFlashLib.h | 215 ++++
.../Library/FlashDeviceLib/FlashDeviceLib.c | 165 +++
.../Library/FlashDeviceLib/FlashDeviceLib.inf | 38 +
UefiPayloadPkg/Library/SpiFlashLib/PchSpi.c | 173 +++
UefiPayloadPkg/Library/SpiFlashLib/RegsSpi.h | 129 ++
.../Library/SpiFlashLib/SpiCommon.h | 208 ++++
.../Library/SpiFlashLib/SpiFlashLib.c | 857 +++++++++++++
.../Library/SpiFlashLib/SpiFlashLib.inf | 48 +
.../PchSmiDispatchSmm/PchSmiDispatchSmm.c | 455 +++++++
.../PchSmiDispatchSmm/PchSmiDispatchSmm.h | 37 +
.../PchSmiDispatchSmm/PchSmiDispatchSmm.inf | 51 +
UefiPayloadPkg/SmmAccessDxe/SmmAccessDxe.c | 254 ++++
UefiPayloadPkg/SmmAccessDxe/SmmAccessDxe.h | 37 +
UefiPayloadPkg/SmmAccessDxe/SmmAccessDxe.inf | 51 +
.../SmmControlRuntimeDxe.c | 256 ++++
.../SmmControlRuntimeDxe.inf | 50 +
UefiPayloadPkg/UefiPayloadPkg.dec | 10 +
UefiPayloadPkg/UefiPayloadPkg.dsc | 101 +-
UefiPayloadPkg/UefiPayloadPkg.fdf | 38 +-
33 files changed, 5660 insertions(+), 11 deletions(-)
create mode 100644 UefiPayloadPkg/BlSupportSmm/BlSupportSmm.c
create mode 100644 UefiPayloadPkg/BlSupportSmm/BlSupportSmm.h
create mode 100644 UefiPayloadPkg/BlSupportSmm/BlSupportSmm.inf
create mode 100644 UefiPayloadPkg/FvbRuntimeDxe/FvbInfo.c
create mode 100644 UefiPayloadPkg/FvbRuntimeDxe/FvbService.c
create mode 100644 UefiPayloadPkg/FvbRuntimeDxe/FvbService.h
create mode 100644 UefiPayloadPkg/FvbRuntimeDxe/FvbServiceSmm.c
create mode 100644 UefiPayloadPkg/FvbRuntimeDxe/FvbSmm.inf
create mode 100644 UefiPayloadPkg/FvbRuntimeDxe/FvbSmmCommon.h
create mode 100644 UefiPayloadPkg/Include/Guid/NvVariableInfoGuid.h
create mode 100644 UefiPayloadPkg/Include/Guid/SmmRegisterInfoGuid.h
create mode 100644 UefiPayloadPkg/Include/Guid/SmmS3CommunicationInfoGuid.h
create mode 100644 UefiPayloadPkg/Include/Guid/SpiFlashInfoGuid.h
create mode 100644 UefiPayloadPkg/Include/Library/FlashDeviceLib.h
create mode 100644 UefiPayloadPkg/Include/Library/SpiFlashLib.h
create mode 100644 UefiPayloadPkg/Library/FlashDeviceLib/FlashDeviceLib.c
create mode 100644 UefiPayloadPkg/Library/FlashDeviceLib/FlashDeviceLib.inf
create mode 100644 UefiPayloadPkg/Library/SpiFlashLib/PchSpi.c
create mode 100644 UefiPayloadPkg/Library/SpiFlashLib/RegsSpi.h
create mode 100644 UefiPayloadPkg/Library/SpiFlashLib/SpiCommon.h
create mode 100644 UefiPayloadPkg/Library/SpiFlashLib/SpiFlashLib.c
create mode 100644 UefiPayloadPkg/Library/SpiFlashLib/SpiFlashLib.inf
create mode 100644 UefiPayloadPkg/PchSmiDispatchSmm/PchSmiDispatchSmm.c
create mode 100644 UefiPayloadPkg/PchSmiDispatchSmm/PchSmiDispatchSmm.h
create mode 100644 UefiPayloadPkg/PchSmiDispatchSmm/PchSmiDispatchSmm.inf
create mode 100644 UefiPayloadPkg/SmmAccessDxe/SmmAccessDxe.c
create mode 100644 UefiPayloadPkg/SmmAccessDxe/SmmAccessDxe.h
create mode 100644 UefiPayloadPkg/SmmAccessDxe/SmmAccessDxe.inf
create mode 100644 UefiPayloadPkg/SmmControlRuntimeDxe/SmmControlRuntimeDxe.c
create mode 100644 UefiPayloadPkg/SmmControlRuntimeDxe/SmmControlRuntimeDxe.inf

--
2.32.0.windows.2


Benjamin You
 

Reviewed-by: Benjamin You <benjamin.you@intel.com>

-----Original Message-----
From: Dong, Guo <guo.dong@intel.com>
Sent: Friday, October 22, 2021 11:46 PM
To: devel@edk2.groups.io
Cc: Dong, Guo <guo.dong@intel.com>; Ni, Ray <ray.ni@intel.com>; Ma,
Maurice <maurice.ma@intel.com>; You, Benjamin <benjamin.you@intel.com>
Subject: [`edk2-devel][PATCH V3 0/8] Add SMM variable support for UEFI
payload

From: Guo Dong <guo.dong@intel.com>

V3: Add SMM communication region EFI_ALLOCATED check
in UefiPayloadPkg/BlSupportSmm/BlSupportSmm.c
V2: Added SMM communication region size check
Fixed ECC reported issues and other minor update.

https://bugzilla.tianocore.org/show_bug.cgi?id=3084

Currently UEFI payload uses emulated variable driver. So it could
not support secureboot and measured boot since both need NV variable
support.

EDKII already has SMM modules and variable modules. And modern Intel
platform supports SPI flash hardware sequence to operate flash. So it
is possible to have a common SPI module for Intel platforms.

This patch enhances UEFI payload to support SMM variable with a
common SPI library for Intel platforms. To avoid impact existing
usage, all the new modules are included under SMM_ENABLE and
VARIABLE_SUPPORT and by default SMM variable is not be enabled.

SMM variable could be enabled only when UNIVERSAL_PAYLOAD is set
since non-universal payload need update ParseLib to provide SMM
variable related infromation which is not in the plan.

Signed-off-by: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Benjamin You <benjamin.you@intel.com

Guo Dong (8):
UefiPayloadPkg: Add a common SmmAccessDxe module
UefiPayloadPkg: Add a common SMM control Runtime DXE module
UefiPayloadPkg: Add bootloader SMM support module
UefiPayloadPkg: Add SpiFlashLib
UefiPayloadPkg: Add FlashDeviceLib
UefiPayloadPkg: Add a common FVB SMM module
UefiPayloadPkg: Add a SMM dispatch module
UefiPayloadPkg: Add SMM support and SMM variable support

UefiPayloadPkg/BlSupportSmm/BlSupportSmm.c | 431 +++++++
UefiPayloadPkg/BlSupportSmm/BlSupportSmm.h | 41 +
UefiPayloadPkg/BlSupportSmm/BlSupportSmm.inf | 49 +
UefiPayloadPkg/FvbRuntimeDxe/FvbInfo.c | 151 +++
UefiPayloadPkg/FvbRuntimeDxe/FvbService.c | 1088 +++++++++++++++++
UefiPayloadPkg/FvbRuntimeDxe/FvbService.h | 187 +++
UefiPayloadPkg/FvbRuntimeDxe/FvbServiceSmm.c | 139 +++
UefiPayloadPkg/FvbRuntimeDxe/FvbSmm.inf | 71 ++
UefiPayloadPkg/FvbRuntimeDxe/FvbSmmCommon.h | 69 ++
.../Include/Guid/NvVariableInfoGuid.h | 24 +
.../Include/Guid/SmmRegisterInfoGuid.h | 48 +
.../Include/Guid/SmmS3CommunicationInfoGuid.h | 54 +
.../Include/Guid/SpiFlashInfoGuid.h | 38 +
.../Include/Library/FlashDeviceLib.h | 108 ++
UefiPayloadPkg/Include/Library/SpiFlashLib.h | 215 ++++
.../Library/FlashDeviceLib/FlashDeviceLib.c | 165 +++
.../Library/FlashDeviceLib/FlashDeviceLib.inf | 38 +
UefiPayloadPkg/Library/SpiFlashLib/PchSpi.c | 173 +++
UefiPayloadPkg/Library/SpiFlashLib/RegsSpi.h | 129 ++
.../Library/SpiFlashLib/SpiCommon.h | 208 ++++
.../Library/SpiFlashLib/SpiFlashLib.c | 857 +++++++++++++
.../Library/SpiFlashLib/SpiFlashLib.inf | 48 +
.../PchSmiDispatchSmm/PchSmiDispatchSmm.c | 455 +++++++
.../PchSmiDispatchSmm/PchSmiDispatchSmm.h | 37 +
.../PchSmiDispatchSmm/PchSmiDispatchSmm.inf | 51 +
UefiPayloadPkg/SmmAccessDxe/SmmAccessDxe.c | 254 ++++
UefiPayloadPkg/SmmAccessDxe/SmmAccessDxe.h | 37 +
UefiPayloadPkg/SmmAccessDxe/SmmAccessDxe.inf | 51 +
.../SmmControlRuntimeDxe.c | 256 ++++
.../SmmControlRuntimeDxe.inf | 50 +
UefiPayloadPkg/UefiPayloadPkg.dec | 10 +
UefiPayloadPkg/UefiPayloadPkg.dsc | 101 +-
UefiPayloadPkg/UefiPayloadPkg.fdf | 38 +-
33 files changed, 5660 insertions(+), 11 deletions(-)
create mode 100644 UefiPayloadPkg/BlSupportSmm/BlSupportSmm.c
create mode 100644 UefiPayloadPkg/BlSupportSmm/BlSupportSmm.h
create mode 100644 UefiPayloadPkg/BlSupportSmm/BlSupportSmm.inf
create mode 100644 UefiPayloadPkg/FvbRuntimeDxe/FvbInfo.c
create mode 100644 UefiPayloadPkg/FvbRuntimeDxe/FvbService.c
create mode 100644 UefiPayloadPkg/FvbRuntimeDxe/FvbService.h
create mode 100644 UefiPayloadPkg/FvbRuntimeDxe/FvbServiceSmm.c
create mode 100644 UefiPayloadPkg/FvbRuntimeDxe/FvbSmm.inf
create mode 100644 UefiPayloadPkg/FvbRuntimeDxe/FvbSmmCommon.h
create mode 100644 UefiPayloadPkg/Include/Guid/NvVariableInfoGuid.h
create mode 100644 UefiPayloadPkg/Include/Guid/SmmRegisterInfoGuid.h
create mode 100644
UefiPayloadPkg/Include/Guid/SmmS3CommunicationInfoGuid.h
create mode 100644 UefiPayloadPkg/Include/Guid/SpiFlashInfoGuid.h
create mode 100644 UefiPayloadPkg/Include/Library/FlashDeviceLib.h
create mode 100644 UefiPayloadPkg/Include/Library/SpiFlashLib.h
create mode 100644 UefiPayloadPkg/Library/FlashDeviceLib/FlashDeviceLib.c
create mode 100644 UefiPayloadPkg/Library/FlashDeviceLib/FlashDeviceLib.inf
create mode 100644 UefiPayloadPkg/Library/SpiFlashLib/PchSpi.c
create mode 100644 UefiPayloadPkg/Library/SpiFlashLib/RegsSpi.h
create mode 100644 UefiPayloadPkg/Library/SpiFlashLib/SpiCommon.h
create mode 100644 UefiPayloadPkg/Library/SpiFlashLib/SpiFlashLib.c
create mode 100644 UefiPayloadPkg/Library/SpiFlashLib/SpiFlashLib.inf
create mode 100644
UefiPayloadPkg/PchSmiDispatchSmm/PchSmiDispatchSmm.c
create mode 100644
UefiPayloadPkg/PchSmiDispatchSmm/PchSmiDispatchSmm.h
create mode 100644
UefiPayloadPkg/PchSmiDispatchSmm/PchSmiDispatchSmm.inf
create mode 100644 UefiPayloadPkg/SmmAccessDxe/SmmAccessDxe.c
create mode 100644 UefiPayloadPkg/SmmAccessDxe/SmmAccessDxe.h
create mode 100644 UefiPayloadPkg/SmmAccessDxe/SmmAccessDxe.inf
create mode 100644
UefiPayloadPkg/SmmControlRuntimeDxe/SmmControlRuntimeDxe.c
create mode 100644
UefiPayloadPkg/SmmControlRuntimeDxe/SmmControlRuntimeDxe.inf

--
2.32.0.windows.2