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: 129739 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp973332lja; Mon, 26 Feb 2018 20:49:58 -0800 (PST) X-Google-Smtp-Source: AH8x225stVRhOlPeTlPbuus2MpbxsXDYVDYQANDL2AYEZWkozYMuuOMfeFNWEZHTEWRpOpvsirfX X-Received: by 2002:a17:902:5a88:: with SMTP id r8-v6mr13443076pli.426.1519706998301; Mon, 26 Feb 2018 20:49:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519706998; cv=none; d=google.com; s=arc-20160816; b=I1sElfHuO9jhiFr7M1CrcROFo6onGgF79ULVv1rPzRami0C7wnpWdmMQaD5XltvXmk VQ8zOEvqzJsziR+RiIHr7LZzoE7LSE0QOCz6+z8MzDkn/NsvvP6BN9IAtZt8H1h70XS2 s6jFVJCa5yQp+wg+6+KVnf2s6hRfYoMdUw7IqOApWYf7wttSM1USnNcDPaoLTtmCI3l3 zAC9ExzIAaN4iwAxqEgRnBH8GlQNpaTRaQ/Sb4+i2zre/MXqB/W8/DnB3S0FpZp78z2Z Q/QPrTGKxCOsXMiKkzMxIjrqHx7U/DvyuxarmuJzmhq38EquYJITz/weidRKDsqVeYJg IwYg== 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 1-v6si6192007plk.52.2018.02.26.20.49.58; Mon, 26 Feb 2018 20:49:58 -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 S1752164AbeB0Etz (ORCPT + 28 others); Mon, 26 Feb 2018 23:49:55 -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(-) -- 2.16.2 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;