From patchwork Thu Aug 18 18:21:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 9288583 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 935D8607FF for ; Thu, 18 Aug 2016 18:24:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A14A28EA3 for ; Thu, 18 Aug 2016 18:24:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7EDB728EC6; Thu, 18 Aug 2016 18:24:25 +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 392C028EA3 for ; Thu, 18 Aug 2016 18:24:25 +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 1baRxD-0006Zi-4M; Thu, 18 Aug 2016 18:22:11 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1baRwB-0006Bv-4Q; Thu, 18 Aug 2016 18:21:07 +0000 Received: from geoff by merlin.infradead.org with local (Exim 4.85_2 #1 (Red Hat Linux)) id 1baRw6-0002pG-Ss; Thu, 18 Aug 2016 18:21:02 +0000 Message-Id: <7b17bc40e62e90fd92207d4385a0a99aec958d26.1471543843.git.geoff@infradead.org> In-Reply-To: References: From: Geoff Levand Patch-Date: Thu, 18 Aug 2016 11:09:39 -0700 Subject: [PATCH v4 3/3] arm64: Add support for binary image files To: Simon Horman Date: Thu, 18 Aug 2016 18:21:02 +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: Pratyush Anand , AKASHI Takahiro , Mark Rutland , 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 From: Pratyush Anand Signed-off-by: Pratyush Anand [Reworked and cleaned up] Signed-off-by: Geoff Levand --- kexec/arch/arm64/kexec-image-arm64.c | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/kexec/arch/arm64/kexec-image-arm64.c b/kexec/arch/arm64/kexec-image-arm64.c index 42d2ea7..b77b63e 100644 --- a/kexec/arch/arm64/kexec-image-arm64.c +++ b/kexec/arch/arm64/kexec-image-arm64.c @@ -21,14 +21,35 @@ int image_arm64_probe(const char *kernel_buf, off_t kernel_size) return -1; } - fprintf(stderr, "kexec: ARM64 binary image files are currently NOT SUPPORTED.\n"); - return -1; + return 0; } int image_arm64_load(int argc, char **argv, const char *kernel_buf, off_t kernel_size, struct kexec_info *info) { - return -1; + const struct arm64_image_header *h; + unsigned long image_base; + + h = (const struct arm64_image_header *)(kernel_buf); + + if (arm64_process_image_header(h)) + return -1; + + dbgprintf("%s: text_offset: %016lx\n", __func__, + arm64_mem.text_offset); + dbgprintf("%s: image_size: %016lx\n", __func__, + arm64_mem.image_size); + dbgprintf("%s: phys_offset: %016lx\n", __func__, + arm64_mem.phys_offset); + dbgprintf("%s: PE format: %s\n", __func__, + (arm64_header_check_pe_sig(h) ? "yes" : "no")); + + image_base = get_phys_offset() + arm64_mem.text_offset; + + add_segment_phys_virt(info, kernel_buf, kernel_size, image_base, + arm64_mem.image_size, 0); + + return arm64_load_other_segments(info, image_base); } void image_arm64_usage(void) @@ -36,6 +57,4 @@ void image_arm64_usage(void) printf( " An ARM64 binary image, compressed or not, big or little endian.\n" " Typically an Image, Image.gz or Image.lzma file.\n\n"); - printf( -" ARM64 binary image files are currently NOT SUPPORTED.\n\n"); }