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 @@ -841,6 +841,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 dsemul.o cp1emu.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
47 EXTRA_CFLAGS += -Werror
48 --- a/arch/mips/math-emu/cp1emu.c
49 +++ b/arch/mips/math-emu/cp1emu.c
53 /* Function which emulates a floating point instruction. */
54 +#ifdef CONFIG_DEBUG_FS
55 +DEFINE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);
58 +#ifdef CONFIG_MIPS_FPU_EMU
59 static int fpu_emu(struct pt_regs *, struct mips_fpu_struct *,
62 @@ -69,10 +73,6 @@ static int fpux_emu(struct pt_regs *,
64 /* Further private data for which no space exists in mips_fpu_struct */
66 -#ifdef CONFIG_DEBUG_FS
67 -DEFINE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);
70 /* Control registers */
72 #define FPCREG_RID 0 /* $0 = revision id */
73 @@ -1284,7 +1284,6 @@ int fpu_emulator_cop1Handler(struct pt_r
78 #ifdef CONFIG_DEBUG_FS
80 static int fpuemu_stat_get(void *data, u64 *val)
81 @@ -1333,4 +1332,11 @@ static int __init debugfs_fpuemu(void)
84 __initcall(debugfs_fpuemu);
86 +#endif /* CONFIG_DEBUGFS */
88 +int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
93 +#endif /* CONFIG_MIPS_FPU_EMU */
94 --- a/arch/mips/math-emu/dsemul.c
95 +++ b/arch/mips/math-emu/dsemul.c
96 @@ -109,6 +109,7 @@ int mips_dsemul(struct pt_regs *regs, mi
97 return SIGILL; /* force out of emulation loop */
100 +#ifdef CONFIG_MIPS_FPU_EMU
101 int do_dsemulret(struct pt_regs *xcp)
103 struct emuframe __user *fr;
104 @@ -165,3 +166,9 @@ int do_dsemulret(struct pt_regs *xcp)
109 +int do_dsemulret(struct pt_regs *xcp)
113 +#endif /* CONFIG_MIPS_FPU_EMU */
114 --- a/arch/mips/math-emu/kernel_linkage.c
115 +++ b/arch/mips/math-emu/kernel_linkage.c
118 #define SIGNALLING_NAN 0x7ff800007ff80000LL
120 +#ifdef CONFIG_MIPS_FPU_EMU
121 void fpu_emulator_init_fpu(void)
123 static int first = 1;
124 @@ -112,4 +113,36 @@ int fpu_emulator_restore_context32(struc
129 +#endif /* CONFIG_64BIT */
132 +void fpu_emulator_init_fpu(void)
134 + printk(KERN_INFO "FPU emulator disabled, make sure your toolchain"
135 + "was compiled with software floating point support (soft-float)\n");
139 +int fpu_emulator_save_context(struct sigcontext __user *sc)
144 +int fpu_emulator_restore_context(struct sigcontext __user *sc)
149 +int fpu_emulator_save_context32(struct sigcontext32 __user *sc)
154 +int fpu_emulator_restore_context32(struct sigcontext32 __user *sc)
160 +#endif /* CONFIG_64BIT */
161 +#endif /* CONFIG_MIPS_FPU_EMU */