]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - arch/arm64/kernel/head.S
arm64: relocatable: deal with physically misaligned kernel images
[mirror_ubuntu-bionic-kernel.git] / arch / arm64 / kernel / head.S
index c5e5edca6897b7a1d8a0735302f0acc29ee11ad5..00a32101ab51862aa12e8c88a60bffb9cec5c470 100644 (file)
@@ -25,6 +25,7 @@
 #include <linux/irqchip/arm-gic-v3.h>
 
 #include <asm/assembler.h>
+#include <asm/boot.h>
 #include <asm/ptrace.h>
 #include <asm/asm-offsets.h>
 #include <asm/cache.h>
@@ -213,8 +214,8 @@ efi_header_end:
 ENTRY(stext)
        bl      preserve_boot_args
        bl      el2_setup                       // Drop to EL1, w20=cpu_boot_mode
-       mov     x23, xzr                        // KASLR offset, defaults to 0
        adrp    x24, __PHYS_OFFSET
+       and     x23, x24, MIN_KIMG_ALIGN - 1    // KASLR offset, defaults to 0
        bl      set_cpu_boot_mode_flag
        bl      __create_page_tables            // x25=TTBR0, x26=TTBR1
        /*
@@ -449,11 +450,13 @@ __primary_switched:
        bl      kasan_early_init
 #endif
 #ifdef CONFIG_RANDOMIZE_BASE
-       cbnz    x23, 0f                         // already running randomized?
+       tst     x23, ~(MIN_KIMG_ALIGN - 1)      // already running randomized?
+       b.ne    0f
        mov     x0, x21                         // pass FDT address in x0
+       mov     x1, x23                         // pass modulo offset in x1
        bl      kaslr_early_init                // parse FDT for KASLR options
        cbz     x0, 0f                          // KASLR disabled? just proceed
-       mov     x23, x0                         // record KASLR offset
+       orr     x23, x23, x0                    // record KASLR offset
        ret     x28                             // we must enable KASLR, return
                                                // to __enable_mmu()
 0: