Subject: Crashes on fpu-less computers
To: None <tech-kern@NetBSD.org>
From: Julio M. Merino Vidal <jmmv@menta.net>
List: tech-kern
Date: 07/17/2004 22:29:52
Hi all,

just get a 2.0/current kernel and run it on a fpu-less 68k based computer.
It will crash just at the beginning of the boot.  Well, in fact I don't
know for all archs; I've only tested it in mac68k with a 680LC40 processor.

This problem comes from the following commit, introduced in the nathan_sa
branch:

	http://mail-index.netbsd.org/source-changes/2001/12/02/0068.html

which added this in machdep.c files:

	if (fputype != FPU_NONE)
		m68k_make_fpu_idle_frame();

These are executed very early in the kernel boot, even before the fpu
is initialized.  This means that fputype value is _always_ the same (the
default value assigned to it, which for mac68k is different than FPU_NONE).
This piece of code can't be correct (the conditional is useless).

I have pasted a patch below that attempts to fix it for mac68k (it'll
probably need to be applied to all other archs affected by the mentioned
commit).  I'm asking because, although this works, it may not be correct
from sa's point of view.  Can anybody review it, please?

PR port-mac68k/26250 which contains a bit more of info.

Thanks.

Index: fpu.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mac68k/mac68k/fpu.c,v
retrieving revision 1.30
diff -u -r1.30 fpu.c
--- fpu.c	15 Jul 2003 02:43:20 -0000	1.30
+++ fpu.c	17 Jul 2004 16:15:49 -0000
@@ -99,6 +99,10 @@
 	char *descr;
 
 	fputype = fpu_probe();
+
+	if (fputype != FPU_NONE)
+		m68k_make_fpu_idle_frame();
+
 	if ((0 <= fputype) && (fputype <= 3))
 		descr = fpu_descr[fputype];
 	else
Index: machdep.c
===================================================================
RCS file: /cvsroot/src/sys/arch/mac68k/mac68k/machdep.c,v
retrieving revision 1.297
diff -u -r1.297 machdep.c
--- machdep.c	24 Mar 2004 15:34:49 -0000	1.297
+++ machdep.c	17 Jul 2004 16:15:49 -0000
@@ -422,9 +422,6 @@
 	int delay;
 	char pbuf[9];
 
-	if (fputype != FPU_NONE)
-		m68k_make_fpu_idle_frame();
-
 	/*
 	 * Initialize the kernel crash dump header.
 	 */

-- 
Julio M. Merino Vidal <jmmv@menta.net>
http://www.livejournal.com/users/jmmv/
The NetBSD Project - http://www.NetBSD.org/