mirror of
https://github.com/torvalds/linux.git
synced 2024-11-13 07:31:45 +00:00
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 <hch@lst.de> Reviewed-by: Anup Patel <anup@brainfault.org> Signed-off-by: Paul Walmsley <paul.walmsley@sifive.com>
This commit is contained in:
parent
a6d9e26726
commit
e8f44c50df
@ -111,7 +111,6 @@ DO_ERROR_INFO(do_trap_ecall_s,
|
|||||||
DO_ERROR_INFO(do_trap_ecall_m,
|
DO_ERROR_INFO(do_trap_ecall_m,
|
||||||
SIGILL, ILL_ILLTRP, "environment call from M-mode");
|
SIGILL, ILL_ILLTRP, "environment call from M-mode");
|
||||||
|
|
||||||
#ifdef CONFIG_GENERIC_BUG
|
|
||||||
static inline unsigned long get_break_insn_length(unsigned long pc)
|
static inline unsigned long get_break_insn_length(unsigned long pc)
|
||||||
{
|
{
|
||||||
bug_insn_t insn;
|
bug_insn_t insn;
|
||||||
@ -120,28 +119,15 @@ static inline unsigned long get_break_insn_length(unsigned long pc)
|
|||||||
return 0;
|
return 0;
|
||||||
return (((insn & __INSN_LENGTH_MASK) == __INSN_LENGTH_32) ? 4UL : 2UL);
|
return (((insn & __INSN_LENGTH_MASK) == __INSN_LENGTH_32) ? 4UL : 2UL);
|
||||||
}
|
}
|
||||||
#endif /* CONFIG_GENERIC_BUG */
|
|
||||||
|
|
||||||
asmlinkage void do_trap_break(struct pt_regs *regs)
|
asmlinkage void do_trap_break(struct pt_regs *regs)
|
||||||
{
|
{
|
||||||
if (user_mode(regs)) {
|
if (user_mode(regs))
|
||||||
force_sig_fault(SIGTRAP, TRAP_BRKPT,
|
force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->sepc);
|
||||||
(void __user *)(regs->sepc));
|
else if (report_bug(regs->sepc, regs) == BUG_TRAP_TYPE_WARN)
|
||||||
return;
|
regs->sepc += get_break_insn_length(regs->sepc);
|
||||||
}
|
else
|
||||||
#ifdef CONFIG_GENERIC_BUG
|
die(regs, "Kernel BUG");
|
||||||
{
|
|
||||||
enum bug_trap_type type;
|
|
||||||
|
|
||||||
type = report_bug(regs->sepc, regs);
|
|
||||||
if (type == BUG_TRAP_TYPE_WARN) {
|
|
||||||
regs->sepc += get_break_insn_length(regs->sepc);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_GENERIC_BUG */
|
|
||||||
|
|
||||||
die(regs, "Kernel BUG");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_GENERIC_BUG
|
#ifdef CONFIG_GENERIC_BUG
|
||||||
|
Loading…
Reference in New Issue
Block a user