Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3407712rwa; Tue, 23 Aug 2022 04:23:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR62rYmVX8LF0PXz19Uzhe78bFdIlFtqdyTXWfRoui0uNTBGjaEJb3gnIwLggVBOfwn6D/mw X-Received: by 2002:a17:90b:3508:b0:1fa:f7a8:811f with SMTP id ls8-20020a17090b350800b001faf7a8811fmr2842101pjb.7.1661253721422; Tue, 23 Aug 2022 04:22:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253721; cv=none; d=google.com; s=arc-20160816; b=sgHnNV8esdLtfzwNXitueT+ndsFG4JCpqne3PTaWkqDuPw2IuAdH65+XUMkfTAU7Ma rHc+RGzePq2JBgeLcZjRNDAd9+Lif2VafkZ3DeXnwhWJW98B97vIR0sB+ELqBx108uQA o37NugglnrtJ4PegrdnXZZfxak3gZLkR1MCKLdbKJYQfuwuoiiazEt5XFCdVGJmI/6cs 63j9YPc+R9Bqiix5kwWi1mqvG3Wvu60yAUha9V6iTnGvdRfvPQ8MqaVGtWoDV+Ugt4nX cKNa2ao9mxGzHl/iiU1T6NKr07xLahPRy9uvHaE2gFREgzSoqgcsRTXRZ2gcpVI2kvUM CS/g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XxmDkUEeH+MuazOq+5C/ei2ZWmn4CauUsyekZvFaOno=; b=IBjHa4S2BaaD58ZMU1EeMMtPJ/+jdeuz/uuLsOZ/DSbgJmZ4j63iUyX3NQPMgiIsiY KMJ1A8zV9FY7hFeU7xPn6KAm30KWSlXqV/IjGYIfrzHWTuFTppXIFI3yKq7vRtVWKoiV 7pcfIZnW0hieQQ44460CeokhPZL1jXEd/y8uDnrmAGudeepz16CBD7tFWrJYs9eIEP1+ NA+BwO5rp59QbJSdjF+ctAdJjA15L/M9aaoXWFTxgTj2cgLeU5aL4mkDmSiIa3luK9MQ Txx6EZciWy1NqDUcIwAAcH8izL1Ba8Li9K3ANuWPULxcM+gcS35Ui+psNFKpJJLqAsww I+QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Hc2eGEak; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h192-20020a636cc9000000b0041c4d623573si16189831pgc.769.2022.08.23.04.21.50; Tue, 23 Aug 2022 04:22:01 -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=@linuxfoundation.org header.s=korg header.b=Hc2eGEak; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354975AbiHWKag (ORCPT + 99 others); Tue, 23 Aug 2022 06:30:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353376AbiHWKOf (ORCPT ); Tue, 23 Aug 2022 06:14:35 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C61073322; Tue, 23 Aug 2022 02:00:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 90666CE1B45; Tue, 23 Aug 2022 08:59:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EEDFC433C1; Tue, 23 Aug 2022 08:59:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245198; bh=rjjCfkyDLgishq46C0BsFbiiIVJXO157qW9QTrr4C8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hc2eGEakvxra1SDyfAo4dN4UfSda23FxGmqN8OqKuWt+I6GWXMTc7BeMAzfEbr/AQ TKL+aFx/6xMr6SjMxpff3aQvV/o8xLBipqwKnYQ40rDFLnDo1H/TSYtSFNNrPcuwTp XVQ5uSKTcetmx1qzu3h+o4jrqxz6m8K6u1wfsA58= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guo Ren , Xianting Tian , Palmer Dabbelt , Sasha Levin Subject: [PATCH 5.15 218/244] RISC-V: Add fast call path of crash_kexec() Date: Tue, 23 Aug 2022 10:26:17 +0200 Message-Id: <20220823080106.799832477@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Xianting Tian [ Upstream commit 3f1901110a89b0e2e13adb2ac8d1a7102879ea98 ] 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 Link: https://lore.kernel.org/r/20220606082308.2883458-1-xianting.tian@linux.alibaba.com Signed-off-by: Palmer Dabbelt Signed-off-by: Sasha Levin --- 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 0daaa3e4630d..b938ffe129d6 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); -- 2.35.1