Skip to content

Commit 8b04825

Browse files
VincentZWCpaul-walmsley-sifive
authored andcommitted
riscv: avoid kernel hangs when trapped in BUG()
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 <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: Paul Walmsley <[email protected]>
1 parent da0c9ea commit 8b04825

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/riscv/kernel/traps.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,23 +124,23 @@ static inline unsigned long get_break_insn_length(unsigned long pc)
124124

125125
asmlinkage void do_trap_break(struct pt_regs *regs)
126126
{
127-
#ifdef CONFIG_GENERIC_BUG
128127
if (!user_mode(regs)) {
129128
enum bug_trap_type type;
130129

131130
type = report_bug(regs->sepc, regs);
132131
switch (type) {
132+
#ifdef CONFIG_GENERIC_BUG
133133
case BUG_TRAP_TYPE_NONE:
134134
break;
135135
case BUG_TRAP_TYPE_WARN:
136136
regs->sepc += get_break_insn_length(regs->sepc);
137137
break;
138138
case BUG_TRAP_TYPE_BUG:
139+
#endif /* CONFIG_GENERIC_BUG */
140+
default:
139141
die(regs, "Kernel BUG");
140142
}
141143
}
142-
#endif /* CONFIG_GENERIC_BUG */
143-
144144
force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)(regs->sepc));
145145
}
146146

0 commit comments

Comments
 (0)