From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4881FC83F12 for ; Tue, 29 Aug 2023 12:17:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=hETOfah6frDc8zCiFqb/PSvpRHOIgwVLktFMA79HqYs=; b=Eb18frv43ScuCf C9rc0h5W+rq47uue7ByMH2DTfQ3uKdqxCtjE279Ak8KO83Jg6fGJwPi13f7QiuVshonmLo1jchTOL 1YbkW25J78ugkOTZBZ2QBU/mX4rhsCSwjX7jZof3soAc/Kg7m756013F+1QCRZgcQsPIHoaiIN7D4 7bJgwfKKeMtJ7sgzElJRNn3K9z1axeoYFukTheCobRY5RmLmfbGDX1Bt6xR1+nbqrVyKH9jbDN/yt +t8HS54bOtMAiRdGsUJIUmPyguCR0/G4VHT/wcC08GmW4FQfo/k+0kNYshtKeSOfm1uNLpNC2WVk+ aM5qPtOi5JbmO1UWr+gg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qaxeB-00BTZD-3C; Tue, 29 Aug 2023 12:16:39 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qaxe8-00BTXD-1L for linux-arm-kernel@lists.infradead.org; Tue, 29 Aug 2023 12:16:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1693311395; 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=Ti+FZphx3tTCt2+5tJQ+9yD5S9gf+CV5t2KKqvLpfrs=; b=AB2TdT13UrFTPfi8WiRo6XtL2pHLnST0h/5rgh/n9j1xrVkCfvZuv9UbyZKbDMHpg9covD PJw2o1TcR8zJqTxQeuDeylqYFY7gKtEFj2fvD+eyvrQ6WcWub81nTi78LblLTvlRlkqJrm ZwxS8qDhWhxboL48OxfRvQnpJ/+UQU4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-524-jJXsGeYGPDecp-p64D2GmQ-1; Tue, 29 Aug 2023 08:16:33 -0400 X-MC-Unique: jJXsGeYGPDecp-p64D2GmQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1C92D104458F; Tue, 29 Aug 2023 12:16:33 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id B8F026B2B4; Tue, 29 Aug 2023 12:16:28 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, catalin.marinas@arm.com, thunder.leizhen@huawei.com, dyoung@redhat.com, prudo@redhat.com, samuel.holland@sifive.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, Baoquan He Subject: [PATCH v2 3/8] crash_core: change parse_crashkernel() to support crashkernel=,high|low parsing Date: Tue, 29 Aug 2023 20:16:05 +0800 Message-ID: <20230829121610.138107-4-bhe@redhat.com> In-Reply-To: <20230829121610.138107-1-bhe@redhat.com> References: <20230829121610.138107-1-bhe@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230829_051636_522231_5B676EB9 X-CRM114-Status: GOOD ( 16.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Now parse_crashkernel() is a real entry point for all kinds of crahskernel parsing on any architecture. And wrap the crahskernel=,high|low handling inside CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION ifdeffery scope. Signed-off-by: Baoquan He --- include/linux/crash_core.h | 6 ++++++ kernel/crash_core.c | 28 +++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h index 2e76289699ff..85260bf4a734 100644 --- a/include/linux/crash_core.h +++ b/include/linux/crash_core.h @@ -77,6 +77,12 @@ Elf_Word *append_elf_note(Elf_Word *buf, char *name, unsigned int type, void *data, size_t data_len); void final_note(Elf_Word *buf); +#ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION +#ifndef DEFAULT_CRASH_KERNEL_LOW_SIZE +#define DEFAULT_CRASH_KERNEL_LOW_SIZE (128UL << 20) +#endif +#endif + int __init parse_crashkernel(char *cmdline, unsigned long long system_ram, unsigned long long *crash_size, unsigned long long *crash_base, unsigned long long *low_size, bool *high); diff --git a/kernel/crash_core.c b/kernel/crash_core.c index f6a5c219e2e1..355b0ab5189c 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -276,6 +276,9 @@ static int __init __parse_crashkernel(char *cmdline, /* * That function is the entry point for command line parsing and should be * called from the arch-specific code. + * + * If crashkernel=,high|low is supported on architecture, non-NULL values + * should be passed to parameters 'low_size' and 'high'. */ int __init parse_crashkernel(char *cmdline, unsigned long long system_ram, @@ -291,7 +294,30 @@ int __init parse_crashkernel(char *cmdline, crash_base, NULL); if (!high) return ret; - +#ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION + else if (ret == -ENOENT) { + ret = __parse_crashkernel(cmdline, 0, crash_size, + crash_base, suffix_tbl[SUFFIX_HIGH]); + if (ret || !*crash_size) + return -1; + + /* + * crashkernel=Y,low can be specified or not, but invalid value + * is not allowed. + */ + ret = __parse_crashkernel(cmdline, 0, low_size, + crash_base, suffix_tbl[SUFFIX_LOW]); + if (ret == -ENOENT) + *low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE; + else if (ret) + return -1; + + *high = true; + } else if (ret || !*crash_size) { + /* The specified value is invalid */ + return -1; + } +#endif return 0; } -- 2.41.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel