kexec-tools/kexec-tools-2.0.13-arm64-Add-support-for-additional-relocations-in-the-kexec-purgatory-code.patch
Pingfan Liu aee378209e Add initial upstream support for kexec on aarch64
Fix Bug 925630 - kexec-tools: support for arm64
https://bugzilla.redhat.com/show_bug.cgi?id=925630
involves three things:
  1. back porting upstream code to enable the function of kexec-tools on arm64
     patchset backported from upstream:
        commit abdfe97736f89d9bc73662b9134604b0229a599e
        commit 522df5f7217fda01ece3f6ac3e9987b0320c2bb0
        commit 217bcc00c9309416a6c6cd0584196559d28a9259
  2. fix the arm related building issue by using autoreconf in spec file

  3. patches to fix the issue of higher version gcc used by koji (not upstrem yet,
     and the corresponding fix in kernel side is in other package)
        kexec-tools-2.0.13-arm64-Add-support-for-additional-relocations-in-the-kexec-purgatory-code.patch
        kexec-tools-2.0.13-arm64-Add-support-of-R_AARCH64_PREL32-relocation-in-.patch
[panand: apply patches in 3 of above paragraph]

Signed-off-by: Pingfan Liu <piliu@redhat.com>
Acked-by: Dave Young <dyoung@redhat.com>
Acked-by: Pratyush Anand <panand@redhat.com>
2016-10-27 14:44:13 +08:00

107 lines
3.3 KiB
Diff

From patchwork Thu Oct 20 10:43:31 2016
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [v2] arm64: Add support for additional relocations in the kexec
purgatory code
From: Catalin Marinas <catalin.marinas@arm.com>
X-Patchwork-Id: 9386541
Message-Id: <1476960211-25594-1-git-send-email-catalin.marinas@arm.com>
To: Simon Horman <horms@verge.net.au>
Cc: Geoff Levand <geoff@infradead.org>, kexec@lists.infradead.org,
linux-arm-kernel@lists.infradead.org
Date: Thu, 20 Oct 2016 11:43:31 +0100
When compiling the kexec-tools with gcc6, the following additional
reolcations are generated in the purgatory.ro file:
R_AARCH64_ADR_PREL_PG_HI21
R_AARCH64_ADD_ABS_LO12_NC
R_AARCH64_LDST64_ABS_LO12_NC
This patch modifies the arm64 machine_apply_elf_rel() function to handle
these relocations.
Cc: Geoff Levand <geoff@infradead.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Reviewed-by: Geoff Levand <geoff@infradead.org>
---
Changes for v2:
- Fixed the type string to drop the "R_AARCH64_" prefix
kexec/arch/arm64/kexec-arm64.c | 35 +++++++++++++++++++++++++++++++++++
1 file changed, 35 insertions(+)
diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
index 2e8839a..e067a23 100644
--- a/kexec/arch/arm64/kexec-arm64.c
+++ b/kexec/arch/arm64/kexec-arm64.c
@@ -550,6 +550,14 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, struct mem_sym *UNUSED(sym),
# define R_AARCH64_ADR_PREL_LO21 274
#endif
+#if !defined(R_AARCH64_ADR_PREL_PG_HI21)
+# define R_AARCH64_ADR_PREL_PG_HI21 275
+#endif
+
+#if !defined(R_AARCH64_ADD_ABS_LO12_NC)
+# define R_AARCH64_ADD_ABS_LO12_NC 277
+#endif
+
#if !defined(R_AARCH64_JUMP26)
# define R_AARCH64_JUMP26 282
#endif
@@ -558,10 +566,15 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, struct mem_sym *UNUSED(sym),
# define R_AARCH64_CALL26 283
#endif
+#if !defined(R_AARCH64_LDST64_ABS_LO12_NC)
+# define R_AARCH64_LDST64_ABS_LO12_NC 286
+#endif
+
uint64_t *loc64;
uint32_t *loc32;
uint64_t *location = (uint64_t *)ptr;
uint64_t data = *location;
+ uint64_t imm;
const char *type = NULL;
switch(r_type) {
@@ -585,6 +598,19 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, struct mem_sym *UNUSED(sym),
*loc32 = cpu_to_le32(le32_to_cpu(*loc32)
+ (((value - address) << 3) & 0xffffe0));
break;
+ case R_AARCH64_ADR_PREL_PG_HI21:
+ type = "ADR_PREL_PG_HI21";
+ imm = ((value & ~0xfff) - (address & ~0xfff)) >> 12;
+ loc32 = ptr;
+ *loc32 = cpu_to_le32(le32_to_cpu(*loc32)
+ + ((imm & 3) << 29) + ((imm & 0x1ffffc) << (5 - 2)));
+ break;
+ case R_AARCH64_ADD_ABS_LO12_NC:
+ type = "ADD_ABS_LO12_NC";
+ loc32 = ptr;
+ *loc32 = cpu_to_le32(le32_to_cpu(*loc32)
+ + ((value & 0xfff) << 10));
+ break;
case R_AARCH64_JUMP26:
type = "JUMP26";
loc32 = ptr;
@@ -597,6 +623,15 @@ void machine_apply_elf_rel(struct mem_ehdr *ehdr, struct mem_sym *UNUSED(sym),
*loc32 = cpu_to_le32(le32_to_cpu(*loc32)
+ (((value - address) >> 2) & 0x3ffffff));
break;
+ case R_AARCH64_LDST64_ABS_LO12_NC:
+ if (value & 7)
+ die("%s: ERROR Unaligned value: %lx\n", __func__,
+ value);
+ type = "LDST64_ABS_LO12_NC";
+ loc32 = ptr;
+ *loc32 = cpu_to_le32(le32_to_cpu(*loc32)
+ + ((value & 0xff8) << (10 - 3)));
+ break;
default:
die("%s: ERROR Unknown type: %lu\n", __func__, r_type);
break;