From patchwork Wed Oct 19 15:58:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 78296 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp321679qge; Wed, 19 Oct 2016 09:00:25 -0700 (PDT) X-Received: by 10.98.144.83 with SMTP id a80mr12606588pfe.156.1476892824722; Wed, 19 Oct 2016 09:00:24 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id v26si39808114pfg.226.2016.10.19.09.00.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Oct 2016 09:00:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org 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 1bwtGu-0001A7-31; Wed, 19 Oct 2016 15:59:16 +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 1bwtGa-0000nz-G6; Wed, 19 Oct 2016 15:59:03 +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 AC4B3F; Wed, 19 Oct 2016 08:58:39 -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 CD50D3F218; Wed, 19 Oct 2016 08:58:38 -0700 (PDT) From: Catalin Marinas To: Simon Horman Subject: [PATCH] arm64: Add support for additional relocations in the kexec purgatory code Date: Wed, 19 Oct 2016 16:58:34 +0100 Message-Id: <1476892714-27304-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-20161019_085856_945735_B771197C X-CRM114-Status: UNSURE ( 7.78 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -8.3 (--------) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-8.3 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [217.140.101.70 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.4 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 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+patch=linaro.org@lists.infradead.org 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 --- kexec/arch/arm64/kexec-arm64.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) -- 2.10.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 = "R_AARCH64_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 = "R_AARCH64_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;