Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2206818rwb; Thu, 17 Nov 2022 07:52:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf7rSi3NdjaKfzMQRHKeyTCEDzkQQQlLVDAIopUe/qBhJhhbiaBy9ilACnDC+nsOxetea9vI X-Received: by 2002:a17:906:d103:b0:7ad:9673:8b73 with SMTP id b3-20020a170906d10300b007ad96738b73mr2735785ejz.14.1668700363804; Thu, 17 Nov 2022 07:52:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668700363; cv=none; d=google.com; s=arc-20160816; b=yJuh6sJ3IVyJ66P/MkMx5msX1GyRsZnZq74cN5ZPMwX12cnfuIgVsquYeVnULzTVNj d8GQgfL1dB5u8m7k8lN3UzqRwe7EoR2FjkCZ2tsmcxW99Is6FtRKh36vZyrM2An6ovyJ 1RWF/vuZGzz4JsEzg0HYWwbIWIPSKbmeBEEAhs9wFSvJrMwEiLXI+bnfLJZf4+FDUqMr 50oTd5WzVhv8kyCfmInbP/wdGkVxUjN0MKeruY5phcmgN/Z4jgMfL8RRHMMW2+OdT1Xu Sm9zbHE8AEB5YD99zWRKha8XAGmUn5tKy6dyPa/d6Exgp7lZ91ycS/iz2oIfQJvyEDwC 2oAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=UGn0cu4OQR5BrpATplUvfJkso1o8nOc/7b5XR3DJptA=; b=qLtvg68DfzT1+TdVPXjgE0kGhEBgO5DE/hGhMtUDLl2ZLmJ4+643sWrm7Samsd1JtI ooKVN1tflpKNgT47tQfOkU6sI9CKy74jHTH/p0D14gIqhxoyylmvpe/LbvKcqFwaz9Ji 6gSWectL1pldm+2bSAZlGesxu1o4kxMnqEKxF4eD+xIDIEdFGKWkKedP+86DTUViqKlI WQ/XsVNcLdul7Imt9+UYOVzdh911crS0/3QPYXptoKmP2sbuC663TNgQpEe7XI5toYI7 vU4goTS7GblQA1p1XHClA3cWSApeu8QisAUZ3kQXz1GU3xU7jcZBYq5CDc6X4wNqV9+C OErw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MV8KXCxP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i21-20020a170906251500b0078d2a99972fsi647545ejb.316.2022.11.17.07.52.19; Thu, 17 Nov 2022 07:52:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MV8KXCxP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234768AbiKQPn0 (ORCPT + 92 others); Thu, 17 Nov 2022 10:43:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234844AbiKQPnW (ORCPT ); Thu, 17 Nov 2022 10:43:22 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA7C0BD3; Thu, 17 Nov 2022 07:43:21 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 2C96AB820C9; Thu, 17 Nov 2022 15:43:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA88EC4314D; Thu, 17 Nov 2022 15:43:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1668699798; bh=IlMz1HuDGTEi4UcjN5UC5MjvYMpLuVoL5C47NsVRGi8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=MV8KXCxPDxlnaKY59Ujsn17Jn1JdwF3WvZA/R6qSE+Vgo8B1k3a66PghuhUHoUAss q1qmQjdYWZ66do8Iotpe05/KaXsL/OOazs1FQlD5C0ptx+UgOdPtPy9PTTgN0cJ685 sY5Yb7RLF2M2NYHHcEIT0vHf4q1CLDMkOVgYiJB7hM9K7cBlsRxDWVerLGrMYdr0o4 zwWhRKYct7ge6cD3RECAtdsoAXfvaNmc9lYCMT1w7N0VL2GX9ZmgIMb2CBQtQ5a9UL osTF3yuuWf753W3Muwm9jNqMGvDF+HBrLhW/rdAm7AbW2yTaQLoymAeOKqA7ghtOtj dwvVHqvAKTJxA== Received: by mail-ed1-f49.google.com with SMTP id a5so3072450edb.11; Thu, 17 Nov 2022 07:43:18 -0800 (PST) X-Gm-Message-State: ANoB5pkT9zDdLxFFzArCNXMO3Tc2X+S4iPVtkuXzXvjMEALCd1ZqDm46 FNWlqf+ryyroEo9xNQ/+ScC37o8lajhp0kExekQ= X-Received: by 2002:a05:6402:1a:b0:467:30ad:c4ca with SMTP id d26-20020a056402001a00b0046730adc4camr2658516edu.285.1668699796927; Thu, 17 Nov 2022 07:43:16 -0800 (PST) MIME-Version: 1.0 References: <20221026144208.373504-1-xianting.tian@linux.alibaba.com> <20221026144208.373504-2-xianting.tian@linux.alibaba.com> In-Reply-To: <20221026144208.373504-2-xianting.tian@linux.alibaba.com> From: Guo Ren Date: Thu, 17 Nov 2022 23:43:05 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH V5 1/2] RISC-V: Add arch_crash_save_vmcoreinfo support To: Xianting Tian Cc: paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, anup@brainfault.org, heiko@sntech.de, mick@ics.forth.gr, alexandre.ghiti@canonical.com, bhe@redhat.com, vgoyal@redhat.com, dyoung@redhat.com, corbet@lwn.net, Conor.Dooley@microchip.com, bagasdotme@gmail.com, kexec@lists.infradead.org, linux-doc@vger.kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, crash-utility@redhat.com, heinrich.schuchardt@canonical.com, k-hagio-ab@nec.com, hschauhan@nulltrace.org, yixun.lan@gmail.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Tested-by: Guo Ren On Wed, Oct 26, 2022 at 10:42 PM Xianting Tian wrote: > > Add arch_crash_save_vmcoreinfo(), which exports VM layout(MODULES, VMALLOC, > VMEMMAP ranges and KERNEL_LINK_ADDR), va bits and ram base for vmcore. > > Default pagetable levels and PAGE_OFFSET aren't same for different kernel > version as below. For pagetable levels, it sets sv57 by default and falls > back to setting sv48 at boot time if sv57 is not supported by the hardware. > > For ram base, the default value is 0x80200000 for qemu riscv64 env and, > for example, is 0x200000 on the XuanTie 910 CPU. > > * Linux Kernel 5.18 ~ > * PGTABLE_LEVELS = 5 > * PAGE_OFFSET = 0xff60000000000000 > * Linux Kernel 5.17 ~ > * PGTABLE_LEVELS = 4 > * PAGE_OFFSET = 0xffffaf8000000000 > * Linux Kernel 4.19 ~ > * PGTABLE_LEVELS = 3 > * PAGE_OFFSET = 0xffffffe000000000 > > Since these configurations change from time to time and version to version, > it is preferable to export them via vmcoreinfo than to change the crash's > code frequently, it can simplify the development of crash tool. > > Signed-off-by: Xianting Tian > --- > arch/riscv/kernel/Makefile | 1 + > arch/riscv/kernel/crash_core.c | 21 +++++++++++++++++++++ > 2 files changed, 22 insertions(+) > create mode 100644 arch/riscv/kernel/crash_core.c > > diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile > index db6e4b1294ba..4cf303a779ab 100644 > --- a/arch/riscv/kernel/Makefile > +++ b/arch/riscv/kernel/Makefile > @@ -81,6 +81,7 @@ obj-$(CONFIG_KGDB) += kgdb.o > obj-$(CONFIG_KEXEC_CORE) += kexec_relocate.o crash_save_regs.o machine_kexec.o > obj-$(CONFIG_KEXEC_FILE) += elf_kexec.o machine_kexec_file.o > obj-$(CONFIG_CRASH_DUMP) += crash_dump.o > +obj-$(CONFIG_CRASH_CORE) += crash_core.o > > obj-$(CONFIG_JUMP_LABEL) += jump_label.o > > diff --git a/arch/riscv/kernel/crash_core.c b/arch/riscv/kernel/crash_core.c > new file mode 100644 > index 000000000000..b351a3c01355 > --- /dev/null > +++ b/arch/riscv/kernel/crash_core.c > @@ -0,0 +1,21 @@ > +// SPDX-License-Identifier: GPL-2.0-only > + > +#include > +#include > + > +void arch_crash_save_vmcoreinfo(void) > +{ > + VMCOREINFO_NUMBER(VA_BITS); > + VMCOREINFO_NUMBER(phys_ram_base); > + > + vmcoreinfo_append_str("NUMBER(PAGE_OFFSET)=0x%lx\n", PAGE_OFFSET); > + vmcoreinfo_append_str("NUMBER(VMALLOC_START)=0x%lx\n", VMALLOC_START); > + vmcoreinfo_append_str("NUMBER(VMALLOC_END)=0x%lx\n", VMALLOC_END); > + vmcoreinfo_append_str("NUMBER(VMEMMAP_START)=0x%lx\n", VMEMMAP_START); > + vmcoreinfo_append_str("NUMBER(VMEMMAP_END)=0x%lx\n", VMEMMAP_END); > +#ifdef CONFIG_64BIT > + vmcoreinfo_append_str("NUMBER(MODULES_VADDR)=0x%lx\n", MODULES_VADDR); > + vmcoreinfo_append_str("NUMBER(MODULES_END)=0x%lx\n", MODULES_END); > +#endif > + vmcoreinfo_append_str("NUMBER(KERNEL_LINK_ADDR)=0x%lx\n", KERNEL_LINK_ADDR); > +} > -- > 2.17.1 > -- Best Regards Guo Ren