kexec-tools/kexec-tools-2.0.12-ppc64-purgatory-Handle-local-symbols-in-ELF-ABIv2.patch
Dave Young 59c1aab531 ppc64le: fix kexec hang due to ppc64 elf abi breakage
Fedora bug:
https://bugzilla.redhat.com/show_bug.cgi?id=1310495

kexec kernel hangs in ppc64le test. It is caused by kexec does not support
abi v2 properly.

Backport upstream patches below fixes the issue:
There is no code conflicts.

commit 3debb8cf3272216119cb2e59a4963ce3c18fe8e3
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Feb 26 18:06:15 2016 +1100

    Properly align powerpc64 .toc

    gcc leaves .toc byte aligned, relying on the linker to align the section.

        * kexec/arch/ppc64/kexec-elf-rel-ppc64.c (machine_verify_elf_rel):
        Fudge alignment of .toc section.

    Signed-off-by: Alan Modra <amodra@gmail.com>
    Signed-off-by: Anton Blanchard <anton@samba.org>
    Tested-by: Dave Young <dyoung@redhat.com>
    Signed-off-by: Simon Horman <horms@verge.net.au>

commit 1e423dc297d10eb7ff25c829d2856ef12fc81d77
Author: Anton Blanchard <anton@samba.org>
Date:   Fri Feb 26 18:04:16 2016 +1100

    ppc64: purgatory: Handle local symbols in ELF ABIv2

    The PowerPC64 ELF ABIv2 has the concept of global and local symbols
    and information on this is encoded in sym->st_other. When doing a
    R_PPC64_REL24 branch we want to hit the local entry point, so adjust
    it as necessary.

    Signed-off-by: Anton Blanchard <anton@samba.org>
    Tested-by: Dave Young <dyoung@redhat.com>
    Signed-off-by: Simon Horman <horms@verge.net.au>

commit 4a2ae3a39c64dc43e9d094be9541253234ff4822
Author: Anton Blanchard <anton@samba.org>
Date:   Fri Feb 26 18:03:11 2016 +1100

    Pass struct mem_sym into machine_apply_elf_rel()

    On PowerPC64 ABIv2 we need to look at the symbol to determine
    if it has a local entry point. Pass struct mem_sym into
    machine_apply_elf_rel() so we can.

    Signed-off-by: Anton Blanchard <anton@samba.org>
    Tested-by: Dave Young <dyoung@redhat.com>
    Signed-off-by: Simon Horman <horms@verge.net.au>

Signed-off-by: Dave Young <dyoung@redhat.com>
Acked-by: Xunlei Pang <xlpang@redhat.com>
2016-03-25 10:35:44 +08:00

58 lines
1.8 KiB
Diff

From 1e423dc297d10eb7ff25c829d2856ef12fc81d77 Mon Sep 17 00:00:00 2001
From: Anton Blanchard <anton@samba.org>
Date: Fri, 26 Feb 2016 18:04:16 +1100
Subject: [PATCH 2/3] ppc64: purgatory: Handle local symbols in ELF ABIv2
The PowerPC64 ELF ABIv2 has the concept of global and local symbols
and information on this is encoded in sym->st_other. When doing a
R_PPC64_REL24 branch we want to hit the local entry point, so adjust
it as necessary.
Signed-off-by: Anton Blanchard <anton@samba.org>
Tested-by: Dave Young <dyoung@redhat.com>
Signed-off-by: Simon Horman <horms@verge.net.au>
---
kexec/arch/ppc64/kexec-elf-rel-ppc64.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/kexec/arch/ppc64/kexec-elf-rel-ppc64.c b/kexec/arch/ppc64/kexec-elf-rel-ppc64.c
index 8604c4f..43851f6 100644
--- a/kexec/arch/ppc64/kexec-elf-rel-ppc64.c
+++ b/kexec/arch/ppc64/kexec-elf-rel-ppc64.c
@@ -5,6 +5,24 @@
#include "../../kexec-elf.h"
#include "kexec-ppc64.h"
+#if defined(_CALL_ELF) && _CALL_ELF == 2
+#define STO_PPC64_LOCAL_BIT 5
+#define STO_PPC64_LOCAL_MASK (7 << STO_PPC64_LOCAL_BIT)
+#define PPC64_LOCAL_ENTRY_OFFSET(other) \
+ (((1 << (((other) & STO_PPC64_LOCAL_MASK) >> STO_PPC64_LOCAL_BIT)) >> 2) << 2)
+
+static unsigned int local_entry_offset(struct mem_sym *sym)
+{
+ /* If this symbol has a local entry point, use it. */
+ return PPC64_LOCAL_ENTRY_OFFSET(sym->st_other);
+}
+#else
+static unsigned int local_entry_offset(struct mem_sym *UNUSED(sym))
+{
+ return 0;
+}
+#endif
+
int machine_verify_elf_rel(struct mem_ehdr *ehdr)
{
if (ehdr->ei_class != ELFCLASS64) {
@@ -114,6 +132,7 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, struct mem_sym *sym,
break;
case R_PPC64_REL24:
+ value += local_entry_offset(sym);
/* Convert value to relative */
value -= address;
if (value + 0x2000000 > 0x3ffffff || (value & 3) != 0) {
--
2.5.0