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
49 return (ex_handler_t)((unsigned long)&x->handler + x->handler);49 return (ex_handler_t)((unsigned long)&x->handler + x->handler);
50}50}
51 51
52static 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
63#define ARCH_HAS_RELATIVE_EXTABLE52#define ARCH_HAS_RELATIVE_EXTABLE
64 53
65static inline void swap_ex_entry_fixup(struct exception_table_entry *a,54static 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
78}67}
79#define swap_ex_entry_fixup swap_ex_entry_fixup68#define swap_ex_entry_fixup swap_ex_entry_fixup
80 69
70bool fixup_exception(struct pt_regs *regs);
71
81#endif72#endif
arch/s390/kernel/early.c+1−5
@@ -151,12 +151,8 @@ static __init void setup_topology(void) · 150 unmodified lines
151 151
152static void early_pgm_check_handler(struct pt_regs *regs)152static void early_pgm_check_handler(struct pt_regs *regs)
153{153{
154 const struct exception_table_entry *fixup;154 if (!fixup_exception(regs))
155
156 fixup = s390_search_extables(regs->psw.addr);
157 if (!fixup)
158 disabled_wait();155 disabled_wait();
159 regs->psw.addr = extable_fixup(fixup);
160}156}
161 157
162static noinline __init void setup_lowcore_early(void)158static 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
465{465{
466 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();466 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
467 struct kprobe *p = kprobe_running();467 struct kprobe *p = kprobe_running();
468 const struct exception_table_entry *entry;
469 468
470 switch(kcb->kprobe_status) {469 switch(kcb->kprobe_status) {
471 case KPROBE_HIT_SS:470 case KPROBE_HIT_SS:
@@ -487,10 +486,8 @@ static int kprobe_trap_handler(struct pt_regs *regs, int trapnr) · 15 unmodified lines
487 * In case the user-specified fault handler returned486 * In case the user-specified fault handler returned
488 * zero, try to fix up.487 * zero, try to fix up.
489 */488 */
490 entry = s390_search_extables(regs->psw.addr);489 if (fixup_exception(regs))
491 if (entry && ex_handle(entry, regs))
492 return 1;490 return 1;
493
494 /*491 /*
495 * fixup_exception() could not handle it,492 * fixup_exception() could not handle it,
496 * Let do_page_fault() fix it.493 * 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
54 force_sig_fault(si_signo, si_code, get_trap_ip(regs));54 force_sig_fault(si_signo, si_code, get_trap_ip(regs));
55 report_user_fault(regs, si_signo, 0);55 report_user_fault(regs, si_signo, 0);
56 } else {56 } else {
57 const struct exception_table_entry *fixup;57 if (!fixup_exception(regs))
58 fixup = s390_search_extables(regs->psw.addr);
59 if (!fixup || !ex_handle(fixup, regs))
60 die(regs, str);58 die(regs, str);
61 }59 }
62}60}
@@ -245,16 +243,12 @@ static void space_switch_exception(struct pt_regs *regs) · 182 unmodified lines
245 243
246static void monitor_event_exception(struct pt_regs *regs)244static void monitor_event_exception(struct pt_regs *regs)
247{245{
248 const struct exception_table_entry *fixup;
249
250 if (user_mode(regs))246 if (user_mode(regs))
251 return;247 return;
252 248
253 switch (report_bug(regs->psw.addr - (regs->int_code >> 16), regs)) {249 switch (report_bug(regs->psw.addr - (regs->int_code >> 16), regs)) {
254 case BUG_TRAP_TYPE_NONE:250 case BUG_TRAP_TYPE_NONE:
255 fixup = s390_search_extables(regs->psw.addr);251 fixup_exception(regs);
256 if (fixup)
257 ex_handle(fixup, regs);
258 break;252 break;
259 case BUG_TRAP_TYPE_WARN:253 case BUG_TRAP_TYPE_WARN:
260 break;254 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
14 num = __stop_amode31_ex_table - __start_amode31_ex_table;14 num = __stop_amode31_ex_table - __start_amode31_ex_table;
15 return search_extable(__start_amode31_ex_table, num, addr);15 return search_extable(__start_amode31_ex_table, num, addr);
16}16}
17
18bool 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
230 230
231static noinline void do_no_context(struct pt_regs *regs)231static noinline void do_no_context(struct pt_regs *regs)
232{232{
233 const struct exception_table_entry *fixup;233 if (fixup_exception(regs))
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))
238 return;234 return;
239
240 /*235 /*
241 * Oops. The kernel tried to access some bad page. We'll have to236 * Oops. The kernel tried to access some bad page. We'll have to
242 * terminate things with extreme prejudice.237 * 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