Received: by 2002:a05:7412:ba23:b0:fa:4c10:6cad with SMTP id jp35csp1052424rdb; Fri, 19 Jan 2024 06:56:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IHmiYXG7qevKTS9dB9oYZFHqEfiVNlMFi+BRXyXH1qM5llSizyEyDW4NZO3VEmFGjqpBst1 X-Received: by 2002:a05:6359:459a:b0:176:280c:56c2 with SMTP id no26-20020a056359459a00b00176280c56c2mr1863849rwb.40.1705676204030; Fri, 19 Jan 2024 06:56:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705676204; cv=pass; d=google.com; s=arc-20160816; b=punXxJdP2un+mKdkLth2oaP1St05z9JCPWsrChgtDpJtKDVu7hQmPGUBBFSLZJ4p+4 /FMBGRwX7ZitIwLpz8lTl0gGPz+oO78swMJF80tnECc5EXiuvjGcULSV/U5v6nJ5oEWL n6GOBRjJDAs24LaD24hbg9+uh13l6RyiJlHFnmyiQdlU10b1zIgNuKTcGylwEnEc+GUc deiUczItYlsNS7EF9do4ZeCNkQLTraFYJHiTXAKmk62J+7/NZZdhAdnzIrcmjA20e7G1 PWhnnFvca4pi4rLTk0DB2BPAuhx6grVH0vwrt87zcYIFAqPdsglGuZ2b1QGNFEzkSvce U7ug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=YldSOlh0hkcoW/MWmNQsk4AfGocgJu1kcEOopM/OxN4=; fh=zRw2lYWZmEZ+xk8Dyhrd0rqHIpogjnUXaVblO2ikfrI=; b=dH8VVTK+Pa0lbh20IxjFbE9oRofzYLbywiV+OT/MjDSR8OjDSqvbZAwFxVM7gmU+af DQA4bnFT5j+SIZIm+Mw6cejY6q2p9dn9H018uiz7ON51LEkMtM/PHwgEain04+ENec60 B8zLxfzxyvp+ti0eyUqLyueXDL16Hcz/iYOS8p/DNVHHKv0939iT3yDsp2eokvCDjo4J PtCZvqTR/pZigiepANnsvwYphAo5mLRb6b4nVdJZS0B85KFOOHzfeokOHxDbcfQF0Gea TdNroAJizQE2hkcCK3Dk74YrwoSU5UaS3BMLu/5MsF2r9b2JrgyiIdegyj+tViW5AEuu 5K7Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZFynpPgp; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-31290-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31290-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id o15-20020a0c8c4f000000b0067f99bbc781si16800677qvb.109.2024.01.19.06.56.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jan 2024 06:56:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-31290-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZFynpPgp; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-31290-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-31290-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C30951C22A67 for ; Fri, 19 Jan 2024 14:56:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0733654F8E; Fri, 19 Jan 2024 14:54:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZFynpPgp" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DBF9E54F99 for ; Fri, 19 Jan 2024 14:54:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705676083; cv=none; b=DrP6aYcw2c2zmYdiK4uXy4p0HDKopMBc5C94tuN4Dpi/I3/E0Yi6Ty70cN6tLwDrHhNvgviK/qvA2CsSfdd32vhUegF2q2sm1OZPZDa5hq+TL5GyD6wtLMLnk+4DoWyFyABaqbtWisAZuZT0sALzkMbA+37QefviYcFPXsVOT4E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705676083; c=relaxed/simple; bh=XhmWHnKNjQt4hKXjEYLb81eIOcvKOMTGJnj1T40tBWY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-type; b=nb/Oh8IoL24kbqWjMVBu8PFjNIqGUFWZdHqZwWtqtoamiGRuWVkd/Qe3LtIDiRWTxT+lJLXfbqpq/KBtxsG8/MscKfKuZJ9Kxocl9SSf60SCIt2bm3hYYdAXkr1AtZ60LlhiQsO9DMrLfRgc3UEWzWfd9Ank0H6eUHrIH90Bm/s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZFynpPgp; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705676081; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YldSOlh0hkcoW/MWmNQsk4AfGocgJu1kcEOopM/OxN4=; b=ZFynpPgpffaHwiSlF1dOzGISyn3xWR2A/E5UKq/KRmMxfP+rimVbgjoyb+2WVuqLd0zIcf ArwV98ctpwrQGyrqMV5hiP4vONZoG7JFT0Tr0C1uw1SwduOkt7qeIgghweuj/CD7FWG3GC w+zSkVneapWiKhm46KKBFJD1nmdVAx0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-142-SZO2mk4PNgKXUDyiPm7Mhg-1; Fri, 19 Jan 2024 09:54:33 -0500 X-MC-Unique: SZO2mk4PNgKXUDyiPm7Mhg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3C41183DE48; Fri, 19 Jan 2024 14:54:30 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.116.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 189422949; Fri, 19 Jan 2024 14:54:23 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: kexec@lists.infradead.org, x86@kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-mips@vger.kernel.org, linux-riscv@lists.infradead.org, loongarch@lists.linux.dev, akpm@linux-foundation.org, ebiederm@xmission.com, hbathini@linux.ibm.com, piliu@redhat.com, viro@zeniv.linux.org.uk, Baoquan He Subject: [PATCH v2 13/14] riscv, crash: wrap crash dumping code into crash related ifdefs Date: Fri, 19 Jan 2024 22:52:40 +0800 Message-ID: <20240119145241.769622-14-bhe@redhat.com> In-Reply-To: <20240119145241.769622-1-bhe@redhat.com> References: <20240119145241.769622-1-bhe@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 Now crash codes under kernel/ folder has been split out from kexec code, crash dumping can be separated from kexec reboot in config items on risc-v with some adjustments. Here wrap up crash dumping codes with CONFIG_CRASH_DUMP ifdeffery, and use IS_ENABLED(CONFIG_CRASH_RESERVE) check to decide if compiling in the crashkernel reservation code. Signed-off-by: Baoquan He --- arch/riscv/kernel/elf_kexec.c | 9 +++++++-- arch/riscv/mm/init.c | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/arch/riscv/kernel/elf_kexec.c b/arch/riscv/kernel/elf_kexec.c index 5bd1ec3341fe..54260c16f991 100644 --- a/arch/riscv/kernel/elf_kexec.c +++ b/arch/riscv/kernel/elf_kexec.c @@ -117,6 +117,7 @@ static int elf_find_pbase(struct kimage *image, unsigned long kernel_len, return ret; } +#ifdef CONFIG_CRASH_DUMP static int get_nr_ram_ranges_callback(struct resource *res, void *arg) { unsigned int *nr_ranges = arg; @@ -189,6 +190,7 @@ static char *setup_kdump_cmdline(struct kimage *image, char *cmdline, cmdline_ptr[COMMAND_LINE_SIZE - 1] = '\0'; return cmdline_ptr; } +#endif static void *elf_kexec_load(struct kimage *image, char *kernel_buf, unsigned long kernel_len, char *initrd, @@ -196,12 +198,11 @@ static void *elf_kexec_load(struct kimage *image, char *kernel_buf, unsigned long cmdline_len) { int ret; + void *fdt; unsigned long old_kernel_pbase = ULONG_MAX; unsigned long new_kernel_pbase = 0UL; unsigned long initrd_pbase = 0UL; - unsigned long headers_sz; unsigned long kernel_start; - void *fdt, *headers; struct elfhdr ehdr; struct kexec_buf kbuf; struct kexec_elf_info elf_info; @@ -227,8 +228,11 @@ static void *elf_kexec_load(struct kimage *image, char *kernel_buf, kbuf.buf_min = new_kernel_pbase + kernel_len; kbuf.buf_max = ULONG_MAX; +#ifdef CONFIG_CRASH_DUMP /* Add elfcorehdr */ if (image->type == KEXEC_TYPE_CRASH) { + void *headers; + unsigned long headers_sz; ret = prepare_elf_headers(&headers, &headers_sz); if (ret) { pr_err("Preparing elf core header failed\n"); @@ -264,6 +268,7 @@ static void *elf_kexec_load(struct kimage *image, char *kernel_buf, } cmdline = modified_cmdline; } +#endif #ifdef CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY /* Add purgatory to the image */ diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index a65937336cdc..f580d1f6ee13 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -1354,7 +1354,7 @@ static void __init arch_reserve_crashkernel(void) bool high = false; int ret; - if (!IS_ENABLED(CONFIG_KEXEC_CORE)) + if (!IS_ENABLED(CONFIG_CRASH_RESERVE)) return; ret = parse_crashkernel(cmdline, memblock_phys_mem_size(), -- 2.41.0