Skip to content

Commit e62b9e6

Browse files
ardbiesheuvelwilldeacon
authored andcommitted
arm64: head: Ignore bogus KASLR displacement on non-relocatable kernels
Even non-KASLR kernels can be built as relocatable, to work around broken bootloaders that violate the rules regarding physical placement of the kernel image - in this case, the physical offset modulo 2 MiB is used as the KASLR offset, and all absolute symbol references are fixed up in the usual way. This workaround is enabled by default. CONFIG_RELOCATABLE can also be disabled entirely, in which case the relocation code and the code that captures the offset are omitted from the build. However, since commit aacd149 ("arm64: head: avoid relocating the kernel twice for KASLR"), this code got out of sync, and we still add the offset to the kernel virtual address before populating the page tables even though we never capture it. This means we add a bogus value instead, breaking the boot entirely. Fixes: aacd149 ("arm64: head: avoid relocating the kernel twice for KASLR") Signed-off-by: Ard Biesheuvel <[email protected]> Tested-by: Mikulas Patocka <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 4831be7 commit e62b9e6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

arch/arm64/kernel/head.S

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,9 @@ SYM_FUNC_END(create_idmap)
371371
SYM_FUNC_START_LOCAL(create_kernel_mapping)
372372
adrp x0, init_pg_dir
373373
mov_q x5, KIMAGE_VADDR // compile time __va(_text)
374+
#ifdef CONFIG_RELOCATABLE
374375
add x5, x5, x23 // add KASLR displacement
376+
#endif
375377
adrp x6, _end // runtime __pa(_end)
376378
adrp x3, _text // runtime __pa(_text)
377379
sub x6, x6, x3 // _end - _text

0 commit comments

Comments
 (0)