efi_loader: Align runtime section to 64kb
PATCH 1/1 efi_loader: Align runtime section to 64kb
The UEFI spec mandates that runtime sections are 64kb aligned to enable support for 64kb page size OSs.
This patch ensures that we extend the runtime section to 64kb to be spec compliant.
--- lib/efi_loader/efi_memory.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
lib/efi_loader/efi_memory.c +4 -3
@@ -11,6 +11,7 @@#include <mapmem.h> #include <watchdog.h> #include <linux/list_sort.h> +#include <linux/sizes.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -526,10 +527,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); -/* Add Runtime Services */ - runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK ; +/* Add Runtime Services,must be 64kb aligned */ + runtime_start = (ulong)&__efi_runtime_start & ~(SZ_64K -1 ); runtime_end = (ulong)&__efi_runtime_stop; - runtime_end = (runtime_end +EFI_PAGE_MASK ) & ~EFI_PAGE_MASK ; + runtime_end = (runtime_end +SZ_64K -1 ) & ~(SZ_64K -1 ); runtime_pages = (runtime_end - runtime_start) >>EFI_PAGE_SHIFT ;efi_add_memory_map (runtime_start, runtime_pages,EFI_RUNTIME_SERVICES_CODE , false);
Signature · 1 line
2.12.3
PATCH 1/1 efi_loader: Align runtime section to 64kb
Quoted 1 line · Alexander Graf
The UEFI spec mandates that runtime sections are 64kb aligned to enable
%s/kb/ kiB/g
The spec requires a multiple of 64,000 not of 65,536.
Quoted 23 lines
support for 64kb page size OSs.
This patch ensures that we extend the runtime section to 64kb to be spec compliant.
Signed-off-by Alexander Graf <[email protected]>--- lib/efi_loader/efi_memory.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)lib/efi_loader/efi_memory.c +1
-0@@ -11,6 +11,7 @@#include <mapmem.h> #include <watchdog.h> #include <linux/list_sort.h> +#include <linux/sizes.h> DECLARE_GLOBAL_DATA_PTR ;
lib/efi_loader/efi_memory.c static void add_u_boot_and_runtime(void) · line 531
Quoted 7 lines
lib/efi_loader/efi_memory.c +2
-2@@ -526,10 +527,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); -/* Add Runtime Services */ - runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK ; +/* Add Runtime Services,must be 64kb aligned */ + runtime_start = (ulong)&__efi_runtime_start & ~(SZ_64K -1 );
Please, add a comment in the code referring to the requirement in the UEFI spec.
Best regards
Heinrich
Quoted 7 lines
lib/efi_loader/efi_memory.c +1
-1runtime_end = (ulong)&__efi_runtime_stop; - runtime_end = (runtime_end +EFI_PAGE_MASK ) & ~EFI_PAGE_MASK ; + runtime_end = (runtime_end +SZ_64K -1 ) & ~(SZ_64K -1 ); runtime_pages = (runtime_end - runtime_start) >>EFI_PAGE_SHIFT ;efi_add_memory_map (runtime_start, runtime_pages,EFI_RUNTIME_SERVICES_CODE , false);
PATCH 1/1 efi_loader: Align runtime section to 64kb
Quoted 4 lines · Heinrich Schuchardt
Quoted 1 line · Alexander Graf
The UEFI spec mandates that runtime sections are 64kb aligned to enable
%s/kb/ kiB/g
The spec requires a multiple of 64,000 not of 65,536.
The other way around you mean I guess? We do usually use "kb" for multiples of 1024 though, no?
Quoted 27 lines
Quoted 27 lines
support for 64kb page size OSs.
This patch ensures that we extend the runtime section to 64kb to be spec compliant.
Signed-off-by Alexander Graf <[email protected]>--- lib/efi_loader/efi_memory.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)lib/efi_loader/efi_memory.c +1
-0@@ -11,6 +11,7 @@#include <mapmem.h> #include <watchdog.h> #include <linux/list_sort.h> +#include <linux/sizes.h> DECLARE_GLOBAL_DATA_PTR ;@@ -526,10 +527,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);
Quoted 7 lines
lib/efi_loader/efi_memory.c static void add_u_boot_and_runtime(void) · line 531
Quoted 4 lines
lib/efi_loader/efi_memory.c +2
-2-/* Add Runtime Services */ - runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK ; +/* Add Runtime Services,must be 64kb aligned */ + runtime_start = (ulong)&__efi_runtime_start & ~(SZ_64K -1 );Please, add a comment in the code referring to the requirement in the UEFI spec.
Sure, it's part of 2.6.3 (AArch64 Platforms) in the 2.7 spec.
Alex
PATCH 1/1 efi_loader: Align runtime section to 64kb
In reply to Alexander GrafQuoted 2 lines · Alexander Graf
The UEFI spec mandates that runtime sections are 64kb aligned to enable support for 64kb page size OSs.
Where in the spec did you find this? I could neither find the term "runtime section" nor "64kb" in the text.
Best regards
Heinrich
Quoted 36 lines
This patch ensures that we extend the runtime section to 64kb to be spec compliant.
Signed-off-by Alexander Graf <[email protected]>--- lib/efi_loader/efi_memory.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)lib/efi_loader/efi_memory.c +4
-3@@ -11,6 +11,7 @@#include <mapmem.h> #include <watchdog.h> #include <linux/list_sort.h> +#include <linux/sizes.h> DECLARE_GLOBAL_DATA_PTR ;@@ -526,10 +527,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); -/* Add Runtime Services */ - runtime_start = (ulong)&__efi_runtime_start & ~EFI_PAGE_MASK ; +/* Add Runtime Services,must be 64kb aligned */ + runtime_start = (ulong)&__efi_runtime_start & ~(SZ_64K -1 ); runtime_end = (ulong)&__efi_runtime_stop; - runtime_end = (runtime_end +EFI_PAGE_MASK ) & ~EFI_PAGE_MASK ; + runtime_end = (runtime_end +SZ_64K -1 ) & ~(SZ_64K -1 ); runtime_pages = (runtime_end - runtime_start) >>EFI_PAGE_SHIFT ;efi_add_memory_map (runtime_start, runtime_pages,EFI_RUNTIME_SERVICES_CODE , false);