Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp1238209iof; Tue, 7 Jun 2022 01:12:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMq5B0EL+BZ95j0QvicQy9cDL4SYw4CtGrpSj0R6WDHTJPwROlGEWeHqynH1eqtprwHPqJ X-Received: by 2002:a05:6402:d0a:b0:421:10e6:2ecc with SMTP id eb10-20020a0564020d0a00b0042110e62eccmr31898520edb.329.1654589555563; Tue, 07 Jun 2022 01:12:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654589555; cv=none; d=google.com; s=arc-20160816; b=Zlktuy82XTpoeHYXex8LY6of4OnhZKvQjGxL0rkld57rTw5YctjHte0xlr9SDyY4I9 WH+ZZN7x5xnDVWccBGQU/LqdIKYLnir2JMWdEd4BsjTLVUs8t8ncHPGU6KAJjf1/uSEG QA0NbZgBRUHUUDUG2TEmYkOxz2kS0J6TpcdzWAA38EdxCmriCQ0+vxpxtmtfKAFwM/Da GozGBFIx8PbKgdA4URYEMyQuURbXlObh2xLFoCxWJ7KBrguYPc5x9T4z1pzsrdGILVXz fktygsobzQS3Md7P0EA20mntHDIXJqFShcMGu3B2kBrXuhvQ/mJgPuA6WP5q6r9OdhZH UlTw== 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:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=X+LBMXE7izUO/UHvXFK7zJkxHnBaIdsqSXok5guNFMQ=; b=olk9tBaoqbflG0zSKVpvcVUsUa9jQZFzrk1bVOIbM4rUgsjvI9zXot6gj80TRh9a5L LkBmLzKpFS5eYIpNQVBNB9BMuBAVPl+tOWqTKG6X2Qj1E21PwaCh2sApPNJWrPwD91Jn YuF1F1K7hmtuBFlBx5enUdCjHIB+nPgZ8ErLcZ2/ToksuG70DeK21A6CVPGTlai+ZbI8 qSX9lpGX0F4qCJZpPBlwYSaWpObtOUKVzdej9MHDt414X3Yb8u05L4R1tvNMFcYMNovw R94tSZmiyPmfsyBtWgUBcH3JtXNqRjiFc0DamgsOfyTgzo+n0fl2OWLnvlYJI4BhP7If yRXQ== 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mp14-20020a1709071b0e00b006f3a3c628c8si11131018ejc.781.2022.06.07.01.12.07; Tue, 07 Jun 2022 01:12:35 -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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235654AbiFGBV7 (ORCPT + 99 others); Mon, 6 Jun 2022 21:21:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235633AbiFGBVt (ORCPT ); Mon, 6 Jun 2022 21:21:49 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B11190CF8 for ; Mon, 6 Jun 2022 18:21:47 -0700 (PDT) Received: from dggpemm500022.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4LHCGn27T4zjXPP; Tue, 7 Jun 2022 09:20:49 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500022.china.huawei.com (7.185.36.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 7 Jun 2022 09:21:45 +0800 Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 7 Jun 2022 09:21:44 +0800 Message-ID: Date: Tue, 7 Jun 2022 09:21:44 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v3] RISC-V: Add fixup to support fast call of crash_kexec() Content-Language: en-US To: Xianting Tian , , , , , , , , , CC: , References: <20220606123750.2884245-1-xianting.tian@linux.alibaba.com> From: Kefeng Wang In-Reply-To: <20220606123750.2884245-1-xianting.tian@linux.alibaba.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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, Reviewed-by: Kefeng Wang > bust_spinlocks(0); > add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE); > spin_unlock_irq(&die_lock);