Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2486199ioo; Mon, 23 May 2022 21:30:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5amLAGQa6pNzgE7FHyIKVs20ikDZmeeKelNNXEE8TXOPbae1SDRrOoD2ldRFzIOSWkhFI X-Received: by 2002:a17:907:1b28:b0:6fe:fc41:35ce with SMTP id mp40-20020a1709071b2800b006fefc4135cemr4240692ejc.153.1653366654820; Mon, 23 May 2022 21:30:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653366654; cv=none; d=google.com; s=arc-20160816; b=Cp+fDKLyUIHFMBMgBwVAJHZYqdNWLhoFWTsekAjwolf5yopR3Ry4b3Vgjgrp6HFyBd RbrYLGl+R6t/2rJ77uW7+DmcQW34JWzql0D7h7VZXDHWnOt1+tHRSotFkQQW5WOKKumk np+dGBuMgarPNKkf5uFXNgV7R+dnzWyd5Ki6tv3HJVO1NYzR0iHFPhWn+6WvYdMkI2GM +RO5lrA6BZyWVx1SvuquijISRMHQ5RZYqz30BgvsjdL0YKYubfa0yItKocaM/x6h1rbG jceNbaBcCcWhv6zTqtF1AmvNY+m+CU0KrxlREsze2G4k4szovCMAy05DVCJ60pBCWLv2 tfZg== 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=JgPx00pi/GYEoYSKQOwsOiLYjiMzTF+zc+U6TXpabGU=; b=p11t3aSbhtkrTw1tGvYd8tBrHkTTfbrG1P64EjpSykJJUPv1wPqO7L97GkTh3/wixe 2NJ3BLiypWRsyxQ9G4c+IeXRfzuR5XhO9oU0ViLvDXm521W3E5PMLxQaCSJYtnrppQKx xq7mUnqmN5iYaL9UhcgQvCFzany/ShtlMwOqyLVT2leoxZDL4ay/DoJWohqbs5fo+y6K p3dLlvESWh9QZPSqBmHJkJKhAOLB6WKHexaSmfPCxHapoTepty8ihmKBPL2EaM3myW3B TdY9xqNxBiXnADcFIP09CwEoaEj/kSGcWBOzhfMWpHL0bD4w67AkdntYtMlQl0OUlOZs MDlg== 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 qb22-20020a1709077e9600b006fee2aa8759si1575306ejc.797.2022.05.23.21.30.28; Mon, 23 May 2022 21:30:54 -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 S232800AbiEXBuw (ORCPT + 99 others); Mon, 23 May 2022 21:50:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42144 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232785AbiEXBuu (ORCPT ); Mon, 23 May 2022 21:50:50 -0400 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7C56737A1 for ; Mon, 23 May 2022 18:50:48 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04400;MF=xianting.tian@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0VEFh5GV_1653357042; Received: from B-LB6YLVDL-0141.local(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0VEFh5GV_1653357042) by smtp.aliyun-inc.com(127.0.0.1); Tue, 24 May 2022 09:50:44 +0800 Subject: Re: [PATCH] RISC-V: Add fast call path of crash_kexec() To: paul.walmsley@sifive.com, aou@eecs.berkeley.edu, palmer@dabbelt.com, wangkefeng.wang@huawei.com, vitaly.wool@konsulko.com, rmk+kernel@armlinux.org.uk, ebiederm@xmission.com, tongtiangen@huawei.co Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, guoren@kernel.org, mick@ics.forth.gr References: <20220515131407.946832-1-xianting.tian@linux.alibaba.com> From: Xianting Tian Message-ID: <788c0f2a-1562-b4ca-a1ca-0289032b1f8a@linux.alibaba.com> Date: Tue, 24 May 2022 09:50:42 +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: <20220515131407.946832-1-xianting.tian@linux.alibaba.com> Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.2 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 just a friendly ping ?? 2022/5/15 ????9:14, Xianting Tian ะด??: > 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/virtio/virtio_mmio.c:806 > 806 *(int *)p = 0xdead; > (gdb) > (gdb) bt > #0 0xffffffe00063a4e0 in test_thread (data=) at drivers/virtio/virtio_mmio.c:806 > #1 0x0000000000000000 in ?? () > > Test code to produce NULL address dereference, > +extern int panic_on_oops; > +static struct task_struct *k; > +static int test_thread(void *data) { > + > + void *p = NULL; > + > + while (!panic_on_oops) > + msleep(2000); > + > + *(int *)p = 0xdead; > + > + return 0; > +} > + > static int __init virtio_mmio_init(void) > { > + k = kthread_run(test_thread, NULL, "test_thread"); > + if (IS_ERR(k)) > + pr_err("Couldn't create test kthread\n"); > + > return platform_driver_register(&virtio_mmio_driver); > } > > Signed-off-by: Xianting Tian > --- > 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);