Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

riscv: kexec: Align the kexeced kernel entry

The current riscv boot protocol requires 2MB alignment for RV64
and 4MB alignment for RV32.

In KEXEC_FILE path, the elf_find_pbase() function should align
the kexeced kernel entry according to the requirement, otherwise
the kexeced kernel would silently BUG at the setup_vm().

Fixes: 8acea455fafa ("RISC-V: Support for kexec_file on panic")
Signed-off-by: Song Shuai <songshuaishuai@tinylab.org>
Link: https://lore.kernel.org/r/20230906095817.364390-1-songshuaishuai@tinylab.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>

authored by

Song Shuai and committed by
Palmer Dabbelt
1bfb2b61 0bb80ecc

+7 -1
+7 -1
arch/riscv/kernel/elf_kexec.c
··· 98 98 kbuf.image = image; 99 99 kbuf.buf_min = lowest_paddr; 100 100 kbuf.buf_max = ULONG_MAX; 101 - kbuf.buf_align = PAGE_SIZE; 101 + 102 + /* 103 + * Current riscv boot protocol requires 2MB alignment for 104 + * RV64 and 4MB alignment for RV32 105 + * 106 + */ 107 + kbuf.buf_align = PMD_SIZE; 102 108 kbuf.mem = KEXEC_BUF_MEM_UNKNOWN; 103 109 kbuf.memsz = ALIGN(kernel_len, PAGE_SIZE); 104 110 kbuf.top_down = false;