Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp150975iog; Fri, 17 Jun 2022 00:25:47 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tehNYtKUpeiZUgihXpGN8k7K51vo74qc3BiGidxgSLAfiVe3MbbuFyOCIfBwxAlWt7QdZ3 X-Received: by 2002:a65:6d0b:0:b0:408:7ced:3ca1 with SMTP id bf11-20020a656d0b000000b004087ced3ca1mr7999973pgb.476.1655450746992; Fri, 17 Jun 2022 00:25:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655450746; cv=none; d=google.com; s=arc-20160816; b=NbEjN7g+xyeQDxj//34WG476/PuRhZOTRNYYpGosfDy+tSCl7LatcQIYZeKgPN9V/t YVN60S4j4oYWNDPaBrKMaTlD8nWwdswzJs2EshgJeTPE+cjcu2ZjE3NsViFA/6CJhFaG R0LBhprcu1pefFHjRupztdLSbfyef7fygZpaVWdQnZvrVZ3srPGb5xOPbEjbTmtm23OW Mc1SpG26KK02EXW9e4s5pJVBAAbIxzmcNzAaNXTx2yDSmXx8bkw0tkKrchDH0vZ2n0V2 TUtlHrNxstYPsRq+itUyH7c6Z6hHKxO75P7x+DcsZCycwyGLQMZlGwtXXKssSRd8/PyL 5rYQ== 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:references:cc:to:from :subject; bh=VJck7GANJ9Hy7L75osQTQC8E9YfQ4jMlQ6JxWAVa8us=; b=aVoHdXEDgY1Ewr95lY1/z9xrfCnd5fGecMQZ41Bx3wwD8mgiaVo3fYdPAis1pmjCbM CttZmBRyj9yd6SXDvYEh9hwknVvxwLjC82E6vcxo6L/XDzJgnOokPupO4YiOaaf/vVKk wVDLx6Kosze+kU3v1cwxvtQMDu7p1ldftNSP177GTkqJGzfQUu6RhsrNtvPfxRDGTJxk 5kaqFzgq35GU8wt9yK3VVFFxbrWl6OmFqAIbz2O0BtmUsDRQxGDfdiQ4OdOS9qNWAey8 UM/t5YAoGSE29q1A3ESw1Fo2cPKWkMwbsnF+Q5K/LzdqjHmyyNLtPiULeUPQOIvUXeiH 8l+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 v62-20020a638941000000b0040a88edd57csi5018132pgd.854.2022.06.17.00.25.33; Fri, 17 Jun 2022 00:25:46 -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 S1380002AbiFQGkv (ORCPT + 99 others); Fri, 17 Jun 2022 02:40:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229696AbiFQGku (ORCPT ); Fri, 17 Jun 2022 02:40:50 -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 CC37457144 for ; Thu, 16 Jun 2022 23:40:48 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R591e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046050;MF=xianting.tian@linux.alibaba.com;NM=1;PH=DS;RN=12;SR=0;TI=SMTPD_---0VGdrNNM_1655448044; Received: from B-LB6YLVDL-0141.local(mailfrom:xianting.tian@linux.alibaba.com fp:SMTPD_---0VGdrNNM_1655448044) by smtp.aliyun-inc.com; Fri, 17 Jun 2022 14:40:45 +0800 Subject: Re: [PATCH v3] RISC-V: Add fixup to support fast call of crash_kexec() From: Xianting Tian 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> Message-ID: <9fa53c5b-361a-a044-a08b-57458d7fcab8@linux.alibaba.com> Date: Fri, 17 Jun 2022 14:40:44 +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.5 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 Hi Palmer Will you apply this patch for 5.19? thanks 在 2022/6/7 上午9:46, Xianting Tian 写道: > > 在 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);