The same trick is used as for the original NvVars emulation; the allocation is done early so that it ends up at an invariant address across warm reboot.
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <ler...@redhat.com> --- OvmfPkg/PlatformPei/PlatformPei.inf | 2 ++ OvmfPkg/PlatformPei/Platform.c | 25 +++++++++++++++++++++++++ OvmfPkg/OvmfPkg.dec | 11 +++++++++++ 3 files changed, 38 insertions(+) diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf index 7fe9d47..8811542 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -61,6 +61,8 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfMemFvSize gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress + gUefiOvmfPkgTokenSpaceGuid.PcdEmuSmmAreaSize + gUefiOvmfPkgTokenSpaceGuid.PcdEmuSmmAreaBase gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index 7363702..4bce240 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -373,6 +373,30 @@ ReserveEmuVariableNvStore ( VOID +ReserveEmuSmmArea ( + VOID + ) +{ + UINT32 AreaSize; + VOID *Address; + + AreaSize = PcdGet32 (PcdEmuSmmAreaSize); + if (AreaSize == 0) { + return; + } + + // + // We use the same trick here as in ReserveEmuVariableNvStore(). This area + // expressly doesn't need to survive cold reboots, only S3 Suspend and + // Resume. + // + Address = AllocateRuntimePool (AreaSize); + ASSERT (Address != NULL); + PcdSet64 (PcdEmuSmmAreaBase, (UINT64)(UINTN) Address); +} + + +VOID DebugDumpCmos ( VOID ) @@ -433,6 +457,7 @@ InitializePlatform ( } ReserveEmuVariableNvStore (); + ReserveEmuSmmArea (); PeiFvInitialization (); diff --git a/OvmfPkg/OvmfPkg.dec b/OvmfPkg/OvmfPkg.dec index 9d7fedf..21105ad 100644 --- a/OvmfPkg/OvmfPkg.dec +++ b/OvmfPkg/OvmfPkg.dec @@ -69,6 +69,11 @@ gUefiOvmfPkgTokenSpaceGuid.PcdVirtioScsiMaxTargetLimit|31|UINT16|6 gUefiOvmfPkgTokenSpaceGuid.PcdVirtioScsiMaxLunLimit|7|UINT32|7 + ## This PCD determines the size of the runtime pool allocation that we + # reserve in PlatformPei as backing store for EmuSmmDxe (ie. SMRAM + # emulation). Zero size disables SMRAM emulation. + gUefiOvmfPkgTokenSpaceGuid.PcdEmuSmmAreaSize|0x00100000|UINT32|0x11 + [PcdsFixedAtBuild] gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogBase|0x0|UINT32|0x8 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageEventLogSize|0x0|UINT32|0x9 @@ -83,5 +88,11 @@ gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable|FALSE|BOOLEAN|0x10 + ## The following PCD carries from PlatformPei to EmuSmmDxe the base address + # of the runtime pool allocation that we reserve as backing store for SMRAM + # emulation. Its type cannot be VOID* because PEI and DXE can have different + # bitnesses. + gUefiOvmfPkgTokenSpaceGuid.PcdEmuSmmAreaBase|0x0|UINT64|0x12 + [PcdsFeatureFlag] gUefiOvmfPkgTokenSpaceGuid.PcdSecureBootEnable|FALSE|BOOLEAN|3 -- 1.8.3.1 ------------------------------------------------------------------------------ Sponsored by Intel(R) XDK Develop, test and display web and hybrid apps with a single code base. Download it for free now! http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk _______________________________________________ edk2-devel mailing list edk2-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-devel