]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
riscv: kexec: Align the kexeced kernel entry
authorSong Shuai <songshuaishuai@tinylab.org>
Thu, 7 Sep 2023 10:33:03 +0000 (18:33 +0800)
committerPalmer Dabbelt <palmer@rivosinc.com>
Wed, 20 Sep 2023 09:53:30 +0000 (02:53 -0700)
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/20230907103304.590739-3-songshuaishuai@tinylab.org
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
arch/riscv/kernel/elf_kexec.c

index 5372b708fae21a072f72434625d27d792b83abc7..9a81d6926ac614fedfbe2fc1fa6afdc7e919e917 100644 (file)
@@ -98,7 +98,13 @@ static int elf_find_pbase(struct kimage *image, unsigned long kernel_len,
        kbuf.image = image;
        kbuf.buf_min = lowest_paddr;
        kbuf.buf_max = ULONG_MAX;
-       kbuf.buf_align = PAGE_SIZE;
+
+       /*
+        * Current riscv boot protocol requires 2MB alignment for
+        * RV64 and 4MB alignment for RV32
+        *
+        */
+       kbuf.buf_align = PMD_SIZE;
        kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
        kbuf.memsz = ALIGN(kernel_len, PAGE_SIZE);
        kbuf.top_down = false;