Skip to content

Commit 137f6f3

Browse files
committed
MIPS: Cleanup signal code initialization
Signed-off-by: Ralf Baechle <ralf@linux-mips.org> Cc: linux-mips@linux-mips.org Patchwork: http://patchwork.linux-mips.org/patch/709/
1 parent 69f3a7d commit 137f6f3

4 files changed

Lines changed: 70 additions & 84 deletions

File tree

‎arch/mips/include/asm/fpu.h‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,7 @@
2828
struct sigcontext;
2929
struct sigcontext32;
3030

31-
extern asmlinkage int (*save_fp_context)(struct sigcontext __user *sc);
32-
extern asmlinkage int (*restore_fp_context)(struct sigcontext __user *sc);
33-
34-
extern asmlinkage int (*save_fp_context32)(struct sigcontext32 __user *sc);
35-
extern asmlinkage int (*restore_fp_context32)(struct sigcontext32 __user *sc);
36-
3731
extern void fpu_emulator_init_fpu(void);
38-
extern int fpu_emulator_save_context(struct sigcontext __user *sc);
39-
extern int fpu_emulator_restore_context(struct sigcontext __user *sc);
4032
extern void _init_fpu(void);
4133
extern void _save_fp(struct task_struct *);
4234
extern void _restore_fp(struct task_struct *);

‎arch/mips/kernel/signal.c‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@
3535

3636
#include "signal-common.h"
3737

38+
static int (*save_fp_context)(struct sigcontext __user *sc);
39+
static int (*restore_fp_context)(struct sigcontext __user *sc);
40+
41+
extern asmlinkage int _save_fp_context(struct sigcontext __user *sc);
42+
extern asmlinkage int _restore_fp_context(struct sigcontext __user *sc);
43+
44+
extern asmlinkage int fpu_emulator_save_context(struct sigcontext __user *sc);
45+
extern asmlinkage int fpu_emulator_restore_context(struct sigcontext __user *sc);
46+
3847
/*
3948
* Horribly complicated - with the bloody RM9000 workarounds enabled
4049
* the signal trampolines is moving to the end of the structure so we can
@@ -709,3 +718,40 @@ asmlinkage void do_notify_resume(struct pt_regs *regs, void *unused,
709718
key_replace_session_keyring();
710719
}
711720
}
721+
722+
#ifdef CONFIG_SMP
723+
static int smp_save_fp_context(struct sigcontext __user *sc)
724+
{
725+
return raw_cpu_has_fpu
726+
? _save_fp_context(sc)
727+
: fpu_emulator_save_context(sc);
728+
}
729+
730+
static int smp_restore_fp_context(struct sigcontext __user *sc)
731+
{
732+
return raw_cpu_has_fpu
733+
? _restore_fp_context(sc)
734+
: fpu_emulator_restore_context(sc);
735+
}
736+
#endif
737+
738+
static int signal_setup(void)
739+
{
740+
#ifdef CONFIG_SMP
741+
/* For now just do the cpu_has_fpu check when the functions are invoked */
742+
save_fp_context = smp_save_fp_context;
743+
restore_fp_context = smp_restore_fp_context;
744+
#else
745+
if (cpu_has_fpu) {
746+
save_fp_context = _save_fp_context;
747+
restore_fp_context = _restore_fp_context;
748+
} else {
749+
save_fp_context = fpu_emulator_save_context;
750+
restore_fp_context = fpu_emulator_restore_context;
751+
}
752+
#endif
753+
754+
return 0;
755+
}
756+
757+
arch_initcall(signal_setup);

‎arch/mips/kernel/signal32.c‎

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@
3535

3636
#include "signal-common.h"
3737

38+
static int (*save_fp_context32)(struct sigcontext32 __user *sc);
39+
static int (*restore_fp_context32)(struct sigcontext32 __user *sc);
40+
41+
extern asmlinkage int _save_fp_context32(struct sigcontext32 __user *sc);
42+
extern asmlinkage int _restore_fp_context32(struct sigcontext32 __user *sc);
43+
44+
extern asmlinkage int fpu_emulator_save_context32(struct sigcontext32 __user *sc);
45+
extern asmlinkage int fpu_emulator_restore_context32(struct sigcontext32 __user *sc);
46+
3847
/*
3948
* Including <asm/unistd.h> would give use the 64-bit syscall numbers ...
4049
*/
@@ -828,3 +837,18 @@ SYSCALL_DEFINE5(32_waitid, int, which, compat_pid_t, pid,
828837
info.si_code |= __SI_CHLD;
829838
return copy_siginfo_to_user32(uinfo, &info);
830839
}
840+
841+
static int signal32_init(void)
842+
{
843+
if (cpu_has_fpu) {
844+
save_fp_context32 = _save_fp_context32;
845+
restore_fp_context32 = _restore_fp_context32;
846+
} else {
847+
save_fp_context32 = fpu_emulator_save_context32;
848+
restore_fp_context32 = fpu_emulator_restore_context32;
849+
}
850+
851+
return 0;
852+
}
853+
854+
arch_initcall(signal32_init);

