From patchwork Tue Feb 27 04:48:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 10244297 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 47E23602DC for ; Tue, 27 Feb 2018 04:54:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3846E2A32C for ; Tue, 27 Feb 2018 04:54:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D2DB2A33F; Tue, 27 Feb 2018 04:54:33 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A2FC52A32C for ; Tue, 27 Feb 2018 04:54:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Oeemqqe3TeCcaVGrESJsFE9rbxI7PRbeAPFuvt8HNZU=; b=ml8QzEtlXEzoIctuzuX7on3mkv eTmYbPCIvXWA6+LcX2i0KLiHd/y6wa+jYa9tMK2Vwz/DQiQNefWKiaMUeCWFksgYhyV/OaUD7yWZk b+qo3dq90LF1PyflMui9blsxjtpPAMnIpJvR/XScdcP6GCGcLVogo2dPvOdoteoON0b4Al9P2y04C N1qEn7awndSvgVtJCoK+5vHGZJ5eKX+W1U1mIRAC4K1QbnAVbS0nUBJXEjyXPET69ghcOLAGdxg4c U6/0JNRn2K1CSvEZIwU4IJ24N8Z6imMCjg7A0lnPEZXoSc31LDZmlvRG4HOHdIPvnDJnzFQL65Fzz VizWauUA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eqXHU-0000zh-EO; Tue, 27 Feb 2018 04:54:24 +0000 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eqXCR-0005R6-8Z for linux-arm-kernel@lists.infradead.org; Tue, 27 Feb 2018 04:49:30 +0000 Received: by mail-pl0-x243.google.com with SMTP id v9-v6so8712615plp.12 for ; Mon, 26 Feb 2018 20:49:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QvzF2gs9p77aZLCB3cMbh1eerON3Jw+ujHfeF/3NmMU=; b=FrhZKf7NOeSkcgT6GEM1x3Pi3MPt5QgstPi3YppXnG2mA4B1JU9t9XWbs3f/L6KCqG 8M6tktyB0O02RvzsWSVw1Ku07ZPh5OTTBxs11CSdDHcm9G1aNKQaUlaUe52G2vVyqaii UejRjV0QnwtcKgAAGhi2e+o1BASILTrJz0QiY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QvzF2gs9p77aZLCB3cMbh1eerON3Jw+ujHfeF/3NmMU=; b=uKHMhWtEjIXNyUcu9dWpYdUfKliuidG7y7Gn3BoO6odN00NEHvdDQsMVFBgf+VvZ3+ ySe9BQWnRZJL5annUu8zOZYgEmHHKiA9uqodSm3GTG2scEPHCi9Kd9wvSufGzu3ZREnk aUyy7xairZ5eTubDTfLbMlezmA92pMqrATfxFeAcnnutlXl0+RpFQ/fiFo3BneMCy9d3 zHbbPy0ogtPs0LWsuNEGdbrJhYRNwixIlA44a5yhtCCGbiWN2DdADvBXg6z+gxtumrZO N26j5BNEEhjbcv7CmiFjI2uOwfxWIZLFGIP1Zngg6tm0FczTfScA3/nUMi634kj6/CH6 CIBA== X-Gm-Message-State: APf1xPCxaoJNW/4ng4Nr0kHqE3GPcUlGPq5gmYdNUhGYGhz7T+q8NiRL uH/NXpBw4YJ+ZspxtAzcBNFH2Q== X-Google-Smtp-Source: AH8x227iRE/quI/l4eKroa2qtjtoAkgTmB1BVdTN4vmG78njAO8eZG8Z1NQr/Ejhx6JWioM6R7EG/w== X-Received: by 2002:a17:902:9881:: with SMTP id s1-v6mr12791067plp.286.1519706939942; Mon, 26 Feb 2018 20:48:59 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id o184sm16563895pga.16.2018.02.26.20.48.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Feb 2018 20:48:59 -0800 (PST) From: AKASHI Takahiro To: dyoung@redhat.com, vgoyal@redhat.com, bhe@redhat.com, mpe@ellerman.id.au, bauerman@linux.vnet.ibm.com, prudo@linux.vnet.ibm.com Subject: [PATCH 4/7] x86: kexec_file: remove X86_64 dependency from prepare_elf64_headers() Date: Tue, 27 Feb 2018 13:48:11 +0900 Message-Id: <20180227044814.24808-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180227044814.24808-1-takahiro.akashi@linaro.org> References: <20180227044814.24808-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180226_204912_273807_66661FD6 X-CRM114-Status: GOOD ( 13.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-s390@vger.kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, AKASHI Takahiro 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 The code guarded by CONFIG_X86_64 is necessary on some architectures which have a dedicated kernel mapping outside of linear memory mapping. (arm64 is among those.) In this patch, an additional argument, kernel_map, is added to enable/ disable the code removing #ifdef. Signed-off-by: AKASHI Takahiro Cc: Dave Young Cc: Vivek Goyal Cc: Baoquan He --- arch/x86/kernel/crash.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index 2123fa0efc17..913fd8021f8a 100644 --- a/arch/x86/kernel/crash.c +++ b/arch/x86/kernel/crash.c @@ -347,7 +347,7 @@ static int prepare_elf64_ram_headers_callback(struct resource *res, void *arg) return 0; } -static int prepare_elf64_headers(struct crash_elf_data *ced, +static int prepare_elf64_headers(struct crash_elf_data *ced, int kernel_map, void **addr, unsigned long *sz) { Elf64_Ehdr *ehdr; @@ -414,17 +414,17 @@ static int prepare_elf64_headers(struct crash_elf_data *ced, phdr->p_filesz = phdr->p_memsz = VMCOREINFO_NOTE_SIZE; (ehdr->e_phnum)++; -#ifdef CONFIG_X86_64 /* Prepare PT_LOAD type program header for kernel text region */ - phdr = (Elf64_Phdr *)bufp; - bufp += sizeof(Elf64_Phdr); - phdr->p_type = PT_LOAD; - phdr->p_flags = PF_R|PF_W|PF_X; - phdr->p_vaddr = (Elf64_Addr)_text; - phdr->p_filesz = phdr->p_memsz = _end - _text; - phdr->p_offset = phdr->p_paddr = __pa_symbol(_text); - (ehdr->e_phnum)++; -#endif + if (kernel_map) { + phdr = (Elf64_Phdr *)bufp; + bufp += sizeof(Elf64_Phdr); + phdr->p_type = PT_LOAD; + phdr->p_flags = PF_R|PF_W|PF_X; + phdr->p_vaddr = (Elf64_Addr)_text; + phdr->p_filesz = phdr->p_memsz = _end - _text; + phdr->p_offset = phdr->p_paddr = __pa_symbol(_text); + (ehdr->e_phnum)++; + } /* Go through all the ranges in cmem->ranges[] and prepare phdr */ for (i = 0; i < cmem->nr_ranges; i++) { @@ -477,7 +477,8 @@ static int prepare_elf_headers(struct kimage *image, void **addr, goto out; /* By default prepare 64bit headers */ - ret = prepare_elf64_headers(ced, addr, sz); + ret = prepare_elf64_headers(ced, + (int)IS_ENABLED(CONFIG_X86_64), addr, sz); if (ret) goto out;