025-mips_disable_fpu.patch 4.0 KB

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