From patchwork Tue Mar 6 10:23:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 130760 Delivered-To: patch@linaro.org Received: by 10.46.66.2 with SMTP id p2csp3762149lja; Tue, 6 Mar 2018 02:23:37 -0800 (PST) X-Google-Smtp-Source: AG47ELvagU1PYHQjQQa1c2YdpEbyruWSIAwegCYy743hIjGozjxmdJGEhtgS1GgivUvD7uYzqFdV X-Received: by 10.99.185.7 with SMTP id z7mr15141708pge.123.1520331817421; Tue, 06 Mar 2018 02:23:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520331817; cv=none; d=google.com; s=arc-20160816; b=esBKmMwCp4W8hWC22K8OxJtDlSe1BKLzQ3X17rpnTyRD1wajaDHYaxMMJ2dMhHJC7a O8PJ7CXgjUK3Sc8bzzVLcCE5nfsydmgXce69HxGCJTEPfyigMfL07MaaJERoCG6H30Ed PgbRCqvlMPKPk6kt3cHluXwrdhGsLgzNdQbduGHtvhKMVqD4oYNzuFY1m1BKOUbU94KH L5D46BY9FmMv/IN8d4vLEYMxiHIHpIMV32Oi/gxmhlHTltkr8tLxXxC1yMG4LMI6OJh8 r7bHDPTA19SYdbFGYiLCxdvFiyM/e4poYOBep4ltOt5cCBVRHlFuuswHo23DWeSrfHDs Udzw== 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=d6Ypw70si/N5yDuCn8ahcqNjgVw4ZqeO0m057ExWqoA=; b=YvCQyJuy7d1K69bJgb3AUpP36/U34OrJ8hPEBQ02C0Pyjwjcz4rSk09R1fBNLeALRw Nna9lKVOLwCGBATvFU/v7CvpduY3B2hDPfCSng17AiHwyG6MCXEYouvUwCqhz5K1xNgi v9JaY4phloha8m1pylU5Aie22gcEKqjm1She9UidYMfrN3MancydxB1WOBjT4vqpBp6h rE4KFVI1KjLVAOUuVkxbdp50Y1vqeaERexd5nYDQSc6AmN4Rt1Gj0F3q/1WfOFEDfHz8 MpKmJ+zsKszDE6easT03nxJGED6Q4hCN7ELGmXxDuMmQfHX6nCt8yEszHSrwh5TlGbMk ZPuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LQfesa+C; 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 x4-v6si10789697plw.297.2018.03.06.02.23.37; Tue, 06 Mar 2018 02:23:37 -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=LQfesa+C; 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 S1753496AbeCFKXd (ORCPT + 28 others); Tue, 6 Mar 2018 05:23:33 -0500 Received: from mail-it0-f65.google.com ([209.85.214.65]:53418 "EHLO mail-it0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753453AbeCFKXa (ORCPT ); Tue, 6 Mar 2018 05:23:30 -0500 Received: by mail-it0-f65.google.com with SMTP id w63so13141955ita.3 for ; Tue, 06 Mar 2018 02:23:29 -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=d6Ypw70si/N5yDuCn8ahcqNjgVw4ZqeO0m057ExWqoA=; b=LQfesa+Cd9vDV3kRQy2p39RZL2z//JnhmcrN+dVIRRFvElmvR3sWq7bgUcAY/4CPmx TGDUTJ8WbWa0yJlO71ZXiaXECfwsdf6+uX8fe5g4kupHrXYdKQblqj0a3yzWYB03Zra/ iiE6NlaZV895Or03bg/95gGOlKxQBpbPDEiRo= 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=d6Ypw70si/N5yDuCn8ahcqNjgVw4ZqeO0m057ExWqoA=; b=e92mIaXRcv0f1ql18venhj122k8JzkmMmfgA90uOgI7AyHx3L8NLCTXNXg6P4hTnE4 EKEncg5TB0Y2wST2AsjJfRXVOsX+h3G+l2yGrHEIRm+EA4vbnQ0Eu+LzS4g5x/nz3Of8 3lAa04vlMWw7vDZwP4x5cOCJRAkV8D4k7H9+/IuEF14Aeku5PB/pEc9x6+m+0ojt8L58 DFhe2Dzi9gpcVrOBpU9CNJZgO+iFEedT3FAczGEqIEumrrC5JUB5UKEt3RQOvLRUAXr4 4Ildk83pjSTPTpwNABaqg5zmaZ/iaVy5pUVzr5nXK4CQCAZZn+gQ3BsBUKClFdHdbjkr 9bNw== X-Gm-Message-State: AElRT7H4JIr9zDoUN/WYIgft68u2/gvVnHqRIIA7ryatpuA+8VWyDCP4 KTUaXCYiwkE0GUnnwII+wReGCw== X-Received: by 10.36.175.66 with SMTP id l2mr17564596iti.43.1520331809633; Tue, 06 Mar 2018 02:23:29 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id v2sm9672414iob.21.2018.03.06.02.23.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Mar 2018 02:23:29 -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 v2 4/7] x86: kexec_file: remove X86_64 dependency from prepare_elf64_headers() Date: Tue, 6 Mar 2018 19:23:00 +0900 Message-Id: <20180306102303.9063-5-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180306102303.9063-1-takahiro.akashi@linaro.org> References: <20180306102303.9063-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 | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) -- 2.16.2 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c index 2123fa0efc17..b328153cee65 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, bool 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,7 @@ 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, IS_ENABLED(CONFIG_X86_64), addr, sz); if (ret) goto out;