From patchwork Thu Oct 20 10:43:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 9386541 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 74BF160762 for ; Thu, 20 Oct 2016 10:45:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6418129BDE for ; Thu, 20 Oct 2016 10:45:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 57D0F29BE0; Thu, 20 Oct 2016 10:45:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DC8D429BDE for ; Thu, 20 Oct 2016 10:45:16 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bxApP-00033S-H8; Thu, 20 Oct 2016 10:44:03 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bxApI-0002yC-MI; Thu, 20 Oct 2016 10:43:57 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 76E856D; Thu, 20 Oct 2016 03:43:36 -0700 (PDT) Received: from e104818-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 960143F218; Thu, 20 Oct 2016 03:43:35 -0700 (PDT) From: Catalin Marinas To: Simon Horman Subject: [PATCH v2] arm64: Add support for additional relocations in the kexec purgatory code Date: Thu, 20 Oct 2016 11:43:31 +0100 Message-Id: <1476960211-25594-1-git-send-email-catalin.marinas@arm.com> X-Mailer: git-send-email 2.1.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161020_034356_881396_267BCB0F X-CRM114-Status: UNSURE ( 7.93 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Geoff Levand , kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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 Signed-off-by: Catalin Marinas Reviewed-by: Geoff Levand --- 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;