traps.c (cf39d37539068d53e015d8b4f1dcf42c65306b0d) traps.c (cfafe260137418d0265d0df3bb18dc494af2b43e)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2012 Regents of the University of California
4 */
5
6#include <linux/cpu.h>
7#include <linux/kernel.h>
8#include <linux/init.h>

--- 104 unchanged lines hidden (view full) ---

113 SIGILL, ILL_ILLTRP, "environment call from M-mode");
114
115static inline unsigned long get_break_insn_length(unsigned long pc)
116{
117 bug_insn_t insn;
118
119 if (probe_kernel_address((bug_insn_t *)pc, insn))
120 return 0;
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Copyright (C) 2012 Regents of the University of California
4 */
5
6#include <linux/cpu.h>
7#include <linux/kernel.h>
8#include <linux/init.h>

--- 104 unchanged lines hidden (view full) ---

113 SIGILL, ILL_ILLTRP, "environment call from M-mode");
114
115static inline unsigned long get_break_insn_length(unsigned long pc)
116{
117 bug_insn_t insn;
118
119 if (probe_kernel_address((bug_insn_t *)pc, insn))
120 return 0;
121 return (((insn & __INSN_LENGTH_MASK) == __INSN_LENGTH_32) ? 4UL : 2UL);
121
122 return GET_INSN_LENGTH(insn);
122}
123
124asmlinkage __visible void do_trap_break(struct pt_regs *regs)
125{
126 if (user_mode(regs))
127 force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->epc);
128 else if (report_bug(regs->epc, regs) == BUG_TRAP_TYPE_WARN)
129 regs->epc += get_break_insn_length(regs->epc);

--- 12 unchanged lines hidden (view full) ---

142 return 0;
143 if ((insn & __INSN_LENGTH_MASK) == __INSN_LENGTH_32)
144 return (insn == __BUG_INSN_32);
145 else
146 return ((insn & __COMPRESSED_INSN_MASK) == __BUG_INSN_16);
147}
148#endif /* CONFIG_GENERIC_BUG */
149
123}
124
125asmlinkage __visible void do_trap_break(struct pt_regs *regs)
126{
127 if (user_mode(regs))
128 force_sig_fault(SIGTRAP, TRAP_BRKPT, (void __user *)regs->epc);
129 else if (report_bug(regs->epc, regs) == BUG_TRAP_TYPE_WARN)
130 regs->epc += get_break_insn_length(regs->epc);

--- 12 unchanged lines hidden (view full) ---

143 return 0;
144 if ((insn & __INSN_LENGTH_MASK) == __INSN_LENGTH_32)
145 return (insn == __BUG_INSN_32);
146 else
147 return ((insn & __COMPRESSED_INSN_MASK) == __BUG_INSN_16);
148}
149#endif /* CONFIG_GENERIC_BUG */
150
150void __init trap_init(void)
151void trap_init(void)
151{
152 /*
153 * Set sup0 scratch register to 0, indicating to exception vector
154 * that we are presently executing in the kernel
155 */
156 csr_write(CSR_SCRATCH, 0);
157 /* Set the exception vector address */
158 csr_write(CSR_TVEC, &handle_exception);
159 /* Enable interrupts */
160 csr_write(CSR_IE, IE_SIE | IE_EIE);
161}
152{
153 /*
154 * Set sup0 scratch register to 0, indicating to exception vector
155 * that we are presently executing in the kernel
156 */
157 csr_write(CSR_SCRATCH, 0);
158 /* Set the exception vector address */
159 csr_write(CSR_TVEC, &handle_exception);
160 /* Enable interrupts */
161 csr_write(CSR_IE, IE_SIE | IE_EIE);
162}