1 MIPS: allow disabling the kernel FPU emulator
3 This patch allows turning off the in-kernel Algorithmics
4 FPU emulator support, which allows one to save a couple of
5 precious blocks on an embedded system.
7 Signed-off-by: Florian Fainelli <florian@openwrt.org>
9 --- a/arch/mips/Kconfig
10 +++ b/arch/mips/Kconfig
11 @@ -928,6 +928,17 @@ config I8259
16 + bool "Enable FPU emulation"
19 + This option allows building a kernel with or without the Algorithmics
20 + FPU emulator enabled. Turning off this option results in a kernel which
21 + does not catch floating operations exceptions. Make sure that your toolchain
22 + is configured to enable software floating point emulation in that case.
24 + If unsure say Y here.
29 --- a/arch/mips/math-emu/Makefile
30 +++ b/arch/mips/math-emu/Makefile
32 # Makefile for the Linux/MIPS kernel FPU emulation.
35 -obj-y := cp1emu.o ieee754m.o ieee754d.o ieee754dp.o ieee754sp.o ieee754.o \
36 +obj-y := kernel_linkage.o
38 +obj-$(CONFIG_MIPS_FPU_EMU) += ieee754m.o ieee754d.o ieee754dp.o ieee754sp.o ieee754.o \
39 ieee754xcpt.o dp_frexp.o dp_modf.o dp_div.o dp_mul.o dp_sub.o \
40 dp_add.o dp_fsp.o dp_cmp.o dp_logb.o dp_scalb.o dp_simple.o \
41 dp_tint.o dp_fint.o dp_tlong.o dp_flong.o sp_frexp.o sp_modf.o \
42 sp_div.o sp_mul.o sp_sub.o sp_add.o sp_fdp.o sp_cmp.o sp_logb.o \
43 sp_scalb.o sp_simple.o sp_tint.o sp_fint.o sp_tlong.o sp_flong.o \
44 - dp_sqrt.o sp_sqrt.o kernel_linkage.o dsemul.o
45 + dp_sqrt.o sp_sqrt.o dsemul.o cp1emu.o
46 --- a/arch/mips/math-emu/kernel_linkage.c
47 +++ b/arch/mips/math-emu/kernel_linkage.c
50 #define SIGNALLING_NAN 0x7ff800007ff80000LL
52 +#ifdef CONFIG_MIPS_FPU_EMU
53 void fpu_emulator_init_fpu(void)
56 @@ -113,3 +114,36 @@ int fpu_emulator_restore_context32(struc
63 +void fpu_emulator_init_fpu(void)
65 + printk(KERN_INFO "FPU emulator disabled, make sure your toolchain"
66 + "was compiled with software floating point support (soft-float)\n");
70 +int fpu_emulator_save_context(struct sigcontext __user *sc)
75 +int fpu_emulator_restore_context(struct sigcontext __user *sc)
81 +int fpu_emulator_save_context32(struct sigcontext32 __user *sc)
86 +int fpu_emulator_restore_context32(struct sigcontext32 __user *sc)
90 +#endif /* CONFIG_64BIT */
92 +#endif /* CONFIG_MIPS_FPU_EMU */
93 --- a/arch/mips/include/asm/fpu_emulator.h
94 +++ b/arch/mips/include/asm/fpu_emulator.h
97 #include <asm/local.h>
99 +#ifdef CONFIG_MIPS_FPU_EMU
101 #ifdef CONFIG_DEBUG_FS
103 struct mips_fpu_emulator_stats {
104 @@ -60,6 +62,38 @@ extern int fpu_emulator_cop1Handler(stru
105 int process_fpemu_return(int sig, void __user *fault_addr);
106 int mm_isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
107 unsigned long *contpc);
109 +static inline int mips_dsemul(struct pt_regs *regs, mips_instruction ir,
115 +static inline int do_dsemulret(struct pt_regs *xcp)
120 +static inline int fpu_emulator_cop1Handler(struct pt_regs *xcp,
121 + struct mips_fpu_struct *ctx,
123 + void *__user *fault_addr)
128 +static inline int process_fpemu_return(int sig, void __user *fault_addr)
133 +static inline int mm_isBranchInstr(struct pt_regs *regs,
134 + struct mm_decoded_insn dec_insn,
135 + unsigned long *contpc)
139 +#endif /* CONFIG_MIPS_FPU_EMU */
142 * Instruction inserted following the badinst to further tag the sequence
143 --- a/arch/mips/kernel/traps.c
144 +++ b/arch/mips/kernel/traps.c
145 @@ -700,6 +700,7 @@ asmlinkage void do_ov(struct pt_regs *re
146 exception_exit(prev_state);
149 +#ifdef CONFIG_MIPS_FPU_EMU
150 int process_fpemu_return(int sig, void __user *fault_addr)
152 if (sig == SIGSEGV || sig == SIGBUS) {
153 @@ -723,6 +724,7 @@ int process_fpemu_return(int sig, void _
157 +#endif /* CONFIG_MIPS_FPU_EMU */
160 * XXX Delayed fp exceptions when doing a lazy ctx switch XXX