Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3414576rwa; Tue, 23 Aug 2022 04:30:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR6lj1fcBZUSbbESZMGkATK3GW+zZdhKM3KfOf6KxI/S1HKu2eJV0F0hL7/WA4KqnQW7m4cf X-Received: by 2002:a05:6402:5c9:b0:446:fb0:56bb with SMTP id n9-20020a05640205c900b004460fb056bbmr3359012edx.173.1661254244019; Tue, 23 Aug 2022 04:30:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661254244; cv=none; d=google.com; s=arc-20160816; b=YTOS0a/b0UUlab1caTs8kEVxLi/g5cHwJ7EU9GY0k0VwpG2UiLMlX34P+3Mh0/eRyu vipVDhJBYHFVBE+RoNc9nvUmGz80YDQDzE0UQDmzT5hhuKw1LDAciF/0eoZyqC+A4167 mL61s+MuVX38KA9M4Kuw1Scjegi0ZJTZ9DvYwGQrlqGCzUd+Cqo8P1cNe3u9pDcb5i5C MmcUDSuUs757mPvXoKBL8ciXjU+erCb+ZvugA6vaAF7giktFKbGmhEDwMIl9438duquq jf+D6I81zsNGk2CdGCj6GSpaM6zBtxZKKeKgMAC2TGtwGT9I6s787SnmLNS70i34bMEc BWmA== 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=hJ8cEDE0/eVE2kNPOHzMPV/frs+iAZ3I99qd6aR0IMg=; b=LH4gfR/hDNdRv54854eKBPCr7ag9GVlHE7+crwh0IhzfJ4fgFiPLw78ldVbpnUEpnZ iOMR86yXVRq+TCQY8bMyPnWXC41NV4TeTtgIeQyCzYEsGfJiPCTGHsvXPFMp+V8n1Vrc 58eHbNBkr+31+WW8NVrHwZ/ELYhNLErCTTBJQ37WYAFfaSnKXWQtDmkgoDuLGQpQCkgj ttIvyG9UGt5NQfNGdVyplH6hg1+3XJiXq5QEeR0+KktZcz+8auULOlMw9T7pzQ+Dod0a h6OoYhWgkb06YnTAQDutq3HTNSuXBWYfIhzg5m1YN0VUbWSCC6T1xRSRbIXdaEqMvonE EyZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sEJc8e3U; 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 oz44-20020a1709077dac00b0073301e9817dsi12008180ejc.620.2022.08.23.04.30.17; Tue, 23 Aug 2022 04:30:43 -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=sEJc8e3U; 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 S1357013AbiHWLFE (ORCPT + 99 others); Tue, 23 Aug 2022 07:05:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357480AbiHWLC3 (ORCPT ); Tue, 23 Aug 2022 07:02:29 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A80C9B2758; Tue, 23 Aug 2022 02:15:04 -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 ams.source.kernel.org (Postfix) with ESMTPS id 3D4D8B81C66; Tue, 23 Aug 2022 09:15:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 74FD3C433D6; Tue, 23 Aug 2022 09:15:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661246101; bh=tJ4/GjcFTOYm1eHzzFoim4ZayD31016TtBq0nigveEE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sEJc8e3UNwILZbpGkJwonc/Z6Bp2t09SMtQBZEb3y+p2V/QeHvc9oEwdlnZed2fUQ zU8V4LKgAL+gFn3aA7Y1To0S7eG4Y2GQdnSN6kjX4A+Xr0Rgl4zDvIa7aJSChqmtSF pqF1Xx2jQN+q8dLdga9qmP6b96BwlHmAhgUwjQyM= 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 4.19 275/287] RISC-V: Add fast call path of crash_kexec() Date: Tue, 23 Aug 2022 10:27:24 +0200 Message-Id: <20220823080110.667293814@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@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 24a9333dda2c..7c65750508f2 100644 --- a/arch/riscv/kernel/traps.c +++ b/arch/riscv/kernel/traps.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -50,6 +51,9 @@ void die(struct pt_regs *regs, const char *str) ret = notify_die(DIE_OOPS, str, regs, 0, regs->scause, 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