public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/edk2] rawhide: cherry-pick one more tdx fix
Date: Wed, 05 Aug 2026 10:30:22 GMT	[thread overview]
Message-ID: <178592582243.1.4901520666728064677.rpms-edk2-1c16af00ceef@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/edk2
            Branch : rawhide
            Commit : 1c16af00ceefea521f34e9be5ec5ee3ea75618e4
            Author : Gerd Hoffmann <kraxel@redhat.com>
            Date   : 2026-08-04T17:18:19+02:00
            Stats  : +81/-0 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/edk2/c/1c16af00ceefea521f34e9be5ec5ee3ea75618e4?branch=rawhide

            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

                 reply	other threads:[~2026-08-05 10:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178592582243.1.4901520666728064677.rpms-edk2-1c16af00ceef@fedoraproject.org \
    --to=kraxel@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox