Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit a39416d

Browse files
isrcsygregkh
authored andcommitted
riscv/kexec_file: Fix relocation type R_RISCV_ADD16 and R_RISCV_SUB16 unknown
[ Upstream commit c6ebf2c ] Runs on the kernel with CONFIG_RISCV_ALTERNATIVE enabled: kexec -sl vmlinux Error: kexec_image: Unknown rela relocation: 34 kexec_image: Error loading purgatory ret=-8 and kexec_image: Unknown rela relocation: 38 kexec_image: Error loading purgatory ret=-8 The purgatory code uses the 16-bit addition and subtraction relocation type, but not handled, resulting in kexec_file_load failure. So add handle to arch_kexec_apply_relocations_add(). Tested on RISC-V64 Qemu-virt, issue fixed. Co-developed-by: Petr Tesarik <[email protected]> Signed-off-by: Petr Tesarik <[email protected]> Signed-off-by: Ying Sun <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 740a605 commit a39416d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

arch/riscv/kernel/elf_kexec.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,12 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
444444
*(u32 *)loc = CLEAN_IMM(CJTYPE, *(u32 *)loc) |
445445
ENCODE_CJTYPE_IMM(val - addr);
446446
break;
447+
case R_RISCV_ADD16:
448+
*(u16 *)loc += val;
449+
break;
450+
case R_RISCV_SUB16:
451+
*(u16 *)loc -= val;
452+
break;
447453
case R_RISCV_ADD32:
448454
*(u32 *)loc += val;
449455
break;

0 commit comments

Comments
 (0)