Skip to contentSkip to conversation

riscv: relocate R_RISCV_CALL_PLT in kexec_file

PATCH In review Torsten Duwe 4 participants 5 messages Mar 10, 2023 – Jul 23, 2023 RISC-V

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: relocate R_RISCV_CALL_PLT in kexec_file

Depending on the toolchain (here: gcc-12, binutils-2.40) the relocation entries for function calls are no longer R_RISCV_CALL, but R_RISCV_CALL_PLT. When trying kexec_load_file on such kernels, it will fail with

kexec_image: Unknown rela relocation: 19
kexec_image: Error loading purgatory ret=-8

The binary code at the call site remains the same, so tell arch_kexec_apply_relocations_add() to handle _PLT alike.

Fixes 838b3e28488f702 ("Load purgatory in kexec_file")

---

arch/riscv/kernel/elf_kexec.c +1 -0
@@ -425,6 +425,7 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
 		 * sym, instead of searching the whole relsec.
 		 */
 		case R_RISCV_PCREL_HI20:
+		case R_RISCV_CALL_PLT:
 		case R_RISCV_CALL:
 			*(u64 *)loc = CLEAN_IMM(UITYPE, *(u64 *)loc) |
 				 ENCODE_UJTYPE_IMM(val - addr);
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Torsten Duwe

Depending on the toolchain (here: gcc-12, binutils-2.40) the relocation entries for function calls are no longer R_RISCV_CALL, but R_RISCV_CALL_PLT. When trying kexec_load_file on such kernels, it will fail with

kexec_image: Unknown rela relocation: 19
kexec_image: Error loading purgatory ret=-8

The binary code at the call site remains the same, so tell arch_kexec_apply_relocations_add() to handle _PLT alike.

R_RISCV_CALL has already been deprecated, and replaced by R_RISCV_CALL_PLT.

See Enum 18-19 in Table 3. Relocation types from https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc .

It was deprecated in ("Deprecated R_RISCV_CALL, prefer R_RISCV_CALL_PLT") https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a0dced85018d7a0ec17023c9389cbd70b1dbc1b0

Quoted 17 lines
Fixes 838b3e28488f702 ("Load purgatory in kexec_file")

---

arch/riscv/kernel/elf_kexec.c +1 -0
@@ -425,6 +425,7 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
  		 * sym, instead of searching the whole relsec.
  		 */
  		case R_RISCV_PCREL_HI20:
+		case R_RISCV_CALL_PLT:
  		case R_RISCV_CALL:
  			*(u64 *)loc = CLEAN_IMM(UITYPE, *(u64 *)loc) |
  				 ENCODE_UJTYPE_IMM(val - addr);
Quoted 1 line

.

Palmer, please apply these references to the commit message.

#2 lore raw
Quoted 39 lines · On Mon, 13 Mar 2023 11:13:17 +0800 Li Zhengyu <[email protected]> wrote:
Quoted 10 lines · Torsten Duwe

Depending on the toolchain (here: gcc-12, binutils-2.40) the relocation entries for function calls are no longer R_RISCV_CALL, but R_RISCV_CALL_PLT. When trying kexec_load_file on such kernels, it will fail with

kexec_image: Unknown rela relocation: 19
kexec_image: Error loading purgatory ret=-8

The binary code at the call site remains the same, so tell arch_kexec_apply_relocations_add() to handle _PLT alike.

R_RISCV_CALL has already been deprecated, and replaced by R_RISCV_CALL_PLT.

See Enum 18-19 in Table 3. Relocation types from
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc
.

It was deprecated in ("Deprecated R_RISCV_CALL, prefer R_RISCV_CALL_PLT")
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a0dced85018d7a0ec17023c9389cbd70b1dbc1b0

Quoted 17 lines
Fixes 838b3e28488f702 ("Load purgatory in kexec_file")

---

arch/riscv/kernel/elf_kexec.c +1 -0
@@ -425,6 +425,7 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
  		 * sym, instead of searching the whole relsec.
  		 */
  		case R_RISCV_PCREL_HI20:
+		case R_RISCV_CALL_PLT:
  		case R_RISCV_CALL:
  			*(u64 *)loc = CLEAN_IMM(UITYPE, *(u64 *)loc) |
  				 ENCODE_UJTYPE_IMM(val - addr);
Quoted 6 lines
Quoted 1 line

.

Palmer, please apply these references to the commit message.

Ping?

#3 lore raw
Quoted 42 lines · Torsten Duwe
Quoted 39 lines · On Mon, 13 Mar 2023 11:13:17 +0800 Li Zhengyu <[email protected]> wrote:
Quoted 10 lines · Torsten Duwe

Depending on the toolchain (here: gcc-12, binutils-2.40) the relocation entries for function calls are no longer R_RISCV_CALL, but R_RISCV_CALL_PLT. When trying kexec_load_file on such kernels, it will fail with

kexec_image: Unknown rela relocation: 19
kexec_image: Error loading purgatory ret=-8

The binary code at the call site remains the same, so tell arch_kexec_apply_relocations_add() to handle _PLT alike.

