Hello Gred

On 11/19/2025 12:49 PM, Gerd Hoffmann wrote:
On Mon, Nov 10, 2025 at 03:20:13PM -0600, Tom Lendacky wrote:
What is occurring is ValidateFvHeader() is supplied the address from
PcdOvmfFlashNvStorageVariableBase, which is an MMIO address. A #VC is
generated when the code accesses this memory. However, the memory is
accessed with a CMP instruction, which is an unsupported MMIO
instruction, resulting in the assert.
Thanks for the analysis.  Does this help?

https://github.com/tianocore/edk2/pull/11770


That patch did not apply cleanly on current edk2 master[46548b1]. I could manually do the changes:


--- a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c
+++ b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c
@@ -565,17 +565,25 @@ ValidateFvHeader (
   IN EFI_FIRMWARE_VOLUME_HEADER  *FwVolHeader
   )
 {
-  UINT16  Checksum;
+  UINT16                      Checksum;
+  EFI_FIRMWARE_VOLUME_HEADER  Hdr;
+
+  //
+  // Instruction emulation in the #VC handler does not support cmp instructions. +  // So avoid accessing the header (which might be an mmio address) directly
+  // with cmp, copy to stack and compare fields in the copy instead.
+  //
+  CopyMem (&Hdr, FwVolHeader, sizeof (Hdr));

   //
   // Verify the header revision, header signature, length
   // Length of FvBlock cannot be 2**64-1
   // HeaderLength cannot be an odd number
   //
-  if ((FwVolHeader->Revision != EFI_FVH_REVISION) ||
-      (FwVolHeader->Signature != EFI_FVH_SIGNATURE) ||
-      (FwVolHeader->FvLength != EMU_FVB_SIZE) ||
-      (FwVolHeader->HeaderLength != EMU_FV_HEADER_LENGTH)
+  if ((Hdr.Revision != EFI_FVH_REVISION) ||
+      (Hdr.Signature != EFI_FVH_SIGNATURE) ||
+      (Hdr.FvLength != EMU_FVB_SIZE) ||
+      (Hdr.HeaderLength != EMU_FV_HEADER_LENGTH)
       )
   {
     DEBUG ((DEBUG_INFO, "EMU Variable FVB: Basic FV headers were invalid\n"));

Still SEV-ES guest boot crashes, with below trace:

InstallProtocolInterface: 5B1B31A1-9562-11D2-8E3F-00A0C969723B 7F0E41C0
Loading driver at 0x0007F6D4000 EntryPoint=0x0007F6D6642 EmuVariableFvbRuntimeDxe.efi
InstallProtocolInterface: BC62157E-3E33-4FEC-9920-2D3B36D750DF 7F0E4918
ProtectUefiImageCommon - 0x7F0E41C0
  - 0x000000007F6D4000 - 0x0000000000006000
EMU Variable FVB Started
EMU Variable FVB: Using pre-reserved block at 7FB7A000
EMU Variable FVB: Basic FV headers were invalid
Invalid MMIO opcode (A5)
ASSERT [CpuDxe] CcExitVcHandler.c(498): ((BOOLEAN)(0==1))



take care,
   Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#121686): https://edk2.groups.io/g/devel/message/121686
Mute This Topic: https://groups.io/mt/115616009/21656
Group Owner: [email protected]
Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to