Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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/

+70 -84
-8
arch/mips/include/asm/fpu.h
··· 28 28 struct sigcontext; 29 29 struct sigcontext32; 30 30 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 - 37 31 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); 40 32 extern void _init_fpu(void); 41 33 extern void _save_fp(struct task_struct *); 42 34 extern void _restore_fp(struct task_struct *);
+46
arch/mips/kernel/signal.c
··· 35 35 36 36 #include "signal-common.h" 37 37 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 + 38 47 /* 39 48 * Horribly complicated - with the bloody RM9000 workarounds enabled 40 49 * the signal trampolines is moving to the end of the structure so we can ··· 718 709 key_replace_session_keyring(); 719 710 } 720 711 } 712 + 713 + #ifdef CONFIG_SMP 714 + static int smp_save_fp_context(struct sigcontext __user *sc) 715 + { 716 + return raw_cpu_has_fpu 717 + ? _save_fp_context(sc) 718 + : fpu_emulator_save_context(sc); 719 + } 720 + 721 + static int smp_restore_fp_context(struct sigcontext __user *sc) 722 + { 723 + return raw_cpu_has_fpu 724 + ? _restore_fp_context(sc) 725 + : fpu_emulator_restore_context(sc); 726 + } 727 + #endif 728 + 729 + static int signal_setup(void) 730 + { 731 + #ifdef CONFIG_SMP 732 + /* For now just do the cpu_has_fpu check when the functions are invoked */ 733 + save_fp_context = smp_save_fp_context; 734 + restore_fp_context = smp_restore_fp_context; 735 + #else 736 + if (cpu_has_fpu) { 737 + save_fp_context = _save_fp_context; 738 + restore_fp_context = _restore_fp_context; 739 + } else { 740 + save_fp_context = fpu_emulator_save_context; 741 + restore_fp_context = fpu_emulator_restore_context; 742 + } 743 + #endif 744 + 745 + return 0; 746 + } 747 + 748 + arch_initcall(signal_setup);
+24
arch/mips/kernel/signal32.c
··· 35 35 36 36 #include "signal-common.h" 37 37 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 + 38 47 /* 39 48 * Including <asm/unistd.h> would give use the 64-bit syscall numbers ... 40 49 */ ··· 837 828 info.si_code |= __SI_CHLD; 838 829 return copy_siginfo_to_user32(uinfo, &info); 839 830 } 831 + 832 + static int signal32_init(void) 833 + { 834 + if (cpu_has_fpu) { 835 + save_fp_context32 = _save_fp_context32; 836 + restore_fp_context32 = _restore_fp_context32; 837 + } else { 838 + save_fp_context32 = fpu_emulator_save_context32; 839 + restore_fp_context32 = fpu_emulator_restore_context32; 840 + } 841 + 842 + return 0; 843 + } 844 + 845 + arch_initcall(signal32_init);
-76
arch/mips/kernel/traps.c
··· 1395 1395 return set_vi_srs_handler(n, addr, 0); 1396 1396 } 1397 1397 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 - 1469 1398 extern void cpu_cache_init(void); 1470 1399 extern void tlb_init(void); 1471 1400 extern void flush_tlb_handlers(void); ··· 1707 1778 memcpy((void *)(ebase + 0x180), &except_vec3_generic, 0x80); 1708 1779 else 1709 1780 memcpy((void *)(ebase + 0x080), &except_vec3_generic, 0x80); 1710 - 1711 - signal_init(); 1712 - #ifdef CONFIG_MIPS32_COMPAT 1713 - signal32_init(); 1714 - #endif 1715 1781 1716 1782 local_flush_icache_range(ebase, ebase + 0x400); 1717 1783 flush_tlb_handlers();