Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp255713imi; Thu, 21 Jul 2022 21:08:00 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vnu4QuihZg+03QQZGdChaWr+7mzXMWsqnJUbbGySu0MbkKSl23smfhnhJrn5MPmChRUiit X-Received: by 2002:a17:906:98ca:b0:72b:7bb4:4ebc with SMTP id zd10-20020a17090698ca00b0072b7bb44ebcmr1463758ejb.585.1658462879963; Thu, 21 Jul 2022 21:07:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658462879; cv=none; d=google.com; s=arc-20160816; b=ogzPl64ZtjLe7XqTZi5tn+/ZwmccMNx5yGlRm6JUx0eS6e3nSX9HwkUehg9YvRRqrp dA3Pn84+Yrv26rNYSp9hHF2r7my17GNfiLqMGE3Qc+BdcVP+mHI27mWRKn1iwO/uaA7Z UYTnY5CCQXgTiS2p3O2+W04COCcBZuxIm575tmJLmKVgEICGnlvUGGtaX+G5D0PCmQKC DdrT3sOXNTf6cBl+k3fTElXzHXTqkjiQtnP+4C2HnPbX3IVdFODBNxukrLLFngBEAR4T 13zr2/KNrYtgYwHN67B3vfSbMtZ+fRy0/wYkCOOBsXWXBnMqVd/6dfYZTBUj2FmvyiS2 GCtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=BD5tbAknc0U3A5WROs13llQv9ZQbEx6erdWlgw/+KeM=; b=eyDUwZGY8EQWE2UsHrjjMx8vnWuNg4aIDahby4V88seXS6jCF/KnQXYFiPuMPkDOR6 6cFAvMpmal6p0Z8yrQGLMkHaitqIaCGef45tMWm+5p2Ur6nmd6uOFo22x9IYWRlcgaY4 wRJu4oeqnN2dNn3usDzwb7NhgBgYswdSB8RbNdy5LtcH/xP8wIoQ1y8Qhvdd93s3nu1y JQzg6BIAQo1XKGEokTRMNZVA+cuu1lg5r0uKSqQcRj5Kv9U6kKcoYavL1ftexXQUIFQu Jj7Fb3jRydu/kogJGSE6jpxGgELH3Wh1NWkeodEs48h/OmEhZr8cs5G0e3UwfaXyVIrI hD+Q== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v14-20020a056402348e00b0043a59e9f4cesi4561265edc.30.2022.07.21.21.07.32; Thu, 21 Jul 2022 21:07:59 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231854AbiGVDlP (ORCPT + 99 others); Thu, 21 Jul 2022 23:41:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229605AbiGVDlN (ORCPT ); Thu, 21 Jul 2022 23:41:13 -0400 Received: from out30-45.freemail.mail.aliyun.com (out30-45.freemail.mail.aliyun.com [115.124.30.45]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D870F47B91 for ; Thu, 21 Jul 2022 20:41:11 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R891e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=xianting.tian@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0VK3QLxV_1658461267; Received: from B-LB6YLVDL-0141.local(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0VK3QLxV_1658461267) by smtp.aliyun-inc.com; Fri, 22 Jul 2022 11:41:08 +0800 Subject: Re: [RESEND PATCH v2] RISC-V: Add fast call path of crash_kexec() To: Palmer Dabbelt Cc: Paul Walmsley , aou@eecs.berkeley.edu, wangkefeng.wang@huawei.com, philipp.tomsich@vrull.eu, ebiederm@xmission.com, heiko@sntech.de, vitaly.wool@konsulko.com, tongtiangen@huawei.com, guoren@kernel.org, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org References: From: tianxianting Message-ID: <6412d106-24c0-a2ad-79b9-de6664c8723d@linux.alibaba.com> Date: Fri, 22 Jul 2022 11:41:07 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-9.9 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 在 2022/7/22 上午8:11, Palmer Dabbelt 写道: > On Mon, 06 Jun 2022 01:23:08 PDT (-0700), > xianting.tian@linux.alibaba.com wrote: >> Currently, almost all archs (x86, arm64, mips...) support fast call >> of crash_kexec() when "regs && kexec_should_crash()" is true. But >> RISC-V not, it can only enter crash system via panic(). However panic() >> doesn't pass the regs of the real accident scene to crash_kexec(), >> it caused we can't get accurate backtrace via gdb, >>     $ riscv64-linux-gnu-gdb vmlinux vmcore >>     Reading symbols from vmlinux... >>     [New LWP 95] >>     #0  console_unlock () at kernel/printk/printk.c:2557 >>     2557                    if (do_cond_resched) >>     (gdb) bt >>     #0  console_unlock () at kernel/printk/printk.c:2557 >>     #1  0x0000000000000000 in ?? () >> >> With the patch we can get the accurate backtrace, >>     $ riscv64-linux-gnu-gdb vmlinux vmcore >>     Reading symbols from vmlinux... >>     [New LWP 95] >>     #0  0xffffffe00063a4e0 in test_thread (data=) at >> drivers/test_crash.c:81 >>     81             *(int *)p = 0xdead; >>     (gdb) >>     (gdb) bt >>     #0  0xffffffe00064d5c0 in test_thread (data=) at >> drivers/test_crash.c:81 >>     #1  0x0000000000000000 in ?? () >> >> Test code to produce NULL address dereference in test_crash.c, >>     void *p = NULL; >>     *(int *)p = 0xdead; >> >> Reviewed-by: Guo Ren >> Tested-by: Xianting Tian >> Signed-off-by: Xianting Tian >> --- >> Changes from v1: >> - simplify the commit message >> --- >>  arch/riscv/kernel/traps.c | 4 ++++ >>  1 file changed, 4 insertions(+) >> >> diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c >> index fe92e119e6a3..e666ebfa2a64 100644 >> --- a/arch/riscv/kernel/traps.c >> +++ b/arch/riscv/kernel/traps.c >> @@ -16,6 +16,7 @@ >>  #include >>  #include >>  #include >> +#include >> >>  #include >>  #include >> @@ -44,6 +45,9 @@ void die(struct pt_regs *regs, const char *str) >> >>      ret = notify_die(DIE_OOPS, str, regs, 0, regs->cause, SIGSEGV); >> >> +    if (regs && kexec_should_crash(current)) >> +        crash_kexec(regs); >> + >>      bust_spinlocks(0); >>      add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE); >>      spin_unlock_irq(&die_lock); > > Thanks, this is on for-next. Palmer, thanks for the reply, Last week, I commit a series of patches(https://lkml.org/lkml/2022/7/17/64 ), which contains this one. This series of patches worked with crash-utility for RISCV64, Could you please review it? We expect 5.19 could support crash-utility, it is a good functionality. crash-utility patches for RISCV64: https://lore.kernel.org/all/20220718025346.411758-1-xianting.tian@linux.alibaba.com/