OvmfPkg/PlatformPei: Move NV vars init to after SEV-SNP memory acceptance

When OVMF is built with the SECURE_BOOT_ENABLE set to true, reserving and
initializing the emulated variable store happens before memory has been
accepted under SEV-SNP. This results in a #VC exception for accessing
memory that hasn't been validated (error code 0x404). The #VC handler
treats this error code as a fatal error, causing the OVMF boot to fail.

Move the call to ReserveEmuVariableNvStore() to after memory has been
accepted by AmdSevInitialize().

Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
This commit is contained in:
Tom Lendacky 2024-11-18 12:59:32 -06:00 committed by mergify[bot]
parent f0d2bc3ab2
commit 52fa7e78d2
1 changed files with 10 additions and 4 deletions

View File

@ -353,10 +353,6 @@ InitializePlatform (
InitializeRamRegions (PlatformInfoHob); InitializeRamRegions (PlatformInfoHob);
if (PlatformInfoHob->BootMode != BOOT_ON_S3_RESUME) { if (PlatformInfoHob->BootMode != BOOT_ON_S3_RESUME) {
if (!PlatformInfoHob->SmmSmramRequire) {
ReserveEmuVariableNvStore ();
}
PeiFvInitialization (PlatformInfoHob); PeiFvInitialization (PlatformInfoHob);
MemTypeInfoInitialization (PlatformInfoHob); MemTypeInfoInitialization (PlatformInfoHob);
MemMapInitialization (PlatformInfoHob); MemMapInitialization (PlatformInfoHob);
@ -378,5 +374,15 @@ InitializePlatform (
RelocateSmBase (); RelocateSmBase ();
} }
//
// Performed after CoCo (SEV/TDX) initialization to allow the memory
// used to be validated before being used.
//
if (PlatformInfoHob->BootMode != BOOT_ON_S3_RESUME) {
if (!PlatformInfoHob->SmmSmramRequire) {
ReserveEmuVariableNvStore ();
}
}
return EFI_SUCCESS; return EFI_SUCCESS;
} }