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 diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
10 index 65d3b19..a467ee5 100644
11 --- a/arch/mips/Kconfig
12 +++ b/arch/mips/Kconfig
13 @@ -811,6 +811,17 @@ config I8259
21 + This option allows building a kernel with or without the Algorithmics
22 + FPU emulator enabled. Turning off this option results in a kernel which
23 + does not catch floating operations exceptions. Make sure that your toolchain
24 + is configured to enable software floating point emulation in that case.
26 + If unsure say Y here.
31 diff --git a/arch/mips/math-emu/Makefile b/arch/mips/math-emu/Makefile
32 index d547efd..7fdef24 100644
33 --- a/arch/mips/math-emu/Makefile
34 +++ b/arch/mips/math-emu/Makefile
36 # Makefile for the Linux/MIPS kernel FPU emulation.
39 -obj-y := cp1emu.o ieee754m.o ieee754d.o ieee754dp.o ieee754sp.o ieee754.o \
40 +obj-y := kernel_linkage.o dsemul.o cp1emu.o
42 +obj-$(CONFIG_MIPS_FPU_EMU) += ieee754m.o ieee754d.o ieee754dp.o ieee754sp.o ieee754.o \
43 ieee754xcpt.o dp_frexp.o dp_modf.o dp_div.o dp_mul.o dp_sub.o \
44 dp_add.o dp_fsp.o dp_cmp.o dp_logb.o dp_scalb.o dp_simple.o \
45 dp_tint.o dp_fint.o dp_tlong.o dp_flong.o sp_frexp.o sp_modf.o \
46 sp_div.o sp_mul.o sp_sub.o sp_add.o sp_fdp.o sp_cmp.o sp_logb.o \
47 sp_scalb.o sp_simple.o sp_tint.o sp_fint.o sp_tlong.o sp_flong.o \
48 - dp_sqrt.o sp_sqrt.o kernel_linkage.o dsemul.o
51 EXTRA_CFLAGS += -Werror
52 diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
53 index 890f779..9f4c767 100644
54 --- a/arch/mips/math-emu/cp1emu.c
55 +++ b/arch/mips/math-emu/cp1emu.c
60 +/* Further private data for which no space exists in mips_fpu_struct */
62 +struct mips_fpu_emulator_stats fpuemustats;
64 +#ifdef CONFIG_MIPS_FPU_EMU
66 /* Function which emulates a floating point instruction. */
68 static int fpu_emu(struct pt_regs *, struct mips_fpu_struct *,
69 @@ -66,10 +72,6 @@ static int fpux_emu(struct pt_regs *,
70 struct mips_fpu_struct *, mips_instruction);
73 -/* Further private data for which no space exists in mips_fpu_struct */
75 -struct mips_fpu_emulator_stats fpuemustats;
77 /* Control registers */
79 #define FPCREG_RID 0 /* $0 = revision id */
80 @@ -1273,6 +1275,13 @@ int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
85 +int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
90 +#endif /* CONFIG_MIPS_FPU_EMU */
92 #ifdef CONFIG_DEBUG_FS
93 extern struct dentry *mips_debugfs_dir;
94 diff --git a/arch/mips/math-emu/dsemul.c b/arch/mips/math-emu/dsemul.c
95 index df7b9d9..9b42bfd 100644
96 --- a/arch/mips/math-emu/dsemul.c
97 +++ b/arch/mips/math-emu/dsemul.c
98 @@ -109,6 +109,7 @@ int mips_dsemul(struct pt_regs *regs, mips_instruction ir, unsigned long cpc)
99 return SIGILL; /* force out of emulation loop */
102 +#ifdef CONFIG_MIPS_FPU_EMU
103 int do_dsemulret(struct pt_regs *xcp)
105 struct emuframe __user *fr;
106 @@ -165,3 +166,9 @@ int do_dsemulret(struct pt_regs *xcp)
111 +int do_dsemulret(struct pt_regs *xcp)
115 +#endif /* CONFIG_MIPS_FPU_EMU */
116 diff --git a/arch/mips/math-emu/kernel_linkage.c b/arch/mips/math-emu/kernel_linkage.c
117 index 52e6c58..211a399 100644
118 --- a/arch/mips/math-emu/kernel_linkage.c
119 +++ b/arch/mips/math-emu/kernel_linkage.c
122 #define SIGNALLING_NAN 0x7ff800007ff80000LL
124 +#ifdef CONFIG_MIPS_FPU_EMU
125 void fpu_emulator_init_fpu(void)
127 static int first = 1;
128 @@ -112,4 +113,34 @@ int fpu_emulator_restore_context32(struct sigcontext32 __user *sc)
133 +#endif /* CONFIG_64BIT */
136 +void fpu_emulator_init_fpu(void)
141 +int fpu_emulator_save_context(struct sigcontext __user *sc)
146 +int fpu_emulator_restore_context(struct sigcontext __user *sc)
151 +int fpu_emulator_save_context32(struct sigcontext32 __user *sc)
156 +int fpu_emulator_restore_context32(struct sigcontext32 __user *sc)
162 +#endif /* CONFIG_64BIT */
163 +#endif /* CONFIG_MIPS_FPU_EMU */