Subject: Re: awk dumping core on -current snapshot
To: Tillman Hodgson <tillman@seekingfire.com>
From: Hugh Graham <hugh@openbsd.org>
List: port-vax
Date: 07/30/2004 15:07:28
On Fri, Jul 30, 2004 at 03:49:24PM -0600, Tillman Hodgson wrote:
> On Mon, Jul 19, 2004 at 01:36:15PM -0600, Tillman Hodgson wrote:
> > On Mon, Jul 19, 2004 at 11:53:45AM -0700, Hugh Graham wrote:
> > > Rambling on assuming it is indeed emodd, Brandon did write kernel
> > > emulation for it a while back, which has been incorporated into
> > > NetBSD. Was your kernel built with NO_INSN_EMULATE defined?
> > 
> > I'm using a base (no X) install with the generic kernel.
> 
> And it is indeed not built in GENERIC:
> 
> [root@lapislazuli /usr/src/sys/arch/vax/conf]# grep NO_INSN_EMULATE GENERIC
> #options        NO_INSN_EMULATE # CPU does not lack some hardware instructions.

It's there. It's just so much default that you need an option
to turn it off!
> 
> I can't fit /usr/src on the Vax, so it looks like I get to figure out
> how to do kernel cross-builds from the SGI O2 ;-)
> 
> If this emulation is required for some percentage of Vax hardware, would
> providing two pre-built GENERIC kernels make sense (like the sgimips
> IP22/IP32 situation)?

You could put a counter on the "privileged instruction" vector to
see how much it's getting used, though outside of modf and pieces
of libm I've not encountered missing instructions.

I also did a hack like this in OpenBSD so that modf wouldn't have
to fall back to kernel emodd emulation unless the number was too
big to fit a longword. (much faster on most systems in the typical
case, and little overhead otherwise)

/Hugh

Index: modf.S
===================================================================
RCS file: /cvs/src/lib/libc/arch/vax/gen/modf.S,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- modf.S	18 Mar 2001 07:29:04 -0000	1.3
+++ modf.S	18 Apr 2001 11:53:39 -0000	1.4
@@ -33,7 +33,7 @@
 
 #if defined(LIBC_SCCS)
 	.text
-	.asciz "$OpenBSD: modf.S,v 1.3 2001/03/18 07:29:04 bjc Exp $"
+	.asciz "$OpenBSD: modf.S,v 1.4 2001/04/18 11:53:39 hugh Exp $"
 #endif /* LIBC_SCCS */
 
 /*
@@ -47,8 +47,14 @@
 #include "DEFS.h"
 
 ENTRY(modf, R2)
+	cvtdl	4(ap),r2
+	bvs	0f
+	cvtld	r2,*12(ap)
+	subd3	*12(ap),4(ap),r0
+	ret
+0:
 	emodd	4(ap),$0,$0f1.0,r2,r0
-	jvs	1f			# integer overflow
+	bvs	1f			# integer overflow
 	cvtld	r2,*12(ap)
 	ret
 1: