Skip to contentSkip to conversation

MIPS no FP patch

PATCH Matej Kupljen 3 participants 3 messages Nov 30, 2005 – Dec 1, 2005 MIPS

lore
Share & tools
lore
#0 lore raw

Hi

This is a patch that makes FP emulation in kernel an option. I used this when I was looking why there are still some FP instruction in glibc, even though it was configured with --withot-fp. This seemed the best way to ensure this.

It is for the 2.6.14-rc2, but I think there is only a minimal work to use it on latest kernel.

BR,
Matej

Patch introduces a option, with which you can enable
or disable the FP emulator in the kernel.
It was written to ensure that no user space binaries uses
FP instruction. This was necessary because glibc
still contained some FP instructions even though it
was configured with --without-fp and gcc with --with-float=soft. See <http://sources.redhat.com/ml/crossgcc/2005-09/msg00054.html>
for details and <http://sources.redhat.com/ml/crossgcc/2005-09/msg00125.html>
for patch.

arch/mips/Kconfig +7 -0
diff -ruN linux-latest/arch/mips/Kconfig linux-20051025-dbau1200/arch/mips/Kconfig
@@ -1623,6 +1623,13 @@
 
 source "kernel/Kconfig.preempt"
 
+config MIPS_FPU_EMULATOR
+	bool "Include FPU emulator in the kernel"
+	default y
+	help
+	  Enables or disables FP emulation in kernel.
+	  If unsure, say YES
+
 config RTC_DS1742
 	bool "DS1742 BRAM/RTC support"
 	depends on TOSHIBA_JMR3927 || TOSHIBA_RBTX4927
arch/mips/Makefile +7 -1
diff -ruN linux-latest/arch/mips/Makefile linux-20051025-dbau1200/arch/mips/Makefile
@@ -752,7 +752,13 @@
 libs-$(CONFIG_32BIT)	+= arch/mips/lib-32/
 libs-$(CONFIG_64BIT)	+= arch/mips/lib-64/
 
-core-y			+= arch/mips/kernel/ arch/mips/mm/ arch/mips/math-emu/
+core-y			+= arch/mips/kernel/ arch/mips/mm/
+
+ifdef CONFIG_MIPS_FPU_EMULATOR
+core-y                 += arch/mips/math-emu/
+else
+core-y                 += arch/mips/no-math-emu/
+endif
 
 drivers-$(CONFIG_OPROFILE)	+= arch/mips/oprofile/
 
arch/mips/no-math-emu/cp1emu.c +21 -0
diff -ruN linux-latest/arch/mips/no-math-emu/cp1emu.c linux-20051025-dbau1200/arch/mips/no-math-emu/cp1emu.c
@@ -0,0 +1,21 @@
+/*
+ * cp1emu.c: a MIPS coprocessor 1 (fpu) instruction emulator
+ * 
+ * Dummy file that just calls BUG() when a coprocessor 1
+ * instruction is encountered.
+ * It was wrtitten to ensure that no FP instruction is
+ * present in userspace binaries.
+ * 
+ * Written by Matej Kupljen <[email protected]>, 2005
+ */
+
+#include <asm/fpu_emulator.h>
+#include <asm/processor.h>
+#include <asm/bug.h>
+
+int fpu_emulator_cop1Handler(int xcptno, struct pt_regs *xcp,
+	struct mips_fpu_soft_struct *ctx)
+{
+	BUG();
+	return 0;
+}
arch/mips/no-math-emu/dsemul.c +14 -0
diff -ruN linux-latest/arch/mips/no-math-emu/dsemul.c linux-20051025-dbau1200/arch/mips/no-math-emu/dsemul.c
@@ -0,0 +1,14 @@
+/*
+ * Dummy file to support kernel without FP emulator.
+ * Matej Kupljen <[email protected]>, 2005
+ */
+
+#include <asm/fpu_emulator.h>
+#include <asm/processor.h>
+#include <asm/bug.h>
+
+int do_dsemulret(struct pt_regs *xcp)
+{
+	BUG();
+	return 1;
+}
arch/mips/no-math-emu/kernel_linkage.c +53 -0

53 lines not on this page · raw message

arch/mips/no-math-emu/Makefile +5 -0
diff -ruN linux-latest/arch/mips/no-math-emu/Makefile linux-20051025-dbau1200/arch/mips/no-math-emu/Makefile
@@ -0,0 +1,5 @@
+#
+# Makefile for the Linux/MIPS kernel FPU emulation.
+#
+
+obj-y	:= cp1emu.o kernel_linkage.o dsemul.o
#1 lore raw
Quoted 7 lines · Matej Kupljen

This is a patch that makes FP emulation in kernel an option. I used this when I was looking why there are still some FP instruction in glibc, even though it was configured with --withot-fp. This seemed the best way to ensure this.

It is for the 2.6.14-rc2, but I think there is only a minimal work to use it on latest kernel.

We used to have this option but I eventually got rid of it because people just don't grok that they must enable it in precense of an FPU.

Ralf

#2 lore raw
Quoted 3 lines · Ralf Baechle

We used to have this option but I eventually got rid of it because people just don't grok that they must enable it in precense of an FPU.

For cores that have FPUs you could have Kconfig "select" it automatically.