Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/i386/i386 Rework how user-mode instruction and stac...



details:   https://anonhg.NetBSD.org/src/rev/ea2c91916efe
branches:  trunk
changeset: 511235:ea2c91916efe
user:      sommerfeld <sommerfeld%NetBSD.org@localhost>
date:      Fri Jun 15 05:43:40 2001 +0000

description:
Rework how user-mode instruction and stack fetches are done.
While we're in here, catch another vm86 protocol botch.

diffstat:

 sys/arch/i386/i386/vm86.c |  75 +++++++++++++---------------------------------
 1 files changed, 21 insertions(+), 54 deletions(-)

diffs (106 lines):

diff -r ea1d70a7b197 -r ea2c91916efe sys/arch/i386/i386/vm86.c
--- a/sys/arch/i386/i386/vm86.c Fri Jun 15 04:01:39 2001 +0000
+++ b/sys/arch/i386/i386/vm86.c Fri Jun 15 05:43:40 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vm86.c,v 1.23 2000/12/22 22:58:54 jdolecek Exp $       */
+/*     $NetBSD: vm86.c,v 1.24 2001/06/15 05:43:40 sommerfeld Exp $     */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -69,68 +69,28 @@
 #define        SS(tf)          (*(u_short *)&tf->tf_ss)
 #define        SP(tf)          (*(u_short *)&tf->tf_esp)
 
-
 #define putword(base, ptr, val) \
-__asm__ __volatile__( \
-       "decw %w0\n\t" \
-       "movb %h2,0(%1,%0)\n\t" \
-       "decw %w0\n\t" \
-       "movb %b2,0(%1,%0)" \
-       : "=r" (ptr) \
-       : "r" (base), "q" (val), "0" (ptr))
+       ({ ptr = (ptr - 1) & 0xffff;                    \
+          subyte((void *)(base+ptr), (val>>8));                        \
+           ptr = (ptr - 1) & 0xffff;                   \
+          subyte((void *)(base+ptr), (val&0xff)); })
 
 #define putdword(base, ptr, val) \
-__asm__ __volatile__( \
-       "rorl $16,%2\n\t" \
-       "decw %w0\n\t" \
-       "movb %h2,0(%1,%0)\n\t" \
-       "decw %w0\n\t" \
-       "movb %b2,0(%1,%0)\n\t" \
-       "rorl $16,%2\n\t" \
-       "decw %w0\n\t" \
-       "movb %h2,0(%1,%0)\n\t" \
-       "decw %w0\n\t" \
-       "movb %b2,0(%1,%0)" \
-       : "=r" (ptr) \
-       : "r" (base), "q" (val), "0" (ptr))
+       ({ putword(base, ptr, (val >> 16));             \
+          putword(base, ptr, (val & 0xffff)); })
 
 #define getbyte(base, ptr) \
-({ unsigned long __res; \
-__asm__ __volatile__( \
-       "movb 0(%1,%0),%b2\n\t" \
-       "incw %w0" \
-       : "=r" (ptr), "=r" (base), "=q" (__res) \
-       : "0" (ptr), "1" (base), "2" (0)); \
-__res; })
+       ({ unsigned long __tmp = fubyte((void *)(base+ptr));     \
+          if (__tmp == ~0) goto bad;                            \
+          ptr = (ptr + 1) & 0xffff; __tmp; })
 
 #define getword(base, ptr) \
-({ unsigned long __res; \
-__asm__ __volatile__( \
-       "movb 0(%1,%0),%b2\n\t" \
-       "incw %w0\n\t" \
-       "movb 0(%1,%0),%h2\n\t" \
-       "incw %w0" \
-       : "=r" (ptr), "=r" (base), "=q" (__res) \
-       : "0" (ptr), "1" (base), "2" (0)); \
-__res; })
+       ({ unsigned long __tmp = getbyte(base, ptr);    \
+          __tmp |= (getbyte(base, ptr) << 8); __tmp;})
 
 #define getdword(base, ptr) \
-({ unsigned long __res; \
-__asm__ __volatile__( \
-       "movb 0(%1,%0),%b2\n\t" \
-       "incw %w0\n\t" \
-       "movb 0(%1,%0),%h2\n\t" \
-       "incw %w0\n\t" \
-       "rorl $16,%2\n\t" \
-       "movb 0(%1,%0),%b2\n\t" \
-       "incw %w0\n\t" \
-       "movb 0(%1,%0),%h2\n\t" \
-       "incw %w0\n\t" \
-       "rorl $16,%2" \
-       : "=r" (ptr), "=r" (base), "=q" (__res) \
-       : "0" (ptr), "1" (base)); \
-__res; })
-
+       ({ unsigned long __tmp = getword(base, ptr);    \
+          __tmp |= (getword(base, ptr) << 16); __tmp;})
 
 static __inline int
 is_bitset(nr, bitmap)
@@ -242,7 +202,14 @@
 #endif
                sigexit(p, SIGILL);
                /* NOTREACHED */
+       } else if (sigismember(&p->p_sigctx.ps_sigignore, SIGURG)) {
+#ifdef DIAGNOSTIC
+               printf("pid %d killed on VM86 protocol screwup (SIGURG ignored)\n",
+                   p->p_pid);
+#endif
+               sigexit(p, SIGILL);
        }
+       
        trapsignal(p, SIGURG, retval);
 }
 



Home | Main Index | Thread Index | Old Index