* Re: [2.1.82] SERIOUS FLAWS in IEEE math handling on ALPHA.
[not found] <199802111859.TAA06269@sundiver.zdv.uni-mainz.de>
@ 1998-02-12 19:25 ` Richard Henderson
0 siblings, 0 replies; 3+ messages in thread
From: Richard Henderson @ 1998-02-12 19:25 UTC (permalink / raw)
--gBBFr7Ir9EOA20Yy
Content-Type: text/plain; charset=us-ascii
Attached is a patch that cures the problems as reported by paranoia.
Note that to fix the sqrt tests, I removed the optimized sqrt routine
from libc/sysdeps/alpha/w_sqrt.S, falling back on the libm-ieee764
version, and rebuilt libm.so. At some point someone might want to
fix up the alpha-optimized sqrt to cope with denormals, but ...
The patch is a bit bigger than necessary to just fix the problem, as
it also adds a kernel hacking option to build the emulator as a module,
which helps quite a lot when debugging it.
r~
--gBBFr7Ir9EOA20Yy
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=d-emu
diff -ruNp 2.1.86/arch/alpha/Makefile 2.1.86-axp/arch/alpha/Makefile
--- 2.1.86/arch/alpha/Makefile Thu Jan 15 21:52:46 1998
+++ 2.1.86-axp/arch/alpha/Makefile Thu Feb 12 05:27:21 1998
@@ -18,8 +18,12 @@ HEAD := arch/alpha/kernel/head.o
SUBDIRS := $(SUBDIRS) arch/alpha/kernel arch/alpha/mm arch/alpha/lib \
arch/alpha/math-emu
CORE_FILES := arch/alpha/kernel/kernel.o arch/alpha/mm/mm.o $(CORE_FILES)
-LIBS := $(TOPDIR)/arch/alpha/math-emu/math-emu.a \
- $(TOPDIR)/arch/alpha/lib/lib.a $(LIBS) $(TOPDIR)/arch/alpha/lib/lib.a
+
+ifeq ($(CONFIG_MATHEMU),y)
+ CORE_FILES := $(CORE_FILES) arch/alpha/math-emu/math-emu.o
+endif
+
+LIBS := arch/alpha/lib/lib.a $(LIBS) arch/alpha/lib/lib.a
MAKEBOOT = $(MAKE) -C arch/$(ARCH)/boot
diff -ruNp 2.1.86/arch/alpha/config.in 2.1.86-axp/arch/alpha/config.in
--- 2.1.86/arch/alpha/config.in Thu Feb 12 08:58:24 1998
+++ 2.1.86-axp/arch/alpha/config.in Thu Feb 12 05:02:04 1998
@@ -245,6 +245,12 @@ bool 'Kernel profiling support' CONFIG_P
if [ "$CONFIG_PROFILE" = "y" ]; then
int ' Profile shift count' CONFIG_PROFILE_SHIFT 2
fi
+if [ "$CONFIG_EXPERIMENTAL" = "y" ]; then
+ tristate 'Kernel FP software completion' CONFIG_MATHEMU
+else
+ define_bool CONFIG_MATHEMU y
+fi
+
bool 'Magic SysRq key' CONFIG_MAGIC_SYSRQ
endmenu
diff -ruNp 2.1.86/arch/alpha/defconfig 2.1.86-axp/arch/alpha/defconfig
--- 2.1.86/arch/alpha/defconfig Thu Feb 5 14:39:40 1998
+++ 2.1.86-axp/arch/alpha/defconfig Thu Feb 12 05:02:28 1998
@@ -30,14 +30,19 @@ CONFIG_NATIVE=y
# CONFIG_ALPHA_JENSEN is not set
# CONFIG_ALPHA_NONAME is not set
# CONFIG_ALPHA_MIKASA is not set
+# CONFIG_ALPHA_NORITAKE is not set
CONFIG_ALPHA_ALCOR=y
+# CONFIG_ALPHA_MIATA is not set
+# CONFIG_ALPHA_SABLE is not set
+# CONFIG_ALPHA_BOOK1 is not set
# CONFIG_ALPHA_P2K is not set
CONFIG_PCI=y
-CONFIG_PCI_OLD_PROC=y
CONFIG_ALPHA_EV5=y
CONFIG_ALPHA_CIA=y
CONFIG_ALPHA_SRM=y
+CONFIG_ALPHA_EISA=y
CONFIG_TGA_CONSOLE=y
+CONFIG_PCI_OLD_PROC=y
CONFIG_NET=y
CONFIG_SYSVIPC=y
CONFIG_SYSCTL=y
@@ -70,28 +75,35 @@ CONFIG_BLK_DEV_FD=y
# CONFIG_BLK_DEV_MD is not set
# CONFIG_BLK_DEV_RAM is not set
# CONFIG_BLK_DEV_XD is not set
-# CONFIG_BLK_DEV_EZ is not set
+CONFIG_PARIDE_PARPORT=y
+# CONFIG_PARIDE is not set
# CONFIG_BLK_DEV_HD is not set
#
# Networking options
#
+# CONFIG_PACKET is not set
# CONFIG_NETLINK is not set
# CONFIG_FIREWALL is not set
# CONFIG_NET_ALIAS is not set
+# CONFIG_FILTER is not set
+CONFIG_UNIX=y
CONFIG_INET=y
# CONFIG_IP_MULTICAST is not set
+# CONFIG_IP_ADVANCED_ROUTER is not set
+# CONFIG_IP_PNP is not set
# CONFIG_IP_ACCT is not set
+# CONFIG_IP_MASQUERADE is not set
# CONFIG_IP_ROUTER is not set
# CONFIG_NET_IPIP is not set
+# CONFIG_NET_IPGRE is not set
+# CONFIG_IP_ALIAS is not set
# CONFIG_SYN_COOKIES is not set
#
# (it is safe to leave these untouched)
#
-# CONFIG_INET_PCTCP is not set
# CONFIG_INET_RARP is not set
-CONFIG_PATH_MTU_DISCOVERY=y
CONFIG_IP_NOSR=y
CONFIG_SKB_LARGE=y
@@ -100,7 +112,6 @@ CONFIG_SKB_LARGE=y
#
# CONFIG_IPX is not set
# CONFIG_ATALK is not set
-# CONFIG_AX25 is not set
#
# SCSI support
@@ -121,6 +132,7 @@ CONFIG_BLK_DEV_SR=y
#
# CONFIG_SCSI_MULTI_LUN is not set
CONFIG_SCSI_CONSTANTS=y
+# CONFIG_SCSI_LOGGING is not set
#
# SCSI low-level drivers
@@ -139,11 +151,15 @@ CONFIG_SCSI_CONSTANTS=y
# CONFIG_SCSI_EATA_PIO is not set
# CONFIG_SCSI_EATA is not set
# CONFIG_SCSI_FUTURE_DOMAIN is not set
+# CONFIG_SCSI_GDTH is not set
# CONFIG_SCSI_GENERIC_NCR5380 is not set
# CONFIG_SCSI_NCR53C406A is not set
# CONFIG_SCSI_NCR53C7xx is not set
# CONFIG_SCSI_NCR53C8XX is not set
# CONFIG_SCSI_PAS16 is not set
+# CONFIG_SCSI_PCI2000 is not set
+# CONFIG_SCSI_PCI2220I is not set
+# CONFIG_SCSI_PSI240I is not set
# CONFIG_SCSI_QLOGIC_FAS is not set
CONFIG_SCSI_QLOGIC_ISP=y
# CONFIG_SCSI_SEAGATE is not set
@@ -177,13 +193,19 @@ CONFIG_DE4X5=y
# CONFIG_FDDI is not set
# CONFIG_DLCI is not set
# CONFIG_PPP is not set
-# CONFIG_NET_RADIO is not set
# CONFIG_SLIP is not set
+# CONFIG_NET_RADIO is not set
# CONFIG_TR is not set
+# CONFIG_WAN_DRIVERS is not set
# CONFIG_LAPBETHER is not set
# CONFIG_X25_ASY is not set
#
+# Amateur Radio support
+#
+# CONFIG_HAMRADIO is not set
+
+#
# ISDN subsystem
#
# CONFIG_ISDN is not set
@@ -192,6 +214,7 @@ CONFIG_DE4X5=y
# CD-ROM drivers (not for SCSI or IDE/ATAPI drives)
#
# CONFIG_CD_NO_IDESCSI is not set
+CONFIG_CDROM=y
#
# Filesystems
@@ -199,25 +222,29 @@ CONFIG_DE4X5=y
# CONFIG_QUOTA is not set
# CONFIG_MINIX_FS is not set
CONFIG_EXT2_FS=y
+CONFIG_ISO9660_FS=y
+# CONFIG_JOLIET is not set
# CONFIG_FAT_FS is not set
# CONFIG_MSDOS_FS is not set
-# CONFIG_VFAT_FS is not set
# CONFIG_UMSDOS_FS is not set
+# CONFIG_VFAT_FS is not set
CONFIG_PROC_FS=y
CONFIG_NFS_FS=y
-# CONFIG_ROOT_NFS is not set
# CONFIG_NFSD is not set
CONFIG_SUNRPC=y
CONFIG_LOCKD=y
+# CONFIG_CODA_FS is not set
# CONFIG_SMB_FS is not set
-CONFIG_ISO9660_FS=y
# CONFIG_HPFS_FS is not set
+# CONFIG_NTFS_FS is not set
# CONFIG_SYSV_FS is not set
# CONFIG_AFFS_FS is not set
+# CONFIG_HFS_FS is not set
# CONFIG_ROMFS_FS is not set
# CONFIG_AUTOFS_FS is not set
# CONFIG_UFS_FS is not set
# CONFIG_MAC_PARTITION is not set
+# CONFIG_NLS is not set
#
# Character devices
@@ -225,6 +252,7 @@ CONFIG_ISO9660_FS=y
CONFIG_VT=y
CONFIG_VT_CONSOLE=y
CONFIG_SERIAL=y
+# CONFIG_SERIAL_CONSOLE is not set
# CONFIG_SERIAL_EXTENDED is not set
# CONFIG_SERIAL_NONSTANDARD is not set
CONFIG_MOUSE=y
@@ -236,12 +264,18 @@ CONFIG_PSMOUSE=y
# CONFIG_PC110_PAD is not set
# CONFIG_UMISC is not set
# CONFIG_QIC02_TAPE is not set
-# CONFIG_FTAPE is not set
# CONFIG_APM is not set
# CONFIG_WATCHDOG is not set
# CONFIG_RTC is not set
+# CONFIG_VIDEO_DEV is not set
# CONFIG_NVRAM is not set
# CONFIG_JOYSTICK is not set
+# CONFIG_MISC_RADIO is not set
+
+#
+# Ftape, the floppy tape device driver
+#
+# CONFIG_FTAPE is not set
#
# Sound
@@ -252,4 +286,5 @@ CONFIG_PSMOUSE=y
# Kernel hacking
#
# CONFIG_PROFILE is not set
+CONFIG_MATHEMU=y
# CONFIG_MAGIC_SYSRQ is not set
diff -ruNp 2.1.86/arch/alpha/kernel/Makefile 2.1.86-axp/arch/alpha/kernel/Makefile
--- 2.1.86/arch/alpha/kernel/Makefile Thu Jan 15 21:52:46 1998
+++ 2.1.86-axp/arch/alpha/kernel/Makefile Thu Feb 12 03:07:54 1998
@@ -16,7 +16,7 @@ all: kernel.o head.o
O_TARGET := kernel.o
O_OBJS := entry.o traps.o process.o osf_sys.o irq.o signal.o setup.o \
- bios32.o ptrace.o time.o
+ bios32.o ptrace.o time.o fpreg.o
OX_OBJS := alpha_ksyms.o
diff -ruNp 2.1.86/arch/alpha/kernel/alpha_ksyms.c 2.1.86-axp/arch/alpha/kernel/alpha_ksyms.c
--- 2.1.86/arch/alpha/kernel/alpha_ksyms.c Thu Feb 12 08:58:24 1998
+++ 2.1.86-axp/arch/alpha/kernel/alpha_ksyms.c Thu Feb 12 03:33:59 1998
@@ -21,6 +21,7 @@
#include <asm/checksum.h>
#include <linux/interrupt.h>
#include <asm/softirq.h>
+#include <asm/fpu.h>
#define __KERNEL_SYSCALLS__
#include <asm/unistd.h>
@@ -88,6 +89,8 @@ EXPORT_SYMBOL(dump_fpu);
EXPORT_SYMBOL(hwrpb);
EXPORT_SYMBOL(wrusp);
EXPORT_SYMBOL(start_thread);
+EXPORT_SYMBOL(alpha_read_fp_reg);
+EXPORT_SYMBOL(alpha_write_fp_reg);
/* In-kernel system calls. */
EXPORT_SYMBOL(__kernel_thread);
@@ -109,6 +112,11 @@ EXPORT_SYMBOL(ip_fast_csum);
EXPORT_SYMBOL(csum_partial_copy);
EXPORT_SYMBOL(csum_partial_copy_from_user);
EXPORT_SYMBOL(csum_ipv6_magic);
+
+#ifdef CONFIG_MATHEMU_MODULE
+extern long (*alpha_fp_emul_imprecise)(struct pt_regs *, unsigned long);
+EXPORT_SYMBOL(alpha_fp_emul_imprecise);
+#endif
/*
* The following are specially called from the uaccess assembly stubs.
diff -ruNp 2.1.86/arch/alpha/kernel/fpreg.c 2.1.86-axp/arch/alpha/kernel/fpreg.c
--- 2.1.86/arch/alpha/kernel/fpreg.c Wed Dec 31 16:00:00 1969
+++ 2.1.86-axp/arch/alpha/kernel/fpreg.c Thu Feb 12 03:07:38 1998
@@ -0,0 +1,104 @@
+/*
+ * kernel/fpreg.c
+ *
+ * (C) Copyright 1998 Linus Torvalds
+ */
+
+unsigned long
+alpha_read_fp_reg (unsigned long reg)
+{
+ unsigned long r;
+
+ switch (reg) {
+ case 0: asm ("stt $f0,%0" : "m="(r)); break;
+ case 1: asm ("stt $f1,%0" : "m="(r)); break;
+ case 2: asm ("stt $f2,%0" : "m="(r)); break;
+ case 3: asm ("stt $f3,%0" : "m="(r)); break;
+ case 4: asm ("stt $f4,%0" : "m="(r)); break;
+ case 5: asm ("stt $f5,%0" : "m="(r)); break;
+ case 6: asm ("stt $f6,%0" : "m="(r)); break;
+ case 7: asm ("stt $f7,%0" : "m="(r)); break;
+ case 8: asm ("stt $f8,%0" : "m="(r)); break;
+ case 9: asm ("stt $f9,%0" : "m="(r)); break;
+ case 10: asm ("stt $f10,%0" : "m="(r)); break;
+ case 11: asm ("stt $f11,%0" : "m="(r)); break;
+ case 12: asm ("stt $f12,%0" : "m="(r)); break;
+ case 13: asm ("stt $f13,%0" : "m="(r)); break;
+ case 14: asm ("stt $f14,%0" : "m="(r)); break;
+ case 15: asm ("stt $f15,%0" : "m="(r)); break;
+ case 16: asm ("stt $f16,%0" : "m="(r)); break;
+ case 17: asm ("stt $f17,%0" : "m="(r)); break;
+ case 18: asm ("stt $f18,%0" : "m="(r)); break;
+ case 19: asm ("stt $f19,%0" : "m="(r)); break;
+ case 20: asm ("stt $f20,%0" : "m="(r)); break;
+ case 21: asm ("stt $f21,%0" : "m="(r)); break;
+ case 22: asm ("stt $f22,%0" : "m="(r)); break;
+ case 23: asm ("stt $f23,%0" : "m="(r)); break;
+ case 24: asm ("stt $f24,%0" : "m="(r)); break;
+ case 25: asm ("stt $f25,%0" : "m="(r)); break;
+ case 26: asm ("stt $f26,%0" : "m="(r)); break;
+ case 27: asm ("stt $f27,%0" : "m="(r)); break;
+ case 28: asm ("stt $f28,%0" : "m="(r)); break;
+ case 29: asm ("stt $f29,%0" : "m="(r)); break;
+ case 30: asm ("stt $f30,%0" : "m="(r)); break;
+ case 31: asm ("stt $f31,%0" : "m="(r)); break;
+ default:
+ break;
+ }
+ return r;
+}
+
+#if 1
+/*
+ * This is IMHO the better way of implementing LDT(). But it
+ * has the disadvantage that gcc 2.7.0 refuses to compile it
+ * (invalid operand constraints), so instead, we use the uglier
+ * macro below.
+ */
+# define LDT(reg,val) \
+ asm volatile ("ldt $f"#reg",%0" : : "m"(val));
+#else
+# define LDT(reg,val) \
+ asm volatile ("ldt $f"#reg",0(%0)" : : "r"(&val));
+#endif
+
+void
+alpha_write_fp_reg (unsigned long reg, unsigned long val)
+{
+ switch (reg) {
+ case 0: LDT( 0, val); break;
+ case 1: LDT( 1, val); break;
+ case 2: LDT( 2, val); break;
+ case 3: LDT( 3, val); break;
+ case 4: LDT( 4, val); break;
+ case 5: LDT( 5, val); break;
+ case 6: LDT( 6, val); break;
+ case 7: LDT( 7, val); break;
+ case 8: LDT( 8, val); break;
+ case 9: LDT( 9, val); break;
+ case 10: LDT(10, val); break;
+ case 11: LDT(11, val); break;
+ case 12: LDT(12, val); break;
+ case 13: LDT(13, val); break;
+ case 14: LDT(14, val); break;
+ case 15: LDT(15, val); break;
+ case 16: LDT(16, val); break;
+ case 17: LDT(17, val); break;
+ case 18: LDT(18, val); break;
+ case 19: LDT(19, val); break;
+ case 20: LDT(20, val); break;
+ case 21: LDT(21, val); break;
+ case 22: LDT(22, val); break;
+ case 23: LDT(23, val); break;
+ case 24: LDT(24, val); break;
+ case 25: LDT(25, val); break;
+ case 26: LDT(26, val); break;
+ case 27: LDT(27, val); break;
+ case 28: LDT(28, val); break;
+ case 29: LDT(29, val); break;
+ case 30: LDT(30, val); break;
+ case 31: LDT(31, val); break;
+ default:
+ break;
+ }
+}
diff -ruNp 2.1.86/arch/alpha/kernel/head.S 2.1.86-axp/arch/alpha/kernel/head.S
--- 2.1.86/arch/alpha/kernel/head.S Thu Jan 15 21:52:46 1998
+++ 2.1.86-axp/arch/alpha/kernel/head.S Thu Feb 12 03:24:29 1998
@@ -121,37 +121,3 @@ cserve_dis:
call_pal PAL_cserve
ret ($26)
.end cserve_dis
-
- #
- # The following two functions don't need trapb/excb instructions
- # around the mf_fpcr/mt_fpcr instructions because (a) the kernel
- # never generates arithmetic faults and (b) call_pal instructions
- # are implied trap barriers.
- #
- .align 3
- .globl rdfpcr
- .ent rdfpcr
-rdfpcr:
- lda $30,-0x10($30)
- stt $f0,0($30)
- mf_fpcr $f0
- stt $f0,8($30)
- ldt $f0,0($30)
- ldq $0,8($30)
- lda $30,0x10($30)
- ret ($26)
- .end rdfpcr
-
- .align 3
- .globl wrfpcr
- .ent wrfpcr
-wrfpcr:
- lda $30,-0x10($30)
- stt $f0,0($30)
- stq $16,8($30)
- ldt $f0,8($30)
- mt_fpcr $f0
- ldt $f0,0($30)
- lda $30,0x10($30)
- ret ($26)
- .end wrfpcr
diff -ruNp 2.1.86/arch/alpha/kernel/traps.c 2.1.86-axp/arch/alpha/kernel/traps.c
--- 2.1.86/arch/alpha/kernel/traps.c Thu Feb 12 08:58:24 1998
+++ 2.1.86-axp/arch/alpha/kernel/traps.c Thu Feb 12 04:59:19 1998
@@ -105,14 +105,24 @@ void die_if_kernel(char * str, struct pt
do_exit(SIGSEGV);
}
+#ifndef CONFIG_MATHEMU
+static long dummy_alpha_fp_emul_imprecise(struct pt_regs *r, unsigned long wm)
+{
+ return 0;
+}
+
+long (*alpha_fp_emul_imprecise)(struct pt_regs *regs, unsigned long writemask)
+ = dummy_alpha_fp_emul_imprecise;
+#else
+long alpha_fp_emul_imprecise(struct pt_regs *regs, unsigned long writemask);
+#endif
+
asmlinkage void do_entArith(unsigned long summary, unsigned long write_mask,
unsigned long a2, unsigned long a3,
unsigned long a4, unsigned long a5,
struct pt_regs regs)
{
if ((summary & 1)) {
- extern long alpha_fp_emul_imprecise (struct pt_regs * regs,
- unsigned long write_mask);
/*
* Software-completion summary bit is set, so try to
* emulate the instruction.
diff -ruNp 2.1.86/arch/alpha/math-emu/Makefile 2.1.86-axp/arch/alpha/math-emu/Makefile
--- 2.1.86/arch/alpha/math-emu/Makefile Thu Dec 21 22:22:05 1995
+++ 2.1.86-axp/arch/alpha/math-emu/Makefile Thu Feb 12 05:28:31 1998
@@ -2,11 +2,11 @@
# Makefile for math-emulator files...
#
-OBJS = fp-emul.o ieee-math.o
+O_TARGET := math-emu.o
+O_OBJS := fp-emul.o ieee-math.o
-math-emu.a: $(OBJS)
- $(AR) rcs $@ $(OBJS)
-
-dep:
+ifeq ($(CONFIG_MATHEMU),m)
+M_OBJS := $(O_TARGET)
+endif
include $(TOPDIR)/Rules.make
diff -ruNp 2.1.86/arch/alpha/math-emu/fp-emul.c 2.1.86-axp/arch/alpha/math-emu/fp-emul.c
--- 2.1.86/arch/alpha/math-emu/fp-emul.c Sat Jul 26 15:17:14 1997
+++ 2.1.86-axp/arch/alpha/math-emu/fp-emul.c Thu Feb 12 03:18:52 1998
@@ -1,5 +1,5 @@
+#include <linux/module.h>
#include <linux/types.h>
-
#include <linux/kernel.h>
#include <linux/sched.h>
@@ -52,111 +52,33 @@
#define MISC_TRAPB 0x0000
#define MISC_EXCB 0x0400
-
-extern unsigned long rdfpcr (void);
-extern void wrfpcr (unsigned long);
+extern unsigned long alpha_read_fp_reg (unsigned long reg);
+extern void alpha_write_fp_reg (unsigned long reg, unsigned long val);
-unsigned long
-alpha_read_fp_reg (unsigned long reg)
-{
- unsigned long r;
+#ifdef MODULE
- switch (reg) {
- case 0: asm ("stt $f0,%0" : "m="(r)); break;
- case 1: asm ("stt $f1,%0" : "m="(r)); break;
- case 2: asm ("stt $f2,%0" : "m="(r)); break;
- case 3: asm ("stt $f3,%0" : "m="(r)); break;
- case 4: asm ("stt $f4,%0" : "m="(r)); break;
- case 5: asm ("stt $f5,%0" : "m="(r)); break;
- case 6: asm ("stt $f6,%0" : "m="(r)); break;
- case 7: asm ("stt $f7,%0" : "m="(r)); break;
- case 8: asm ("stt $f8,%0" : "m="(r)); break;
- case 9: asm ("stt $f9,%0" : "m="(r)); break;
- case 10: asm ("stt $f10,%0" : "m="(r)); break;
- case 11: asm ("stt $f11,%0" : "m="(r)); break;
- case 12: asm ("stt $f12,%0" : "m="(r)); break;
- case 13: asm ("stt $f13,%0" : "m="(r)); break;
- case 14: asm ("stt $f14,%0" : "m="(r)); break;
- case 15: asm ("stt $f15,%0" : "m="(r)); break;
- case 16: asm ("stt $f16,%0" : "m="(r)); break;
- case 17: asm ("stt $f17,%0" : "m="(r)); break;
- case 18: asm ("stt $f18,%0" : "m="(r)); break;
- case 19: asm ("stt $f19,%0" : "m="(r)); break;
- case 20: asm ("stt $f20,%0" : "m="(r)); break;
- case 21: asm ("stt $f21,%0" : "m="(r)); break;
- case 22: asm ("stt $f22,%0" : "m="(r)); break;
- case 23: asm ("stt $f23,%0" : "m="(r)); break;
- case 24: asm ("stt $f24,%0" : "m="(r)); break;
- case 25: asm ("stt $f25,%0" : "m="(r)); break;
- case 26: asm ("stt $f26,%0" : "m="(r)); break;
- case 27: asm ("stt $f27,%0" : "m="(r)); break;
- case 28: asm ("stt $f28,%0" : "m="(r)); break;
- case 29: asm ("stt $f29,%0" : "m="(r)); break;
- case 30: asm ("stt $f30,%0" : "m="(r)); break;
- case 31: asm ("stt $f31,%0" : "m="(r)); break;
- default:
- break;
- }
- return r;
-}
+MODULE_DESCRIPTION("FP Software completion module");
+extern long (*alpha_fp_emul_imprecise)(struct pt_regs *, unsigned long);
+static long (*save_emul)(struct pt_regs *, unsigned long);
+long do_alpha_fp_emul_imprecise(struct pt_regs *, unsigned long);
-#if 0
-/*
- * This is IMHO the better way of implementing LDT(). But it
- * has the disadvantage that gcc 2.7.0 refuses to compile it
- * (invalid operand constraints), so instead, we use the uglier
- * macro below.
- */
-# define LDT(reg,val) \
- asm volatile ("ldt $f"#reg",%0" :: "m"(val));
-#else
-# define LDT(reg,val) \
- asm volatile ("ldt $f"#reg",0(%0)" :: "r"(&val));
-#endif
+int init_module(void)
+{
+ save_emul = alpha_fp_emul_imprecise;
+ alpha_fp_emul_imprecise = do_alpha_fp_emul_imprecise;
+ return 0;
+}
-void
-alpha_write_fp_reg (unsigned long reg, unsigned long val)
+void cleanup_module(void)
{
- switch (reg) {
- case 0: LDT( 0, val); break;
- case 1: LDT( 1, val); break;
- case 2: LDT( 2, val); break;
- case 3: LDT( 3, val); break;
- case 4: LDT( 4, val); break;
- case 5: LDT( 5, val); break;
- case 6: LDT( 6, val); break;
- case 7: LDT( 7, val); break;
- case 8: LDT( 8, val); break;
- case 9: LDT( 9, val); break;
- case 10: LDT(10, val); break;
- case 11: LDT(11, val); break;
- case 12: LDT(12, val); break;
- case 13: LDT(13, val); break;
- case 14: LDT(14, val); break;
- case 15: LDT(15, val); break;
- case 16: LDT(16, val); break;
- case 17: LDT(17, val); break;
- case 18: LDT(18, val); break;
- case 19: LDT(19, val); break;
- case 20: LDT(20, val); break;
- case 21: LDT(21, val); break;
- case 22: LDT(22, val); break;
- case 23: LDT(23, val); break;
- case 24: LDT(24, val); break;
- case 25: LDT(25, val); break;
- case 26: LDT(26, val); break;
- case 27: LDT(27, val); break;
- case 28: LDT(28, val); break;
- case 29: LDT(29, val); break;
- case 30: LDT(30, val); break;
- case 31: LDT(31, val); break;
- default:
- break;
- }
+ alpha_fp_emul_imprecise = save_emul;
}
+#define alpha_fp_emul_imprecise do_alpha_fp_emul_imprecise
+
+#endif /* MODULE */
/*
* Emulate the floating point instruction at address PC. Returns 0 if
@@ -334,6 +256,8 @@ alpha_fp_emul_imprecise (struct pt_regs
unsigned long trigger_pc = regs->pc - 4;
unsigned long insn, opcode, rc;
+ MOD_INC_USE_COUNT;
+
/*
* Turn off the bits corresponding to registers that are the
* target of instructions that set bits in the exception
@@ -354,12 +278,14 @@ alpha_fp_emul_imprecise (struct pt_regs
case OPC_PAL:
case OPC_JSR:
case 0x30 ... 0x3f: /* branches */
+ MOD_DEC_USE_COUNT;
return 0;
case OPC_MISC:
switch (insn & 0xffff) {
case MISC_TRAPB:
case MISC_EXCB:
+ MOD_DEC_USE_COUNT;
return 0;
default:
@@ -386,11 +312,13 @@ alpha_fp_emul_imprecise (struct pt_regs
{
/* re-execute insns in trap-shadow: */
regs->pc = trigger_pc + 4;
+ MOD_DEC_USE_COUNT;
return 1;
}
break;
}
trigger_pc -= 4;
}
+ MOD_DEC_USE_COUNT;
return 0;
}
diff -ruNp 2.1.86/arch/alpha/math-emu/ieee-math.c 2.1.86-axp/arch/alpha/math-emu/ieee-math.c
--- 2.1.86/arch/alpha/math-emu/ieee-math.c Thu Apr 11 23:49:30 1996
+++ 2.1.86-axp/arch/alpha/math-emu/ieee-math.c Thu Feb 12 04:51:45 1998
@@ -137,9 +137,8 @@ sub128 (const unsigned long a[2], const
static inline void
mul64 (const unsigned long a, const unsigned long b, unsigned long c[2])
{
- asm ("mulq %2,%3,%0\n\t"
- "umulh %2,%3,%1"
- : "r="(c[0]), "r="(c[1]) : "r"(a), "r"(b));
+ c[0] = a * b;
+ asm ("umulh %1,%2,%0" : "=r"(c[1]) : "r"(a), "r"(b));
}
@@ -276,7 +275,7 @@ make_s_ieee (long f, EXTENDED *a, unsign
{
unsigned long res, sticky;
- if (!a->f[0] && !a->f[1]) {
+ if (!a->e && !a->f[0] && !a->f[1]) {
*b = (unsigned long) a->s << 63; /* return +/-0 */
return 0;
}
@@ -356,7 +355,7 @@ make_t_ieee (long f, EXTENDED *a, unsign
{
unsigned long res, sticky;
- if (!a->f[0] && !a->f[1]) {
+ if (!a->e && !a->f[0] && !a->f[1]) {
*b = (unsigned long) a->s << 63; /* return +/-0 */
return 0;
}
@@ -384,7 +383,7 @@ make_t_ieee (long f, EXTENDED *a, unsign
a->e = -0x3ff;
}
}
- if (a->e > 0x3ff) {
+ if (a->e >= 0x3ff) {
res = FPCR_OVF | FPCR_INE;
if (f & IEEE_TRAP_ENABLE_OVF) {
a->e -= 0x600; /* scale down result by 2^alpha */
@@ -1143,12 +1142,9 @@ ieee_MULS (int f, unsigned long a, unsig
return 0;
}
op_c.s = op_a.s ^ op_b.s;
- op_c.e = op_a.e + op_b.e;
+ op_c.e = op_a.e + op_b.e - 55;
mul64(op_a.f[0], op_b.f[0], op_c.f);
- normalize(&op_c);
- op_c.e -= 55; /* drop the 55 original bits. */
-
return round_s_ieee(f, &op_c, c);
}
@@ -1200,11 +1196,8 @@ ieee_MULT (int f, unsigned long a, unsig
return 0;
}
op_c.s = op_a.s ^ op_b.s;
- op_c.e = op_a.e + op_b.e;
+ op_c.e = op_a.e + op_b.e - 55;
mul64(op_a.f[0], op_b.f[0], op_c.f);
-
- normalize(&op_c);
- op_c.e -= 55; /* drop the 55 original bits. */
return round_t_ieee(f, &op_c, c);
}
diff -ruNp 2.1.86/include/asm-alpha/fpu.h 2.1.86-axp/include/asm-alpha/fpu.h
--- 2.1.86/include/asm-alpha/fpu.h Thu Jan 15 21:53:04 1998
+++ 2.1.86-axp/include/asm-alpha/fpu.h Thu Feb 12 03:33:30 1998
@@ -81,7 +81,38 @@ ieee_swcr_to_fpcr(unsigned long sw)
return fp;
}
-extern unsigned long rdfpcr(void);
-extern void wrfpcr(unsigned long);
+#ifdef __KERNEL__
+
+/* The following two functions don't need trapb/excb instructions
+ around the mf_fpcr/mt_fpcr instructions because (a) the kernel
+ never generates arithmetic faults and (b) call_pal instructions
+ are implied trap barriers. */
+
+static inline unsigned long rdfpcr(void)
+{
+ unsigned long tmp, ret;
+ __asm__ ("stt $f0,%0\n\t"
+ "mf_fpcr $f0\n\t"
+ "stt $f0,%1\n\t"
+ "ldt $f0,%0"
+ : "=m"(tmp), "=m"(ret));
+ return ret;
+}
+
+static inline void wrfpcr(unsigned long val)
+{
+ unsigned long tmp;
+ __asm__ __volatile__ (
+ "stt $f0,%0\n\t"
+ "ldt $f0,%1\n\t"
+ "mt_fpcr $f0\n\t"
+ "ldt $f0,%0"
+ : "=m"(tmp) : "m"(val));
+}
+
+extern unsigned long alpha_read_fp_reg (unsigned long reg);
+extern void alpha_write_fp_reg (unsigned long reg, unsigned long val);
+
+#endif /* __KERNEL__ */
#endif /* __ASM_ALPHA_FPU_H */
--gBBFr7Ir9EOA20Yy--
--
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
^ permalink raw reply [flat|nested] 3+ messages in thread