Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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.

Reviewed-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>

authored by

Heiko Carstens and committed by
Vasily Gorbik
46fee16f cfa45c5e

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