Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp4481908ybx; Mon, 4 Nov 2019 14:09:33 -0800 (PST) X-Google-Smtp-Source: APXvYqw7EdOR0GxzR5IzdyARoPw0lV3f/LDWdxJxSvun0XWteHMK9D0PR7qUJqk/w4J3SoXcOU+d X-Received: by 2002:a17:906:4dd5:: with SMTP id f21mr25896526ejw.203.1572905373191; Mon, 04 Nov 2019 14:09:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1572905373; cv=none; d=google.com; s=arc-20160816; b=g8kOihaPKLdG72u1r4e0CWVuMd5v02euDcBCviqYhpRyn7GzcPVIENOUOKTU86mPFC 0DGCHKlaS8HJ2kgEt8PBLPT+cyr8hMIAutbmIQSuIMCv9vxwMPeb1bSEUt65EuPrjDfr xRV/8SqYEvbpYD+U0aYAws2bcN00qg55WA+28kl+lOoDzQtaqaNx9w0UM4hjTvN5LcbE AoAKcdFX6+hZWOql0krBEJ7xAikd54rkOgRissaAEL8CgN6bibOvUPhgUAn+w/+nhoMH PtrjjlFRYC43avi76Uz0uonHEW+12T6MvksvSuZQs2Xbg39/0XJGuKjKEW9xTULBqpYL 5t5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kTqvR7VKGk6q/79ZXDH/uA++cdRp4VO8boY0LJmRjVg=; b=bLM8Denc7e6V2/FkEDL1JfgUlEmrWjvsrtJD5NHXI/bECPLn2krI1JR2+1l8lQYfY/ d7vaspsdURfuS8N6wG9qtelJC5eqSA8dRBc2pqD9W8cU0VldCvoXuVxzzNRPgXVoAWIo WsPphMlixeWe321TrJNZ4yxeATMkI2PbSmRtLa1DpEIywWFRacAE+la28x09iYdbnD9Q uGlMORhrETDgkKg/2msZ2p/jfD11zH9yZx+2luLR3xKgNIweDRtzqon6E2vYj9ir+BjN SNdCxgmf1Yv2konIyUYfNHmog1ta6E0VF0vbi6qhDKR8ATGGCVwsJOxPVCCKAizfljJR AhAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IQKQH2l+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p21si8203688edc.305.2019.11.04.14.09.09; Mon, 04 Nov 2019 14:09:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=IQKQH2l+; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390213AbfKDWIU (ORCPT + 99 others); Mon, 4 Nov 2019 17:08:20 -0500 Received: from mail.kernel.org ([198.145.29.99]:41104 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389799AbfKDWIP (ORCPT ); Mon, 4 Nov 2019 17:08:15 -0500 Received: from localhost (6.204-14-84.ripe.coltfrance.com [84.14.204.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7C03C2084D; Mon, 4 Nov 2019 22:08:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1572905295; bh=d/6zc+tZJQ0l59lFjH5IKUXNkBz2OQ9GKqznhzOEnoA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IQKQH2l+S5EDi9t+QnEQh4khUtUuLH8aPn6yUqEZRPP1VOPefiq4NIZKgmYh4hFqb MCvCsUQSIc7Kf68JNQhIVZFIApEyajy0nyNq4T+R59SFZFygDY0ILHyyDshmsYjgii L9AEkZ7L0QQuPMntDO0VUVwxvRMh1aZ58oudHzcI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vincent Chen , Christoph Hellwig , Paul Walmsley , Sasha Levin Subject: [PATCH 5.3 054/163] riscv: avoid kernel hangs when trapped in BUG() Date: Mon, 4 Nov 2019 22:44:04 +0100 Message-Id: <20191104212144.063503330@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191104212140.046021995@linuxfoundation.org> References: <20191104212140.046021995@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vincent Chen [ Upstream commit 8b04825ed205da38754f86f4c07ea8600d8c2a65 ] When the CONFIG_GENERIC_BUG is disabled by disabling CONFIG_BUG, if a kernel thread is trapped by BUG(), the whole system will be in the loop that infinitely handles the ebreak exception instead of entering the die function. To fix this problem, the do_trap_break() will always call the die() to deal with the break exception as the type of break is BUG_TRAP_TYPE_BUG. Signed-off-by: Vincent Chen Reviewed-by: Christoph Hellwig Signed-off-by: Paul Walmsley Signed-off-by: Sasha Levin --- arch/riscv/kernel/traps.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/riscv/kernel/traps.c b/arch/riscv/kernel/traps.c index 424eb72d56b10..055a937aca70a 100644 --- a/arch/riscv/kernel/traps.c +++ b/arch/riscv/kernel/traps.c @@ -124,23 +124,23 @@ static inline unsigned long get_break_insn_length(unsigned long pc) asmlinkage void do_trap_break(struct pt_regs *regs) { -#ifdef CONFIG_GENERIC_BUG if (!user_mode(regs)) { enum bug_trap_type type; type = report_bug(regs->sepc, regs); switch (type) { +#ifdef CONFIG_GENERIC_BUG case BUG_TRAP_TYPE_NONE: break; case BUG_TRAP_TYPE_WARN: regs->sepc += get_break_insn_length(regs->sepc); break; case BUG_TRAP_TYPE_BUG: +#endif /* CONFIG_GENERIC_BUG */ + default: die(regs, "Kernel BUG"); } } -#endif /* CONFIG_GENERIC_BUG */ - force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)(regs->sepc)); } -- 2.20.1