diff mbox series

[-fixes] riscv: kexec: Align the kexeced kernel entry

Message ID 20230906095817.364390-1-songshuaishuai@tinylab.org (mailing list archive)
State Accepted
Commit 1bfb2b618d52e59a4ef1896b46c4698ad2be66b7
Headers show
Series [-fixes] riscv: kexec: Align the kexeced kernel entry | expand

Checks

Context Check Description
conchuod/cover_letter success Single patches do not need cover letters
conchuod/tree_selection success Guessed tree name to be fixes at HEAD e0152e7481c6
conchuod/fixes_present success Fixes tag present in non-next series
conchuod/maintainers_pattern success MAINTAINERS pattern errors before the patch: 2 and now 2
conchuod/verify_signedoff success Signed-off-by tag matches author and committer
conchuod/kdoc success Errors and warnings before: 0 this patch: 0
conchuod/build_rv64_clang_allmodconfig success Errors and warnings before: 9 this patch: 9
conchuod/module_param success Was 0 now: 0
conchuod/build_rv64_gcc_allmodconfig success Errors and warnings before: 9 this patch: 9
conchuod/build_rv32_defconfig success Build OK
conchuod/dtb_warn_rv64 success Errors and warnings before: 39 this patch: 39
conchuod/header_inline success No static functions without inline keyword in header files
conchuod/checkpatch success total: 0 errors, 0 warnings, 0 checks, 14 lines checked
conchuod/build_rv64_nommu_k210_defconfig success Build OK
conchuod/verify_fixes success Fixes tag looks correct
conchuod/build_rv64_nommu_virt_defconfig success Build OK

Commit Message

Song Shuai Sept. 6, 2023, 9:58 a.m. UTC
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>
---
You can use my kexec-tools[1] to test the kexec-file-syscall and this patch.

[1]: https://github.com/sugarfillet/kexec-tools/tree/fix-riscv 
---
 arch/riscv/kernel/elf_kexec.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Palmer Dabbelt Sept. 13, 2023, 12:23 a.m. UTC | #1
On Wed, 06 Sep 2023 17:58:17 +0800, Song Shuai wrote:
> 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().
> 
> [...]

Applied, thanks!

[1/1] riscv: kexec: Align the kexeced kernel entry
      https://git.kernel.org/palmer/c/1bfb2b618d52

Best regards,
patchwork-bot+linux-riscv@kernel.org Sept. 13, 2023, 12:37 a.m. UTC | #2
Hello:

This patch was applied to riscv/linux.git (fixes)
by Palmer Dabbelt <palmer@rivosinc.com>:

On Wed,  6 Sep 2023 17:58:17 +0800 you wrote:
> 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().
> 
> [...]

Here is the summary with links:
  - [-fixes] riscv: kexec: Align the kexeced kernel entry
    https://git.kernel.org/riscv/c/1bfb2b618d52

You are awesome, thank you!
diff mbox series

Patch

diff --git a/arch/riscv/kernel/elf_kexec.c b/arch/riscv/kernel/elf_kexec.c
index 5372b708fae2..9a81d6926ac6 100644
--- a/arch/riscv/kernel/elf_kexec.c
+++ b/arch/riscv/kernel/elf_kexec.c
@@ -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;