From patchwork Mon Aug 8 22:19:33 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 9269883 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 4F13660754 for ; Mon, 8 Aug 2016 22:22:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A6BA20748 for ; Mon, 8 Aug 2016 22:22:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0637D28173; Mon, 8 Aug 2016 22:22:07 +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 330C320748 for ; Mon, 8 Aug 2016 22:22:04 +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 1bWstf-0004Mg-TS; Mon, 08 Aug 2016 22:19:47 +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 1bWstV-0004KT-Pa; Mon, 08 Aug 2016 22:19:37 +0000 Received: from geoff by merlin.infradead.org with local (Exim 4.85_2 #1 (Red Hat Linux)) id 1bWstR-0001PN-EX; Mon, 08 Aug 2016 22:19:33 +0000 Message-Id: <726816b353ad67c222d135117145dd03663bb863.1470693832.git.geoff@infradead.org> In-Reply-To: References: From: Geoff Levand Patch-Date: Tue, 26 Jul 2016 11:47:26 -0700 Subject: [PATCH v3 3/3] arm64: Add support for binary image files To: Simon Horman Date: Mon, 08 Aug 2016 22:19:33 +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 | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/kexec/arch/arm64/kexec-image-arm64.c b/kexec/arch/arm64/kexec-image-arm64.c index 84386f7..cad7c73 100644 --- a/kexec/arch/arm64/kexec-image-arm64.c +++ b/kexec/arch/arm64/kexec-image-arm64.c @@ -24,21 +24,40 @@ 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 -EFAILED; + 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 -EINVAL; + + 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) { printf( " An ARM64 binary image, compressed or not, big or little endian.\n" -" Typically an Image, Image.gz or Image.lzma file.\n" -" This file type is currently NOT SUPPORTED.\n\n"); +" Typically an Image, Image.gz or Image.lzma file.\n\n"); }