[PATCH V2 0/2] riscv: kexec: cleanup and fixups

Song Shuai songshuaishuai at tinylab.org
Wed Oct 11 01:31:30 PDT 2023


Changes since V1:
https://lore.kernel.org/linux-riscv/20230907103304.590739-1-songshuaishuai@tinylab.org/

- the old Patch2 in V1 had been merged to riscv/fixes, so take it out of this series  
- Patch1 : replace `.align 2` with `.balign 4` as Andreas suggested
- Patch2 : fix the conflict caused by commit a72ab0361110 ("riscv/purgatory: Disable CFI")


riscv: kexec: Cleanup riscv_kexec_relocate (Patch1)
==================================================

For readability and simplicity, cleanup the riscv_kexec_relocate code:

 - Re-sort the first 4 `mv` instructions against `riscv_kexec_method()`
 - Eliminate registers for debugging (s9,s10,s11) and storing const-value (s5,s6)
 - Replace `jalr` with `jr` for no-link jump

riscv: kexec: Remove -fPIE for PURGATORY_CFLAGS (Patch2 : the Patch3 in V1)
==========================================================================

With CONFIG_RELOCATABLE enabled, KBUILD_CFLAGS had a -fPIE option
and then the purgatory/string.o was built to reference _ctype symbol
via R_RISCV_GOT_HI20 relocations which can't be handled by purgatory.

As a consequence, the kernel failed kexec_load_file() with:

[  880.386562] kexec_image: The entry point of kernel at 0x80200000
[  880.388650] kexec_image: Unknown rela relocation: 20
[  880.389173] kexec_image: Error loading purgatory ret=-8

So remove the -fPIE option for PURGATORY_CFLAGS to generate
R_RISCV_PCREL_HI20 relocations type making puragtory work as it was.

Song Shuai (2):
  riscv: kexec: Cleanup riscv_kexec_relocate
  riscv: kexec: Remove -fPIE for PURGATORY_CFLAGS

 arch/riscv/kernel/kexec_relocate.S | 54 +++++++++++++-----------------
 arch/riscv/purgatory/Makefile      |  4 +++
 2 files changed, 28 insertions(+), 30 deletions(-)

-- 
2.20.1




More information about the kexec mailing list