304-mips_disable_fpu.patch 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. MIPS: allow disabling the kernel FPU emulator
  2. This patch allows turning off the in-kernel Algorithmics
  3. FPU emulator support, which allows one to save a couple of
  4. precious blocks on an embedded system.
  5. Signed-off-by: Florian Fainelli <[email protected]>
  6. --
  7. --- a/arch/mips/Kconfig
  8. +++ b/arch/mips/Kconfig
  9. @@ -981,6 +981,17 @@ config I8259
  10. config MIPS_BONITO64
  11. bool
  12. +config MIPS_FPU_EMU
  13. + bool "Enable FPU emulation"
  14. + default y
  15. + help
  16. + This option allows building a kernel with or without the Algorithmics
  17. + FPU emulator enabled. Turning off this option results in a kernel which
  18. + does not catch floating operations exceptions. Make sure that your toolchain
  19. + is configured to enable software floating point emulation in that case.
  20. +
  21. + If unsure say Y here.
  22. +
  23. config MIPS_MSC
  24. bool
  25. --- a/arch/mips/math-emu/Makefile
  26. +++ b/arch/mips/math-emu/Makefile
  27. @@ -2,10 +2,12 @@
  28. # Makefile for the Linux/MIPS kernel FPU emulation.
  29. #
  30. -obj-y := cp1emu.o ieee754m.o ieee754d.o ieee754dp.o ieee754sp.o ieee754.o \
  31. +obj-y := kernel_linkage.o
  32. +
  33. +obj-$(CONFIG_MIPS_FPU_EMU) += ieee754m.o ieee754d.o ieee754dp.o ieee754sp.o ieee754.o \
  34. ieee754xcpt.o dp_frexp.o dp_modf.o dp_div.o dp_mul.o dp_sub.o \
  35. dp_add.o dp_fsp.o dp_cmp.o dp_logb.o dp_scalb.o dp_simple.o \
  36. dp_tint.o dp_fint.o dp_tlong.o dp_flong.o sp_frexp.o sp_modf.o \
  37. sp_div.o sp_mul.o sp_sub.o sp_add.o sp_fdp.o sp_cmp.o sp_logb.o \
  38. sp_scalb.o sp_simple.o sp_tint.o sp_fint.o sp_tlong.o sp_flong.o \
  39. - dp_sqrt.o sp_sqrt.o kernel_linkage.o dsemul.o
  40. + dp_sqrt.o sp_sqrt.o dsemul.o cp1emu.o
  41. --- a/arch/mips/math-emu/kernel_linkage.c
  42. +++ b/arch/mips/math-emu/kernel_linkage.c
  43. @@ -29,6 +29,7 @@
  44. #define SIGNALLING_NAN 0x7ff800007ff80000LL
  45. +#ifdef CONFIG_MIPS_FPU_EMU
  46. void fpu_emulator_init_fpu(void)
  47. {
  48. static int first = 1;
  49. @@ -113,3 +114,36 @@ int fpu_emulator_restore_context32(struc
  50. return err;
  51. }
  52. #endif
  53. +
  54. +#else
  55. +
  56. +void fpu_emulator_init_fpu(void)
  57. +{
  58. + printk(KERN_INFO "FPU emulator disabled, make sure your toolchain"
  59. + "was compiled with software floating point support (soft-float)\n");
  60. + return;
  61. +}
  62. +
  63. +int fpu_emulator_save_context(struct sigcontext __user *sc)
  64. +{
  65. + return 0;
  66. +}
  67. +
  68. +int fpu_emulator_restore_context(struct sigcontext __user *sc)
  69. +{
  70. + return 0;
  71. +}
  72. +
  73. +#ifdef CONFIG_64BIT
  74. +int fpu_emulator_save_context32(struct sigcontext32 __user *sc)
  75. +{
  76. + return 0;
  77. +}
  78. +
  79. +int fpu_emulator_restore_context32(struct sigcontext32 __user *sc)
  80. +{
  81. + return 0;
  82. +}
  83. +#endif /* CONFIG_64BIT */
  84. +
  85. +#endif /* CONFIG_MIPS_FPU_EMU */
  86. --- a/arch/mips/include/asm/fpu_emulator.h
  87. +++ b/arch/mips/include/asm/fpu_emulator.h
  88. @@ -27,6 +27,8 @@
  89. #include <asm/inst.h>
  90. #include <asm/local.h>
  91. +#ifdef CONFIG_MIPS_FPU_EMU
  92. +
  93. #ifdef CONFIG_DEBUG_FS
  94. struct mips_fpu_emulator_stats {
  95. @@ -60,6 +62,38 @@ extern int fpu_emulator_cop1Handler(stru
  96. int process_fpemu_return(int sig, void __user *fault_addr);
  97. int mm_isBranchInstr(struct pt_regs *regs, struct mm_decoded_insn dec_insn,
  98. unsigned long *contpc);
  99. +#else
  100. +static inline int mips_dsemul(struct pt_regs *regs, mips_instruction ir,
  101. + unsigned long cpc)
  102. +{
  103. + return 0;
  104. +}
  105. +
  106. +static inline int do_dsemulret(struct pt_regs *xcp)
  107. +{
  108. + return 0;
  109. +}
  110. +
  111. +static inline int fpu_emulator_cop1Handler(struct pt_regs *xcp,
  112. + struct mips_fpu_struct *ctx,
  113. + int has_fpu,
  114. + void *__user *fault_addr)
  115. +{
  116. + return 0;
  117. +}
  118. +
  119. +static inline int process_fpemu_return(int sig, void __user *fault_addr)
  120. +{
  121. + return -EINVAL;
  122. +}
  123. +
  124. +static inline int mm_isBranchInstr(struct pt_regs *regs,
  125. + struct mm_decoded_insn dec_insn,
  126. + unsigned long *contpc)
  127. +{
  128. + return 0;
  129. +}
  130. +#endif /* CONFIG_MIPS_FPU_EMU */
  131. /*
  132. * Instruction inserted following the badinst to further tag the sequence
  133. --- a/arch/mips/kernel/traps.c
  134. +++ b/arch/mips/kernel/traps.c
  135. @@ -684,6 +684,7 @@ asmlinkage void do_ov(struct pt_regs *re
  136. force_sig_info(SIGFPE, &info, current);
  137. }
  138. +#ifdef CONFIG_MIPS_FPU_EMU
  139. int process_fpemu_return(int sig, void __user *fault_addr)
  140. {
  141. if (sig == SIGSEGV || sig == SIGBUS) {
  142. @@ -707,6 +708,7 @@ int process_fpemu_return(int sig, void _
  143. return 0;
  144. }
  145. }
  146. +#endif /* CONFIG_MIPS_FPU_EMU */
  147. /*
  148. * XXX Delayed fp exceptions when doing a lazy ctx switch XXX