hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/arch/s390/kernel/traps.c
....@@ -45,21 +45,13 @@
4545 void do_report_trap(struct pt_regs *regs, int si_signo, int si_code, char *str)
4646 {
4747 if (user_mode(regs)) {
48
- force_sig_fault(si_signo, si_code, get_trap_ip(regs), current);
48
+ force_sig_fault(si_signo, si_code, get_trap_ip(regs));
4949 report_user_fault(regs, si_signo, 0);
5050 } else {
5151 const struct exception_table_entry *fixup;
52
- fixup = search_exception_tables(regs->psw.addr);
53
- if (fixup)
54
- regs->psw.addr = extable_fixup(fixup);
55
- else {
56
- enum bug_trap_type btt;
57
-
58
- btt = report_bug(regs->psw.addr, regs);
59
- if (btt == BUG_TRAP_TYPE_WARN)
60
- return;
52
+ fixup = s390_search_extables(regs->psw.addr);
53
+ if (!fixup || !ex_handle(fixup, regs))
6154 die(regs, str);
62
- }
6355 }
6456 }
6557
....@@ -79,7 +71,7 @@
7971 if (!current->ptrace)
8072 return;
8173 force_sig_fault(SIGTRAP, TRAP_HWBKPT,
82
- (void __force __user *) current->thread.per_event.address, current);
74
+ (void __force __user *) current->thread.per_event.address);
8375 }
8476 NOKPROBE_SYMBOL(do_per_trap);
8577
....@@ -165,7 +157,7 @@
165157 return;
166158 if (*((__u16 *) opcode) == S390_BREAKPOINT_U16) {
167159 if (current->ptrace)
168
- force_sig_fault(SIGTRAP, TRAP_BRKPT, location, current);
160
+ force_sig_fault(SIGTRAP, TRAP_BRKPT, location);
169161 else
170162 signal = SIGILL;
171163 #ifdef CONFIG_UPROBES
....@@ -229,17 +221,11 @@
229221
230222 void data_exception(struct pt_regs *regs)
231223 {
232
- int signal = 0;
233
-
234224 save_fpu_regs();
235225 if (current->thread.fpu.fpc & FPC_DXC_MASK)
236
- signal = SIGFPE;
237
- else
238
- signal = SIGILL;
239
- if (signal == SIGFPE)
240226 do_fp_trap(regs, current->thread.fpu.fpc);
241
- else if (signal)
242
- do_trap(regs, signal, ILL_ILLOPN, "data exception");
227
+ else
228
+ do_trap(regs, SIGILL, ILL_ILLOPN, "data exception");
243229 }
244230
245231 void space_switch_exception(struct pt_regs *regs)
....@@ -249,6 +235,27 @@
249235 regs->psw.mask |= PSW_ASC_HOME;
250236 /* Send SIGILL. */
251237 do_trap(regs, SIGILL, ILL_PRVOPC, "space switch event");
238
+}
239
+
240
+void monitor_event_exception(struct pt_regs *regs)
241
+{
242
+ const struct exception_table_entry *fixup;
243
+
244
+ if (user_mode(regs))
245
+ return;
246
+
247
+ switch (report_bug(regs->psw.addr - (regs->int_code >> 16), regs)) {
248
+ case BUG_TRAP_TYPE_NONE:
249
+ fixup = s390_search_extables(regs->psw.addr);
250
+ if (fixup)
251
+ ex_handle(fixup, regs);
252
+ break;
253
+ case BUG_TRAP_TYPE_WARN:
254
+ break;
255
+ case BUG_TRAP_TYPE_BUG:
256
+ die(regs, "monitor event");
257
+ break;
258
+ }
252259 }
253260
254261 void kernel_stack_overflow(struct pt_regs *regs)
....@@ -261,7 +268,25 @@
261268 }
262269 NOKPROBE_SYMBOL(kernel_stack_overflow);
263270
271
+static void __init test_monitor_call(void)
272
+{
273
+ int val = 1;
274
+
275
+ if (!IS_ENABLED(CONFIG_BUG))
276
+ return;
277
+ asm volatile(
278
+ " mc 0,0\n"
279
+ "0: xgr %0,%0\n"
280
+ "1:\n"
281
+ EX_TABLE(0b,1b)
282
+ : "+d" (val));
283
+ if (!val)
284
+ panic("Monitor call doesn't work!\n");
285
+}
286
+
264287 void __init trap_init(void)
265288 {
289
+ sort_extable(__start_dma_ex_table, __stop_dma_ex_table);
266290 local_mcck_enable();
291
+ test_monitor_call();
267292 }