Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/usermode Use to the MAP_NOSYSCALLS argument to mmap...
details: https://anonhg.NetBSD.org/src/rev/60b72aa77837
branches: trunk
changeset: 772145:60b72aa77837
user: reinoud <reinoud%NetBSD.org@localhost>
date: Tue Dec 20 15:45:36 2011 +0000
description:
Use to the MAP_NOSYSCALLS argument to mmap() to allow for NetBSD/usermode to
execute bog-standard native programs.
diffstat:
sys/arch/usermode/include/thunk.h | 3 ++-
sys/arch/usermode/usermode/pmap.c | 17 +++++++++++------
sys/arch/usermode/usermode/syscall.c | 6 ++++--
sys/arch/usermode/usermode/thunk.c | 11 +++++++++--
4 files changed, 26 insertions(+), 11 deletions(-)
diffs (130 lines):
diff -r 6405b2433e17 -r 60b72aa77837 sys/arch/usermode/include/thunk.h
--- a/sys/arch/usermode/include/thunk.h Tue Dec 20 15:43:51 2011 +0000
+++ b/sys/arch/usermode/include/thunk.h Tue Dec 20 15:45:36 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.h,v 1.41 2011/12/15 03:42:32 jmcneill Exp $ */
+/* $NetBSD: thunk.h,v 1.42 2011/12/20 15:45:36 reinoud Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -61,6 +61,7 @@
#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
diff -r 6405b2433e17 -r 60b72aa77837 sys/arch/usermode/usermode/pmap.c
--- a/sys/arch/usermode/usermode/pmap.c Tue Dec 20 15:43:51 2011 +0000
+++ b/sys/arch/usermode/usermode/pmap.c Tue Dec 20 15:45:36 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pmap.c,v 1.79 2011/12/14 17:06:28 reinoud Exp $ */
+/* $NetBSD: pmap.c,v 1.80 2011/12/20 15:45:37 reinoud 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.79 2011/12/14 17:06:28 reinoud Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.80 2011/12/20 15:45:37 reinoud Exp $");
#include "opt_memsize.h"
#include "opt_kmempages.h"
@@ -626,11 +626,15 @@
{
paddr_t pa = pv->pv_ppn * PAGE_SIZE;
vaddr_t va = pv->pv_lpn * PAGE_SIZE + VM_MIN_ADDRESS; /* L->V */
+ uint32_t map_flags;
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,
- THUNK_MAP_FILE | THUNK_MAP_FIXED | THUNK_MAP_SHARED,
- mem_fh, pa);
+ map_flags, mem_fh, pa);
dprintf_debug("page_activate: (va %p, pa %p, prot %d, ppl %d) -> %p\n",
(void *) va, (void *) pa, pv->pv_prot, pv->pv_mmap_ppl,
(void *) addr);
@@ -648,14 +652,15 @@
{
paddr_t pa = pv->pv_ppn * PAGE_SIZE;
vaddr_t va = pv->pv_lpn * PAGE_SIZE + VM_MIN_ADDRESS; /* L->V */
+ uint32_t map_flags;
void *addr;
if (pv->pv_vflags & PV_WIRED)
return;
+ map_flags = THUNK_MAP_FILE | THUNK_MAP_FIXED | THUNK_MAP_SHARED;
addr = thunk_mmap((void *) va, PAGE_SIZE, THUNK_PROT_NONE,
- THUNK_MAP_FILE | THUNK_MAP_FIXED | THUNK_MAP_SHARED,
- mem_fh, pa);
+ map_flags, mem_fh, pa);
dprintf_debug("page_deactivate: (va %p, pa %p, ppl %d) -> %p\n",
(void *) va, (void *) pa, pv->pv_mmap_ppl, (void *) addr);
if (addr != (void *) va)
diff -r 6405b2433e17 -r 60b72aa77837 sys/arch/usermode/usermode/syscall.c
--- a/sys/arch/usermode/usermode/syscall.c Tue Dec 20 15:43:51 2011 +0000
+++ b/sys/arch/usermode/usermode/syscall.c Tue Dec 20 15:45:36 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: syscall.c,v 1.18 2011/12/15 11:23:52 jmcneill Exp $ */
+/* $NetBSD: syscall.c,v 1.19 2011/12/20 15:45:37 reinoud Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.18 2011/12/15 11:23:52 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: syscall.c,v 1.19 2011/12/20 15:45:37 reinoud Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -99,6 +99,8 @@
curcpu()->ci_data.cpu_nsyscall++;
LWP_CACHE_CREDS(l, l->l_proc);
+ /* TODO are we allowed to execute system calls in this memory space? */
+
/* XXX do we want do do emulation? */
md_syscall_get_opcode(ucp, &opcode);
md_syscall_get_syscallnumber(ucp, &code);
diff -r 6405b2433e17 -r 60b72aa77837 sys/arch/usermode/usermode/thunk.c
--- a/sys/arch/usermode/usermode/thunk.c Tue Dec 20 15:43:51 2011 +0000
+++ b/sys/arch/usermode/usermode/thunk.c Tue Dec 20 15:45:36 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.47 2011/12/15 03:42:33 jmcneill Exp $ */
+/* $NetBSD: thunk.c,v 1.48 2011/12/20 15:45:37 reinoud 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.47 2011/12/15 03:42:33 jmcneill Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.48 2011/12/20 15:45:37 reinoud Exp $");
#endif
#include <sys/types.h>
@@ -165,6 +165,13 @@
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