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. Signed-off-by: Matej Kupljen <matej.kupljen@xxxxxxxx> 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@xxxxxxxx>, 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@xxxxxxxx>, 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@xxxxxxxx + * Copyright (C) 2000 MIPS Technologies, Inc. All rights reserved. + * + * Dummy file to support kernel without FP emulator. + * + * Modified by Matej Kupljen <matej.kupljen@xxxxxxxx>, 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