From: Matej Kupljen <matej.kupljen@ultra.si>
To: linux-mips@linux-mips.org
Cc: Jordan Crouse <jordan.crouse@amd.com>
Subject: MIPS no FP patch
Date: Wed, 30 Nov 2005 12:07:32 +0100 [thread overview]
Message-ID: <1133348852.24526.31.camel@localhost.localdomain> (raw)
[-- Attachment #1: Type: text/plain, Size: 343 bytes --]
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
[-- Attachment #2: linux-2.6.14-rc2-no-fp.patch --]
[-- Type: text/x-patch, Size: 4829 bytes --]
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.
Signed-off-by: Matej Kupljen <matej.kupljen@ultra.si>
diff -ruN linux-latest/arch/mips/Kconfig linux-20051025-dbau1200/arch/mips/Kconfig
--- linux-latest/arch/mips/Kconfig 2005-10-24 13:36:24.000000000 +0200
+++ linux-20051025-dbau1200/arch/mips/Kconfig 2005-11-30 11:14:59.823169816 +0100
@@ -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
diff -ruN linux-latest/arch/mips/Makefile linux-20051025-dbau1200/arch/mips/Makefile
--- linux-latest/arch/mips/Makefile 2005-10-24 13:36:24.000000000 +0200
+++ linux-20051025-dbau1200/arch/mips/Makefile 2005-11-30 10:45:12.000000000 +0100
@@ -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/
diff -ruN linux-latest/arch/mips/no-math-emu/cp1emu.c linux-20051025-dbau1200/arch/mips/no-math-emu/cp1emu.c
--- linux-latest/arch/mips/no-math-emu/cp1emu.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-20051025-dbau1200/arch/mips/no-math-emu/cp1emu.c 2005-11-30 11:44:16.410128008 +0100
@@ -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 <matej.kupljen@ultra.si>, 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;
+}
diff -ruN linux-latest/arch/mips/no-math-emu/dsemul.c linux-20051025-dbau1200/arch/mips/no-math-emu/dsemul.c
--- linux-latest/arch/mips/no-math-emu/dsemul.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-20051025-dbau1200/arch/mips/no-math-emu/dsemul.c 2005-11-30 11:44:11.307903664 +0100
@@ -0,0 +1,14 @@
+/*
+ * Dummy file to support kernel without FP emulator.
+ * Matej Kupljen <matej.kupljen@ultra.si>, 2005
+ */
+
+#include <asm/fpu_emulator.h>
+#include <asm/processor.h>
+#include <asm/bug.h>
+
+int do_dsemulret(struct pt_regs *xcp)
+{
+ BUG();
+ return 1;
+}
diff -ruN linux-latest/arch/mips/no-math-emu/kernel_linkage.c linux-20051025-dbau1200/arch/mips/no-math-emu/kernel_linkage.c
--- linux-latest/arch/mips/no-math-emu/kernel_linkage.c 1970-01-01 01:00:00.000000000 +0100
+++ linux-20051025-dbau1200/arch/mips/no-math-emu/kernel_linkage.c 2005-11-30 11:44:05.818738144 +0100
@@ -0,0 +1,53 @@
+/*
+ * Kevin D. Kissell, kevink@mips and Carsten Langgaard, carstenl@mips.com
+ * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved.
+ *
+ * Dummy file to support kernel without FP emulator.
+ *
+ * Modified by Matej Kupljen <matej.kupljen@ultra.si>, 2005
+ */
+
+#include <asm/fpu_emulator.h>
+#include <linux/sched.h>
+#include <asm/bug.h>
+
+void fpu_emulator_init_fpu(void)
+{
+ static int first = 1;
+
+ if (first) {
+ first = 0;
+ printk("Kernel without FPU emulator!\n");
+ }
+}
+
+int fpu_emulator_save_context(struct sigcontext *sc)
+{
+ BUG();
+ return -1;
+}
+
+int fpu_emulator_restore_context(struct sigcontext *sc)
+{
+ BUG();
+ return -1;
+}
+
+#ifdef CONFIG_MIPS64
+/*
+ * This is the o32 version
+ */
+
+int fpu_emulator_save_context32(struct sigcontext32 *sc)
+{
+ BUG();
+ return -1;
+}
+
+int fpu_emulator_restore_context32(struct sigcontext32 *sc)
+{
+ BUG();
+
+ return err;
+}
+#endif
diff -ruN linux-latest/arch/mips/no-math-emu/Makefile linux-20051025-dbau1200/arch/mips/no-math-emu/Makefile
--- linux-latest/arch/mips/no-math-emu/Makefile 1970-01-01 01:00:00.000000000 +0100
+++ linux-20051025-dbau1200/arch/mips/no-math-emu/Makefile 2005-09-06 09:13:54.000000000 +0200
@@ -0,0 +1,5 @@
+#
+# Makefile for the Linux/MIPS kernel FPU emulation.
+#
+
+obj-y := cp1emu.o kernel_linkage.o dsemul.o
next reply other threads:[~2005-11-30 11:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-30 11:07 Matej Kupljen [this message]
2005-11-30 11:28 ` MIPS no FP patch Ralf Baechle
2005-12-01 3:55 ` Chris Wedgwood
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1133348852.24526.31.camel@localhost.localdomain \
--to=matej.kupljen@ultra.si \
--cc=jordan.crouse@amd.com \
--cc=linux-mips@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox