efi/libstub/arm64: align PE/COFF sections to segment alignment
authorArd Biesheuvel <ardb@kernel.org>
Mon, 13 Apr 2020 15:55:18 +0000 (17:55 +0200)
committerWill Deacon <will@kernel.org>
Tue, 28 Apr 2020 16:36:52 +0000 (17:36 +0100)
The arm64 kernel's segment alignment is fixed at 64 KB for any page
size, and relocatable kernels are able to fix up any misalignment of
the kernel image with respect to the 2 MB section alignment that is
mandated by the arm64 boot protocol.

Let's increase the PE/COFF section alignment to the same value, so that
kernels loaded by the UEFI PE/COFF loader are guaranteed to end up at
an address that doesn't require any reallocation to be done if the
kernel is relocatable.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20200413155521.24698-6-ardb@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/kernel/efi-header.S
arch/arm64/kernel/vmlinux.lds.S

index 914999ccaf8afad83c69e24782563970782d974b..6f58998ef6479fafa10fab7b899f3e9455b17d8f 100644 (file)
@@ -32,7 +32,7 @@ optional_header:
 
 extra_header_fields:
        .quad   0                                       // ImageBase
-       .long   SZ_4K                                   // SectionAlignment
+       .long   SEGMENT_ALIGN                           // SectionAlignment
        .long   PECOFF_FILE_ALIGNMENT                   // FileAlignment
        .short  0                                       // MajorOperatingSystemVersion
        .short  0                                       // MinorOperatingSystemVersion
index 81cb501b84f38b9b495288b037a61e08522e0781..3be6321776310c94c88fb2656c173b7e374139a9 100644 (file)
@@ -170,7 +170,7 @@ SECTIONS
                *(.altinstr_replacement)
        }
 
-       . = ALIGN(PAGE_SIZE);
+       . = ALIGN(SEGMENT_ALIGN);
        __inittext_end = .;
        __initdata_begin = .;
 
@@ -241,6 +241,7 @@ SECTIONS
        . += INIT_DIR_SIZE;
        init_pg_end = .;
 
+       . = ALIGN(SEGMENT_ALIGN);
        __pecoff_data_size = ABSOLUTE(. - __initdata_begin);
        _end = .;