‎arch/mips/kernel/traps.c‎

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,77 +1395,6 @@ void *set_vi_handler(int n, vi_handler_t addr)
13951395
return set_vi_srs_handler(n, addr, 0);
13961396
}
13971397

1398-
/*
1399-
* This is used by native signal handling
1400-
*/
1401-
asmlinkage int (*save_fp_context)(struct sigcontext __user *sc);
1402-
asmlinkage int (*restore_fp_context)(struct sigcontext __user *sc);
1403-
1404-
extern asmlinkage int _save_fp_context(struct sigcontext __user *sc);
1405-
extern asmlinkage int _restore_fp_context(struct sigcontext __user *sc);
1406-
1407-
extern asmlinkage int fpu_emulator_save_context(struct sigcontext __user *sc);
1408-
extern asmlinkage int fpu_emulator_restore_context(struct sigcontext __user *sc);
1409-
1410-
#ifdef CONFIG_SMP
1411-
static int smp_save_fp_context(struct sigcontext __user *sc)
1412-
{
1413-
return raw_cpu_has_fpu
1414-
? _save_fp_context(sc)
1415-
: fpu_emulator_save_context(sc);
1416-
}
1417-
1418-
static int smp_restore_fp_context(struct sigcontext __user *sc)
1419-
{
1420-
return raw_cpu_has_fpu
1421-
? _restore_fp_context(sc)
1422-
: fpu_emulator_restore_context(sc);
1423-
}
1424-
#endif
1425-
1426-
static inline void signal_init(void)
1427-
{
1428-
#ifdef CONFIG_SMP
1429-
/* For now just do the cpu_has_fpu check when the functions are invoked */
1430-
save_fp_context = smp_save_fp_context;
1431-
restore_fp_context = smp_restore_fp_context;
1432-
#else
1433-
if (cpu_has_fpu) {
1434-
save_fp_context = _save_fp_context;
1435-
restore_fp_context = _restore_fp_context;
1436-
} else {
1437-
save_fp_context = fpu_emulator_save_context;
1438-
restore_fp_context = fpu_emulator_restore_context;
1439-
}
1440-
#endif
1441-
}
1442-
1443-
#ifdef CONFIG_MIPS32_COMPAT
1444-
1445-
/*
1446-
* This is used by 32-bit signal stuff on the 64-bit kernel
1447-
*/
1448-
asmlinkage int (*save_fp_context32)(struct sigcontext32 __user *sc);
1449-
asmlinkage int (*restore_fp_context32)(struct sigcontext32 __user *sc);
1450-
1451-
extern asmlinkage int _save_fp_context32(struct sigcontext32 __user *sc);
1452-
extern asmlinkage int _restore_fp_context32(struct sigcontext32 __user *sc);
1453-
1454-
extern asmlinkage int fpu_emulator_save_context32(struct sigcontext32 __user *sc);
1455-
extern asmlinkage int fpu_emulator_restore_context32(struct sigcontext32 __user *sc);
1456-
1457-
static inline void signal32_init(void)
1458-
{
1459-
if (cpu_has_fpu) {
1460-
save_fp_context32 = _save_fp_context32;
1461-
restore_fp_context32 = _restore_fp_context32;
1462-
} else {
1463-
save_fp_context32 = fpu_emulator_save_context32;
1464-
restore_fp_context32 = fpu_emulator_restore_context32;
1465-
}
1466-
}
1467-
#endif
1468-
14691398
extern void cpu_cache_init(void);
14701399
extern void tlb_init(void);
14711400
extern void flush_tlb_handlers(void);
@@ -1779,11 +1708,6 @@ void __init trap_init(void)
17791708
else
17801709
memcpy((void *)(ebase + 0x080), &except_vec3_generic, 0x80);
17811710

1782-
signal_init();
1783-
#ifdef CONFIG_MIPS32_COMPAT
1784-
signal32_init();
1785-
#endif
1786-
17871711
local_flush_icache_range(ebase, ebase + 0x400);
17881712
flush_tlb_handlers();
17891713

0 commit comments

Comments
 (0)