o32 sigcontext fixes for mips64
PATCH 1/1 o32 sigcontext fixes for mips64
This 2.4 patch fixes some issues with the signal context save and restore for o32 binaries running on the mips64 kernel.
Any comments?
Kip
Index: include/asm-mips64/fpu.h
===================================================================
RCS file: /home/cvs/linux/include/asm-mips64/fpu.h,v retrieving revision 1.1.2.4
asm-mips64/fpu.h +4 -0
@@ -21,9 +21,13 @@#include <asm/current.h> struct sigcontext ; +struct sigcontext32 ; extern asmlinkage int (*save_fp_context)(struct sigcontext *sc); extern asmlinkage int (*restore_fp_context)(struct sigcontext *sc); + +extern asmlinkage int (*save_fp_context32)(struct sigcontext32 *sc); +extern asmlinkage int (*restore_fp_context32)(struct sigcontext32 *sc);extern void fpu_emulator_init_fpu (void );extern void _init_fpu (void );
Index: include/asm-mips64/sigcontext.h
===================================================================
RCS file: /home/cvs/linux/include/asm-mips64/sigcontext.h,v retrieving revision 1.3.2.2
asm-mips64/sigcontext.h +20 -0
@@ -27,4 +27,24 @@ unsigned int sc_badvaddr; }; +struct sigcontext32 { +u32 sc_regmask;/* Unused */ +u32 sc_status; +u64 sc_pc; +u64 sc_regs[32 ]; +u64 sc_fpregs[32 ]; +u32 sc_ownedfp;/* Unused */ +u32 sc_fpc_csr; +u32 sc_fpc_eir;/* Unused */ +u32 sc_used_math; +u32 sc_ssflags;/* Unused */ +u64 sc_mdhi; +u64 sc_mdlo; + +u32 sc_cause;/* Unused */ +u32 sc_badvaddr;/* Unused */ + +u32 sc_sigset[4 ];/* kernel's sigset_t */ +}; +#endif /* _ASM_SIGCONTEXT_H */
Index: arch/mips/tools/offset.c
===================================================================
RCS file: /home/cvs/linux/arch/mips/tools/Attic/offset.c,v retrieving revision 1.16.4.6
mips/tools/offset.c +9 -0
@@ -8,6 +8,7 @@* Kevin Kissell, [email protected] and Carsten Langgaard, [email protected] * Copyright (C) 2000 MIPS Technologies, Inc. */ +#include <linux/config.h> #include <linux/types.h> #include <linux/sched.h> #include <linux/mm.h>
@@ -156,6 +157,14 @@ offset("#define SC_CAUSE ", struct sigcontext, sc_cause); offset("#define SC_BADVADDR ", struct sigcontext, sc_badvaddr); linefeed; + +#ifdef CONFIG_MIPS64 +text ("/* Linux 32-bit sigcontext offsets. */" ); + offset("#define SC32_FPREGS ", struct sigcontext32, sc_fpregs); + offset("#define SC32_FPC_CSR ", struct sigcontext32, sc_fpc_csr); + offset("#define SC32_FPC_EIR ", struct sigcontext32, sc_fpc_eir); + linefeed; +#endif }void output_signal_defined (void )
Index: arch/mips64/kernel/signal32.c
===================================================================
RCS file: /home/cvs/linux/arch/mips64/kernel/signal32.c,v retrieving revision 1.20.2.12
mips64/kernel/signal32.c +32 -14
132 lines not on this page · raw message
Index: arch/mips64/kernel/traps.c
===================================================================
RCS file: /home/cvs/linux/arch/mips64/kernel/traps.c,v retrieving revision 1.30.2.54
mips64/kernel/traps.c +13 -0
@@ -781,12 +781,21 @@ asmlinkage int (*save_fp_context)(struct sigcontext *sc); asmlinkage int (*restore_fp_context)(struct sigcontext *sc); +asmlinkage int (*save_fp_context32)(struct sigcontext32 *sc); +asmlinkage int (*restore_fp_context32)(struct sigcontext32 *sc); + extern asmlinkage int _save_fp_context(struct sigcontext *sc); extern asmlinkage int _restore_fp_context(struct sigcontext *sc); +extern asmlinkage int _save_fp_context32(struct sigcontext32 *sc); +extern asmlinkage int _restore_fp_context32(struct sigcontext32 *sc); + extern asmlinkage int fpu_emulator_save_context(struct sigcontext *sc); extern asmlinkage int fpu_emulator_restore_context(struct sigcontext *sc); +extern asmlinkage int fpu_emulator_save_context32(struct sigcontext32 *sc); +extern asmlinkage int fpu_emulator_restore_context32(struct sigcontext32 *sc); +void __init per_cpu_trap_init (void ) {unsigned int cpu =smp_processor_id ();
@@ -904,9 +913,13 @@if (cpu_has_fpu) { save_fp_context = _save_fp_context; restore_fp_context = _restore_fp_context; + save_fp_context32 = _save_fp_context32; + restore_fp_context32 = _restore_fp_context32; }else { save_fp_context = fpu_emulator_save_context; restore_fp_context = fpu_emulator_restore_context; + save_fp_context32 = fpu_emulator_save_context32; + restore_fp_context32 = fpu_emulator_restore_context32; }flush_icache_range (KSEG0 ,KSEG0 +0x400 );
Index: arch/mips64/kernel/r4k_fpu.S
===================================================================
RCS file: /home/cvs/linux/arch/mips64/kernel/r4k_fpu.S,v retrieving revision 1.3.2.1
mips64/kernel/r4k_fpu.S +58 -22
123 lines not on this page · raw message
Index: arch/mips/math-emu/kernel_linkage.c
===================================================================
RCS file: /home/cvs/linux/arch/mips/math-emu/kernel_linkage.c,v retrieving revision 1.5.2.1
mips/math-emu/kernel_linkage.c +37 -0
@@ -90,3 +90,40 @@return err; } +#ifdef CONFIG_MIPS64 +/* +* This is the o32 version +*/ + +int fpu_emulator_save_context32 (struct sigcontext32 *sc) +{ +int i; +int err =0 ; + +for (i =0 ; i <32 ; i+=2 ) { + err |= +__put_user (current->thread.fpu.soft.regs[i], + &sc->sc_fpregs[i]); + } + err |=__put_user (current->thread.fpu.soft.sr, &sc->sc_fpc_csr); + err |=__put_user (fpuemuprivate.eir, &sc->sc_fpc_eir); + +return err; +} + +int fpu_emulator_restore_context32 (struct sigcontext32 *sc) +{ +int i; +int err =0 ; + +for (i =0 ; i <32 ; i+=2 ) { + err |= +__get_user (current->thread.fpu.soft.regs[i], + &sc->sc_fpregs[i]); + } + err |=__get_user (current->thread.fpu.soft.sr, &sc->sc_fpc_csr); + err |=__get_user (fpuemuprivate.eir, &sc->sc_fpc_eir); + +return err; +} +#endif