025-mips_disable_fpu.patch 4.1 KB

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