- Rebase to edk2-stable202502 [RHEL-75592] - Resolves: RHEL-75592 (rebase to edk2-stable202502) - Resulves: RHEL-82646 (fix typo in fwcfg file name) - Resolves: RHEL-82837 (The newer revocation file and Server 2025 required to update it)
124 lines
4.1 KiB
Diff
124 lines
4.1 KiB
Diff
From fce5a29e2fe628ff3be48634295de6f287dcab6d Mon Sep 17 00:00:00 2001
|
|
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
Date: Thu, 16 Jan 2025 17:20:38 +0100
|
|
Subject: [PATCH] OvmfPkg/X64: add opt/org.tianocore/UninstallMemAttrProtocol
|
|
support (RH only)
|
|
|
|
Add support for opt/org.tianocore/UninstallMemAttrProtocol, to allow
|
|
turning off EFI_MEMORY_ATTRIBUTE_PROTOCOL, simliar to ArmVirtPkg.
|
|
|
|
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
---
|
|
.../PlatformBootManagerLib/BdsPlatform.c | 63 +++++++++++++++++++
|
|
.../PlatformBootManagerLib.inf | 2 +
|
|
2 files changed, 65 insertions(+)
|
|
|
|
diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
|
|
index 9efdb1ce72..1a55342f43 100644
|
|
--- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
|
|
+++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
|
|
@@ -1840,6 +1840,49 @@ SaveS3BootScript (
|
|
ASSERT_EFI_ERROR (Status);
|
|
}
|
|
|
|
+/**
|
|
+ Uninstall the EFI memory attribute protocol if it exists.
|
|
+**/
|
|
+STATIC
|
|
+VOID
|
|
+UninstallEfiMemoryAttributesProtocol (
|
|
+ VOID
|
|
+ )
|
|
+{
|
|
+ EFI_STATUS Status;
|
|
+ EFI_HANDLE Handle;
|
|
+ UINTN Size;
|
|
+ VOID *MemoryAttributeProtocol;
|
|
+
|
|
+ Size = sizeof (Handle);
|
|
+ Status = gBS->LocateHandle (
|
|
+ ByProtocol,
|
|
+ &gEfiMemoryAttributeProtocolGuid,
|
|
+ NULL,
|
|
+ &Size,
|
|
+ &Handle
|
|
+ );
|
|
+
|
|
+ if (EFI_ERROR (Status)) {
|
|
+ ASSERT (Status == EFI_NOT_FOUND);
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ Status = gBS->HandleProtocol (
|
|
+ Handle,
|
|
+ &gEfiMemoryAttributeProtocolGuid,
|
|
+ &MemoryAttributeProtocol
|
|
+ );
|
|
+ ASSERT_EFI_ERROR (Status);
|
|
+
|
|
+ Status = gBS->UninstallProtocolInterface (
|
|
+ Handle,
|
|
+ &gEfiMemoryAttributeProtocolGuid,
|
|
+ MemoryAttributeProtocol
|
|
+ );
|
|
+ ASSERT_EFI_ERROR (Status);
|
|
+}
|
|
+
|
|
/**
|
|
Do the platform specific action after the console is ready
|
|
|
|
@@ -1860,6 +1903,7 @@ PlatformBootManagerAfterConsole (
|
|
)
|
|
{
|
|
EFI_BOOT_MODE BootMode;
|
|
+ BOOLEAN Uninstall;
|
|
|
|
DEBUG ((DEBUG_INFO, "PlatformBootManagerAfterConsole\n"));
|
|
|
|
@@ -1906,6 +1950,25 @@ PlatformBootManagerAfterConsole (
|
|
//
|
|
StoreQemuBootOrder ();
|
|
|
|
+ //
|
|
+ // Work around shim's terminally broken use of the EFI memory attributes
|
|
+ // protocol, by uninstalling it if requested on the QEMU command line.
|
|
+ //
|
|
+ // E.g.,
|
|
+ // -fw_cfg opt/org.tianocore/UninstallMemAttrProtocol,string=y
|
|
+ //
|
|
+ Uninstall = FixedPcdGetBool (PcdUninstallMemAttrProtocol);
|
|
+ QemuFwCfgParseBool ("opt/org.tianocore/UninstallMemAttrProtocol", &Uninstall);
|
|
+ DEBUG ((
|
|
+ DEBUG_WARN,
|
|
+ "%a: %auninstalling EFI memory protocol\n",
|
|
+ __func__,
|
|
+ Uninstall ? "" : "not "
|
|
+ ));
|
|
+ if (Uninstall) {
|
|
+ UninstallEfiMemoryAttributesProtocol ();
|
|
+ }
|
|
+
|
|
//
|
|
// Process QEMU's -kernel command line option
|
|
//
|
|
diff --git a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
|
|
index 3a70feb30e..7f5cc256c7 100644
|
|
--- a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
|
|
+++ b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
|
|
@@ -66,6 +66,7 @@
|
|
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable
|
|
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
|
|
gUefiOvmfPkgTokenSpaceGuid.PcdBootRestrictToFirmware
|
|
+ gUefiOvmfPkgTokenSpaceGuid.PcdUninstallMemAttrProtocol
|
|
gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiS3Enable
|
|
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
|
|
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate ## CONSUMES
|
|
@@ -85,6 +86,7 @@
|
|
gEfiLoadedImageProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
|
|
gEfiFirmwareVolume2ProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
|
|
gEfiRngProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
|
|
+ gEfiMemoryAttributeProtocolGuid
|
|
|
|
[Guids]
|
|
gEfiEndOfDxeEventGroupGuid
|