From 1506c6da7bb6820beb1a1170909f181b69d63c8a Mon Sep 17 00:00:00 2001 From: Jakov Zauzolkov Date: Tue, 30 Jun 2026 09:47:21 +0200 Subject: [PATCH] OvmfPkg: Replace BaseAcpiTimerLib with BaseRomAcpiTimerLib in PEI The BaseAcpiTimerLib instance contains a static global variable, 'mAcpiTimerIoAddr', that caches the ACPI timer IO base address. As this library executes during PEI phase prior to the PEIFV measurement into PCR0, the value of the variable is included into the measurement. This causes the PEIFV binary footprint to change, preventing a precomputation of the expected value needed for remote attestation. Fix this by using the BaseRomAcpiTimerLib in the PEI phase instead of the BaseAcpiTimerLib. This library dynamically computes the required address and does not introduce global variables, keeping the PEIFV binary unchanged. Co-authored-by: Simon Ott Signed-off-by: Jakov Zauzolkov --- OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf | 2 +- OvmfPkg/OvmfPkgIa32X64.dsc | 2 ++ OvmfPkg/OvmfPkgX64.dsc | 2 ++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf b/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf index 8f9bedbfe2..99ea20e829 100644 --- a/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf +++ b/OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf @@ -13,7 +13,7 @@ FILE_GUID = CDD9D74F-213E-4c28-98F7-8B4A167DB936 MODULE_TYPE = BASE VERSION_STRING = 1.0 - LIBRARY_CLASS = TimerLib|SEC + LIBRARY_CLASS = TimerLib|SEC PEI_CORE PEIM CONSTRUCTOR = AcpiTimerLibConstructor [Sources] diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index aacf6b6f9b..2119527c1c 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -297,6 +297,7 @@ MemDebugLogLib|OvmfPkg/Library/MemDebugLogLib/MemDebugLogPeiCoreLib.inf !endif PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf + TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf [LibraryClasses.common.PEIM] HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf @@ -325,6 +326,7 @@ MpInitLib|UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/PeiQemuFwCfgS3LibFwCfg.inf PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf + TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf PlatformInitLib|OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index d4b3cff7fd..098c8cd464 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -329,6 +329,7 @@ !endif PeCoffLib|MdePkg/Library/BasePeCoffLib/BasePeCoffLib.inf CcProbeLib|OvmfPkg/Library/CcProbeLib/SecPeiCcProbeLib.inf + TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf [LibraryClasses.common.PEIM] HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf @@ -357,6 +358,7 @@ MpInitLib|UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf QemuFwCfgS3Lib|OvmfPkg/Library/QemuFwCfgS3Lib/PeiQemuFwCfgS3LibFwCfg.inf PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf + TimerLib|OvmfPkg/Library/AcpiTimerLib/BaseRomAcpiTimerLib.inf QemuFwCfgLib|OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf PlatformInitLib|OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf