inform users when the in-kernel mips FPU emulator is disabled (#5774)
[openwrt/staging/chunkeey.git] / target / linux / generic-2.6 / patches-2.6.30 / 025-mips_disable_fpu.patch
1 MIPS: allow disabling the kernel FPU emulator
2
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.
6
7 Signed-off-by: Florian Fainelli <florian@openwrt.org>
8 --
9 Index: linux-2.6.30.7/arch/mips/Kconfig
10 ===================================================================
11 --- linux-2.6.30.7.orig/arch/mips/Kconfig 2009-09-28 08:21:26.000000000 +0200
12 +++ linux-2.6.30.7/arch/mips/Kconfig 2009-09-28 08:21:31.000000000 +0200
13 @@ -791,6 +791,17 @@
14 config MIPS_BONITO64
15 bool
16
17 +config MIPS_FPU_EMU
18 + bool
19 + default n
20 + help
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.
25 +
26 + If unsure say Y here.
27 +
28 config MIPS_MSC
29 bool
30
31 Index: linux-2.6.30.7/arch/mips/math-emu/Makefile
32 ===================================================================
33 --- linux-2.6.30.7.orig/arch/mips/math-emu/Makefile 2009-09-28 08:21:26.000000000 +0200
34 +++ linux-2.6.30.7/arch/mips/math-emu/Makefile 2009-09-28 08:21:31.000000000 +0200
35 @@ -2,12 +2,14 @@
36 # Makefile for the Linux/MIPS kernel FPU emulation.
37 #
38
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
41 +
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
49 + dp_sqrt.o sp_sqrt.o
50
51 EXTRA_CFLAGS += -Werror
52 Index: linux-2.6.30.7/arch/mips/math-emu/cp1emu.c
53 ===================================================================
54 --- linux-2.6.30.7.orig/arch/mips/math-emu/cp1emu.c 2009-09-28 08:21:26.000000000 +0200
55 +++ linux-2.6.30.7/arch/mips/math-emu/cp1emu.c 2009-09-28 08:21:31.000000000 +0200
56 @@ -56,6 +56,12 @@
57 #endif
58 #define __mips 4
59
60 +/* Further private data for which no space exists in mips_fpu_struct */
61 +
62 +struct mips_fpu_emulator_stats fpuemustats;
63 +
64 +#ifdef CONFIG_MIPS_FPU_EMU
65 +
66 /* Function which emulates a floating point instruction. */
67
68 static int fpu_emu(struct pt_regs *, struct mips_fpu_struct *,
69 @@ -66,10 +72,6 @@
70 struct mips_fpu_struct *, mips_instruction);
71 #endif
72
73 -/* Further private data for which no space exists in mips_fpu_struct */
74 -
75 -struct mips_fpu_emulator_stats fpuemustats;
76 -
77 /* Control registers */
78
79 #define FPCREG_RID 0 /* $0 = revision id */
80 @@ -1273,6 +1275,13 @@
81
82 return sig;
83 }
84 +#else
85 +int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
86 + int has_fpu)
87 +{
88 + return 0;
89 +}
90 +#endif /* CONFIG_MIPS_FPU_EMU */
91
92 #ifdef CONFIG_DEBUG_FS
93 extern struct dentry *mips_debugfs_dir;
94 Index: linux-2.6.30.7/arch/mips/math-emu/dsemul.c
95 ===================================================================
96 --- linux-2.6.30.7.orig/arch/mips/math-emu/dsemul.c 2009-09-28 08:21:26.000000000 +0200
97 +++ linux-2.6.30.7/arch/mips/math-emu/dsemul.c 2009-09-28 08:21:31.000000000 +0200
98 @@ -109,6 +109,7 @@
99 return SIGILL; /* force out of emulation loop */
100 }
101
102 +#ifdef CONFIG_MIPS_FPU_EMU
103 int do_dsemulret(struct pt_regs *xcp)
104 {
105 struct emuframe __user *fr;
106 @@ -165,3 +166,9 @@
107
108 return 1;
109 }
110 +#else
111 +int do_dsemulret(struct pt_regs *xcp)
112 +{
113 + return 0;
114 +}
115 +#endif /* CONFIG_MIPS_FPU_EMU */
116 Index: linux-2.6.30.7/arch/mips/math-emu/kernel_linkage.c
117 ===================================================================
118 --- linux-2.6.30.7.orig/arch/mips/math-emu/kernel_linkage.c 2009-09-28 08:21:26.000000000 +0200
119 +++ linux-2.6.30.7/arch/mips/math-emu/kernel_linkage.c 2009-09-28 08:22:36.000000000 +0200
120 @@ -29,6 +29,7 @@
121
122 #define SIGNALLING_NAN 0x7ff800007ff80000LL
123
124 +#ifdef CONFIG_MIPS_FPU_EMU
125 void fpu_emulator_init_fpu(void)
126 {
127 static int first = 1;
128 @@ -112,4 +113,36 @@
129
130 return err;
131 }
132 -#endif
133 +#endif /* CONFIG_64BIT */
134 +#else
135 +
136 +void fpu_emulator_init_fpu(void)
137 +{
138 + printk(KERN_INFO "FPU emulator disabled, make sure your toolchain"
139 + "was compiled with software floating point support (soft-float)\n");
140 + return;
141 +}
142 +
143 +int fpu_emulator_save_context(struct sigcontext __user *sc)
144 +{
145 + return 0;
146 +}
147 +
148 +int fpu_emulator_restore_context(struct sigcontext __user *sc)
149 +{
150 + return 0;
151 +}
152 +
153 +int fpu_emulator_save_context32(struct sigcontext32 __user *sc)
154 +{
155 + return 0;
156 +}
157 +
158 +int fpu_emulator_restore_context32(struct sigcontext32 __user *sc)
159 +{
160 + return 0;
161 +}
162 +
163 +#ifdef CONFIG_64BIT
164 +#endif /* CONFIG_64BIT */
165 +#endif /* CONFIG_MIPS_FPU_EMU */