MIPS: move mmips branch support code out of the fpu emu code
RFC PATCH v5 1/2 MIPS: move mmips branch support code out of the fpu emu code
moves mm_isBranchInstr() from math-emu code to branch code. Required for a follow-on patch to disable the math-emu code completely.
---
v4/v5: initial patch, no changes
arch/mips/include/asm/branch.h | 2 + arch/mips/include/asm/fpu_emulator.h | 2 - arch/mips/kernel/branch.c | 200 +++++++++++++++++++++++++++++++++++ arch/mips/math-emu/cp1emu.c | 198 ---------------------------------- 4 files changed, 202 insertions(+), 200 deletions(-)
arch/mips/include/asm/branch.h +2 -0
@@ -17,6 +17,8 @@ extern int __compute_return_epc_for_insn(struct pt_regs *regs, union mips_instruction insn);extern int __microMIPS_compute_return_epc (struct pt_regs *regs);extern int __MIPS16e_compute_return_epc (struct pt_regs *regs); +int mm_isBranchInstr (struct pt_regs *regs,struct mm_decoded_insn dec_insn, +unsigned long *contpc);static inline int delay_slot (struct pt_regs *regs)
arch/mips/include/asm/fpu_emulator.h +0 -2
@@ -58,8 +58,6 @@ extern int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx, int has_fpu, void *__user *fault_addr);int process_fpemu_return (int sig,void __user *fault_addr); -int mm_isBranchInstr (struct pt_regs *regs,struct mm_decoded_insn dec_insn, -unsigned long *contpc);/* * Instruction inserted following the badinst to further tag the sequence
arch/mips/kernel/branch.c +200 -0
212 lines not on this page · raw message
arch/mips/math-emu/cp1emu.c +0 -198
216 lines not on this page · raw message
Signature · 1 line
1.9.1
RFC PATCH v5 2/2 MIPS: optional floating point support
Makes floating point support a selectable kernel option. Disabling this option will make the kernel 50kB lighter and kill all float uses with an illegal instruction exception.
---
v5: now disable float support completely to avoid sudden program crashes
on buggy fpus when the fpu emulator cannot take over (suggested by Paul Burton).
v4: rediffed because of patch 1/2, should now work with micromips as well
v3: updated patch description with size savings.
v2: incorporated changes suggested by Jonas Gorski
force the fpu emulator on for micromips: relocating the parts of the mmips code in the emulator to other areas would be a much larger change; I went the cheap route instead with this.
arch/mips/Kbuild | 2 +- arch/mips/Kconfig | 11 +++++++++++ arch/mips/include/asm/fpu.h | 20 +++++++++++--------- arch/mips/include/asm/fpu_emulator.h | 15 +++++++++++++++ 4 files changed, 38 insertions(+), 10 deletions(-)
arch/mips/Kbuild +1 -1
@@ -16,7 +16,7 @@ obj- := $(platform-) obj-y += kernel/ obj-y += mm/ -obj-y += math-emu/ +obj-$(CONFIG_MIPS_FPU_SUPPORT) += math-emu/ ifdef CONFIG_KVM obj-y += kvm/
arch/mips/Kconfig +11 -0
@@ -2482,6 +2482,17 @@ config MIPS_O32_FP64_SUPPORT If unsure, say N. +config MIPS_FPU_SUPPORT + bool "MIPS FPU Support" + default y + help + Support for floating point registers and FP-hardware, and also + the in-kernel FPU emulator. Disabling this option will result + in all uses of floating point hardware to be killed with an + illegal instruction exception, and about a 50kB smaller kernel. + + Say Y. + config USE_OF bool select OF
arch/mips/include/asm/fpu.h +11 -9
@@ -155,16 +155,18 @@ static inline int init_fpu(void) {int ret =0 ; -preempt_disable (); -if (cpu_has_fpu) { - ret =__own_fpu (); -if (!ret) -_init_fpu (); - }else { -fpu_emulator_init_fpu (); - } +if (IS_ENABLED (CONFIG_MIPS_FPU_SUPPORT )) { +preempt_disable (); +if (cpu_has_fpu) { + ret =__own_fpu (); +if (!ret) +_init_fpu (); + }else +fpu_emulator_init_fpu (); +preempt_enable (); + }else + ret =SIGILL ; -preempt_enable ();return ret; }
arch/mips/include/asm/fpu_emulator.h +15 -0
@@ -27,6 +27,7 @@#include <asm/inst.h> #include <asm/local.h> +#ifdef CONFIG_MIPS_FPU_SUPPORT #ifdef CONFIG_DEBUG_FS struct mips_fpu_emulator_stats {
@@ -57,6 +58,20 @@ extern int do_dsemulret(struct pt_regs *xcp);extern int fpu_emulator_cop1Handler (struct pt_regs *xcp,struct mips_fpu_struct *ctx,int has_fpu,void *__user *fault_addr); +#else /* no CONFIG_MIPS_FPU_SUPPORT */ +static inline int do_dsemulret (struct pt_regs *xcp) +{ +return 0 ;/* 0 means error, should never get here anyway */ +} + +static inline int fpu_emulator_cop1Handler (struct pt_regs *xcp, +struct mips_fpu_struct *ctx,int has_fpu, +void *__user *fault_addr) +{ +return SIGILL ;/* we don't speak MIPS FPU */ +} +#endif /* CONFIG_MIPS_FPU_SUPPORT */ +int process_fpemu_return (int sig,void __user *fault_addr);/*
Signature · 1 line
1.9.1
Re: [RFC PATCH v5 2/2] MIPS: optional floating point support
On 04/07/2014 10:53 AM, Manuel Lauss wrote:
[...]
arch/mips/include/asm/fpu_emulator.h extern int do_dsemulret(struct pt_regs *xcp); · line 71
Quoted 11 lines
arch/mips/include/asm/fpu_emulator.h +11
-0+#else /* no CONFIG_MIPS_FPU_SUPPORT */ +static inline int do_dsemulret (struct pt_regs *xcp) +{ +return 0 ;/* 0 means error, should never get here anyway */ +} + +static inline int fpu_emulator_cop1Handler (struct pt_regs *xcp, +struct mips_fpu_struct *ctx,int has_fpu, +void *__user *fault_addr) +{ +return SIGILL ;/* we don't speak MIPS FPU */
In a message in the other branch, Ralf suggested emitting very ugly messages in the case that something tries to use the FPU.
This code doesn't quite satisfy that request.
Quoted 7 lines
arch/mips/include/asm/fpu_emulator.h +3
-0+} +#endif /* CONFIG_MIPS_FPU_SUPPORT */ +int process_fpemu_return (int sig,void __user *fault_addr);/*