Skip to content

Commit 46fee16

Browse files
hcahcaVasily Gorbik
authored andcommitted
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>
1 parent cfa45c5 commit 46fee16

6 files changed

Lines changed: 22 additions & 34 deletions

File tree

arch/s390/include/asm/extable.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,6 @@ ex_fixup_handler(const struct exception_table_entry *x)
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,
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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,8 @@ static __init void setup_topology(void)
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

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,6 @@ static int kprobe_trap_handler(struct pt_regs *regs, int trapnr)
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)
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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ void do_report_trap(struct pt_regs *regs, int si_signo, int si_code, char *str)
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)
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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,18 @@ const struct exception_table_entry *s390_search_extables(unsigned long addr)
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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,8 @@ static noinline void do_sigsegv(struct pt_regs *regs, int si_code)
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.

0 commit comments

Comments
 (0)