kernel: add support for 3.9-rc2
[openwrt.git] / target / linux / generic / patches-3.9 / 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 @@ -974,6 +974,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,11 @@
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 dsemul.o cp1emu.o
37 +obj-$(CONFIG_MIPS_FPU_EMU)     += ieee754m.o ieee754d.o ieee754dp.o ieee754sp.o ieee754.o \
38            ieee754xcpt.o dp_frexp.o dp_modf.o dp_div.o dp_mul.o dp_sub.o \
39            dp_add.o dp_fsp.o dp_cmp.o dp_logb.o dp_scalb.o dp_simple.o \
40            dp_tint.o dp_fint.o dp_tlong.o dp_flong.o sp_frexp.o sp_modf.o \
41            sp_div.o sp_mul.o sp_sub.o sp_add.o sp_fdp.o sp_cmp.o sp_logb.o \
42            sp_scalb.o sp_simple.o sp_tint.o sp_fint.o sp_tlong.o sp_flong.o \
43 -          dp_sqrt.o sp_sqrt.o kernel_linkage.o dsemul.o
44 +          dp_sqrt.o sp_sqrt.o
45 --- a/arch/mips/math-emu/cp1emu.c
46 +++ b/arch/mips/math-emu/cp1emu.c
47 @@ -58,7 +58,11 @@
48  #define __mips 4
49  
50  /* Function which emulates a floating point instruction. */
51 +#ifdef CONFIG_DEBUG_FS
52 +DEFINE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);
53 +#endif
54  
55 +#ifdef CONFIG_MIPS_FPU_EMU
56  static int fpu_emu(struct pt_regs *, struct mips_fpu_struct *,
57         mips_instruction);
58  
59 @@ -69,10 +73,6 @@ static int fpux_emu(struct pt_regs *,
60  
61  /* Further private data for which no space exists in mips_fpu_struct */
62  
63 -#ifdef CONFIG_DEBUG_FS
64 -DEFINE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);
65 -#endif
66 -
67  /* Control registers */
68  
69  #define FPCREG_RID     0       /* $0  = revision id */
70 @@ -1361,7 +1361,6 @@ int fpu_emulator_cop1Handler(struct pt_r
71  
72         return sig;
73  }
74 -
75  #ifdef CONFIG_DEBUG_FS
76  
77  static int fpuemu_stat_get(void *data, u64 *val)
78 @@ -1410,4 +1409,11 @@ static int __init debugfs_fpuemu(void)
79         return 0;
80  }
81  __initcall(debugfs_fpuemu);
82 -#endif
83 +#endif /* CONFIG_DEBUGFS */
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 --- a/arch/mips/math-emu/dsemul.c
92 +++ b/arch/mips/math-emu/dsemul.c
93 @@ -108,6 +108,7 @@ int mips_dsemul(struct pt_regs *regs, mi
94         return SIGILL;          /* force out of emulation loop */
95  }
96  
97 +#ifdef CONFIG_MIPS_FPU_EMU
98  int do_dsemulret(struct pt_regs *xcp)
99  {
100         struct emuframe __user *fr;
101 @@ -164,3 +165,9 @@ int do_dsemulret(struct pt_regs *xcp)
102  
103         return 1;
104  }
105 +#else
106 +int do_dsemulret(struct pt_regs *xcp)
107 +{
108 +       return 0;
109 +}
110 +#endif /* CONFIG_MIPS_FPU_EMU */
111 --- a/arch/mips/math-emu/kernel_linkage.c
112 +++ b/arch/mips/math-emu/kernel_linkage.c
113 @@ -29,6 +29,7 @@
114  
115  #define SIGNALLING_NAN 0x7ff800007ff80000LL
116  
117 +#ifdef CONFIG_MIPS_FPU_EMU
118  void fpu_emulator_init_fpu(void)
119  {
120         static int first = 1;
121 @@ -112,4 +113,36 @@ int fpu_emulator_restore_context32(struc
122  
123         return err;
124  }
125 -#endif
126 +#endif /* CONFIG_64BIT */
127 +#else
128 +
129 +void fpu_emulator_init_fpu(void)
130 +{
131 +       printk(KERN_INFO "FPU emulator disabled, make sure your toolchain"
132 +               "was compiled with software floating point support (soft-float)\n");
133 +       return;
134 +}
135 +
136 +int fpu_emulator_save_context(struct sigcontext __user *sc)
137 +{
138 +       return 0;
139 +}
140 +
141 +int fpu_emulator_restore_context(struct sigcontext __user *sc)
142 +{
143 +       return 0;
144 +}
145 +
146 +int fpu_emulator_save_context32(struct sigcontext32 __user *sc)
147 +{
148 +       return 0;
149 +}
150 +
151 +int fpu_emulator_restore_context32(struct sigcontext32 __user *sc)
152 +{
153 +       return 0;
154 +}
155 +
156 +#ifdef CONFIG_64BIT
157 +#endif /* CONFIG_64BIT */
158 +#endif /* CONFIG_MIPS_FPU_EMU */