public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/edk2] f44: cherry-pick one more tdx fix
@ 2026-08-05 11:03 Gerd Hoffmann
  0 siblings, 0 replies; only message in thread
From: Gerd Hoffmann @ 2026-08-05 11:03 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/edk2
            Branch : f44
            Commit : 60151018a25e9ae89de0e97a6e7d9e2838f7d1fd
            Author : Gerd Hoffmann <kraxel@redhat.com>
            Date   : 2026-08-05T13:03:13+02:00
            Stats  : +81/-0 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/edk2/c/60151018a25e9ae89de0e97a6e7d9e2838f7d1fd?branch=f44

            Log:
            cherry-pick one more tdx fix

Resolves: rhbz#2508383

---
diff --git a/0023-OvmfPkg-PlatformInitLib-restore-below-4G-low-memory-.patch b/0023-OvmfPkg-PlatformInitLib-restore-below-4G-low-memory-.patch
new file mode 100644
index 0000000..30d0bc1
--- /dev/null
+++ b/0023-OvmfPkg-PlatformInitLib-restore-below-4G-low-memory-.patch
@@ -0,0 +1,80 @@
+From c329ada8988685230cb1c56f8ad8baf34e8494f3 Mon Sep 17 00:00:00 2001
+From: Stanislaw Grams <stanislaw.grams@intel.com>
+Date: Fri, 3 Jul 2026 13:31:38 +0200
+Subject: [PATCH 23/23] OvmfPkg/PlatformInitLib: restore below-4G low memory
+ detection for TDVF
+
+Commit 0a0919607c ("OvmfPkg/PlatformInitLib: redefine low memory") narrowed
+PlatformGetLowMemoryCB() to consider only the first below-4G memory block
+whose base address is zero. The change was intended to fix SVSM guests,
+where SVSM caves a chunk out of below-4G RAM and OVMF must not stray into
+that hole.
+
+TDVF, however, reports its below-4G RAM through the TdHob as two adjacent
+resource descriptors:
+
+  [0, 0x800000)              EFI_RESOURCE_SYSTEM_MEMORY   (pre-accepted)
+  [0x800000, ~4G)            EFI_RESOURCE_MEMORY_UNACCEPTED
+
+PlatformScanE820Tdx() surfaces both as EfiAcpiAddressRangeMemory E820
+entries. After 0a0919607c only the first, tiny 8 MiB block is picked up,
+so PlatformInfoHob->LowMemory becomes 0x800000.
+In OvmfPkg/PlatformPei/MemDetect.c PublishPeiMemory() this drives:
+
+  LowerMemorySize = 0x00800000            // LowMemory
+  PeiMemoryCap    = 0x04F82000            // ~81 MiB
+  MemoryBase      = LowerMemorySize - PeiMemoryCap   // UINT32 underflow
+                  = 0xFB87E000
+
+Permanent PEI memory is then published at 0xFB87E000, which is not backed
+by RAM. TemporaryRamMigration()'s first CopyMem into that phantom range
+(observed as 0xFB898000 in the failing log) faults, tearing down the TD.
+
+Fold adjacent below-4G memory blocks into the low-memory span: accept an
+entry whose base equals the current LowMemory and advance LowMemory by
+its length. LowMemory starts at zero, so the first accepted block at
+address 0 still starts the sequence; non-adjacent above-4G or SVSM-carved
+blocks continue to be skipped (their base does not match LowMemory); and
+the TDVF accepted+unaccepted pair, which is contiguous, is now grouped
+correctly.
+
+Co-authored-by: Gerd Hoffmann <kraxel@redhat.com>
+Signed-off-by: Stanislaw Grams <stanislaw.grams@intel.com>
+---
+ OvmfPkg/Library/PlatformInitLib/MemDetect.c | 10 +++++++---
+ 1 file changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/PlatformInitLib/MemDetect.c
+index 3a2c974e087c..611cad986738 100644
+--- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c
++++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c
+@@ -164,6 +164,10 @@ PlatformGetFirstNonAddressCB (
+   there are multiple memory blocks below 4G though, because SVSM caves out a
+   chunk of memory for itself.  Only the first of these blocks is considered
+   low memory.
++
++  Multiple blocks without gap inbetween are grouped together.
++  This is required for TDX which has two low memory descriptors
++  (accepted and unaccepted).
+ **/
+ STATIC
+ VOID
+@@ -176,12 +180,12 @@ PlatformGetLowMemoryCB (
+     return;
+   }
+ 
+-  if (E820Entry->BaseAddr != 0) {
++  if (E820Entry->BaseAddr != PlatformInfoHob->LowMemory) {
+     return;
+   }
+ 
+-  DEBUG ((DEBUG_INFO, "%a: LowMemory=0x%Lx\n", __func__, E820Entry->Length));
+-  PlatformInfoHob->LowMemory = (UINT32)E820Entry->Length;
++  PlatformInfoHob->LowMemory += (UINT32)E820Entry->Length;
++  DEBUG ((DEBUG_INFO, "%a: LowMemory=0x%Lx\n", __func__, PlatformInfoHob->LowMemory));
+ }
+ 
+ /**
+-- 
+2.55.0
+

diff --git a/edk2.spec b/edk2.spec
index b424f2e..8197c31 100644
--- a/edk2.spec
+++ b/edk2.spec
@@ -146,6 +146,7 @@ Patch0019: 0019-CryptoPkg-TlsLib-downgrade-security-level-from-3-to-.patch
 Patch0020: 0020-OvmfPkg-PlatformDxe-proper-addr-masking.patch
 Patch0021: 0021-OvmfPkg-EmuVariableFvbRuntimeDxe-fix-ValidateFvHeade.patch
 Patch0022: 0022-OvmfPkg-IntelTdx-Move-BootManagerMenuApp-from-NCCFV-.patch
+Patch0023: 0023-OvmfPkg-PlatformInitLib-restore-below-4G-low-memory-.patch
 
 
 # needed by %prep

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-05 11:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-05 11:03 [rpms/edk2] f44: cherry-pick one more tdx fix Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox