Skip to content

Commit e8f44c5

Browse files
Christoph Hellwigpaul-walmsley-sifive
authored andcommitted
riscv: cleanup do_trap_break
If we always compile the get_break_insn_length inline function we can remove the ifdefs and let dead code elimination take care of the warn branch that is now unreadable because the report_bug stub always returns BUG_TRAP_TYPE_BUG. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Anup Patel <[email protected]> Signed-off-by: Paul Walmsley <[email protected]>
1 parent a6d9e26 commit e8f44c5

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

arch/riscv/kernel/traps.c

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ DO_ERROR_INFO(do_trap_ecall_s,
111111
DO_ERROR_INFO(do_trap_ecall_m,
112112
SIGILL, ILL_ILLTRP, "environment call from M-mode");
113113

114-
#ifdef CONFIG_GENERIC_BUG
115114
static inline unsigned long get_break_insn_length(unsigned long pc)
116115
{
117116
bug_insn_t insn;
@@ -120,28 +119,15 @@ static inline unsigned long get_break_insn_length(unsigned long pc)
120119
return 0;
121120
return (((insn & __INSN_LENGTH_MASK) == __INSN_LENGTH_32) ? 4UL : 2UL);
122121
}
123-
#endif /* CONFIG_GENERIC_BUG */
124122

125123
asmlinkage void do_trap_break(struct pt_regs *regs)
126124
{
127-
if (user_mode(regs)) {
128-
force_sig_fault(SIGTRAP, TRAP_BRKPT,
129-
(void __user *)(regs->sepc));
130-
return;
131-
}
132-
#ifdef CONFIG_GENERIC_BUG
133-
{
134-
enum bug_trap_type type;
135-
136-
type = report_bug(regs->sepc, regs);
137-
if (type == BUG_TRAP_TYPE_WARN) {
138-
regs->sepc += get_break_insn_length(regs->sepc);
139-
return;
140-
}
141-
}
142-
#endif /* CONFIG_GENERIC_BUG */
143-
144-
die(regs, "Kernel BUG");
125+
if (user_mode(regs))
126+
force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->sepc);
127+
else if (report_bug(regs->sepc, regs) == BUG_TRAP_TYPE_WARN)
128+
regs->sepc += get_break_insn_length(regs->sepc);
129+
else
130+
die(regs, "Kernel BUG");
145131
}
146132

147133
#ifdef CONFIG_GENERIC_BUG

0 commit comments

Comments
 (0)