From 5b6f59c05464d07b70117e8b5fa1bfa51e18d203 Mon Sep 17 00:00:00 2001 From: David Abdurachmanov Date: Thu, 21 Sep 2023 10:42:38 +0300 Subject: [PATCH] Backport riscv64 patch from v6.5.5 This patch is already in v6.5 stable queue waiting for v6.5.5. Signed-off-by: David Abdurachmanov --- linux-kernel-test.patch | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/linux-kernel-test.patch b/linux-kernel-test.patch index e69de29bb..ea1325b13 100644 --- a/linux-kernel-test.patch +++ b/linux-kernel-test.patch @@ -0,0 +1,47 @@ +From f3a721f8d050c391aec90297e1160583866d3b8b Mon Sep 17 00:00:00 2001 +From: Sasha Levin +Date: Wed, 6 Sep 2023 17:58:17 +0800 +Subject: riscv: kexec: Align the kexeced kernel entry + +From: Song Shuai + +[ Upstream commit 1bfb2b618d52e59a4ef1896b46c4698ad2be66b7 ] + +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 +Link: https://lore.kernel.org/r/20230906095817.364390-1-songshuaishuai@tinylab.org +Signed-off-by: Palmer Dabbelt +Signed-off-by: Sasha Levin +--- + arch/riscv/kernel/elf_kexec.c | 8 +++++++- + 1 file changed, 7 insertions(+), 1 deletion(-) + +diff --git a/arch/riscv/kernel/elf_kexec.c b/arch/riscv/kernel/elf_kexec.c +index c08bb5c3b3857..b3b96ff46d193 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; +-- +2.40.1 +