From 37287bf9add9edbfbc0dac9a66f8f2a3112e3ce8 Mon Sep 17 00:00:00 2001 From: Oliver Smith-Denny Date: Fri, 19 Jul 2024 12:33:49 -0700 Subject: [PATCH] ArmPkg: CpuDxe: Add Memory Attribute Protocol Logging The memory attribute protocol is primarily used by bootloaders and there are many released bootloaders who use the protocol incorrectly. It is challenging to debug these situations because the bootloaders are generally black boxes and we silently fail on the FW side. This patch adds logging to some common memory attribute protocol failures in CpuDxe. Signed-off-by: Oliver Smith-Denny --- ArmPkg/Drivers/CpuDxe/MemoryAttribute.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ArmPkg/Drivers/CpuDxe/MemoryAttribute.c b/ArmPkg/Drivers/CpuDxe/MemoryAttribute.c index 16cc4ef474..c77feb848c 100644 --- a/ArmPkg/Drivers/CpuDxe/MemoryAttribute.c +++ b/ArmPkg/Drivers/CpuDxe/MemoryAttribute.c @@ -82,6 +82,13 @@ GetMemoryAttributes ( EFI_STATUS Status; if ((Length == 0) || (Attributes == NULL)) { + DEBUG (( + DEBUG_ERROR, + "%a: BaseAddress 0x%llx Length 0x%llx is zero or Attributes is NULL\n", + __func__, + BaseAddress, + Length + )); return EFI_INVALID_PARAMETER; } @@ -195,6 +202,13 @@ SetMemoryAttributes ( if ((Length == 0) || ((Attributes & ~(EFI_MEMORY_RO | EFI_MEMORY_RP | EFI_MEMORY_XP)) != 0)) { + DEBUG (( + DEBUG_ERROR, + "%a: BaseAddress 0x%llx Length is zero or Attributes (0x%llx) is invalid\n", + __func__, + BaseAddress, + Attributes + )); return EFI_INVALID_PARAMETER; } @@ -256,6 +270,13 @@ ClearMemoryAttributes ( if ((Length == 0) || ((Attributes & ~(EFI_MEMORY_RO | EFI_MEMORY_RP | EFI_MEMORY_XP)) != 0)) { + DEBUG (( + DEBUG_ERROR, + "%a: BaseAddress 0x%llx Length is zero or Attributes (0x%llx) is invalid\n", + __func__, + BaseAddress, + Attributes + )); return EFI_INVALID_PARAMETER; }