From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by mx.groups.io with SMTP id smtpd.web08.10360.1634917620423800129 for ; Fri, 22 Oct 2021 08:47:00 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.136, mailfrom: guo.dong@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10145"; a="209428381" X-IronPort-AV: E=Sophos;i="5.87,173,1631602800"; d="scan'208";a="209428381" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 08:46:45 -0700 X-IronPort-AV: E=Sophos;i="5.87,173,1631602800"; d="scan'208";a="445333103" Received: from gdong1-mobl1.amr.corp.intel.com ([10.212.41.65]) by orsmga006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Oct 2021 08:46:45 -0700 From: "Guo Dong" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Maurice Ma , Benjamin You Subject: [`edk2-devel][PATCH V3 8/8] UefiPayloadPkg: Add SMM support and SMM variable support Date: Fri, 22 Oct 2021 08:46:27 -0700 Message-Id: <20211022154627.1607-9-guo.dong@intel.com> X-Mailer: git-send-email 2.32.0.windows.2 In-Reply-To: <20211022154627.1607-1-guo.dong@intel.com> References: <20211022154627.1607-1-guo.dong@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Guo Dong Add SMM variable support for universal UEFI payload. By default they are disabled. Signed-off-by: Guo Dong Cc: Ray Ni Cc: Maurice Ma Cc: Benjamin You Reviewed-by: Ray Ni Reviewed-by: Benjamin You --- UefiPayloadPkg/UefiPayloadPkg.dsc | 101 +++++++++++++++++++++++++++--- UefiPayloadPkg/UefiPayloadPkg.fdf | 38 ++++++++++- 2 files changed, 128 insertions(+), 11 deletions(-) diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayload= Pkg.dsc index 5aaae94eec..0df5f827c9 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dsc +++ b/UefiPayloadPkg/UefiPayloadPkg.dsc @@ -32,11 +32,12 @@ DEFINE SIO_BUS_ENABLE =3D FALSE=0D DEFINE UNIVERSAL_PAYLOAD =3D FALSE=0D DEFINE SECURITY_STUB_ENABLE =3D TRUE=0D + DEFINE SMM_SUPPORT =3D FALSE=0D #=0D # SBL: UEFI payload for Slim Bootloader=0D # COREBOOT: UEFI payload for coreboot=0D #=0D - DEFINE BOOTLOADER =3D SBL=0D + DEFINE BOOTLOADER =3D SBL=0D =0D #=0D # CPU options=0D @@ -90,7 +91,13 @@ #=0D DEFINE SHELL_TYPE =3D BUILD_SHELL=0D =0D - DEFINE EMU_VARIABLE_ENABLE =3D TRUE=0D + #=0D + # EMU: UEFI payload with EMU variable=0D + # SPI: UEFI payload with SPI NV variable support=0D + # NONE: UEFI payload with no variable modules=0D + #=0D + DEFINE VARIABLE_SUPPORT =3D EMU=0D +=0D DEFINE DISABLE_RESET_SYSTEM =3D FALSE=0D DEFINE NETWORK_DRIVER_ENABLE =3D FALSE=0D =0D @@ -241,10 +248,18 @@ LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf=0D FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf= =0D AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLib= Null.inf=0D +!if $(VARIABLE_SUPPORT) =3D=3D "EMU"=0D TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurem= entLibNull.inf=0D +!elseif $(VARIABLE_SUPPORT) =3D=3D "SPI"=0D + PlatformSecureLib|SecurityPkg/Library/PlatformSecureLibNull/PlatformSecu= reLibNull.inf=0D + TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasure= mentLib.inf=0D + S3BootScriptLib|MdePkg/Library/BaseS3BootScriptLibNull/BaseS3BootScriptL= ibNull.inf=0D + MmUnblockMemoryLib|MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibN= ull.inf=0D +!endif=0D VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf=0D VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyL= ib.inf=0D VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/Var= iablePolicyHelperLib.inf=0D + VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf=0D =0D [LibraryClasses.common.SEC]=0D HobLib|UefiPayloadPkg/Library/PayloadEntryHobLib/HobLib.inf=0D @@ -262,7 +277,6 @@ DebugAgentLib|SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.in= f=0D !endif=0D CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuE= xceptionHandlerLib.inf=0D - VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf=0D =0D [LibraryClasses.common.DXE_DRIVER]=0D PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf=0D @@ -274,7 +288,6 @@ !endif=0D CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuE= xceptionHandlerLib.inf=0D MpInitLib|UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf=0D - VmgExitLib|UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf=0D =0D [LibraryClasses.common.DXE_RUNTIME_DRIVER]=0D PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf=0D @@ -287,6 +300,37 @@ MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAll= ocationLib.inf=0D ReportStatusCodeLib|MdeModulePkg/Library/DxeReportStatusCodeLib/DxeRepor= tStatusCodeLib.inf=0D =0D +[LibraryClasses.common.SMM_CORE]=0D +!if $(SMM_SUPPORT) =3D=3D TRUE=0D + PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf=0D + SmmServicesTableLib|MdeModulePkg/Library/PiSmmCoreSmmServicesTableLib/Pi= SmmCoreSmmServicesTableLib.inf=0D +=0D + MemoryAllocationLib|MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/Pi= SmmCoreMemoryAllocationLib.inf=0D + SmmCorePlatformHookLib|MdeModulePkg/Library/SmmCorePlatformHookLibNull/S= mmCorePlatformHookLibNull.inf=0D + SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf=0D + ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseRepor= tStatusCodeLibNull.inf=0D +!endif=0D +=0D +[LibraryClasses.common.DXE_SMM_DRIVER]=0D +!if $(SMM_SUPPORT) =3D=3D TRUE=0D + PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf=0D +=0D + MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAlloc= ationLib.inf=0D + SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableL= ib.inf=0D + SmmMemLib|MdePkg/Library/SmmMemLib/SmmMemLib.inf=0D + MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.= inf=0D + DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.in= f=0D + SmmCpuPlatformHookLib|UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCp= uPlatformHookLibNull.inf=0D + SmmCpuFeaturesLib|UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib= .inf=0D + CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuE= xceptionHandlerLib.inf=0D + ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseRepor= tStatusCodeLibNull.inf=0D +!endif=0D +!if $(VARIABLE_SUPPORT) =3D=3D "SPI"=0D + SpiFlashLib|UefiPayloadPkg/Library/SpiFlashLib/SpiFlashLib.inf=0D + FlashDeviceLib|UefiPayloadPkg/Library/FlashDeviceLib/FlashDeviceLib.inf= =0D + BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf=0D +!endif=0D +=0D ##########################################################################= ######=0D #=0D # Pcd Section - list of all EDK II PCD Entries defined by this Platform.=0D @@ -300,15 +344,17 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdInstallAcpiSdtProtocol|TRUE=0D gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|FALSE=0D gEfiMdeModulePkgTokenSpaceGuid.PcdPciDegradeResourceForOptionRom|FALSE=0D + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmEnableBspElection|FALSE=0D =0D [PcdsFixedAtBuild]=0D gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize|0x10000=0D gEfiMdeModulePkgTokenSpaceGuid.PcdMaxHardwareErrorVariableSize|0x8000=0D gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize|0x10000=0D - #=0D - # Make VariableRuntimeDxe work at emulated non-volatile variable mode.=0D - #=0D - gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable|TRUE=0D +!if $(VARIABLE_SUPPORT) =3D=3D "EMU"=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable |TRUE=0D +!else=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable |FALSE= =0D +!endif=0D =0D gEfiMdeModulePkgTokenSpaceGuid.PcdVpdBaseAddress|0x0=0D gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseMemory|FALSE=0D @@ -319,6 +365,7 @@ !if $(SOURCE_DEBUG_ENABLE)=0D gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2=0D !endif=0D + gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmStackSize|0x4000=0D =0D [PcdsPatchableInModule.X64]=0D gPcAtChipsetPkgTokenSpaceGuid.PcdRtcIndexRegister|$(RTC_INDEX_REGISTER)= =0D @@ -390,6 +437,14 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase|0=0D gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase|0=0D gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|3=0D +!if $(VARIABLE_SUPPORT) =3D=3D "SPI"=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize |0=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize|0=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize |0=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase |0=0D +!endif=0D + # Disable SMM S3 script=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable|FALSE=0D =0D ## This PCD defines the video horizontal resolution.=0D # This PCD could be set to 0 then video resolution could be at highest = resolution.=0D @@ -579,6 +634,36 @@ !endif=0D UefiPayloadPkg/GraphicsOutputDxe/GraphicsOutputDxe.inf=0D =0D + #=0D + # SMM Support=0D + #=0D +!if $(SMM_SUPPORT) =3D=3D TRUE=0D + UefiPayloadPkg/SmmAccessDxe/SmmAccessDxe.inf=0D + UefiPayloadPkg/SmmControlRuntimeDxe/SmmControlRuntimeDxe.inf=0D + UefiPayloadPkg/BlSupportSmm/BlSupportSmm.inf=0D + MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf=0D + MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf=0D + UefiPayloadPkg/PchSmiDispatchSmm/PchSmiDispatchSmm.inf=0D + UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf=0D + UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf=0D +!endif=0D +=0D +!if $(VARIABLE_SUPPORT) =3D=3D "EMU"=0D + MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf=0D +!elseif $(VARIABLE_SUPPORT) =3D=3D "SPI"=0D + MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf {=0D + =0D + NULL|MdeModulePkg/Library/VarCheckUefiLib/VarCheckUefiLib.inf=0D + NULL|MdeModulePkg/Library/VarCheckHiiLib/VarCheckHiiLib.inf=0D + NULL|MdeModulePkg/Library/VarCheckPcdLib/VarCheckPcdLib.inf=0D + NULL|MdeModulePkg/Library/VarCheckPolicyLib/VarCheckPolicyLib.inf=0D + }=0D +=0D + UefiPayloadPkg/FvbRuntimeDxe/FvbSmm.inf=0D + MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.inf=0D + MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf=0D +!endif=0D +=0D #------------------------------=0D # Build the shell=0D #------------------------------=0D diff --git a/UefiPayloadPkg/UefiPayloadPkg.fdf b/UefiPayloadPkg/UefiPayload= Pkg.fdf index 72e4c70467..2f5cb17f62 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.fdf +++ b/UefiPayloadPkg/UefiPayloadPkg.fdf @@ -114,11 +114,29 @@ INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe= /MonotonicCounterRuntimeDxe !if $(DISABLE_RESET_SYSTEM) =3D=3D FALSE=0D INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf= =0D !endif=0D -=0D INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe= .inf=0D =0D -!if $(EMU_VARIABLE_ENABLE) =3D=3D TRUE=0D -INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf=0D +#=0D +# SMM Support=0D +#=0D +!if $(SMM_SUPPORT) =3D=3D TRUE=0D + INF UefiPayloadPkg/SmmAccessDxe/SmmAccessDxe.inf=0D + INF UefiPayloadPkg/SmmControlRuntimeDxe/SmmControlRuntimeDxe.inf=0D + INF UefiPayloadPkg/BlSupportSmm/BlSupportSmm.inf=0D + INF MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf=0D + INF MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf=0D + INF UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf=0D + INF UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf=0D + INF UefiPayloadPkg/PchSmiDispatchSmm/PchSmiDispatchSmm.inf=0D +!endif=0D +=0D +!if $(VARIABLE_SUPPORT) =3D=3D "EMU"=0D + INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf=0D +!elseif $(VARIABLE_SUPPORT) =3D=3D "SPI"=0D + INF UefiPayloadPkg/FvbRuntimeDxe/FvbSmm.inf=0D + INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteSmm.i= nf=0D + INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmm.inf=0D + INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf= =0D !endif=0D =0D INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf=0D @@ -271,6 +289,20 @@ INF ShellPkg/Application/Shell/Shell.inf UI STRING=3D"$(MODULE_NAME)" Optional=0D VERSION STRING=3D"$(INF_VERSION)" Optional BUILD_NUM=3D$(BUILD_NUMBER= )=0D }=0D +[Rule.Common.DXE_SMM_DRIVER]=0D + FILE SMM =3D $(NAMED_GUID) {=0D + SMM_DEPEX SMM_DEPEX Optional $(INF_OUTPUT)/$(MODULE_NAME).depex= =0D + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi=0D + UI STRING=3D"$(MODULE_NAME)" Optional=0D + VERSION STRING=3D"$(INF_VERSION)" Optional BUILD_NUM=3D$(BUILD_NUMBE= R)=0D + }=0D +=0D +[Rule.Common.SMM_CORE]=0D + FILE SMM_CORE =3D $(NAMED_GUID) {=0D + PE32 PE32 $(INF_OUTPUT)/$(MODULE_NAME).efi=0D + UI STRING=3D"$(MODULE_NAME)" Optional=0D + VERSION STRING=3D"$(INF_VERSION)" Optional BUILD_NUM=3D$(BUILD_NUMBER= )=0D + }=0D =0D [Rule.Common.UEFI_DRIVER]=0D FILE DRIVER =3D $(NAMED_GUID) {=0D --=20 2.32.0.windows.2