linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mips: add o32_fp64 boot param to disable FP64 support
@ 2020-05-28 23:16 YunQiang Su
  2020-05-29 11:09 ` Thomas Bogendoerfer
  0 siblings, 1 reply; 5+ messages in thread
From: YunQiang Su @ 2020-05-28 23:16 UTC (permalink / raw)
  To: Thomas Bogendoerfer; +Cc: linux-mips, Jiaxun Yang, Huacai Chen, YunQiang Su

When build with CONFIG_O32_FP64_SUPPORTS, even all of the userland
is FPXX, we cannot run any FP32 binary.

Then we need to disable FP64 support temporarily with a boot param:
   o32_fp64=no/disable

Signed-off-by: YunQiang Su <syq@debian.org>
---
 arch/mips/include/asm/abi.h |  2 ++
 arch/mips/include/asm/elf.h |  4 +++-
 arch/mips/kernel/elf.c      |  5 +++--
 arch/mips/kernel/process.c  |  2 +-
 arch/mips/kernel/setup.c    | 15 +++++++++++++++
 arch/mips/math-emu/cp1emu.c |  3 ++-
 6 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/arch/mips/include/asm/abi.h b/arch/mips/include/asm/abi.h
index dba7f4b6bebf..c5d297c67a9c 100644
--- a/arch/mips/include/asm/abi.h
+++ b/arch/mips/include/asm/abi.h
@@ -29,4 +29,6 @@ struct mips_abi {
 	struct mips_vdso_image *vdso;
 };
 
+extern bool o32_fp64_support;
+
 #endif /* _ASM_ABI_H */
diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
index 5aa29ced6970..dc55815923b5 100644
--- a/arch/mips/include/asm/elf.h
+++ b/arch/mips/include/asm/elf.h
@@ -15,6 +15,7 @@
 #include <uapi/linux/elf.h>
 
 #include <asm/current.h>
+#include <asm/abi.h>
 
 /* ELF header e_flags defines. */
 /* MIPS architecture level. */
@@ -293,7 +294,8 @@ void mips_dump_regs64(u64 *uregs, const struct pt_regs *regs);
 	if (((__h->e_flags & EF_MIPS_ABI) != 0) &&			\
 	    ((__h->e_flags & EF_MIPS_ABI) != EF_MIPS_ABI_O32))		\
 		__res = 0;						\
-	if (__h->e_flags & __MIPS_O32_FP64_MUST_BE_ZERO)		\
+	if ((__h->e_flags & __MIPS_O32_FP64_MUST_BE_ZERO) &&		\
+	    !o32_fp64_support)						\
 		__res = 0;						\
 									\
 	__res;								\
diff --git a/arch/mips/kernel/elf.c b/arch/mips/kernel/elf.c
index 7b045d2a0b51..3de15308971c 100644
--- a/arch/mips/kernel/elf.c
+++ b/arch/mips/kernel/elf.c
@@ -11,6 +11,7 @@
 
 #include <asm/cpu-features.h>
 #include <asm/cpu-info.h>
+#include <asm/abi.h>
 
 #ifdef CONFIG_MIPS_FP_SUPPORT
 
@@ -176,7 +177,7 @@ int arch_check_elf(void *_ehdr, bool has_interpreter, void *_interp_ehdr,
 			return -ELIBBAD;
 	}
 
-	if (!IS_ENABLED(CONFIG_MIPS_O32_FP64_SUPPORT))
+	if (!o32_fp64_support)
 		return 0;
 
 	fp_abi = state->fp_abi;
@@ -282,7 +283,7 @@ void mips_set_personality_fp(struct arch_elf_state *state)
 	 * not be worried about N32/N64 binaries.
 	 */
 
-	if (!IS_ENABLED(CONFIG_MIPS_O32_FP64_SUPPORT))
+	if (!o32_fp64_support)
 		return;
 
 	switch (state->overall_fp_mode) {
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index ff5320b79100..1bb93941c4c1 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -760,7 +760,7 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value)
 		return 0;
 
 	/* Only accept a mode change if 64-bit FP enabled for o32.  */
-	if (!IS_ENABLED(CONFIG_MIPS_O32_FP64_SUPPORT))
+	if (!o32_fp64_support)
 		return -EOPNOTSUPP;
 
 	/* And only for o32 tasks.  */
diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
index 7b537fa2035d..2475843487aa 100644
--- a/arch/mips/kernel/setup.c
+++ b/arch/mips/kernel/setup.c
@@ -484,6 +484,21 @@ static int __init early_parse_elfcorehdr(char *p)
 early_param("elfcorehdr", early_parse_elfcorehdr);
 #endif
 
+#ifdef CONFIG_MIPS_O32_FP64_SUPPORT
+bool o32_fp64_support __read_mostly = true;
+static int __init early_parse_o32_fp64(char *p)
+{
+	if (strncmp(p, "no", 2) == 0 ||
+	    strncmp(p, "disable", 7) == 0
+	    strncmp(p, "off", 3) == 0)
+		o32_fp64_support = false;
+	return 0;
+}
+early_param("o32_fp64", early_parse_o32_fp64);
+#else
+bool o32_fp64_support __read_mostly;
+#endif
+
 #ifdef CONFIG_KEXEC
 static void __init mips_parse_crashkernel(void)
 {
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
index 587cf1d115e8..54d7a5122137 100644
--- a/arch/mips/math-emu/cp1emu.c
+++ b/arch/mips/math-emu/cp1emu.c
@@ -33,6 +33,7 @@
 #include <linux/uaccess.h>
 
 #include <asm/cpu-info.h>
+#include <asm/abi.h>
 #include <asm/processor.h>
 #include <asm/fpu_emulator.h>
 #include <asm/fpu.h>
@@ -784,7 +785,7 @@ static inline int cop1_64bit(struct pt_regs *xcp)
 	if (IS_ENABLED(CONFIG_64BIT) && !IS_ENABLED(CONFIG_MIPS32_O32))
 		return 1;
 	else if (IS_ENABLED(CONFIG_32BIT) &&
-		 !IS_ENABLED(CONFIG_MIPS_O32_FP64_SUPPORT))
+		 !o32_fp64_support)
 		return 0;
 
 	return !test_thread_flag(TIF_32BIT_FPREGS);
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-06-11  4:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-28 23:16 [PATCH] mips: add o32_fp64 boot param to disable FP64 support YunQiang Su
2020-05-29 11:09 ` Thomas Bogendoerfer
2020-05-29 14:26   ` YunQiang Su
2020-06-04  0:19     ` Maciej W. Rozycki
2020-06-11  4:54       ` YunQiang Su

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).