Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp1316712iof; Tue, 7 Jun 2022 03:12:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxh+IlGb6AZEajTq7RhOQ+oxhmqYg7bD0bL6IlMsUCZhBatKRWictWQNZ5tmM2f5ZpnTORZ X-Received: by 2002:a17:906:53ca:b0:6fe:ae32:e01e with SMTP id p10-20020a17090653ca00b006feae32e01emr25814169ejo.455.1654596765254; Tue, 07 Jun 2022 03:12:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654596765; cv=none; d=google.com; s=arc-20160816; b=EOGDrBfiWbwB+IRrUT7vs43uVeJesfI1wKIx0k+U9xB3iDpls8Sk2Lg8/ENZBfvnDx W3M/aBAJYb4St8dNDufU17w9k7Y2O1jfELBX6/NfcBG15eOTPRHCQmsKiMHYAhMVZqwN vHD5pOdpHY5JJWN55o3bBmX37w10Jti9bXzYQjqCCAxQJQmzz6NrIfPtdRw0RSeKJSf0 2zb+OZdkJaCo75wj62YwRgvRFvWZso/O86/Kbk9Sq9TarHtDnkax36FOvExOvFuOioUy 12oIfSnFIolWk5yB7JmyZB2yhQ8U8eIkNQlUgvDQ7QrogO6Yk1MlV4gJ1wDIVefz57nW Hhhg== 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=QfsxBiCoUDh3svt4/47H1r/y/OfuzDT+x7MI1pfIQTA=; b=1GlFHLvwVxrQViIaayBIvmpvbV2OZS+Z9cmdsInMzhea6ckzwXrsgtDG6hpyxCseCi ZOWMgt/U1RzqHhvlqtq+ODJ5S/H6j5x21A7l9NzVWleKtyQ5BSPq21mAKRzrmf0bjY65 Yj+W1KKx1WuHuTMQa6iqh461uwgL1jcKJCoW4ip2hiXKWrPPFp2/ulqVGKwRyR0VqC0r hx2UGCPuA8syzqTPNtpuIbwM35dpo2odQzhHOeaTnTQLi0GCj7+DvAQSepRg2dzduaJO C4LtSkpwC6yezrvKT0cWtONnh18bGRg0gS5lZS5OsTSdGOLhJwJmIyFk7N+dA1JHXcRN 4Ebg== 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 b15-20020a056402278f00b0042f9ff7beb1si10510602ede.615.2022.06.07.03.12.17; Tue, 07 Jun 2022 03:12:45 -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 S235037AbiFGBqJ (ORCPT + 99 others); Mon, 6 Jun 2022 21:46:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233175AbiFGBqH (ORCPT ); Mon, 6 Jun 2022 21:46:07 -0400 Received: from out30-54.freemail.mail.aliyun.com (out30-54.freemail.mail.aliyun.com [115.124.30.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEC979877A for ; Mon, 6 Jun 2022 18:46:05 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R561e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=alimailimapcm10staff010182156082;MF=xianting.tian@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0VFbCL8E_1654566361; Received: from B-LB6YLVDL-0141.local(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0VFbCL8E_1654566361) by smtp.aliyun-inc.com; Tue, 07 Jun 2022 09:46:02 +0800 Subject: Re: [PATCH v3] RISC-V: Add fixup to support fast call of crash_kexec() To: Kefeng Wang , paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, philipp.tomsich@vrull.eu, ebiederm@xmission.com, heiko@sntech.de, vitaly.wool@konsulko.com, tongtiangen@huawei.com, guoren@kernel.org Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org References: <20220606123750.2884245-1-xianting.tian@linux.alibaba.com> From: Xianting Tian Message-ID: Date: Tue, 7 Jun 2022 09:46:01 +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=-12.8 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,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/6/7 上午9:21, Kefeng Wang 写道: > > On 2022/6/6 20:37, Xianting Tian 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; >> >> Fixes: 76d2a0493a17 ("RISC-V: Init and Halt Code") >> Reviewed-by: Guo Ren >> Signed-off-by: Xianting Tian >> --- >> Changes from v1: >> - simplify the commit message >> Changes from v2: >> - add fixup in title >> --- >>   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 b40426509244..39d0f8bba4b4 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); >> + > > It seems that the regs won't be null, right? except that, Autually both regs won't be null, But if it is triggered by panic() , the regs are got via riscv_crash_save_regs(), which are the regs of that moment, but not the real accident scene. > > Reviewed-by: Kefeng Wang > >>       bust_spinlocks(0); >>       add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE); >>       spin_unlock_irq(&die_lock);