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 <florian@openwrt.org>
  6. --
  7. --- a/arch/mips/Kconfig
  8. +++ b/arch/mips/Kconfig
  9. @@ -961,6 +961,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,11 +2,13 @@
  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 dsemul.o cp1emu.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
  41. --- a/arch/mips/math-emu/cp1emu.c
  42. +++ b/arch/mips/math-emu/cp1emu.c
  43. @@ -58,7 +58,11 @@
  44. #define __mips 4
  45. /* Function which emulates a floating point instruction. */
  46. +#ifdef CONFIG_DEBUG_FS
  47. +DEFINE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);
  48. +#endif
  49. +#ifdef CONFIG_MIPS_FPU_EMU
  50. static int fpu_emu(struct pt_regs *, struct mips_fpu_struct *,
  51. mips_instruction);
  52. @@ -69,10 +73,6 @@ static int fpux_emu(struct pt_regs *,
  53. /* Further private data for which no space exists in mips_fpu_struct */
  54. -#ifdef CONFIG_DEBUG_FS
  55. -DEFINE_PER_CPU(struct mips_fpu_emulator_stats, fpuemustats);
  56. -#endif
  57. -
  58. /* Control registers */
  59. #define FPCREG_RID 0 /* $0 = revision id */
  60. @@ -1360,7 +1360,6 @@ int fpu_emulator_cop1Handler(struct pt_r
  61. return sig;
  62. }
  63. -
  64. #ifdef CONFIG_DEBUG_FS
  65. static int fpuemu_stat_get(void *data, u64 *val)
  66. @@ -1409,4 +1408,11 @@ static int __init debugfs_fpuemu(void)
  67. return 0;
  68. }
  69. __initcall(debugfs_fpuemu);
  70. -#endif
  71. +#endif /* CONFIG_DEBUGFS */
  72. +#else
  73. +int fpu_emulator_cop1Handler(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
  74. + int has_fpu)
  75. +{
  76. + return 0;
  77. +}
  78. +#endif /* CONFIG_MIPS_FPU_EMU */
  79. --- a/arch/mips/math-emu/dsemul.c
  80. +++ b/arch/mips/math-emu/dsemul.c
  81. @@ -109,6 +109,7 @@ int mips_dsemul(struct pt_regs *regs, mi
  82. return SIGILL; /* force out of emulation loop */
  83. }
  84. +#ifdef CONFIG_MIPS_FPU_EMU
  85. int do_dsemulret(struct pt_regs *xcp)
  86. {
  87. struct emuframe __user *fr;
  88. @@ -165,3 +166,9 @@ int do_dsemulret(struct pt_regs *xcp)
  89. return 1;
  90. }
  91. +#else
  92. +int do_dsemulret(struct pt_regs *xcp)
  93. +{
  94. + return 0;
  95. +}
  96. +#endif /* CONFIG_MIPS_FPU_EMU */
  97. --- a/arch/mips/math-emu/kernel_linkage.c
  98. +++ b/arch/mips/math-emu/kernel_linkage.c
  99. @@ -29,6 +29,7 @@
  100. #define SIGNALLING_NAN 0x7ff800007ff80000LL
  101. +#ifdef CONFIG_MIPS_FPU_EMU
  102. void fpu_emulator_init_fpu(void)
  103. {
  104. static int first = 1;
  105. @@ -112,4 +113,36 @@ int fpu_emulator_restore_context32(struc
  106. return err;
  107. }
  108. -#endif
  109. +#endif /* CONFIG_64BIT */
  110. +#else
  111. +
  112. +void fpu_emulator_init_fpu(void)
  113. +{
  114. + printk(KERN_INFO "FPU emulator disabled, make sure your toolchain"
  115. + "was compiled with software floating point support (soft-float)\n");
  116. + return;
  117. +}
  118. +
  119. +int fpu_emulator_save_context(struct sigcontext __user *sc)
  120. +{
  121. + return 0;
  122. +}
  123. +
  124. +int fpu_emulator_restore_context(struct sigcontext __user *sc)
  125. +{
  126. + return 0;
  127. +}
  128. +
  129. +int fpu_emulator_save_context32(struct sigcontext32 __user *sc)
  130. +{
  131. + return 0;
  132. +}
  133. +
  134. +int fpu_emulator_restore_context32(struct sigcontext32 __user *sc)
  135. +{
  136. + return 0;
  137. +}
  138. +
  139. +#ifdef CONFIG_64BIT
  140. +#endif /* CONFIG_64BIT */
  141. +#endif /* CONFIG_MIPS_FPU_EMU */