Skip to contentSkip to conversation

MIPS: adding a safety check for cpu_has_fpu

PATCH Superseded Stephen Zhang 2 participants 2 messages May 1, 2022 MIPS

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 MIPS: adding a safety check for cpu_has_fpu

From: Shida Zhang <[email protected]>

There is a chance 'cpu_has_fpu' would still be overridden when the CONFIG_MIPS_FP_SUPPORT configuration option has been disabled. So add a safety check for 'cpu_has_fpu'.

---
Changelog in v1 -> v2:
- Choose to redefine cpu_has_fpu to solve the problem silently.

Changelog in v2 -> v3:
- Choose to point out the error instead.

 arch/mips/include/asm/cpu-features.h | 5 +++++
 1 file changed, 5 insertions(+)
arch/mips/include/asm/cpu-features.h +5 -0
index de8cb2ccb781..57ff0f8a507c 100644
@@ -134,6 +134,11 @@
 # endif
 #else
 # define raw_cpu_has_fpu	cpu_has_fpu
+# ifndef CONFIG_MIPS_FP_SUPPORT
+#  if cpu_has_fpu
+#   error "Forcing `cpu_has_fpu' to non-zero is not supported"
+#  endif
+# endif
 #endif
 #ifndef cpu_has_32fpr
 #define cpu_has_32fpr		__isa_ge_or_opt(1, MIPS_CPU_32FPR)
Signature · 1 line
2.30.2
#1 lore raw
Quoted 5 lines · Stephen Zhang
arch/mips/include/asm/cpu-features.h +0 -0
index de8cb2ccb781..57ff0f8a507c 100644

arch/mips/include/asm/cpu-features.h line 142

Quoted 9 lines
arch/mips/include/asm/cpu-features.h +5 -0
@@ -134,6 +134,11 @@
 # endif
 #else
 # define raw_cpu_has_fpu	cpu_has_fpu
+# ifndef CONFIG_MIPS_FP_SUPPORT
+#  if cpu_has_fpu
+#   error "Forcing `cpu_has_fpu' to non-zero is not supported"
+#  endif
+# endif
 #endif

For this to work for `nofpu' the check has to be outside the conditional,
possibly right below the comment we've been discussing.

Maciej