Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/usermode Get rid of MAP_NOSYSCALLS usage; now this ...



details:   https://anonhg.NetBSD.org/src/rev/5daaa9e9c9dd
branches:  trunk
changeset: 772475:5daaa9e9c9dd
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Thu Jan 05 12:12:58 2012 +0000

description:
Get rid of MAP_NOSYSCALLS usage; now this relies on a separate kmod that
you can get here: http://www.netbsd.org/~jmcneill/syscallemu.tar

diffstat:

 sys/arch/usermode/conf/Makefile.usermode |   3 ++-
 sys/arch/usermode/include/thunk.h        |   5 +++--
 sys/arch/usermode/usermode/pmap.c        |  11 +++++++----
 sys/arch/usermode/usermode/thunk.c       |  28 +++++++++++++++++++---------
 4 files changed, 31 insertions(+), 16 deletions(-)

diffs (145 lines):

diff -r 3e9b84c483bf -r 5daaa9e9c9dd sys/arch/usermode/conf/Makefile.usermode
--- a/sys/arch/usermode/conf/Makefile.usermode  Thu Jan 05 07:05:59 2012 +0000
+++ b/sys/arch/usermode/conf/Makefile.usermode  Thu Jan 05 12:12:58 2012 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.usermode,v 1.27 2011/12/31 21:24:07 christos Exp $
+# $NetBSD: Makefile.usermode,v 1.28 2012/01/05 12:12:58 jmcneill Exp $
 
 OPT_CPU_HOST=                  %CPU_HOST%
 .if !empty(OPT_CPU_HOST)
@@ -35,6 +35,7 @@
 
 DEFCOPTS=      -fno-omit-frame-pointer
 CPPFLAGS+=     -Dusermode
+CPPFLAGS+=     -Dsyscall=kernel_syscall
 CPPFLAGS.init_main.c+= -Dmain=kernmain
 
 CPPFLAGS.thunk.c+=     ${USERMODE_CPPFLAGS}
diff -r 3e9b84c483bf -r 5daaa9e9c9dd sys/arch/usermode/include/thunk.h
--- a/sys/arch/usermode/include/thunk.h Thu Jan 05 07:05:59 2012 +0000
+++ b/sys/arch/usermode/include/thunk.h Thu Jan 05 12:12:58 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.55 2012/01/03 12:05:01 reinoud Exp $ */
+/* $NetBSD: thunk.h,v 1.56 2012/01/05 12:12:58 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -61,7 +61,6 @@
 #define THUNK_MAP_FILE         0x0004
 #define THUNK_MAP_SHARED       0x0010
 #define THUNK_MAP_PRIVATE      0x0020
-#define THUNK_MAP_NOSYSCALLS   0x0040
 
 #define THUNK_PROT_NONE                0x00
 #define THUNK_PROT_READ                0x01
@@ -73,6 +72,8 @@
 void   thunk_printf_debug(const char *fmt, ...) __attribute__((__format__(__printf__, 1, 2)));
 void   thunk_printf(const char *fmt, ...) __attribute__((__format__(__printf__, 1, 2)));
 
+int    thunk_syscallemu_init(void *, void *);
+
 int    thunk_setitimer(int, const struct thunk_itimerval *, struct thunk_itimerval *);
 int    thunk_gettimeofday(struct thunk_timeval *, void *);
 unsigned int thunk_getcounter(void);
diff -r 3e9b84c483bf -r 5daaa9e9c9dd sys/arch/usermode/usermode/pmap.c
--- a/sys/arch/usermode/usermode/pmap.c Thu Jan 05 07:05:59 2012 +0000
+++ b/sys/arch/usermode/usermode/pmap.c Thu Jan 05 12:12:58 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.96 2012/01/04 16:20:41 reinoud Exp $ */
+/* $NetBSD: pmap.c,v 1.97 2012/01/05 12:12:58 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Reinoud Zandijk <reinoud%NetBSD.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.96 2012/01/04 16:20:41 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.97 2012/01/05 12:12:58 jmcneill Exp $");
 
 #include "opt_memsize.h"
 #include "opt_kmempages.h"
@@ -399,6 +399,11 @@
            atop(free_end), 
            VM_FREELIST_DEFAULT);
 
+       /* setup syscall emulation */
+       if (thunk_syscallemu_init((void *)VM_MIN_ADDRESS,
+           (void *)VM_MAXUSER_ADDRESS) != 0)
+               panic("couldn't enable syscall emulation");
+
        aprint_verbose("leaving pmap_bootstrap:\n");
        aprint_verbose("\t%"PRIu64" MB of physical pages left\n",
                (uint64_t) (free_end - (free_start + fpos))/1024/1024);
@@ -735,8 +740,6 @@
        void *addr;
 
        map_flags = THUNK_MAP_FILE | THUNK_MAP_FIXED | THUNK_MAP_SHARED;
-       if ((va >= VM_MIN_ADDRESS) && (va < VM_MAXUSER_ADDRESS)) 
-               map_flags |= THUNK_MAP_NOSYSCALLS;
 
        addr = thunk_mmap((void *) va, PAGE_SIZE, pv->pv_mmap_ppl,
                map_flags, mem_fh, pa);
diff -r 3e9b84c483bf -r 5daaa9e9c9dd sys/arch/usermode/usermode/thunk.c
--- a/sys/arch/usermode/usermode/thunk.c        Thu Jan 05 07:05:59 2012 +0000
+++ b/sys/arch/usermode/usermode/thunk.c        Thu Jan 05 12:12:58 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.73 2012/01/04 13:31:30 reinoud Exp $ */
+/* $NetBSD: thunk.c,v 1.74 2012/01/05 12:12:58 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifdef __NetBSD__
-__RCSID("$NetBSD: thunk.c,v 1.73 2012/01/04 13:31:30 reinoud Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.74 2012/01/05 12:12:58 jmcneill Exp $");
 #endif
 
 #include <sys/types.h>
@@ -69,6 +69,10 @@
 
 #include "../include/thunk.h"
 
+#ifdef __NetBSD__
+#define SYS_syscallemu 511
+#endif
+
 #ifndef __arraycount
 #define __arraycount(x)        (sizeof((x)) / sizeof((x)[0]))
 #endif
@@ -104,6 +108,19 @@
        fflush(stderr);
 }
 
+int
+thunk_syscallemu_init(void *ustart, void *uend)
+{
+       int error;
+
+       fprintf(stdout, "%s: syscall(%d, %p, %p)\n", __func__,
+           SYS_syscallemu, ustart, uend);
+       error = syscall(SYS_syscallemu, (uintptr_t)ustart, (uintptr_t)uend);
+       fprintf(stdout, "%s: returned %d\n", __func__, error);
+
+       return error;
+}
+
 static void
 thunk_to_timeval(const struct thunk_timeval *ttv, struct timeval *tv)
 {
@@ -192,13 +209,6 @@
                nflags |= MAP_SHARED;
        if (flags & THUNK_MAP_PRIVATE)
                nflags |= MAP_PRIVATE;
-#ifndef MAP_NOSYSCALLS
-#define MAP_NOSYSCALLS (1<<16)         /* XXX alias for now XXX */
-#endif
-#ifdef MAP_NOSYSCALLS
-       if (flags & THUNK_MAP_NOSYSCALLS)
-               nflags |= MAP_NOSYSCALLS;
-#endif
 
        return nflags;
 }



Home | Main Index | Thread Index | Old Index