Skip to content

Commit 48acba9

Browse files
committed
Merge tag 'riscv/for-v5.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V fixes from Paul Walmsley: - Fix several bugs in the breakpoint trap handler - Drop an unnecessary loop around calls to preempt_schedule_irq() * tag 'riscv/for-v5.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: RISC-V: entry: Remove unneeded need_resched() loop riscv: Correct the handling of unexpected ebreak in do_trap_break() riscv: avoid sending a SIGTRAP to a user thread trapped in WARN() riscv: avoid kernel hangs when trapped in BUG()
2 parents 63f9bff + cd9e72b commit 48acba9

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

arch/riscv/kernel/entry.S

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,11 @@ restore_all:
273273
resume_kernel:
274274
REG_L s0, TASK_TI_PREEMPT_COUNT(tp)
275275
bnez s0, restore_all
276-
need_resched:
277276
REG_L s0, TASK_TI_FLAGS(tp)
278277
andi s0, s0, _TIF_NEED_RESCHED
279278
beqz s0, restore_all
280279
call preempt_schedule_irq
281-
j need_resched
280+
j restore_all
282281
#endif
283282

284283
work_pending:

arch/riscv/kernel/traps.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -124,24 +124,24 @@ 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) {
133-
case BUG_TRAP_TYPE_NONE:
134-
break;
132+
#ifdef CONFIG_GENERIC_BUG
135133
case BUG_TRAP_TYPE_WARN:
136134
regs->sepc += get_break_insn_length(regs->sepc);
137-
break;
135+
return;
138136
case BUG_TRAP_TYPE_BUG:
137+
#endif /* CONFIG_GENERIC_BUG */
138+
default:
139139
die(regs, "Kernel BUG");
140140
}
141+
} else {
142+
force_sig_fault(SIGTRAP, TRAP_BRKPT,
143+
(void __user *)(regs->sepc));
141144
}
142-
#endif /* CONFIG_GENERIC_BUG */
143-
144-
force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)(regs->sepc));
145145
}
146146

147147
#ifdef CONFIG_GENERIC_BUG

0 commit comments

Comments
 (0)