From patchwork Tue Jul 19 23:28:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geoff Levand X-Patchwork-Id: 9238473 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 8826E607DA for ; Tue, 19 Jul 2016 23:30:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 788A526C2F for ; Tue, 19 Jul 2016 23:30:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 627772793D; Tue, 19 Jul 2016 23:30:30 +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 25D90277D9 for ; Tue, 19 Jul 2016 23:30:30 +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 1bPeRN-0005iP-CU; Tue, 19 Jul 2016 23:28:41 +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 1bPeQz-0005bg-QG; Tue, 19 Jul 2016 23:28:17 +0000 Received: from geoff by merlin.infradead.org with local (Exim 4.85_2 #1 (Red Hat Linux)) id 1bPeQv-0006tJ-Ix; Tue, 19 Jul 2016 23:28:13 +0000 Message-Id: <5b7aa684a9f2cf26a71b78f82d279f1d93fd644a.1468970114.git.geoff@infradead.org> In-Reply-To: References: From: Geoff Levand Patch-Date: Thu, 14 May 2015 11:25:37 +0530 Subject: [PATCH v1 4/4] arm64: Add support for binary image files To: Simon Horman Date: Tue, 19 Jul 2016 23:28:13 +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 , 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 caf90c7..cad7c73 100644 --- a/kexec/arch/arm64/kexec-image-arm64.c +++ b/kexec/arch/arm64/kexec-image-arm64.c @@ -24,15 +24,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 -ENOSYS; + 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) @@ -40,5 +60,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"); -" This file type is currently NOT SUPPORTED.\n\n"); }