kernel: update 3.10 to 3.10.9
[openwrt/svn-archive/archive.git] / target / linux / generic / patches-3.10 / 304-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 --- a/arch/mips/Kconfig
10 +++ b/arch/mips/Kconfig
11 @@ -981,6 +981,17 @@ config I8259
12 config MIPS_BONITO64
13 bool
14
15 +config MIPS_FPU_EMU
16 + bool "Enable FPU emulation"
17 + default y
18 + help
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.
23 +
24 + If unsure say Y here.
25 +
26 config MIPS_MSC
27 bool
28
29 --- a/arch/mips/math-emu/Makefile
30 +++ b/arch/mips/math-emu/Makefile
31 @@ -2,10 +2,12 @@
32 # Makefile for the Linux/MIPS kernel FPU emulation.
33 #
34
35 -obj-y := cp1emu.o ieee754m.o ieee754d.o ieee754dp.o ieee754sp.o ieee754.o \
36 +obj-y := kernel_linkage.o
37 +
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
48 @@ -29,6 +29,7 @@
49
50 #define SIGNALLING_NAN 0x7ff800007ff80000LL
51
52 +#ifdef CONFIG_MIPS_FPU_EMU
53 void fpu_emulator_init_fpu(void)
54 {
55 static int first = 1;
56 @@ -113,3 +114,36 @@ int fpu_emulator_restore_context32(struc
57 return err;
58 }
59 #endif
60 +
61 +#else
62 +
63 +void fpu_emulator_init_fpu(void)
64 +{
65 + printk(KERN_INFO "FPU emulator disabled, make sure your toolchain"
66 + "was compiled with software floating point support (soft-float)\n");
67 + return;
68 +}
69 +
70 +int fpu_emulator_save_context(struct sigcontext __user *sc)
71 +{
72 + return 0;
73 +}
74 +
75 +int fpu_emulator_restore_context(struct sigcontext __user *sc)
76 +{
77 + return 0;
78 +}
79 +
80 +#ifdef CONFIG_64BIT
81 +int fpu_emulator_save_context32(struct sigcontext32 __user *sc)
82 +{
83 + return 0;
84 +}
85 +
86 +int fpu_emulator_restore_context32(struct sigcontext32 __user *sc)
87 +{
88 + return 0;
89 +}
90 +#endif /* CONFIG_64BIT */
91 +
92 +#endif /* CONFIG_MIPS_FPU_EMU */
93 --- a/arch/mips/include/asm/fpu_emulator.h
94 +++ b/arch/mips/include/asm/fpu_emulator.h
95 @@ -27,6 +27,8 @@
96 #include <asm/inst.h>
97 #include <asm/local.h>
98
99 +#ifdef CONFIG_MIPS_FPU_EMU
100 +
101 #ifdef CONFIG_DEBUG_FS
102
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);
108 +#else
109 +static inline int mips_dsemul(struct pt_regs *regs, mips_instruction ir,
110 + unsigned long cpc)
111 +{
112 + return 0;
113 +}
114 +
115 +static inline int do_dsemulret(struct pt_regs *xcp)
116 +{
117 + return 0;
118 +}
119 +
120 +static inline int fpu_emulator_cop1Handler(struct pt_regs *xcp,
121 + struct mips_fpu_struct *ctx,
122 + int has_fpu,
123 + void *__user *fault_addr)
124 +{
125 + return 0;
126 +}
127 +
128 +static inline int process_fpemu_return(int sig, void __user *fault_addr)
129 +{
130 + return -EINVAL;
131 +}
132 +
133 +static inline int mm_isBranchInstr(struct pt_regs *regs,
134 + struct mm_decoded_insn dec_insn,
135 + unsigned long *contpc)
136 +{
137 + return 0;
138 +}
139 +#endif /* CONFIG_MIPS_FPU_EMU */
140
141 /*
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 @@ -684,6 +684,7 @@ asmlinkage void do_ov(struct pt_regs *re
146 force_sig_info(SIGFPE, &info, current);
147 }
148
149 +#ifdef CONFIG_MIPS_FPU_EMU
150 int process_fpemu_return(int sig, void __user *fault_addr)
151 {
152 if (sig == SIGSEGV || sig == SIGBUS) {
153 @@ -707,6 +708,7 @@ int process_fpemu_return(int sig, void _
154 return 0;
155 }
156 }
157 +#endif /* CONFIG_MIPS_FPU_EMU */
158
159 /*
160 * XXX Delayed fp exceptions when doing a lazy ctx switch XXX