Skip to content

Commit 1bfb2b6

Browse files
Song Shuaipalmer-dabbelt
authored andcommitted
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: 8acea45 ("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>
1 parent 0bb80ec commit 1bfb2b6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

arch/riscv/kernel/elf_kexec.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,13 @@ static int elf_find_pbase(struct kimage *image, unsigned long kernel_len,
9898
kbuf.image = image;
9999
kbuf.buf_min = lowest_paddr;
100100
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;
102108
kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
103109
kbuf.memsz = ALIGN(kernel_len, PAGE_SIZE);
104110
kbuf.top_down = false;

0 commit comments

Comments
 (0)