History

s390/extable: add and use fixup_exception helper function

Add and use fixup_exception helper function in order to remove the duplicated exception handler fixup code at several places.

Heiko Carstens committed 4 years ago

Commit 46fee161 parent cfa45c56 files · +22 −34Browse files

Unified · Split

6 files
  1. arch/s390/include/asm/extable.h +2 −11
  2. arch/s390/kernel/early.c +1 −5
  3. arch/s390/kernel/kprobes.c +1 −4
  4. arch/s390/kernel/traps.c +2 −8
  5. arch/s390/mm/extable.c +15 −0
  6. arch/s390/mm/fault.c +1 −6
arch/s390/include/asm/extable.h+2−11
@@ -49,17 +49,6 @@ ex_fixup_handler(const struct exception_table_entry *x) · 48 unmodified lines
4949 return (ex_handler_t)((unsigned long)&x->handler + x->handler);
5050 }
5151
52−static inline bool ex_handle(const struct exception_table_entry *x,
53− struct pt_regs *regs)
54−{
55− ex_handler_t handler = ex_fixup_handler(x);
56−
57− if (unlikely(handler))
58− return handler(x, regs);
59− regs->psw.addr = extable_fixup(x);
60− return true;
61−}
62−
6352 #define ARCH_HAS_RELATIVE_EXTABLE
6453
6554 static inline void swap_ex_entry_fixup(struct exception_table_entry *a,
@@ -78,4 +67,6 @@ static inline void swap_ex_entry_fixup(struct exception_table_entry *a, · 12 unmodified lines
7867 }
7968 #define swap_ex_entry_fixup swap_ex_entry_fixup
8069
70+bool fixup_exception(struct pt_regs *regs);
71+
8172 #endif
arch/s390/kernel/early.c+1−5
@@ -151,12 +151,8 @@ static __init void setup_topology(void) · 150 unmodified lines
151151
152152 static void early_pgm_check_handler(struct pt_regs *regs)
153153 {
154− const struct exception_table_entry *fixup;
155−
156− fixup = s390_search_extables(regs->psw.addr);
157− if (!fixup)
154+ if (!fixup_exception(regs))
158155 disabled_wait();
159− regs->psw.addr = extable_fixup(fixup);
160156 }
161157
162158 static noinline __init void setup_lowcore_early(void)
arch/s390/kernel/kprobes.c+1−4
@@ -465,7 +465,6 @@ static int kprobe_trap_handler(struct pt_regs *regs, int trapnr) · 464 unmodified lines
465465 {
466466 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
467467 struct kprobe *p = kprobe_running();
468− const struct exception_table_entry *entry;
469468
470469 switch(kcb->kprobe_status) {
471470 case KPROBE_HIT_SS:
@@ -487,10 +486,8 @@ static int kprobe_trap_handler(struct pt_regs *regs, int trapnr) · 15 unmodified lines
487486 * In case the user-specified fault handler returned
488487 * zero, try to fix up.
489488 */
490− entry = s390_search_extables(regs->psw.addr);
491− if (entry && ex_handle(entry, regs))
489+ if (fixup_exception(regs))
492490 return 1;
493−
494491 /*
495492 * fixup_exception() could not handle it,
496493 * Let do_page_fault() fix it.
arch/s390/kernel/traps.c+2−8
@@ -54,9 +54,7 @@ void do_report_trap(struct pt_regs *regs, int si_signo, int si_code, char *str) · 53 unmodified lines
5454 force_sig_fault(si_signo, si_code, get_trap_ip(regs));
5555 report_user_fault(regs, si_signo, 0);
5656 } else {
57− const struct exception_table_entry *fixup;
58− fixup = s390_search_extables(regs->psw.addr);
59− if (!fixup || !ex_handle(fixup, regs))
57+ if (!fixup_exception(regs))
6058 die(regs, str);
6159 }
6260 }
@@ -245,16 +243,12 @@ static void space_switch_exception(struct pt_regs *regs) · 182 unmodified lines
245243
246244 static void monitor_event_exception(struct pt_regs *regs)
247245 {
248− const struct exception_table_entry *fixup;
249−
250246 if (user_mode(regs))
251247 return;
252248
253249 switch (report_bug(regs->psw.addr - (regs->int_code >> 16), regs)) {
254250 case BUG_TRAP_TYPE_NONE:
255− fixup = s390_search_extables(regs->psw.addr);
256− if (fixup)
257− ex_handle(fixup, regs);
251+ fixup_exception(regs);
258252 break;
259253 case BUG_TRAP_TYPE_WARN:
260254 break;
arch/s390/mm/extable.c+15−0
@@ -14,3 +14,18 @@ const struct exception_table_entry *s390_search_extables(unsigned long addr) · 13 unmodified lines
1414 num = __stop_amode31_ex_table - __start_amode31_ex_table;
1515 return search_extable(__start_amode31_ex_table, num, addr);
1616 }
17+
18+bool fixup_exception(struct pt_regs *regs)
19+{
20+ const struct exception_table_entry *ex;
21+ ex_handler_t handler;
22+
23+ ex = s390_search_extables(instruction_pointer(regs));
24+ if (!ex)
25+ return false;
26+ handler = ex_fixup_handler(ex);
27+ if (unlikely(handler))
28+ return handler(ex, regs);
29+ regs->psw.addr = extable_fixup(ex);
30+ return true;
31+}
arch/s390/mm/fault.c+1−6
@@ -230,13 +230,8 @@ static noinline void do_sigsegv(struct pt_regs *regs, int si_code) · 229 unmodified lines
230230
231231 static noinline void do_no_context(struct pt_regs *regs)
232232 {
233− const struct exception_table_entry *fixup;
234−
235− /* Are we prepared to handle this kernel fault? */
236− fixup = s390_search_extables(regs->psw.addr);
237− if (fixup && ex_handle(fixup, regs))
233+ if (fixup_exception(regs))
238234 return;
239−
240235 /*
241236 * Oops. The kernel tried to access some bad page. We'll have to
242237 * terminate things with extreme prejudice.

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t