Skip to content

Commit 58eb851

Browse files
mxu9mergify[bot]
authored andcommitted
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>
1 parent 4f173db commit 58eb851

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

OvmfPkg/PlatformPei/Platform.c

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -220,24 +220,13 @@ ReserveEmuVariableNvStore (
220220
EFI_PHYSICAL_ADDRESS VariableStore;
221221
RETURN_STATUS PcdStatus;
222222

223-
//
224-
// Allocate storage for NV variables early on so it will be
225-
// at a consistent address. Since VM memory is preserved
226-
// across reboots, this allows the NV variable storage to survive
227-
// a VM reboot.
228-
//
229-
VariableStore =
230-
(EFI_PHYSICAL_ADDRESS)(UINTN)
231-
AllocateRuntimePages (
232-
EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize))
233-
);
234-
DEBUG ((
235-
DEBUG_INFO,
236-
"Reserved variable store memory: 0x%lX; size: %dkb\n",
237-
VariableStore,
238-
(2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024
239-
));
240-
PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);
223+
VariableStore = (EFI_PHYSICAL_ADDRESS)(UINTN)PlatformReserveEmuVariableNvStore ();
224+
PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);
225+
226+
#ifdef SECURE_BOOT_FEATURE_ENABLED
227+
PlatformInitEmuVariableNvStore ((VOID *)(UINTN)VariableStore);
228+
#endif
229+
241230
ASSERT_RETURN_ERROR (PcdStatus);
242231
}
243232

0 commit comments

Comments
 (0)