OvmfPkg/EmuVariableFvbRuntimeDxe: avoid accessing varstore header with cmp

Use explicit MmioReadXX() calls to enforce use of instructions supported
by #VC exception handler emulator.  Does also work in case the varstore
header is located in RAM or ROM because x86 has no special mmio
instructions and non-x86 architectures do not use this code.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Gerd Hoffmann 2025-11-19 08:02:18 +01:00 committed by Ard Biesheuvel
parent a9309b6589
commit 0917ddad25

View file

@ -26,6 +26,7 @@
#include <Library/DevicePathLib.h>
#include <Library/PcdLib.h>
#include <Library/PlatformFvbLib.h>
#include <Library/IoLib.h>
#include "Fvb.h"
#define EFI_AUTHENTICATED_VARIABLE_GUID \
@ -572,10 +573,10 @@ ValidateFvHeader (
// 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 ((MmioRead8 ((UINTN)(&FwVolHeader->Revision)) != EFI_FVH_REVISION) ||
(MmioRead32 ((UINTN)(&FwVolHeader->Signature)) != EFI_FVH_SIGNATURE) ||
(MmioRead64 ((UINTN)(&FwVolHeader->FvLength)) != EMU_FVB_SIZE) ||
(MmioRead16 ((UINTN)(&FwVolHeader->HeaderLength)) != EMU_FV_HEADER_LENGTH)
)
{
DEBUG ((DEBUG_INFO, "EMU Variable FVB: Basic FV headers were invalid\n"));