- edk2-OvmfPkg-EmuVariableFvbRuntimeDxe-fix-ValidateFvHeade.patch [RHEL-220548] - Resolves: RHEL-220548 ([RHEL 10.3] TDX Secure Boot Setup Mode with OVMF.inteltdx.secboot.fd)
105 lines
4.0 KiB
Diff
105 lines
4.0 KiB
Diff
From 731f7856dd9b8fe807a3b9c60f1888f8f114ba0c Mon Sep 17 00:00:00 2001
|
|
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
Date: Thu, 30 Jul 2026 10:44:31 +0200
|
|
Subject: [PATCH] OvmfPkg/EmuVariableFvbRuntimeDxe: fix ValidateFvHeader in tdx
|
|
mode.
|
|
|
|
RH-Author: Gerd Hoffmann <kraxel@redhat.com>
|
|
RH-MergeRequest: 115: OvmfPkg/EmuVariableFvbRuntimeDxe: fix ValidateFvHeader in tdx mode.
|
|
RH-Jira: RHEL-220548
|
|
RH-Acked-by: Luigi Leonardi <None>
|
|
RH-Commit: [1/1] df1ee44a2c9af76f327a9f6bbd7f8a0ce67f1fac (kraxel.rh/centos-src-edk2)
|
|
|
|
In TDX mode MmioRead* functions can not access memory, so avoid that.
|
|
See added source code comments for details.
|
|
|
|
Fixes: 0917ddad2529 ("OvmfPkg/EmuVariableFvbRuntimeDxe: avoid accessing varstore header with cmp")
|
|
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
|
Resolves: https://redhat.atlassian.net/browse/RHEL-220548
|
|
---
|
|
OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c | 41 +++++++++++++++++++++---
|
|
OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf | 1 +
|
|
2 files changed, 38 insertions(+), 4 deletions(-)
|
|
|
|
diff --git a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c
|
|
index 66e3929ec81..12b7fae2a1e 100644
|
|
--- a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c
|
|
+++ b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c
|
|
@@ -8,6 +8,9 @@
|
|
**/
|
|
|
|
#include "PiDxe.h"
|
|
+
|
|
+#include <ConfidentialComputingGuestAttr.h>
|
|
+
|
|
#include <Guid/EventGroup.h>
|
|
#include <Guid/SystemNvDataGuid.h>
|
|
#include <Guid/VariableFormat.h>
|
|
@@ -567,16 +570,46 @@ ValidateFvHeader (
|
|
)
|
|
{
|
|
UINT16 Checksum;
|
|
+ UINT8 Revision;
|
|
+ UINT32 Signature;
|
|
+ UINT64 FvLength;
|
|
+ UINT16 HeaderLength;
|
|
+
|
|
+ if (CC_GUEST_IS_TDX (PcdGet64 (PcdConfidentialComputingGuestAttr))) {
|
|
+ /*
|
|
+ * When in tdx mode the varstore must be in ram not pflash, so there are no
|
|
+ * mmio reads/writes needed. Also in tdx mode BaseIoLibIntrinsic will
|
|
+ * translate the mmio access into TDVMCALL_MMIO calls instead of mov
|
|
+ * instructions, so memory access with MmioRead* functions does not work.
|
|
+ */
|
|
+ Revision = FwVolHeader->Revision;
|
|
+ Signature = FwVolHeader->Signature;
|
|
+ FvLength = FwVolHeader->FvLength;
|
|
+ HeaderLength = FwVolHeader->HeaderLength;
|
|
+ } else {
|
|
+ /*
|
|
+ * In sev mode with varstore in pflash we must use MmioRead* functions so to
|
|
+ * make sure the mov instruction used to access pflash/memory is supported
|
|
+ * by the #VC handler instruction emulator.
|
|
+ *
|
|
+ * Note: Only sev + sev-es need proper pflash handling, sev-snp is like tdx
|
|
+ * incompatible with pflash emulation.
|
|
+ */
|
|
+ Revision = MmioRead8 ((UINTN)(&FwVolHeader->Revision));
|
|
+ Signature = MmioRead32 ((UINTN)(&FwVolHeader->Signature));
|
|
+ FvLength = MmioRead64 ((UINTN)(&FwVolHeader->FvLength));
|
|
+ HeaderLength = MmioRead16 ((UINTN)(&FwVolHeader->HeaderLength));
|
|
+ }
|
|
|
|
//
|
|
// Verify the header revision, header signature, length
|
|
// Length of FvBlock cannot be 2**64-1
|
|
// HeaderLength cannot be an odd number
|
|
//
|
|
- 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)
|
|
+ if ((Revision != EFI_FVH_REVISION) ||
|
|
+ (Signature != EFI_FVH_SIGNATURE) ||
|
|
+ (FvLength != EMU_FVB_SIZE) ||
|
|
+ (HeaderLength != EMU_FV_HEADER_LENGTH)
|
|
)
|
|
{
|
|
DEBUG ((DEBUG_INFO, "EMU Variable FVB: Basic FV headers were invalid\n"));
|
|
diff --git a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
|
|
index 396e6028b40..da1da9e0bd5 100644
|
|
--- a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
|
|
+++ b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf
|
|
@@ -63,6 +63,7 @@
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved
|
|
+ gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr
|
|
|
|
[Depex]
|
|
TRUE
|
|
--
|
|
2.52.0
|
|
|