Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp139323imi; Thu, 21 Jul 2022 17:52:06 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uTivniFMPTlzyS2po7bBxePhlpJVc5zDnXi4l76aTvi4nnneQbKZ8Qc86wq8j7dmC3XSwF X-Received: by 2002:a17:907:7637:b0:72b:3a3b:7d68 with SMTP id jy23-20020a170907763700b0072b3a3b7d68mr962676ejc.566.1658451125928; Thu, 21 Jul 2022 17:52:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658451125; cv=none; d=google.com; s=arc-20160816; b=Y0aM6G3bFpSCwDcO2GdPX/d6vCEckVbf4BW8kYw32acfBxGK0z5VZDpX58Nvg5YJDW e4vdUnHEUyoiu12I1bxNukl9Z2n4K2JpSWE0kmpyoUUgmxNKiEfFBkx1DvuuuaCa5psY gfUYhomJlksVEXDyiYAlKZikyv1Hg756e1DlDHr9NRCEkyNd6u9UYBVIV5LrxW7zoH+p v35i7MwY79DJhQ8uW3QRRfgp5MSoXR7tzxsqwiaUMi3U7q64T3+FeigLO3MPV2uyuEN3 HgLR774vyhZ+HlGmscTssICnWPoOC09n8EizU1J9r166Gn36i5HZe3q7W0fTW+vF2l4U A1Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=PqbUV51qi52lrKQhfCf/gzD84m8gLhls7/B6ZdVqa/M=; b=ucqCbudSJ412xqn8+xxXr7Gsrky5+n5Ih57xPHFfMNidMbPlk5/XkgmWRfonz3ERqi iqg+98LhpQsrDb8Nr05vwCNRnIomVCK9+gk4gFEgxtaS5K3ncI+8nxUCRF5lKhJ6GIeF ZMXPFLnZcG+qmnCbS2c0WRxDlkRicn9ogqCNBUBpj79/4SkLutz7okVxv5fPHgsT3lWC RI6eaoWAG53TeWOCsSRKhUa2ZXoudCusgjE0OEQIdiAIFlQVbxeREJrOjF58aF0C12qv Y7I1mSe6xkZKHdLwrR/vzLZFAoPCeBRG7jEyoI/9eFnAb1FSkGXFqcwk7N07i1MdOmJB 1F1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=ZTVeoyJ2; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o11-20020a170906974b00b006fed9376071si4921535ejy.13.2022.07.21.17.51.41; Thu, 21 Jul 2022 17:52:05 -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; dkim=pass header.i=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=ZTVeoyJ2; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233166AbiGVALK (ORCPT + 99 others); Thu, 21 Jul 2022 20:11:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43326 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229739AbiGVALJ (ORCPT ); Thu, 21 Jul 2022 20:11:09 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B308402C0 for ; Thu, 21 Jul 2022 17:11:07 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id w7so3272178plp.5 for ; Thu, 21 Jul 2022 17:11:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20210112.gappssmtp.com; s=20210112; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=PqbUV51qi52lrKQhfCf/gzD84m8gLhls7/B6ZdVqa/M=; b=ZTVeoyJ2YXiZu5jk15o9L1VobOx0d0pdDXua+aewXF/XkkApabUZE/5ZQ3TU+HUMZL EyBJ5rXuSCDN19gvV87EvXMAclujYjRBFFA7x/W9G258vZ3zmrL80a6RaR7yac1hz7e3 wgDtuY0VvR/ZPdHb4/0aF7p0iygOc8Cly0ssFBHjlrIWWoSOulPh+Fqh02QP8xwhQmio kyOZDr2q0Hpeqk1OW26DohM+xN4/HxIdmoGvBzI4VDD1voJcWlXnwdOtxTs46tix4/nD SaGS5bBCoGmZ5SoyZS/Ic82U5DSrUJ8SwnlFqJICxKl+MGearAs63k7bI5XGQrSCmdr3 E4Vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=PqbUV51qi52lrKQhfCf/gzD84m8gLhls7/B6ZdVqa/M=; b=6Kcv4Gx8RZ3lgNUu8HfKEXtdSlScO5csYe6uCNUlIg43VqxyO+rOXocCkRBjY6U5b7 u/NMB/E1zmYPvoKX3z3aOnp4Ug4s6rsUw+FGyos8HC1aSu5QSRx7SNPdjbpuoYTkeNGF 1k2wJZXPkNpoVhxqmSqCLidcDiGz6sRYYaI1NNZeUaD5H2eEJSE0yl6uWhQdFQ423it0 Am2cwYAf4ZVBa0bc7s7+xjOjopR9fgrSwCZ7f9DNMa0bCQ38MCUU8JfTF75rRQOAN8SP 4gxH7OylcFdWhOxCGAwIlVAgjrwa6dJYXzvNxYK2xCBxkCOdVmTJ+vVWbho+GQzkgyeh uL0Q== X-Gm-Message-State: AJIora/sYeImnahhpzHjBnr1IwVPa7i+VgmGZuke7PtdArCPPmUCodFm 3bUPIirH8ZOm13D0jyFFkXHqGA== X-Received: by 2002:a17:903:41c2:b0:16c:52f8:9240 with SMTP id u2-20020a17090341c200b0016c52f89240mr931214ple.161.1658448666805; Thu, 21 Jul 2022 17:11:06 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id s29-20020a63215d000000b0041166bf9ca8sm2088739pgm.34.2022.07.21.17.11.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Jul 2022 17:11:06 -0700 (PDT) Date: Thu, 21 Jul 2022 17:11:06 -0700 (PDT) X-Google-Original-Date: Thu, 21 Jul 2022 16:52:31 PDT (-0700) Subject: Re: [RESEND PATCH v2] RISC-V: Add fast call path of crash_kexec() In-Reply-To: <20220606082308.2883458-1-xianting.tian@linux.alibaba.com> 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, xianting.tian@linux.alibaba.com From: Palmer Dabbelt To: xianting.tian@linux.alibaba.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,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 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.