Re: [PATCH] riscv/kexec_file: Handle R_RISCV_64 in purgatory relocator
From: Björn Töpel
Date: Wed Mar 26 2025 - 15:55:09 EST
Björn Töpel <bjorn@xxxxxxxxxx> writes:
> Yao Zi <ziyao@xxxxxxxxxxx> writes:
>
>> 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.
>
> Hi!
>
> This patch does fix the vmlinux loading for kexec-file -- very nice!
> However, I haven't been able to get kexec to successfully boot a kernel
> from qemu, i.e.:
>
> kexec -s -l /path/to/vmlinux # fixed w/ your patch
> kexec -e # hangs after "Bye..."
>
> Same when I try vanilla kexec (kexec -c -l /path/to/vmlinux). kexec with
> an Image works for me in qemu.
>
> Before I start to bisect too much; What config/qemu did you use to test
> this?
Nevermind! Got it to work; Sorry for the noise.
Tested-by: Björn Töpel <bjorn@xxxxxxxxxxxx>
Reviewed-by: Björn Töpel <bjorn@xxxxxxxxxxxx>