Skip to content

Commit 28093cf

Browse files
ziyao233Alexandre Ghiti
authored andcommitted
riscv/kexec_file: Handle R_RISCV_64 in purgatory relocator
Commit 58ff537 ("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: 58ff537 ("riscv: Omit optimized string routines when using KASAN") Signed-off-by: Yao Zi <ziyao@disroot.org> Tested-by: Björn Töpel <bjorn@rivosinc.com> Reviewed-by: Björn Töpel <bjorn@rivosinc.com> Link: https://lore.kernel.org/r/20250326051445.55131-2-ziyao@disroot.org Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
1 parent 0049618 commit 28093cf

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/riscv/kernel/elf_kexec.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,9 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
468468
case R_RISCV_ALIGN:
469469
case R_RISCV_RELAX:
470470
break;
471+
case R_RISCV_64:
472+
*(u64 *)loc = val;
473+
break;
471474
default:
472475
pr_err("Unknown rela relocation: %d\n", r_type);
473476
return -ENOEXEC;

0 commit comments

Comments
 (0)