Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3995322rdb; Thu, 14 Sep 2023 08:45:25 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEHA072+F90hcGLv6tbyvjeIxNPZSGQEB0NXFgJSWQvoXez9cDGOdfqZhUJfmA3bpTTJS24 X-Received: by 2002:a05:6358:ce03:b0:142:ecad:c74 with SMTP id gt3-20020a056358ce0300b00142ecad0c74mr3018046rwb.7.1694706325002; Thu, 14 Sep 2023 08:45:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694706324; cv=none; d=google.com; s=arc-20160816; b=J8QiGdC/9PjIiqLi5W2xCSIv5N4yr3NC/LAJKov/VxY7j7iJarJPgM3MeFKplPkWb9 /gROwN94wsPd4wja932LxCngtPVkjww4hykG2uFOOHu8OV/Vz+XK7mMX+Q7UBagYsvNU ncVaOZgB5GjxQWT1aCAkYI9N6ztZOTAm8bIcHx3tKa/sDAvYAm3k5grTPU0x7FkPNpkE AyKflh5DxtBrghvFIE2UHnhbjD5JSt2zyfy46kgu6Gq9/cCEIoZxEAZtqALfAVxOYIs5 4YfoRqeRFe5NM+2rRVJ1Gr4GuvPss7gyt20Ni7O++xxHlAlNj3OvuXbToqoC2mh1xkEY AM0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LO8iddQy5SUYo0oFdFE0+QnNUGHrkEvy5Cyf9fh/McM=; fh=MEj7E4phu0bfxfJQeKfSjdtfALcYFA7fSBdgsxijU1g=; b=POOsKx3vwR5AA8t5af09CdWdE2ghhAe82JAlYFghfB+5w0bsUwt+WQ6bf6+h3OF6Pa EB05H4oqYHVL59E5hqL9kwLzQiuZTHqRznX+8ImS81b/qLBR7f7FAMn02uZ89H8HCJMj u0qNBShUAP8ojhoqs5XIQ5WBbzwBvJo9LhOtsK/YawJcEIZwDWB8wgt3SsU8Ac3eZ4l3 VrU0zV67vA3RgE96OgIsnypO7gn0Rs5FEfQn2z1zKqQCMKWbyAKX4KdAoJ1eDkrfWMZa 2PcKFtTkKbIfUb2fVNMxqAPAuPaBnSSFHdCNKleS1PH/QAsq3uJzE95y5D3CYiBKSKO4 UfTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YIMvQZEV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id o66-20020a634145000000b005777bea0b5esi1676505pga.901.2023.09.14.08.45.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 08:45:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YIMvQZEV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id ABC47828789A; Wed, 13 Sep 2023 20:33:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234364AbjINDdC (ORCPT + 99 others); Wed, 13 Sep 2023 23:33:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54814 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234250AbjINDc5 (ORCPT ); Wed, 13 Sep 2023 23:32:57 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A421E1BE1 for ; Wed, 13 Sep 2023 20:32:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694662325; 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=LO8iddQy5SUYo0oFdFE0+QnNUGHrkEvy5Cyf9fh/McM=; b=YIMvQZEVFHPzz8pQZyPQlm8m+1hCY0GFCU6FU3qEGFaqo2SY3j8ngzEQOa5VGLJ99nIuAm 5txJERGKA4/WLy6ful36hLyavAuKDVIqbZQmuJMjIDUgs0/4qLChYPodoVmrNoZmWV3KAJ W6eAmNEeryLoRgzaA9dUslRedNRmSgk= 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-97-EMldp75JNTm8H3vUthNEkA-1; Wed, 13 Sep 2023 23:32:04 -0400 X-MC-Unique: EMldp75JNTm8H3vUthNEkA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8A7FF185A790; Thu, 14 Sep 2023 03:32:03 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.112.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id B36BA10F1BE7; Thu, 14 Sep 2023 03:31:59 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: akpm@linux-foundation.org, thunder.leizhen@huawei.com, catalin.marinas@arm.com, chenjiahao16@huawei.com, kexec@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, x86@kernel.org, Baoquan He Subject: [PATCH v3 3/9] crash_core: change parse_crashkernel() to support crashkernel=,high|low parsing Date: Thu, 14 Sep 2023 11:31:36 +0800 Message-ID: <20230914033142.676708-4-bhe@redhat.com> In-Reply-To: <20230914033142.676708-1-bhe@redhat.com> References: <20230914033142.676708-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 13 Sep 2023 20:33:09 -0700 (PDT) X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email 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 | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h index 6156355ef831..d8050a7eab01 100644 --- a/include/linux/crash_core.h +++ b/include/linux/crash_core.h @@ -79,6 +79,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 cca1d76e8255..dce2f5874fea 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -283,6 +283,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, @@ -296,10 +299,37 @@ int __init parse_crashkernel(char *cmdline, /* crashkernel=X[@offset] */ ret = __parse_crashkernel(cmdline, system_ram, crash_size, crash_base, NULL); - if (!high) - return ret; +#ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION + /* + * If non-NULL 'high' passed in and no normal crashkernel + * setting detected, try parsing crashkernel=,high|low. + */ + if (high && ret == -ENOENT) { + ret = __parse_crashkernel(cmdline, 0, crash_size, + crash_base, suffix_tbl[SUFFIX_HIGH]); + if (ret || !*crash_size) + return -EINVAL; - return 0; + /* + * 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; + ret = 0; + } else if (ret) { + return ret; + } + + *high = true; + } +#endif + if (!*crash_size) + ret = -EINVAL; + + return ret; } int __init parse_crashkernel_high(char *cmdline, -- 2.41.0