summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/PlatformPei
diff options
context:
space:
mode:
authorMin M Xu <min.m.xu@intel.com>2022-06-22 09:08:41 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2022-09-06 07:21:42 +0000
commit58eb8517ad7b56574f8f04b770a59a9cbed796c4 (patch)
treec5044a46a296ea54a8d3200786a51392ed7e31e9 /OvmfPkg/PlatformPei
parent4f173db8b45b97563e83847cdff45e6690561482 (diff)
downloadedk2-58eb8517ad7b56574f8f04b770a59a9cbed796c4.tar.gz
edk2-58eb8517ad7b56574f8f04b770a59a9cbed796c4.tar.bz2
edk2-58eb8517ad7b56574f8f04b770a59a9cbed796c4.zip
OvmfPkg/PlatformPei: Update ReserveEmuVariableNvStore
ReserveEmuVariableNvStore is updated with below 2 functions defined in PlatformInitLib: - PlatformReserveEmuVariableNvStore - PlatformInitEmuVariableNvStore PlatformInitEmuVariableNvStore works when secure boot feature is enabled. This is because secure boot needs the EFI variables (PK/KEK/DB/DBX, etc) and EmuVariableNvStore is cleared when OVMF is launched with -bios parameter. Cc: Erdem Aktas <erdemaktas@google.com> Cc: James Bottomley <jejb@linux.ibm.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Tom Lendacky <thomas.lendacky@amd.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Min Xu <min.m.xu@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Diffstat (limited to 'OvmfPkg/PlatformPei')
-rw-r--r--OvmfPkg/PlatformPei/Platform.c25
1 files changed, 7 insertions, 18 deletions
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index 009db67ee6..b1f8140d60 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -220,24 +220,13 @@ ReserveEmuVariableNvStore (
EFI_PHYSICAL_ADDRESS VariableStore;
RETURN_STATUS PcdStatus;
- //
- // Allocate storage for NV variables early on so it will be
- // at a consistent address. Since VM memory is preserved
- // across reboots, this allows the NV variable storage to survive
- // a VM reboot.
- //
- VariableStore =
- (EFI_PHYSICAL_ADDRESS)(UINTN)
- AllocateRuntimePages (
- EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize))
- );
- DEBUG ((
- DEBUG_INFO,
- "Reserved variable store memory: 0x%lX; size: %dkb\n",
- VariableStore,
- (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024
- ));
- PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);
+ VariableStore = (EFI_PHYSICAL_ADDRESS)(UINTN)PlatformReserveEmuVariableNvStore ();
+ PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);
+
+ #ifdef SECURE_BOOT_FEATURE_ENABLED
+ PlatformInitEmuVariableNvStore ((VOID *)(UINTN)VariableStore);
+ #endif
+
ASSERT_RETURN_ERROR (PcdStatus);
}