NVRAM emulation has no other purpose than implementing S3 support. With S3 turned off in the VM configuration, this patch saves over 33 MB of guest RAM: the 0x01400000..0x03501000 range is not reserved any longer; see "OvmfPkg/PlatformPei/MemoryMap.txt".
The absence of SMRAM (which is part of the emulated NVRAM) automatically prevents: - loading of the SMM core, and the dependent SmmLockBox and DiscloseSmstSmm drivers, - installation of the EmuSmmPei driver, - installation of the EmuSmmDxe driver, - loading of the BootScriptExecutorDxe driver (via Depex, due to lack of SmmLockBox), - loading of the AcpiS3SaveDxe driver (ditto), - coverage of the NVRAM area with an EfiACPIMemoryNVS memory allocation HOB, in PeiFvInitialization() [OvmfPkg/PlatformPei/Fv.c], - installation of the cold-boot pemanent PEI memory above the NVRAM in PublishPeiMemory() [OvmfPkg/PlatformPei/MemDetect.c] -- it will be placed above the decompressed firmware image, same as before S3 was supported, - enforcement of the decompression scratch buffer falling below the NVRAM base address in DecompressGuidedFv() [OvmfPkg/Sec/SecMain.c]. The patch causes OVMF's SEC to depend on QemuFwCfgLib (via EmuNvramLib), which is where we rely on the new QemuFwCfgSecLib library instance. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <[email protected]> --- OvmfPkg/Library/EmuNvramLib/EmuNvramLib.inf | 1 + OvmfPkg/Library/EmuNvramLib/EmuNvramLib.c | 37 ++++++++++++++++++++++++++++- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/Library/EmuNvramLib/EmuNvramLib.inf b/OvmfPkg/Library/EmuNvramLib/EmuNvramLib.inf index d1d441a..73cd56b 100644 --- a/OvmfPkg/Library/EmuNvramLib/EmuNvramLib.inf +++ b/OvmfPkg/Library/EmuNvramLib/EmuNvramLib.inf @@ -33,6 +33,7 @@ [LibraryClasses] PcdLib DebugLib + QemuFwCfgLib [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdEmuNvramSmramSize diff --git a/OvmfPkg/Library/EmuNvramLib/EmuNvramLib.c b/OvmfPkg/Library/EmuNvramLib/EmuNvramLib.c index 364b070..7d3ab97 100644 --- a/OvmfPkg/Library/EmuNvramLib/EmuNvramLib.c +++ b/OvmfPkg/Library/EmuNvramLib/EmuNvramLib.c @@ -15,11 +15,34 @@ #include <Library/PcdLib.h> #include <Library/DebugLib.h> #include <Library/EmuNvramLib.h> +#include <Library/QemuFwCfgLib.h> + +/** + Detect if S3 support has been explicitly deactivated. + + @retval TRUE if S3 explicitly disabled, + @retval FALSE if firmware configuration unavailable, or S3 enabled. +*/ +STATIC +BOOLEAN +EFIAPI +IsS3Disabled ( + VOID + ) +{ + // + // Since this code can run in SEC, we must explicitly check for the + // availability of the firmware configuration interface. + // + return QemuFwCfgIsAvailable () && QemuFwCfgS3Disabled (); +} + /** Return the size of the NVRAM portion used for SMRAM emulation. @retval 0 if SMRAM emulation inside the NVRAM is disabled. + This includes the case when S3 has been explicitly disabled. @return Size otherwise. */ UINT32 @@ -28,6 +51,9 @@ EmuNvramSmramSize ( VOID ) { + if (IsS3Disabled ()) { + return 0; + } return PcdGet32 (PcdEmuNvramSmramSize); } @@ -36,7 +62,8 @@ EmuNvramSmramSize ( (system management system table). @retval 0 if the NVRAM doesn't provide such - storage, + storage (including the case when S3 has + been explicitly disabled), @retval sizeof(EFI_PHYSICAL_ADDRESS) if the storage is provided. */ UINT32 @@ -47,6 +74,9 @@ EmuNvramSmstPtrSize ( { UINT32 Size; + if (IsS3Disabled ()) { + return 0; + } Size = PcdGet32 (PcdEmuNvramSmstPtrSize); ASSERT (Size == 0 || Size == sizeof (EFI_PHYSICAL_ADDRESS)); return Size; @@ -56,6 +86,7 @@ EmuNvramSmstPtrSize ( Return the size of the NVRAM portion used for S3 Resume Pool emulation. @retval 0 if S3 Resume Pool emulation inside the NVRAM is disabled. + This includes the case when S3 has been explicitly disabled. @return Size otherwise. */ UINT32 @@ -64,6 +95,9 @@ EmuNvramS3ResumePoolSize ( VOID ) { + if (IsS3Disabled ()) { + return 0; + } return PcdGet32 (PcdEmuNvramS3ResumePoolSize); } @@ -71,6 +105,7 @@ EmuNvramS3ResumePoolSize ( Return the full (cumulative) size of the emulated NVRAM. @retval 0 if NVRAM emulation is disabled. + This includes the case when S3 has been explicitly disabled. @return Size otherwise. **/ UINT32 -- 1.8.3.1 ------------------------------------------------------------------------------ Rapidly troubleshoot problems before they affect your business. Most IT organizations don't have a clear picture of how application performance affects their revenue. With AppDynamics, you get 100% visibility into your Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro! http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk _______________________________________________ edk2-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/edk2-devel
