[U-Boot] [PATCH 1/1] efi_loader: revert "Align runtime section to 64kb"

Heinrich Schuchardt xypron.glpk at gmx.de
Sat Dec 8 21:08:54 UTC 2018


Commit 7a82c3051c8f ("efi_loader: Align runtime section to 64kb") lets
booting Linux fail at least on the Odroid C2. The patch alone applied to
v2018.09 or v2018.11 causes the error.

With the patch memory may be marked as code that contains variables.
So let's revert it and look for a better solution to reach compliance
with the 64kb alignment requirement of the UEFI spec.

Fixes: 7a82c3051c8f ("efi_loader: Align runtime section to 64kb")
Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
 lib/efi_loader/efi_memory.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index 4bb517473e4..5359118b4d7 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -11,7 +11,6 @@
 #include <mapmem.h>
 #include <watchdog.h>
 #include <linux/list_sort.h>
-#include <linux/sizes.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -603,7 +602,6 @@ __weak void efi_add_known_memory(void)
 static void add_u_boot_and_runtime(void)
 {
 	unsigned long runtime_start, runtime_end, runtime_pages;
-	unsigned long runtime_mask = EFI_PAGE_MASK;
 	unsigned long uboot_start, uboot_pages;
 	unsigned long uboot_stack_size = 16 * 1024 * 1024;
 
@@ -612,22 +610,10 @@ static void add_u_boot_and_runtime(void)
 	uboot_pages = (gd->ram_top - uboot_start) >> EFI_PAGE_SHIFT;
 	efi_add_memory_map(uboot_start, uboot_pages, EFI_LOADER_DATA, false);
 
-#if defined(__aarch64__)
-	/*
-	 * Runtime Services must be 64KiB aligned according to the
-	 * "AArch64 Platforms" section in the UEFI spec (2.7+).
-	 */
-
-	runtime_mask = SZ_64K - 1;
-#endif
-
-	/*
-	 * Add Runtime Services. We mark surrounding boottime code as runtime as
-	 * well to fulfill the runtime alignment constraints but avoid padding.
-	 */
-	runtime_start = (ulong)&__efi_runtime_start & ~runtime_mask;
+	/* Add Runtime Services */
+	runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK;
 	runtime_end = (ulong)&__efi_runtime_stop;
-	runtime_end = (runtime_end + runtime_mask) & ~runtime_mask;
+	runtime_end = (runtime_end + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;
 	runtime_pages = (runtime_end - runtime_start) >> EFI_PAGE_SHIFT;
 	efi_add_memory_map(runtime_start, runtime_pages,
 			   EFI_RUNTIME_SERVICES_CODE, false);
-- 
2.19.2



More information about the U-Boot mailing list