Received: by 10.223.185.116 with SMTP id b49csp4533972wrg; Mon, 26 Feb 2018 20:51:26 -0800 (PST) X-Google-Smtp-Source: AH8x225bJQaFNkOORGBO4RfRKCYgyZwWzxU13w7ZsJ1I0hPP3ew9P3FkET3zXjocuRnIYgxfap71 X-Received: by 10.101.83.140 with SMTP id x12mr10032204pgq.288.1519707086297; Mon, 26 Feb 2018 20:51:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519707086; cv=none; d=google.com; s=arc-20160816; b=BmyzTQzdmchYQFsGPCpMhBrQqZceWZ40sLR6djyd1Q4sxygvHPgrcl1+wMZcME356a C6ribV5s9HOfjUTFeLZ9V91IDXHoXnFxh/HIdEmjsjkGovwAw2X+GygfyCVvgTwr1Zgo uwepXS+YoQ7rWFhvVVpsBM9iZA536m889tkT7wL25terimo9Ys/Nol+zIv0YNeIM5+v8 rDDiSpISt1MHY1PzemWzsevln6QD43LTcLn7MpRVQMMkqN7Zu5HwxqqZzwn8BbovQxFO hqmLdt2XqbnSuWA+9W3TbD4BOnsrAMgMEglbTsPeMOwXXdHqSLV7LT8Hfn9FvVmcWnK5 FTLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=QvzF2gs9p77aZLCB3cMbh1eerON3Jw+ujHfeF/3NmMU=; b=dmx+Zaiy4S0OKJbU1U5YXWD9W21xpPaXPOUAX3BSw6uhq7pRj+pGQ9Nv/Df5qQdvOK lPxBBI+hN+IpvGHB0sWnIspq3SZOOpPFKhvtfOwYQ+sKJ/UWUXtP7C7TxixlpwZSJJYG jCW9zTGmeWfZm6BuIkB3rOBZjd8SDnW0dpzPKyJGZynqGU6UVRh5Gs40f85zmNn/v6Y4 PhjOaKAibefenH7iBCbt240pFix7fjOcObDU989WhP2NRIGCGw0iKcs/5o/tVfAJlz8l VOLXPMyh0kcxz9PnmN+vkrXrEBpWZGVeNuCJrsgFR7tZMPRhRT5Sj/YM3gHHu9Bu7wPk RxiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FrhZKf7N; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b63-v6si2903338plb.12.2018.02.26.20.51.12; Mon, 26 Feb 2018 20:51:26 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FrhZKf7N; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752062AbeB0Ety (ORCPT + 99 others); Mon, 26 Feb 2018 23:49:54 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:35910 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752066AbeB0EtA (ORCPT ); Mon, 26 Feb 2018 23:49:00 -0500 Received: by mail-pl0-f65.google.com with SMTP id v3so10726204plg.3 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=b6mq5bF2KxzPhBMkVnO0Ed/JJbwuYw3LLHAxv59Le3+tx70LoAdsb31NMiN3z+3wBg 08Er95tWVZhYjDxo1RpIp7mJvSwO3UEUvbOWUj888tAouHH4eh6jami8by05x8a1/kvH JBwrnT4WS1I+0cH3BHVH5Y+j7smBvWPgFiIqQ5MfkMakunHR13rhrfvEuGo45zSs4c4y vQHkZF5JteOCxFp+CT9PwjLaYMpui7cX4N6l/V/wh66MiQ95Ir6wbSyPHZvU5QOuXkxt pdTSQVwmgZXgWqYVRfLEruQlAAtMoSPKMPWQLwTA5jjONVmOww+FAGKQTELFJgrmxQXE V8MA== X-Gm-Message-State: APf1xPC5BIjGU8zi4S5do78OgSuO0ihkl2l0+GDvuFkSdBAde7YETUIA pLTArwyHlPkIwvBOIA8nMKad3A== 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 Cc: kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org, AKASHI Takahiro 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.16.2