Module Name: src
Committed By: jmcneill
Date: Thu Jan 5 12:12:58 UTC 2012
Modified Files:
src/sys/arch/usermode/conf: Makefile.usermode
src/sys/arch/usermode/include: thunk.h
src/sys/arch/usermode/usermode: pmap.c thunk.c
Log Message:
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
To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/usermode/conf/Makefile.usermode
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/usermode/include/thunk.h
cvs rdiff -u -r1.96 -r1.97 src/sys/arch/usermode/usermode/pmap.c
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/usermode/usermode/thunk.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/usermode/conf/Makefile.usermode
diff -u src/sys/arch/usermode/conf/Makefile.usermode:1.27 src/sys/arch/usermode/conf/Makefile.usermode:1.28
--- src/sys/arch/usermode/conf/Makefile.usermode:1.27 Sat Dec 31 21:24:07 2011
+++ src/sys/arch/usermode/conf/Makefile.usermode Thu Jan 5 12:12:58 2012
@@ -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 @@ CPPFLAGS+=-D__NetBSD__ -Wno-unused-but-s
DEFCOPTS= -fno-omit-frame-pointer
CPPFLAGS+= -Dusermode
+CPPFLAGS+= -Dsyscall=kernel_syscall
CPPFLAGS.init_main.c+= -Dmain=kernmain
CPPFLAGS.thunk.c+= ${USERMODE_CPPFLAGS}
Index: src/sys/arch/usermode/include/thunk.h
diff -u src/sys/arch/usermode/include/thunk.h:1.55 src/sys/arch/usermode/include/thunk.h:1.56
--- src/sys/arch/usermode/include/thunk.h:1.55 Tue Jan 3 12:05:01 2012
+++ src/sys/arch/usermode/include/thunk.h Thu Jan 5 12:12:58 2012
@@ -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 <[email protected]>
@@ -61,7 +61,6 @@ struct thunk_termios {
#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 @@ struct aiocb;
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);
Index: src/sys/arch/usermode/usermode/pmap.c
diff -u src/sys/arch/usermode/usermode/pmap.c:1.96 src/sys/arch/usermode/usermode/pmap.c:1.97
--- src/sys/arch/usermode/usermode/pmap.c:1.96 Wed Jan 4 16:20:41 2012
+++ src/sys/arch/usermode/usermode/pmap.c Thu Jan 5 12:12:58 2012
@@ -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 <[email protected]>
@@ -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 @@ pmap_bootstrap(void)
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 @@ pmap_page_activate(struct pv_entry *pv)
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);
Index: src/sys/arch/usermode/usermode/thunk.c
diff -u src/sys/arch/usermode/usermode/thunk.c:1.73 src/sys/arch/usermode/usermode/thunk.c:1.74
--- src/sys/arch/usermode/usermode/thunk.c:1.73 Wed Jan 4 13:31:30 2012
+++ src/sys/arch/usermode/usermode/thunk.c Thu Jan 5 12:12:58 2012
@@ -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 <[email protected]>
@@ -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 @@ __RCSID("$NetBSD: thunk.c,v 1.73 2012/01
#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 @@ thunk_printf(const char *fmt, ...)
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 @@ thunk_to_native_mapflags(int flags)
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;
}