Commit 5d7eccec authored by Heiko Carstens's avatar Heiko Carstens Committed by Martin Schwidefsky

s390/fault: merge report_user_fault implementations

We have two close to identical report_user_fault functions.
Add a parameter to one and get rid of the other one in order
to reduce code duplication.
Signed-off-by: default avatarHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
parent ee8479bb
...@@ -101,6 +101,8 @@ extern void pfault_fini(void); ...@@ -101,6 +101,8 @@ extern void pfault_fini(void);
#define pfault_fini() do { } while (0) #define pfault_fini() do { } while (0)
#endif /* CONFIG_PFAULT */ #endif /* CONFIG_PFAULT */
void report_user_fault(struct pt_regs *regs, long signr, int is_mm_fault);
extern void cmma_init(void); extern void cmma_init(void);
extern void (*_machine_restart)(char *command); extern void (*_machine_restart)(char *command);
......
...@@ -22,8 +22,6 @@ ...@@ -22,8 +22,6 @@
#include <asm/fpu/api.h> #include <asm/fpu/api.h>
#include "entry.h" #include "entry.h"
int show_unhandled_signals = 1;
static inline void __user *get_trap_ip(struct pt_regs *regs) static inline void __user *get_trap_ip(struct pt_regs *regs)
{ {
unsigned long address; unsigned long address;
...@@ -35,21 +33,6 @@ static inline void __user *get_trap_ip(struct pt_regs *regs) ...@@ -35,21 +33,6 @@ static inline void __user *get_trap_ip(struct pt_regs *regs)
return (void __user *) (address - (regs->int_code >> 16)); return (void __user *) (address - (regs->int_code >> 16));
} }
static inline void report_user_fault(struct pt_regs *regs, int signr)
{
if ((task_pid_nr(current) > 1) && !show_unhandled_signals)
return;
if (!unhandled_signal(current, signr))
return;
if (!printk_ratelimit())
return;
printk("User process fault: interruption code %04x ilc:%d ",
regs->int_code & 0xffff, regs->int_code >> 17);
print_vma_addr("in ", regs->psw.addr);
printk("\n");
show_regs(regs);
}
int is_valid_bugaddr(unsigned long addr) int is_valid_bugaddr(unsigned long addr)
{ {
return 1; return 1;
...@@ -65,7 +48,7 @@ void do_report_trap(struct pt_regs *regs, int si_signo, int si_code, char *str) ...@@ -65,7 +48,7 @@ void do_report_trap(struct pt_regs *regs, int si_signo, int si_code, char *str)
info.si_code = si_code; info.si_code = si_code;
info.si_addr = get_trap_ip(regs); info.si_addr = get_trap_ip(regs);
force_sig_info(si_signo, &info, current); force_sig_info(si_signo, &info, current);
report_user_fault(regs, si_signo); report_user_fault(regs, si_signo, 0);
} else { } else {
const struct exception_table_entry *fixup; const struct exception_table_entry *fixup;
fixup = search_exception_tables(regs->psw.addr); fixup = search_exception_tables(regs->psw.addr);
...@@ -111,7 +94,7 @@ NOKPROBE_SYMBOL(do_per_trap); ...@@ -111,7 +94,7 @@ NOKPROBE_SYMBOL(do_per_trap);
void default_trap_handler(struct pt_regs *regs) void default_trap_handler(struct pt_regs *regs)
{ {
if (user_mode(regs)) { if (user_mode(regs)) {
report_user_fault(regs, SIGSEGV); report_user_fault(regs, SIGSEGV, 0);
do_exit(SIGSEGV); do_exit(SIGSEGV);
} else } else
die(regs, "Unknown program exception"); die(regs, "Unknown program exception");
......
...@@ -183,6 +183,8 @@ static void dump_fault_info(struct pt_regs *regs) ...@@ -183,6 +183,8 @@ static void dump_fault_info(struct pt_regs *regs)
{ {
unsigned long asce; unsigned long asce;
pr_alert("Failing address: %016lx TEID: %016lx\n",
regs->int_parm_long & __FAIL_ADDR_MASK, regs->int_parm_long);
pr_alert("Fault in "); pr_alert("Fault in ");
switch (regs->int_parm_long & 3) { switch (regs->int_parm_long & 3) {
case 3: case 3:
...@@ -218,7 +220,9 @@ static void dump_fault_info(struct pt_regs *regs) ...@@ -218,7 +220,9 @@ static void dump_fault_info(struct pt_regs *regs)
dump_pagetable(asce, regs->int_parm_long & __FAIL_ADDR_MASK); dump_pagetable(asce, regs->int_parm_long & __FAIL_ADDR_MASK);
} }
static inline void report_user_fault(struct pt_regs *regs, long signr) int show_unhandled_signals = 1;
void report_user_fault(struct pt_regs *regs, long signr, int is_mm_fault)
{ {
if ((task_pid_nr(current) > 1) && !show_unhandled_signals) if ((task_pid_nr(current) > 1) && !show_unhandled_signals)
return; return;
...@@ -230,8 +234,7 @@ static inline void report_user_fault(struct pt_regs *regs, long signr) ...@@ -230,8 +234,7 @@ static inline void report_user_fault(struct pt_regs *regs, long signr)
regs->int_code & 0xffff, regs->int_code >> 17); regs->int_code & 0xffff, regs->int_code >> 17);
print_vma_addr(KERN_CONT "in ", regs->psw.addr); print_vma_addr(KERN_CONT "in ", regs->psw.addr);
printk(KERN_CONT "\n"); printk(KERN_CONT "\n");
printk(KERN_ALERT "failing address: %016lx TEID: %016lx\n", if (is_mm_fault)
regs->int_parm_long & __FAIL_ADDR_MASK, regs->int_parm_long);
dump_fault_info(regs); dump_fault_info(regs);
show_regs(regs); show_regs(regs);
} }
...@@ -244,7 +247,7 @@ static noinline void do_sigsegv(struct pt_regs *regs, int si_code) ...@@ -244,7 +247,7 @@ static noinline void do_sigsegv(struct pt_regs *regs, int si_code)
{ {
struct siginfo si; struct siginfo si;
report_user_fault(regs, SIGSEGV); report_user_fault(regs, SIGSEGV, 1);
si.si_signo = SIGSEGV; si.si_signo = SIGSEGV;
si.si_code = si_code; si.si_code = si_code;
si.si_addr = (void __user *)(regs->int_parm_long & __FAIL_ADDR_MASK); si.si_addr = (void __user *)(regs->int_parm_long & __FAIL_ADDR_MASK);
...@@ -272,8 +275,6 @@ static noinline void do_no_context(struct pt_regs *regs) ...@@ -272,8 +275,6 @@ static noinline void do_no_context(struct pt_regs *regs)
else else
printk(KERN_ALERT "Unable to handle kernel paging request" printk(KERN_ALERT "Unable to handle kernel paging request"
" in virtual user address space\n"); " in virtual user address space\n");
printk(KERN_ALERT "failing address: %016lx TEID: %016lx\n",
regs->int_parm_long & __FAIL_ADDR_MASK, regs->int_parm_long);
dump_fault_info(regs); dump_fault_info(regs);
die(regs, "Oops"); die(regs, "Oops");
do_exit(SIGKILL); do_exit(SIGKILL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment