public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 1/1] ArmPkg: Add Pcd to disable EFI_MEMORY_ATTRIBUTE_PROTOCOL
@ 2023-06-19 20:32 Oliver Steffen
  2023-06-20  9:32 ` Gerd Hoffmann
  0 siblings, 1 reply; 11+ messages in thread
From: Oliver Steffen @ 2023-06-19 20:32 UTC (permalink / raw)
  To: devel
  Cc: Ard Biesheuvel, Daniel Schaefer, Eric Dong, Gerd Hoffmann,
	Leif Lindholm, Liming Gao, Michael D Kinney, Rahul Kumar, Ray Ni,
	Sami Mujawar, Sunil V L, Zhiguang Liu, Oliver Steffen

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


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-10-05 10:01 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-19 20:32 [PATCH 1/1] ArmPkg: Add Pcd to disable EFI_MEMORY_ATTRIBUTE_PROTOCOL Oliver Steffen
2023-06-20  9:32 ` 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

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