public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Oliver Steffen" <osteffen@redhat.com>
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Daniel Schaefer <git@danielschaefer.me>,
	Eric Dong <eric.dong@intel.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Leif Lindholm <quic_llindhol@quicinc.com>,
	Liming Gao <gaoliming@byosoft.com.cn>,
	Michael D Kinney <michael.d.kinney@intel.com>,
	Rahul Kumar <rahul1.kumar@intel.com>, Ray Ni <ray.ni@intel.com>,
	Sami Mujawar <sami.mujawar@arm.com>,
	Sunil V L <sunilvl@ventanamicro.com>,
	Zhiguang Liu <zhiguang.liu@intel.com>,
	Oliver Steffen <osteffen@redhat.com>
Subject: [PATCH 1/1] ArmPkg: Add Pcd to disable EFI_MEMORY_ATTRIBUTE_PROTOCOL
Date: Mon, 19 Jun 2023 22:32:25 +0200	[thread overview]
Message-ID: <20230619203244.228933-1-osteffen@redhat.com> (raw)

Recent versions of shim (15.6 and 15.7) crash when the newly added
EFI_MEMORY_ATTRIBUTE_PROTOCOL is provided by the firmware.  To allow
existing installations to boot, provide a workaround in form of a Pcd
that allows tuning it off at build time (defaults to 'enabled').

Additionally, check the return code of the protocol installation calls.

Signed-off-by: Oliver Steffen <osteffen@redhat.com>
---
PR: https://github.com/tianocore/edk2/pull/4560
---
 ArmPkg/ArmPkg.dec                |  3 +++
 ArmPkg/Drivers/CpuDxe/CpuDxe.inf |  1 +
 ArmPkg/Drivers/CpuDxe/CpuDxe.c   | 13 +++++++++++--
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/ArmPkg/ArmPkg.dec b/ArmPkg/ArmPkg.dec
index 1a16d044c94b..bd612c8c4b93 100644
--- a/ArmPkg/ArmPkg.dec
+++ b/ArmPkg/ArmPkg.dec
@@ -172,6 +172,9 @@ [PcdsFixedAtBuild.common]
   gArmTokenSpaceGuid.PcdCpuVectorBaseAddress|0xffff0000|UINT64|0x00000004
   gArmTokenSpaceGuid.PcdCpuResetAddress|0x00000000|UINT32|0x00000005
 
+  # Enable/Disable EFI_MEMORY_ATTRIBUTE_PROTOCOL
+  gArmTokenSpaceGuid.PcdEnableEfiMemoryAttributeProtocol|TRUE|BOOLEAN|0x000000EE
+
   #
   # ARM Secure Firmware PCDs
   #
diff --git a/ArmPkg/Drivers/CpuDxe/CpuDxe.inf b/ArmPkg/Drivers/CpuDxe/CpuDxe.inf
index 7d8132200e64..feb4f28b65f1 100644
--- a/ArmPkg/Drivers/CpuDxe/CpuDxe.inf
+++ b/ArmPkg/Drivers/CpuDxe/CpuDxe.inf
@@ -66,6 +66,7 @@ [Guids]
 [Pcd.common]
   gArmTokenSpaceGuid.PcdVFPEnabled
   gEfiMdeModulePkgTokenSpaceGuid.PcdDxeNxMemoryProtectionPolicy
+  gArmTokenSpaceGuid.PcdEnableEfiMemoryAttributeProtocol
 
 [FeaturePcd.common]
   gArmTokenSpaceGuid.PcdDebuggerExceptionSupport
diff --git a/ArmPkg/Drivers/CpuDxe/CpuDxe.c b/ArmPkg/Drivers/CpuDxe/CpuDxe.c
index f820f3f62189..927b91bde36e 100644
--- a/ArmPkg/Drivers/CpuDxe/CpuDxe.c
+++ b/ArmPkg/Drivers/CpuDxe/CpuDxe.c
@@ -329,10 +329,19 @@ CpuDxeInitialize (
                   &mCpuHandle,
                   &gEfiCpuArchProtocolGuid,
                   &mCpu,
-                  &gEfiMemoryAttributeProtocolGuid,
-                  &mMemoryAttribute,
                   NULL
                   );
+  ASSERT_EFI_ERROR (Status);
+
+  if (PcdGetBool (PcdEnableEfiMemoryAttributeProtocol)) {
+    Status = gBS->InstallMultipleProtocolInterfaces (
+                    &mCpuHandle,
+                    &gEfiMemoryAttributeProtocolGuid,
+                    &mMemoryAttribute,
+                    NULL
+                    );
+    ASSERT_EFI_ERROR (Status);
+  }
 
   //
   // Make sure GCD and MMU settings match. This API calls gDS->SetMemorySpaceAttributes ()
-- 
2.41.0


             reply	other threads:[~2023-06-19 20:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-19 20:32 Oliver Steffen [this message]
2023-06-20  9:32 ` [PATCH 1/1] ArmPkg: Add Pcd to disable EFI_MEMORY_ATTRIBUTE_PROTOCOL Gerd Hoffmann
2023-06-20 13:16   ` Ard Biesheuvel
2023-06-20 14:53     ` [edk2-devel] " Michael Kubacki
2023-06-20 16:03     ` Gerd Hoffmann
2023-06-20 17:06       ` [edk2-devel] " Sean
2023-06-23 16:26         ` Ard Biesheuvel
2023-06-23 19:32           ` Sean
2023-10-05  6:31       ` Nhi Pham via groups.io
2023-10-05  8:23         ` Laszlo Ersek
2023-10-05 10:01           ` Gerd Hoffmann

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-list 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=20230619203244.228933-1-osteffen@redhat.com \
    --to=devel@edk2.groups.io \
    /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