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] f45: backport arm tpm fix
Date: Mon, 30 Nov 2026 14:17:49 GMT	[thread overview]
Message-ID: <179604826912.1.9244788229248051991.rpms-edk2-bd59916e2ef9@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/edk2
            Branch : f45
            Commit : bd59916e2ef94518df3f4162ece06638358fb116
            Author : Gerd Hoffmann <kraxel@redhat.com>
            Date   : 2026-11-30T15:17:35+01:00
            Stats  : +116/-0 in 2 file(s)
            URL    : https://src.fedoraproject.org/rpms/edk2/c/bd59916e2ef94518df3f4162ece06638358fb116?branch=f45

            Log:
            backport arm tpm fix

Resolves: rhbz#2585802

---
diff --git a/0028-ArmVirtPkg-PlatformPeiLib-Map-the-TPM-MMIO-region.patch b/0028-ArmVirtPkg-PlatformPeiLib-Map-the-TPM-MMIO-region.patch
new file mode 100644
index 0000000..9ed3f88
--- /dev/null
+++ b/0028-ArmVirtPkg-PlatformPeiLib-Map-the-TPM-MMIO-region.patch
@@ -0,0 +1,115 @@
+From b491b7249754e8f8313ea9df4925d2939c7c7a4c Mon Sep 17 00:00:00 2001
+From: Luigi Leonardi <leonardi@redhat.com>
+Date: Fri, 27 Nov 2026 15:48:56 +0100
+Subject: [PATCH 28/28] ArmVirtPkg/PlatformPeiLib: Map the TPM MMIO region
+
+Commit 158c1b614b ("ArmVirtPkg: Refactor virtual memory mapping for
+qemu guest firmware") stopped mapping the mach-virt peripheral window,
+which included the TPM. As a result, when building with TPM2 support
+and running with a TPM attached, Tcg2ConfigPei faults on the first
+TPM register access and the firmware hangs.
+
+Map the TPM region as device memory right after discovering it, before
+installing the PPI that lets the TPM PEIMs run. To get its size, also
+parse the size cells of the 'reg' property.
+
+Fixes: 158c1b614bb0 ("ArmVirtPkg: Refactor virtual memory mapping for qemu guest firmware")
+Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
+---
+ .../Library/PlatformPeiLib/PlatformPeiLib.inf |  2 ++
+ .../Library/PlatformPeiLib/PlatformPeiLib.c   | 25 ++++++++++++++++---
+ 2 files changed, 24 insertions(+), 3 deletions(-)
+
+diff --git a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf
+index e818fc793c61..28def0ceb9bc 100644
+--- a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf
++++ b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.inf
+@@ -25,12 +25,14 @@ [Packages]
+   MdePkg/MdePkg.dec
+   OvmfPkg/OvmfPkg.dec
+   SecurityPkg/SecurityPkg.dec
++  UefiCpuPkg/UefiCpuPkg.dec
+ 
+ [FeaturePcd]
+   gArmVirtTokenSpaceGuid.PcdTpm2SupportEnabled
+ 
+ [LibraryClasses]
+   ArmCcaInitPeiLib
++  ArmMmuLib
+   BaseLib
+   BaseMemoryLib
+   DebugLib
+diff --git a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c
+index b61e407ef0be..90981bf767e2 100644
+--- a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c
++++ b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c
+@@ -9,8 +9,10 @@
+ **/
+ 
+ #include <PiPei.h>
++#include <Uefi/UefiSpec.h>
+ 
+ #include <Library/ArmCcaInitPeiLib.h>
++#include <Library/ArmMmuLib.h>
+ #include <Library/BaseLib.h>
+ #include <Library/BaseMemoryLib.h>
+ #include <Library/MemoryAllocationLib.h>
+@@ -273,6 +275,7 @@ PlatformPeim (
+   CONST UINT64              *RegProp;
+   CONST UINT32              *RangesProp;
+   UINT64                    TpmBase;
++  UINT64                    TpmSize;
+   EFI_STATUS                Status;
+   CHAR8                     DebugLevelBuf[32];
+   UINTN                     DebugLevelBufSize;
+@@ -368,6 +371,7 @@ PlatformPeim (
+                                  );
+ 
+   TpmBase = 0;
++  TpmSize = 0;
+ 
+   //
+   // Set Parent to suppress incorrect compiler/analyzer warnings.
+@@ -398,9 +402,11 @@ PlatformPeim (
+         RegProp = FdtGetProp (Base, Node, "reg", &Len);
+         ASSERT (Len == 8 || Len == 16);
+         if (Len == 8) {
+-          TpmBase = Fdt32ToCpu (RegProp[0]);
++          TpmBase = Fdt32ToCpu (((CONST UINT32 *)RegProp)[0]);
++          TpmSize = Fdt32ToCpu (((CONST UINT32 *)RegProp)[1]);
+         } else if (Len == 16) {
+-          TpmBase = Fdt64ToCpu (ReadUnaligned64 ((UINT64 *)RegProp));
++          TpmBase = Fdt64ToCpu (ReadUnaligned64 (RegProp));
++          TpmSize = Fdt64ToCpu (ReadUnaligned64 (RegProp + 1));
+         }
+ 
+         if (Depth > 1) {
+@@ -452,11 +458,24 @@ PlatformPeim (
+ 
+   if (FeaturePcdGet (PcdTpm2SupportEnabled)) {
+     if (TpmBase != 0) {
+-      DEBUG ((DEBUG_INFO, "%a: TPM @ 0x%lx\n", __func__, TpmBase));
++      DEBUG ((
++        DEBUG_INFO,
++        "%a: TPM @ 0x%lx (size 0x%lx)\n",
++        __func__,
++        TpmBase,
++        TpmSize
++        ));
+ 
+       Status = (EFI_STATUS)PcdSet64S (PcdTpmBaseAddress, TpmBase);
+       ASSERT_EFI_ERROR (Status);
+ 
++      //
++      // The TPM is not covered by the PEI memory map, so map it before the
++      // TPM PEIMs access it.
++      //
++      Status = ArmSetMemoryAttributes (TpmBase, TpmSize, EFI_MEMORY_UC, 0);
++      ASSERT_EFI_ERROR (Status);
++
+       Status = PeiServicesInstallPpi (&mTpm2DiscoveredPpi);
+     } else {
+       Status = PeiServicesInstallPpi (&mTpm2InitializationDonePpi);
+-- 
+2.56.1
+

diff --git a/edk2.spec b/edk2.spec
index ed95d38..21ff8bf 100644
--- a/edk2.spec
+++ b/edk2.spec
@@ -154,6 +154,7 @@ Patch0024: 0024-SecurityPkg-AuthVariableLib-add-CheckSignatureListFo.patch
 Patch0025: 0025-SecurityPkg-AuthVariableLib-move-SigList-SignatureSi.patch
 Patch0026: 0026-SecurityPkg-AuthVariableLib-verify-signature-count-f.patch
 Patch0027: 0027-ArmVirtPkg-QemuVirtMemInfoLib-Map-two-PL011-UARTs-in.patch
+Patch0028: 0028-ArmVirtPkg-PlatformPeiLib-Map-the-TPM-MMIO-region.patch
 
 
 # needed by %prep

                 reply	other threads:[~2026-11-30 14:17 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=179604826912.1.9244788229248051991.rpms-edk2-bd59916e2ef9@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