m68k: Allow all kernel traps to be handled via exception fixups
Geert Uytterhoeven
maintainercover m68k: Allow all kernel traps to be handled via exception fixups
This patch series is a split and cleanup of the single commit aa8fcffdec0ac8d0ace3af622eb92f5ee804fc44 ("m68k-allow-all-kernel-traps-to-be-handled-via-exception-fixups-all.diff"), which dates back to the Linux/m68k CVS tree.
It's a prerequisite for ARAnyM support.
[PATCH 1/3] m68k: Add helper function handle_kernel_fault() [PATCH 2/3] m68k: Use base_trap_init() to initialize vectors [PATCH 3/3] m68k: Allow all kernel traps to be handled via exception fixups
arch/m68k/kernel/traps.c | 10 +++++++--- b/arch/m68k/include/asm/processor.h | 2 ++ b/arch/m68k/kernel/signal.c | 24 +++++++++++++++++++++++- b/arch/m68k/kernel/traps.c | 10 +++++----- b/arch/m68k/mm/fault.c | 16 +--------------- 5 files changed, 38 insertions(+), 24 deletions(-)
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Geert Uytterhoeven
maintainerPATCH 1/3 m68k: Add helper function handle_kernel_fault()
From: Roman Zippel <[email protected]>
Add helper function handle_kernel_fault() in signal.c, so frame_extra_sizes can become static, and to avoid future code duplication.
--- 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(-)
arch/m68k/include/asm/processor.h +2 -0
@@ -110,6 +110,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 /*
arch/m68k/kernel/signal.c +23 -1
@@ -42,6 +42,7 @@#include <linux/personality.h> #include <linux/tty.h> #include <linux/binfmts.h> +#include <linux/module.h> #include <asm/setup.h> #include <asm/uaccess.h>
@@ -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. */
arch/m68k/mm/fault.c +1 -15
@@ -18,7 +18,6 @@#include <asm/pgalloc.h> 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,
Signature · 1 line
1.7.0.4
Geert Uytterhoeven
maintainerPATCH 2/3 m68k: Use base_trap_init() to initialize vectors
In reply to Geert UytterhoevenFrom: Roman Zippel <[email protected]>
So basic initialization is all in one place.
--- arch/m68k/kernel/traps.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
arch/m68k/kernel/traps.c +5 -5
@@ -48,10 +48,7 @@ asmlinkage void nmihandler(void); asmlinkage void fpu_emu(void);#endif -e_vector vectors[256 ] = { - [VEC_BUSERR ] = buserr, - [VEC_SYS ] = system_call, -}; +e_vector vectors[256 ];/* nmi handler for the Amiga */ asm(".text\n"
@@ -64,7 +61,7 @@ asm(".text\n"*/ void __init base_trap_init (void ) { -if (MACH_IS_SUN3X ) { +if (MACH_IS_SUN3X ) {extern e_vector *sun3x_prom_vbr; __asm__volatile ("movec %%vbr, %0" :"=r" (sun3x_prom_vbr));
@@ -79,6 +76,9 @@ void __init base_trap_init(void) vectors[VEC_UNIMPII ] = unimp_vec; } + + vectors[VEC_BUSERR ] = buserr; + vectors[VEC_SYS ] = system_call; }void __init trap_init (void )
Signature · 1 line
1.7.0.4
Geert Uytterhoeven
maintainerPATCH 3/3 m68k: Allow all kernel traps to be handled via exception fixups
In reply to Geert UytterhoevenFrom: Andreas Schwab <[email protected]>
This will be needed by the ARAnyM Native Feature initialization code. Also document that the VEC_TRACE check is needed for 68020/30.
--- arch/m68k/kernel/traps.c | 10 +++++++--- 1 files changed, 7 insertions(+), 3 deletions(-)
arch/m68k/kernel/traps.c +7 -3
@@ -58,6 +58,7 @@ asm(".text\n"/* * this must be called very early as the kernel might * use some instruction that are emulated on the 060 +* and so we're prepared for early probe attempts (e.g. nf_init). */ void __init base_trap_init (void ) {
@@ -78,6 +79,7 @@ void __init base_trap_init(void) } vectors[VEC_BUSERR ] = buserr; + vectors[VEC_ILLEGAL ] = trap; vectors[VEC_SYS ] = system_call; }
@@ -1055,9 +1057,11 @@ asmlinkage void trap_c(struct frame *fp)siginfo_t info;if (fp->ptregs.sr &PS_S ) { -if ((fp->ptregs.vector >>2 ) ==VEC_TRACE ) { -/* traced a trapping instruction */ - }else +if (fp->ptregs.vector ==VEC_TRACE <<2 ) { +/* traced a trapping instruction on a 68020/30, +* real exception will be executed afterwards. +*/ + }else if (!handle_kernel_fault (&fp->ptregs))bad_super_trap (fp);return ; }
Signature · 1 line
1.7.0.4