[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250326051445.55131-2-ziyao@disroot.org>
Date: Wed, 26 Mar 2025 05:14:46 +0000
From: Yao Zi <ziyao@...root.org>
To: Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>,
Albert Ou <aou@...s.berkeley.edu>,
Alexandre Ghiti <alex@...ti.fr>,
Pasha Tatashin <pasha.tatashin@...een.com>,
Kent Overstreet <kent.overstreet@...ux.dev>,
Petr Tesarik <petr@...arici.cz>,
Ying Sun <sunying@...c.iscas.ac.cn>,
Samuel Holland <samuel.holland@...ive.com>
Cc: linux-riscv@...ts.infradead.org,
linux-kernel@...r.kernel.org,
Han Gao <rabenda.cn@...il.com>,
Yao Zi <ziyao@...root.org>
Subject: [PATCH] riscv/kexec_file: Handle R_RISCV_64 in purgatory relocator
Commit 58ff537109ac ("riscv: Omit optimized string routines when
using KASAN") introduced calls to EXPORT_SYMBOL() in assembly string
routines, which result in R_RISCV_64 relocations against
.export_symbol section. As these rountines are reused by RISC-V
purgatory and our relocator doesn't recognize these relocations, this
fails kexec-file-load with dmesg like
[ 11.344251] kexec_image: Unknown rela relocation: 2
[ 11.345972] kexec_image: Error loading purgatory ret=-8
Let's support R_RISCV_64 relocation to fix kexec on 64-bit RISC-V.
32-bit variant isn't covered since KEXEC_FILE and KEXEC_PURGATORY isn't
available.
Fixes: 58ff537109ac ("riscv: Omit optimized string routines when using KASAN")
Signed-off-by: Yao Zi <ziyao@...root.org>
---
I noticed RISC-V support hasn't been merged into kexec-tools, so this
patch is tested with this dowmstream branch[1].
Thanks for your time and review.
[1]: https://github.com/ziyao233/kexec-tools/tree/rv-Image
arch/riscv/kernel/elf_kexec.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/riscv/kernel/elf_kexec.c b/arch/riscv/kernel/elf_kexec.c
index 3c37661801f9..e783a72d051f 100644
--- a/arch/riscv/kernel/elf_kexec.c
+++ b/arch/riscv/kernel/elf_kexec.c
@@ -468,6 +468,9 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
case R_RISCV_ALIGN:
case R_RISCV_RELAX:
break;
+ case R_RISCV_64:
+ *(u64 *)loc = val;
+ break;
default:
pr_err("Unknown rela relocation: %d\n", r_type);
return -ENOEXEC;
--
2.49.0
Powered by blists - more mailing lists