Hi Philipp,
Thanks for the patch!
Only a small issue, quoting from kexec-tools.spec,
"Patches 401 through 500 are meant for s390 kexec-tools enablement".
On Wed, Jan 19, 2022 at 11:14:07AM +0100, Philipp Rudo wrote:
>Resolves: bz2025860
>Upstream:
git.kernel.org/pub/scm/utils/kernel/kexec/kexec-tools.git
>
>commit 186e7b0752d8fce1618fa37519671c834c46340e
>Author: Alexander Egorenkov <egorenar(a)linux.ibm.com>
>Date: Wed Dec 15 18:48:53 2021 +0100
>
> s390: handle R_390_PLT32DBL reloc entries in machine_apply_elf_rel()
>
> Starting with gcc 11.3, the C compiler will generate PLT-relative function
> calls even if they are local and do not require it. Later on during linking,
> the linker will replace all PLT-relative calls to local functions with
> PC-relative ones. Unfortunately, the purgatory code of kexec/kdump is
> not being linked as a regular executable or shared library would have been,
> and therefore, all PLT-relative addresses remain in the generated purgatory
> object code unresolved. This in turn lets kexec-tools fail with
> "Unknown rela relocation: 0x14 0x73c0901c" for such relocation types.
>
> Furthermore, the clang C compiler has always behaved like described above
> and this commit should fix the purgatory code built with the latter.
>
> Because the purgatory code is no regular executable or shared library,
> contains only calls to local functions and has no PLT, all R_390_PLT32DBL
> relocation entries can be resolved just like a R_390_PC32DBL one.
>
> *
https://refspecs.linuxfoundation.org/ELF/zSeries/lzsabi0_zSeries/x1633.ht...
>
> Relocation entries of purgatory code generated with gcc 11.3
> ------------------------------------------------------------
>
> $ readelf -r purgatory/purgatory.o
>
> Relocation section '.rela.text' at offset 0x6e8 contains 27 entries:
> Offset Info Type Sym. Value Sym. Name + Addend
> 00000000000c 000300000013 R_390_PC32DBL 0000000000000000 .data + 2
> 00000000001a 001000000014 R_390_PLT32DBL 0000000000000000 sha256_starts + 2
> 000000000030 001100000014 R_390_PLT32DBL 0000000000000000 sha256_update + 2
> 000000000046 001200000014 R_390_PLT32DBL 0000000000000000 sha256_finish + 2
> 000000000050 000300000013 R_390_PC32DBL 0000000000000000 .data + 102
> 00000000005a 001300000014 R_390_PLT32DBL 0000000000000000 memcmp + 2
> ...
> 000000000118 001600000014 R_390_PLT32DBL 0000000000000000 setup_arch + 2
> 00000000011e 000300000013 R_390_PC32DBL 0000000000000000 .data + 2
> 00000000012c 000f00000014 R_390_PLT32DBL 0000000000000000
verify_sha256_digest + 2
> 000000000142 001700000014 R_390_PLT32DBL 0000000000000000
> post_verification[...] + 2
>
> Relocation entries of purgatory code generated with gcc 11.2
> ------------------------------------------------------------
>
> $ readelf -r purgatory/purgatory.o
>
> Relocation section '.rela.text' at offset 0x6e8 contains 27 entries:
> Offset Info Type Sym. Value Sym. Name + Addend
> 00000000000e 000300000013 R_390_PC32DBL 0000000000000000 .data + 2
> 00000000001c 001000000013 R_390_PC32DBL 0000000000000000 sha256_starts + 2
> 000000000036 001100000013 R_390_PC32DBL 0000000000000000 sha256_update + 2
> 000000000048 001200000013 R_390_PC32DBL 0000000000000000 sha256_finish + 2
> 000000000052 000300000013 R_390_PC32DBL 0000000000000000 .data + 102
> 00000000005c 001300000013 R_390_PC32DBL 0000000000000000 memcmp + 2
> ...
> 00000000011a 001600000013 R_390_PC32DBL 0000000000000000 setup_arch + 2
> 000000000120 000300000013 R_390_PC32DBL 0000000000000000 .data + 122
> 000000000130 000f00000013 R_390_PC32DBL 0000000000000000
verify_sha256_digest + 2
> 000000000146 001700000013 R_390_PC32DBL 0000000000000000
post_verification[...] + 2
>
> Corresponding s390 kernel discussion:
> *
https://lore.kernel.org/linux-s390/20211208105801.188140-1-egorenar@linux...
>
> Signed-off-by: Alexander Egorenkov <egorenar(a)linux.ibm.com>
> Reported-by: Tao Liu <ltao(a)redhat.com>
> Suggested-by: Philipp Rudo <prudo(a)redhat.com>
> Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
> [hca(a)linux.ibm.com: changed commit message as requested by Philipp Rudo]
> Signed-off-by: Heiko Carstens <hca(a)linux.ibm.com>
> Signed-off-by: Simon Horman <horms(a)verge.net.au>
>
>Signed-off-by: Philipp Rudo <prudo(a)redhat.com>
>---
> ...oc_entries_in_machine_apply_elf_rel_.patch | 95 +++++++++++++++++++
> kexec-tools.spec | 3 +
> 2 files changed, 98 insertions(+)
> create mode 100644
kexec-tools-2.0.23-s390_handle_R_390_PLT32DBL_reloc_entries_in_machine_apply_elf_rel_.patch
>
>diff --git
a/kexec-tools-2.0.23-s390_handle_R_390_PLT32DBL_reloc_entries_in_machine_apply_elf_rel_.patch
b/kexec-tools-2.0.23-s390_handle_R_390_PLT32DBL_reloc_entries_in_machine_apply_elf_rel_.patch
>new file mode 100644
>index 0000000..10bc5ef
>--- /dev/null
>+++
b/kexec-tools-2.0.23-s390_handle_R_390_PLT32DBL_reloc_entries_in_machine_apply_elf_rel_.patch
>@@ -0,0 +1,95 @@
>+commit 186e7b0752d8fce1618fa37519671c834c46340e
>+Author: Alexander Egorenkov <egorenar(a)linux.ibm.com>
>+Date: Wed Dec 15 18:48:53 2021 +0100
>+
>+ s390: handle R_390_PLT32DBL reloc entries in machine_apply_elf_rel()
>+
>+ Starting with gcc 11.3, the C compiler will generate PLT-relative function
>+ calls even if they are local and do not require it. Later on during linking,
>+ the linker will replace all PLT-relative calls to local functions with
>+ PC-relative ones. Unfortunately, the purgatory code of kexec/kdump is
>+ not being linked as a regular executable or shared library would have been,
>+ and therefore, all PLT-relative addresses remain in the generated purgatory
>+ object code unresolved. This in turn lets kexec-tools fail with
>+ "Unknown rela relocation: 0x14 0x73c0901c" for such relocation types.
>+
>+ Furthermore, the clang C compiler has always behaved like described above
>+ and this commit should fix the purgatory code built with the latter.
>+
>+ Because the purgatory code is no regular executable or shared library,
>+ contains only calls to local functions and has no PLT, all R_390_PLT32DBL
>+ relocation entries can be resolved just like a R_390_PC32DBL one.
>+
>+ *
https://refspecs.linuxfoundation.org/ELF/zSeries/lzsabi0_zSeries/x1633.ht...
>+
>+ Relocation entries of purgatory code generated with gcc 11.3
>+ ------------------------------------------------------------
>+
>+ $ readelf -r purgatory/purgatory.o
>+
>+ Relocation section '.rela.text' at offset 0x6e8 contains 27 entries:
>+ Offset Info Type Sym. Value Sym. Name +
Addend
>+ 00000000000c 000300000013 R_390_PC32DBL 0000000000000000 .data + 2
>+ 00000000001a 001000000014 R_390_PLT32DBL 0000000000000000 sha256_starts + 2
>+ 000000000030 001100000014 R_390_PLT32DBL 0000000000000000 sha256_update + 2
>+ 000000000046 001200000014 R_390_PLT32DBL 0000000000000000 sha256_finish + 2
>+ 000000000050 000300000013 R_390_PC32DBL 0000000000000000 .data + 102
>+ 00000000005a 001300000014 R_390_PLT32DBL 0000000000000000 memcmp + 2
>+ ...
>+ 000000000118 001600000014 R_390_PLT32DBL 0000000000000000 setup_arch + 2
>+ 00000000011e 000300000013 R_390_PC32DBL 0000000000000000 .data + 2
>+ 00000000012c 000f00000014 R_390_PLT32DBL 0000000000000000
verify_sha256_digest + 2
>+ 000000000142 001700000014 R_390_PLT32DBL 0000000000000000
>+ post_verification[...] + 2
>+
>+ Relocation entries of purgatory code generated with gcc 11.2
>+ ------------------------------------------------------------
>+
>+ $ readelf -r purgatory/purgatory.o
>+
>+ Relocation section '.rela.text' at offset 0x6e8 contains 27 entries:
>+ Offset Info Type Sym. Value Sym. Name +
Addend
>+ 00000000000e 000300000013 R_390_PC32DBL 0000000000000000 .data + 2
>+ 00000000001c 001000000013 R_390_PC32DBL 0000000000000000 sha256_starts + 2
>+ 000000000036 001100000013 R_390_PC32DBL 0000000000000000 sha256_update + 2
>+ 000000000048 001200000013 R_390_PC32DBL 0000000000000000 sha256_finish + 2
>+ 000000000052 000300000013 R_390_PC32DBL 0000000000000000 .data + 102
>+ 00000000005c 001300000013 R_390_PC32DBL 0000000000000000 memcmp + 2
>+ ...
>+ 00000000011a 001600000013 R_390_PC32DBL 0000000000000000 setup_arch + 2
>+ 000000000120 000300000013 R_390_PC32DBL 0000000000000000 .data + 122
>+ 000000000130 000f00000013 R_390_PC32DBL 0000000000000000
verify_sha256_digest + 2
>+ 000000000146 001700000013 R_390_PC32DBL 0000000000000000
post_verification[...] + 2
>+
>+ Corresponding s390 kernel discussion:
>+ *
https://lore.kernel.org/linux-s390/20211208105801.188140-1-egorenar@linux...
>+
>+ Signed-off-by: Alexander Egorenkov <egorenar(a)linux.ibm.com>
>+ Reported-by: Tao Liu <ltao(a)redhat.com>
>+ Suggested-by: Philipp Rudo <prudo(a)redhat.com>
>+ Reviewed-by: Philipp Rudo <prudo(a)redhat.com>
>+ [hca(a)linux.ibm.com: changed commit message as requested by Philipp Rudo]
>+ Signed-off-by: Heiko Carstens <hca(a)linux.ibm.com>
>+ Signed-off-by: Simon Horman <horms(a)verge.net.au>
>+
>+diff --git a/kexec/arch/s390/kexec-elf-rel-s390.c
b/kexec/arch/s390/kexec-elf-rel-s390.c
>+index
a5e1b73455785ae3bc3aa72b3beee13ae202e82f..91ba86a9991dad4271b834fc3b24861c40309e52 100644
>+--- a/kexec/arch/s390/kexec-elf-rel-s390.c
>++++ b/kexec/arch/s390/kexec-elf-rel-s390.c
>+@@ -56,6 +56,7 @@ void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr),
>+ case R_390_PC16: /* PC relative 16 bit. */
>+ case R_390_PC16DBL: /* PC relative 16 bit shifted by 1. */
>+ case R_390_PC32DBL: /* PC relative 32 bit shifted by 1. */
>++ case R_390_PLT32DBL: /* 32 bit PC rel. PLT shifted by 1. */
>+ case R_390_PC32: /* PC relative 32 bit. */
>+ case R_390_PC64: /* PC relative 64 bit. */
>+ val -= address;
>+@@ -63,7 +64,7 @@ void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr),
>+ *(unsigned short *) loc = val;
>+ else if (r_type == R_390_PC16DBL)
>+ *(unsigned short *) loc = val >> 1;
>+- else if (r_type == R_390_PC32DBL)
>++ else if (r_type == R_390_PC32DBL || r_type == R_390_PLT32DBL)
>+ *(unsigned int *) loc = val >> 1;
>+ else if (r_type == R_390_PC32)
>+ *(unsigned int *) loc = val;
>diff --git a/kexec-tools.spec b/kexec-tools.spec
>index 7419723..f687449 100644
>--- a/kexec-tools.spec
>+++ b/kexec-tools.spec
>@@ -110,6 +110,7 @@ Requires: systemd-udev%{?_isa}
> #
> # Patches 601 onward are generic patches
> #
>+Patch601:
./kexec-tools-2.0.23-s390_handle_R_390_PLT32DBL_reloc_entries_in_machine_apply_elf_rel_.patch
>
> %description
> kexec-tools provides /sbin/kexec binary that facilitates a new
>@@ -125,6 +126,8 @@ mkdir -p -m755 kcp
> tar -z -x -v -f %{SOURCE9}
> tar -z -x -v -f %{SOURCE19}
>
>+%patch601 -p1
>+
> %ifarch ppc
> %define archdef ARCH=ppc
> %endif
>--
>2.34.1
>_______________________________________________
>kexec mailing list -- kexec(a)lists.fedoraproject.org
>To unsubscribe send an email to kexec-leave(a)lists.fedoraproject.org
>Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
>List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
>List Archives:
https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org
>Do not reply to spam on the list, report it:
https://pagure.io/fedora-infrastructure