Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3693938rdb; Wed, 13 Sep 2023 22:39:23 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE+QqELnStl5AoS0ROwvY1iq8mXTyC9zXe26tmljEYJ+NeO6JkD8GrKWOFsYpPXN4eIm3li X-Received: by 2002:a17:903:2001:b0:1c3:66a7:4e8d with SMTP id s1-20020a170903200100b001c366a74e8dmr4072209pla.20.1694669963376; Wed, 13 Sep 2023 22:39:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694669963; cv=none; d=google.com; s=arc-20160816; b=B3QPVqkSZVO5Mcyu91LYWJk/GIsY1My+NKv20LrVBooKvx4yl1o4kRHqo3dt2exR+C SR+phDm7z2SwCiyk9Vxt2ya7GIw78PBBTh/WgWTUH7sY/8KhLHkbW5jVG4a6FpvBjnDY FWgAJmjsgIC2vFQjxXYASd4Cf5wVHBP5mY+cTmtMICM0azCvFwR8zJ5VsChDeDeC4NWG 9aWksvqDogdvTqXkFbThyuGFvzgWSl9dCixX8uMzGQNg92cbEAxUw40e2WZYKQch7rE+ 9WHCeLm4V5GCrQ7qT0c+tWbHl5FHS+EW5WeH7NYZjDQqa/V409pP6VvKXGZIUB+ecvHN UWxQ== 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=CuyFNbtk2D5ZLNQLEQ3vxhJMzL7nFa+vxdXXthC35r8=; fh=MEj7E4phu0bfxfJQeKfSjdtfALcYFA7fSBdgsxijU1g=; b=xY+l9S3q69Rw9r9YpIWBewIBEfR8bQ7XfrjV2dDIiFlMH31bTJnt1oRt02kTLykY/N 5jHPOWgUtPoZ0RTDMq0hA0ikv1GRgYIUS1vwgtrnaZbFp139S+HdmBIJUm7xjy2YThbM CaLZIvyqdG2KUScSZUWa7qGWJ2bdvgyFqNQxIg6vsBccz0vPkGwUft4vq45QMn/MK+tA v39KJID+C4OiZ1Pl1wweVLAh6mcCH/iuEswDQ23RW14Vyg9XYMyFijWDUrU8SFCwltY7 YFyHwViB6TQ3lH1j/2RvwbFIMoochZKdak/e0Lz2uCEJQ4ysFK6zgo9BSL3z70q/LyCW 4GBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="Fi/3adqo"; 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 u1-20020a170902e80100b001b8ac8008a4si996903plg.598.2023.09.13.22.39.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 22:39:23 -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="Fi/3adqo"; 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 1A46882878BD; Wed, 13 Sep 2023 20:33:29 -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 S234316AbjINDdW (ORCPT + 99 others); Wed, 13 Sep 2023 23:33:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44774 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234177AbjINDdE (ORCPT ); Wed, 13 Sep 2023 23:33:04 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 476021BE2 for ; Wed, 13 Sep 2023 20:32:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1694662337; 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=CuyFNbtk2D5ZLNQLEQ3vxhJMzL7nFa+vxdXXthC35r8=; b=Fi/3adqoOKVAtk7yKniszuOzaePBjGmv/h7nJDN7mpFcptPw8+6heGrF1OyvbdmHdHXGve Ki2/Ohg+B4+ob34q3h6bz95pCKLNJFXDzx/oXEzG2QRphOxLkULZV3V3+d7dX2PeFET+xl aODzS5+N1Bo8+I4pyVs2Ubc5kOsmb5o= 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-42-VMWE-biJMa2FUkSHDLWytw-1; Wed, 13 Sep 2023 23:32:13 -0400 X-MC-Unique: VMWE-biJMa2FUkSHDLWytw-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 9FC77857A9A; Thu, 14 Sep 2023 03:32:12 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.112.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id A7E9510F1BE7; Thu, 14 Sep 2023 03:32:08 +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 5/9] crash_core: move crashk_*res definition into crash_core.c Date: Thu, 14 Sep 2023 11:31:38 +0800 Message-ID: <20230914033142.676708-6-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:29 -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 Both crashk_res and crashk_low_res are used to mark the reserved crashkernel regions in iomem_resource tree. And later the generic crashkernel resrvation will be added into crash_core.c. So move crashk_res and crashk_low_res definition into crash_core.c to avoid compiling error if CONFIG_CRASH_CORE=on while CONFIG_KEXEC_CORE is unset. Meanwhile include in if generic reservation is needed. In that case, need be added by ARCH. In asm/crash_core.h, ARCH can provide its own macro definitions to override macros in if needed. Wrap the including into CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION ifdeffery scope to avoid compiling error in other ARCH-es which don't take the generic reservation way yet. Signed-off-by: Baoquan He --- include/linux/crash_core.h | 8 ++++++++ include/linux/kexec.h | 4 ---- kernel/crash_core.c | 16 ++++++++++++++++ kernel/kexec_core.c | 17 ----------------- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h index 4dbd6565e0ff..3c735a7e33fb 100644 --- a/include/linux/crash_core.h +++ b/include/linux/crash_core.h @@ -5,6 +5,14 @@ #include #include #include +#ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION +#include +#endif + +/* Location of a reserved region to hold the crash kernel. + */ +extern struct resource crashk_res; +extern struct resource crashk_low_res; #define CRASH_CORE_NOTE_NAME "CORE" #define CRASH_CORE_NOTE_HEAD_BYTES ALIGN(sizeof(struct elf_note), 4) diff --git a/include/linux/kexec.h b/include/linux/kexec.h index 32c78078552c..8227455192b7 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -22,10 +22,6 @@ #include #include -/* Location of a reserved region to hold the crash kernel. - */ -extern struct resource crashk_res; -extern struct resource crashk_low_res; extern note_buf_t __percpu *crash_notes; #ifdef CONFIG_KEXEC_CORE diff --git a/kernel/crash_core.c b/kernel/crash_core.c index ca66b5f41dc7..ad7dc03f3993 100644 --- a/kernel/crash_core.c +++ b/kernel/crash_core.c @@ -35,6 +35,22 @@ u32 *vmcoreinfo_note; /* trusted vmcoreinfo, e.g. we can make a copy in the crash memory */ static unsigned char *vmcoreinfo_data_safecopy; +/* Location of the reserved area for the crash kernel */ +struct resource crashk_res = { + .name = "Crash kernel", + .start = 0, + .end = 0, + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, + .desc = IORES_DESC_CRASH_KERNEL +}; +struct resource crashk_low_res = { + .name = "Crash kernel", + .start = 0, + .end = 0, + .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, + .desc = IORES_DESC_CRASH_KERNEL +}; + /* * parsing the "crashkernel" commandline * diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c index 9dc728982d79..be5642a4ec49 100644 --- a/kernel/kexec_core.c +++ b/kernel/kexec_core.c @@ -52,23 +52,6 @@ atomic_t __kexec_lock = ATOMIC_INIT(0); /* Flag to indicate we are going to kexec a new kernel */ bool kexec_in_progress = false; - -/* Location of the reserved area for the crash kernel */ -struct resource crashk_res = { - .name = "Crash kernel", - .start = 0, - .end = 0, - .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, - .desc = IORES_DESC_CRASH_KERNEL -}; -struct resource crashk_low_res = { - .name = "Crash kernel", - .start = 0, - .end = 0, - .flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM, - .desc = IORES_DESC_CRASH_KERNEL -}; - int kexec_should_crash(struct task_struct *p) { /* -- 2.41.0