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 <osde@linux.microsoft.com>
This commit is contained in:
Oliver Smith-Denny 2024-07-19 12:33:49 -07:00 committed by mergify[bot]
parent c5582e435c
commit 37287bf9ad

View File

@ -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;
}