R_RISCV_CALL has already been deprecated, and replaced by R_RISCV_CALL_PLT.

See Enum 18-19 in Table 3. Relocation types from
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc
.

It was deprecated in ("Deprecated R_RISCV_CALL, prefer R_RISCV_CALL_PLT")
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a0dced85018d7a0ec17023c9389cbd70b1dbc1b0

Quoted 17 lines
Fixes 838b3e28488f702 ("Load purgatory in kexec_file")

---

arch/riscv/kernel/elf_kexec.c +1 -0
@@ -425,6 +425,7 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
  		 * sym, instead of searching the whole relsec.
  		 */
  		case R_RISCV_PCREL_HI20:
+		case R_RISCV_CALL_PLT:
  		case R_RISCV_CALL:
  			*(u64 *)loc = CLEAN_IMM(UITYPE, *(u64 *)loc) |
  				 ENCODE_UJTYPE_IMM(val - addr);
Quoted 8 lines
Quoted 6 lines
Quoted 1 line

.

Palmer, please apply these references to the commit message.

Ping?

It's not been all that longer than a week & you're in patchwork so you won't be forgotten, but I noticed a complaint when I went looking on patchwork about your fixes tag:

Commit: f28b81e30b4b ("riscv: relocate R_RISCV_CALL_PLT in kexec_file")

	Fixes tag: fixes: 838b3e28488f702 ("Load purgatory in kexec_file")
	Has these problem(s):
		- Subject does not match target commit subject
		  Just use
			git log -1 --format='Fixes: %h ("%s")'

The fixes tag should be:

Fixes 838b3e28488f ("RISC-V: Load purgatory in kexec_file")

Note the capital F & the missed RISC-V: prefix, checkpatch should have complained about this.
Checkpatch also complains that your suse email in the Signoff doesn't match the lst.de email that you used to send the patch (IOW you're missing a From: header that send-email would add).

Could you fix those things up please & I suppose you can take the opportunity to make the changes that Li Zhengyu suggested to the commit message itself at the same time.

Thanks,
Conor.

#4 lore raw

Hey Torsten,

Quoted 47 lines · Conor Dooley
Quoted 46 lines · Torsten Duwe
Quoted 43 lines · On Mon, 13 Mar 2023 11:13:17 +0800 Li Zhengyu <[email protected]> wrote:
Quoted 10 lines · Torsten Duwe

Depending on the toolchain (here: gcc-12, binutils-2.40) the relocation entries for function calls are no longer R_RISCV_CALL, but R_RISCV_CALL_PLT. When trying kexec_load_file on such kernels, it will fail with

kexec_image: Unknown rela relocation: 19
kexec_image: Error loading purgatory ret=-8

The binary code at the call site remains the same, so tell arch_kexec_apply_relocations_add() to handle _PLT alike.

R_RISCV_CALL has already been deprecated, and replaced by R_RISCV_CALL_PLT.

See Enum 18-19 in Table 3. Relocation types from
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc
.

It was deprecated in ("Deprecated R_RISCV_CALL, prefer R_RISCV_CALL_PLT")
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/a0dced85018d7a0ec17023c9389cbd70b1dbc1b0

Quoted 17 lines
Fixes 838b3e28488f702 ("Load purgatory in kexec_file")

---

arch/riscv/kernel/elf_kexec.c +1 -0
@@ -425,6 +425,7 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
  		 * sym, instead of searching the whole relsec.
  		 */
  		case R_RISCV_PCREL_HI20:
+		case R_RISCV_CALL_PLT:
  		case R_RISCV_CALL:
  			*(u64 *)loc = CLEAN_IMM(UITYPE, *(u64 *)loc) |
  				 ENCODE_UJTYPE_IMM(val - addr);
Quoted 1 line

.

Palmer, please apply these references to the commit message.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

Ping?

It's not been all that longer than a week & you're in patchwork so you won't be forgotten,

Turns out it did get forgotten, or more accurately, marked as "Changes Requested".

Quoted 19 lines

but I noticed a complaint when I went looking on
patchwork about your fixes tag:

Commit: f28b81e30b4b ("riscv: relocate R_RISCV_CALL_PLT in kexec_file")

	Fixes tag: fixes: 838b3e28488f702 ("Load purgatory in kexec_file")
	Has these problem(s):
		- Subject does not match target commit subject
		  Just use
			git log -1 --format='Fixes: %h ("%s")'

The fixes tag should be:

Fixes 838b3e28488f ("RISC-V: Load purgatory in kexec_file")

Note the capital F & the missed RISC-V: prefix, checkpatch should have complained about this.
Checkpatch also complains that your suse email in the Signoff doesn't match the lst.de email that you used to send the patch (IOW you're missing a From: header that send-email would add).

Quoted 3 lines

Could you fix those things up please & I suppose you can take the opportunity to make the changes that Li Zhengyu suggested to the commit message itself at the same time.

Would you mind resending this with the Fixes & Signoff corrections?

Thanks,
Conor.

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv