From dcdf3a293522e6ef09d8b3650ac1ceec56438e5d Mon Sep 17 00:00:00 2001 From: Roman Zippel Date: Tue, 18 Nov 2008 21:25:17 +0100 Subject: m68k: Add helper function handle_kernel_fault() Add helper function handle_kernel_fault() in signal.c, so frame_extra_sizes can become static, and to avoid future code duplication. Signed-off-by: Roman Zippel Signed-off-by: Geert Uytterhoeven --- arch/m68k/include/asm/processor.h | 2 ++ arch/m68k/kernel/signal.c | 24 +++++++++++++++++++++++- arch/m68k/mm/fault.c | 16 +--------------- 3 files changed, 26 insertions(+), 16 deletions(-) diff --git a/arch/m68k/include/asm/processor.h b/arch/m68k/include/asm/processor.h index 278c69bad57a..f111b02b704f 100644 --- a/arch/m68k/include/asm/processor.h +++ b/arch/m68k/include/asm/processor.h @@ -113,6 +113,8 @@ static inline void start_thread(struct pt_regs * regs, unsigned long pc, wrusp(usp); } +extern int handle_kernel_fault(struct pt_regs *regs); + #else /* diff --git a/arch/m68k/kernel/signal.c b/arch/m68k/kernel/signal.c index d12c3b0d9e4f..a0afc239304e 100644 --- a/arch/m68k/kernel/signal.c +++ b/arch/m68k/kernel/signal.c @@ -42,6 +42,7 @@ #include #include #include +#include #include #include @@ -51,7 +52,7 @@ #define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP))) -const int frame_extra_sizes[16] = { +static const int frame_extra_sizes[16] = { [1] = -1, /* sizeof(((struct frame *)0)->un.fmt1), */ [2] = sizeof(((struct frame *)0)->un.fmt2), [3] = sizeof(((struct frame *)0)->un.fmt3), @@ -69,6 +70,27 @@ const int frame_extra_sizes[16] = { [15] = -1, /* sizeof(((struct frame *)0)->un.fmtf), */ }; +int handle_kernel_fault(struct pt_regs *regs) +{ + const struct exception_table_entry *fixup; + struct pt_regs *tregs; + + /* Are we prepared to handle this kernel fault? */ + fixup = search_exception_tables(regs->pc); + if (!fixup) + return 0; + + /* Create a new four word stack frame, discarding the old one. */ + regs->stkadj = frame_extra_sizes[regs->format]; + tregs = (struct pt_regs *)((long)regs + regs->stkadj); + tregs->vector = regs->vector; + tregs->format = 0; + tregs->pc = fixup->fixup; + tregs->sr = regs->sr; + + return 1; +} + /* * Atomically swap in the new signal mask, and wait for a signal. */ diff --git a/arch/m68k/mm/fault.c b/arch/m68k/mm/fault.c index a96394a0333d..2db6099784ba 100644 --- a/arch/m68k/mm/fault.c +++ b/arch/m68k/mm/fault.c @@ -18,7 +18,6 @@ #include extern void die_if_kernel(char *, struct pt_regs *, long); -extern const int frame_extra_sizes[]; /* in m68k/kernel/signal.c */ int send_fault_sig(struct pt_regs *regs) { @@ -35,21 +34,8 @@ int send_fault_sig(struct pt_regs *regs) force_sig_info(siginfo.si_signo, &siginfo, current); } else { - const struct exception_table_entry *fixup; - - /* Are we prepared to handle this kernel fault? */ - if ((fixup = search_exception_tables(regs->pc))) { - struct pt_regs *tregs; - /* Create a new four word stack frame, discarding the old - one. */ - regs->stkadj = frame_extra_sizes[regs->format]; - tregs = (struct pt_regs *)((ulong)regs + regs->stkadj); - tregs->vector = regs->vector; - tregs->format = 0; - tregs->pc = fixup->fixup; - tregs->sr = regs->sr; + if (handle_kernel_fault(regs)) return -1; - } //if (siginfo.si_signo == SIGBUS) // force_sig_info(siginfo.si_signo, -- cgit v1.2.3