1 From: Manuel Lauss <manuel.lauss@gmail.com>
\r
2 Subject: [RFC PATCH v4 2/2] MIPS: make FPU emulator optional
\r
3 Date: Mon, 7 Apr 2014 12:57:04 +0200
\r
4 Message-Id: <1396868224-252888-2-git-send-email-manuel.lauss@gmail.com>
\r
6 This small patch makes the MIPS FPU emulator optional. The kernel
\r
7 kills float-users on systems without a hardware FPU by sending a SIGILL.
\r
9 Disabling the emulator shrinks vmlinux by about 54kBytes (32bit,
\r
10 optimizing for size).
\r
12 Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
\r
14 v4: rediffed because of patch 1/2, should now work with micromips as well
\r
15 v3: updated patch description with size savings.
\r
16 v2: incorporated changes suggested by Jonas Gorski
\r
17 force the fpu emulator on for micromips: relocating the parts
\r
18 of the mmips code in the emulator to other areas would be a
\r
19 much larger change; I went the cheap route instead with this.
\r
21 arch/mips/Kbuild | 2 +-
\r
22 arch/mips/Kconfig | 14 ++++++++++++++
\r
23 arch/mips/include/asm/fpu.h | 5 +++--
\r
24 arch/mips/include/asm/fpu_emulator.h | 15 +++++++++++++++
\r
25 4 files changed, 33 insertions(+), 3 deletions(-)
\r
27 --- a/arch/mips/Kconfig
28 +++ b/arch/mips/Kconfig
29 @@ -2484,6 +2484,20 @@ config MIPS_O32_FP64_SUPPORT
33 +config MIPS_FPU_EMULATOR
34 + bool "MIPS FPU Emulator"
37 + This option lets you disable the built-in MIPS FPU (Coprocessor 1)
38 + emulator, which handles floating-point instructions on processors
39 + without a hardware FPU. It is generally a good idea to keep the
40 + emulator built-in, unless you are perfectly sure you have a
41 + complete soft-float environment. With the emulator disabled, all
42 + users of float operations will be killed with an illegal instr-
50 --- a/arch/mips/Makefile
51 +++ b/arch/mips/Makefile
52 @@ -266,7 +266,7 @@ OBJCOPYFLAGS += --remove-section=.regin
53 head-y := arch/mips/kernel/head.o
55 libs-y += arch/mips/lib/
56 -libs-y += arch/mips/math-emu/
57 +libs-$(CONFIG_MIPS_FPU_EMULATOR) += arch/mips/math-emu/
59 # See arch/mips/Kbuild for content of core part of the kernel
61 --- a/arch/mips/include/asm/fpu.h
62 +++ b/arch/mips/include/asm/fpu.h
63 @@ -168,8 +168,10 @@ static inline int init_fpu(void)
68 + } else if (IS_ENABLED(CONFIG_MIPS_FPU_EMULATOR))
69 fpu_emulator_init_fpu();
75 --- a/arch/mips/include/asm/fpu_emulator.h
76 +++ b/arch/mips/include/asm/fpu_emulator.h
78 #include <asm/local.h>
79 #include <asm/processor.h>
81 +#ifdef CONFIG_MIPS_FPU_EMULATOR
82 #ifdef CONFIG_DEBUG_FS
84 struct mips_fpu_emulator_stats {
85 @@ -65,6 +66,20 @@ extern int do_dsemulret(struct pt_regs *
86 extern int fpu_emulator_cop1Handler(struct pt_regs *xcp,
87 struct mips_fpu_struct *ctx, int has_fpu,
88 void *__user *fault_addr);
89 +#else /* no CONFIG_MIPS_FPU_EMULATOR */
90 +static inline int do_dsemulret(struct pt_regs *xcp)
92 + return 0; /* 0 means error, should never get here anyway */
95 +static inline int fpu_emulator_cop1Handler(struct pt_regs *xcp,
96 + struct mips_fpu_struct *ctx, int has_fpu,
97 + void *__user *fault_addr)
99 + return SIGILL; /* we don't speak MIPS FPU */
101 +#endif /* CONFIG_MIPS_FPU_EMULATOR */
103 int process_fpemu_return(int sig, void __user *fault_addr);
104 int mm_isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
105 unsigned long *contpc);