[PATCH] arm64: efi: Make runtime region misalignment warning less noisy

Ard Biesheuvel ardb at kernel.org
Sat Nov 5 15:52:33 PDT 2022


The EFI spec requires that on arm64 systems, all runtime code and data
regions that share a 64k page can be mapped with the same memory type
attributes. Unfortunately, this does not take permission attributes into
account, and so the firmware is permitted to expose runtime code and
data regions that share 64k pages, and this may prevent the OS from
using restricted permissions in such cases, e.g., map data regions with
non-exec attributes.

We currently emit a warning when hitting this at boot, but the warning
is problematic for a number of reasons:
- it uses WARN() which spews a lot of irrelevant information into the
  log about the execution context where the issue was detected;
- it only takes the start of the region into account and not the size

Let's just drop the warning, as the condition does not strictly violate
the spec (although it only occurs with U-Boot), and fix the check to
take both the start and the end addresses into account.

Cc: Heinrich Schuchardt <heinrich.schuchardt at canonical.com>
Cc: Ilias Apalodimas <ilias.apalodimas at linaro.org>
Reported-by: Linus Torvalds <torvalds at linux-foundation.org>
Signed-off-by: Ard Biesheuvel <ardb at kernel.org>
---
 arch/arm64/kernel/efi.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/kernel/efi.c b/arch/arm64/kernel/efi.c
index e1be6c429810d0d5..3dd6f0c66f8aeb78 100644
--- a/arch/arm64/kernel/efi.c
+++ b/arch/arm64/kernel/efi.c
@@ -25,8 +25,8 @@ static __init pteval_t create_mapping_protection(efi_memory_desc_t *md)
 	if (type == EFI_MEMORY_MAPPED_IO)
 		return PROT_DEVICE_nGnRE;
 
-	if (WARN_ONCE(!PAGE_ALIGNED(md->phys_addr),
-		      "UEFI Runtime regions are not aligned to 64 KB -- buggy firmware?"))
+	if (!PAGE_ALIGNED(md->phys_addr) ||
+	    !PAGE_ALIGNED(md->num_pages * EFI_PAGE_SIZE))
 		/*
 		 * If the region is not aligned to the page size of the OS, we
 		 * can not use strict permissions, since that would also affect
-- 
2.35.1




More information about the linux-arm-kernel mailing list