Source-Changes-HG archive

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

[src/trunk]: src/sys/rump/librump/rumpkern Put all sysproxy routines to their...



details:   https://anonhg.NetBSD.org/src/rev/73a53171b0f8
branches:  trunk
changeset: 335338:73a53171b0f8
user:      pooka <pooka%NetBSD.org@localhost>
date:      Sat Jan 03 17:23:51 2015 +0000

description:
Put all sysproxy routines to their own C module, sysproxy.c

diffstat:

 sys/rump/librump/rumpkern/Makefile.rumpkern |    4 +-
 sys/rump/librump/rumpkern/emul.c            |    8 +-
 sys/rump/librump/rumpkern/rump.c            |  169 +------------------
 sys/rump/librump/rumpkern/rump_private.h    |   16 +-
 sys/rump/librump/rumpkern/rumpcopy.c        |   18 +-
 sys/rump/librump/rumpkern/signals.c         |    6 +-
 sys/rump/librump/rumpkern/sysproxy.c        |  246 ++++++++++++++++++++++++++++
 sys/rump/librump/rumpkern/vm.c              |    6 +-
 8 files changed, 289 insertions(+), 184 deletions(-)

diffs (truncated from 682 to 300 lines):

diff -r c70b4b1716c3 -r 73a53171b0f8 sys/rump/librump/rumpkern/Makefile.rumpkern
--- a/sys/rump/librump/rumpkern/Makefile.rumpkern       Sat Jan 03 16:44:14 2015 +0000
+++ b/sys/rump/librump/rumpkern/Makefile.rumpkern       Sat Jan 03 17:23:51 2015 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.rumpkern,v 1.151 2014/12/02 01:59:15 pooka Exp $
+#      $NetBSD: Makefile.rumpkern,v 1.152 2015/01/03 17:23:51 pooka Exp $
 #
 
 .include "${RUMPTOP}/Makefile.rump"
@@ -28,7 +28,7 @@
 SRCS+= rump.c rumpcopy.c cons.c emul.c etfs_wrap.c intr.c      \
        lwproc.c klock.c kobj_rename.c ltsleep.c scheduler.c    \
        signals.c sleepq.c threads.c vm.c hyperentropy.c        \
-       accessors.c
+       accessors.c sysproxy.c
 
 SRCS+= rumpkern_syscalls.c
 
diff -r c70b4b1716c3 -r 73a53171b0f8 sys/rump/librump/rumpkern/emul.c
--- a/sys/rump/librump/rumpkern/emul.c  Sat Jan 03 16:44:14 2015 +0000
+++ b/sys/rump/librump/rumpkern/emul.c  Sat Jan 03 17:23:51 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: emul.c,v 1.168 2014/11/18 16:57:52 pooka Exp $ */
+/*     $NetBSD: emul.c,v 1.169 2015/01/03 17:23:51 pooka Exp $ */
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.168 2014/11/18 16:57:52 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.169 2015/01/03 17:23:51 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/null.h>
@@ -382,7 +382,7 @@
        /* your wish is my command */
        if (howto & RB_HALT) {
                printf("rump kernel halted\n");
-               rumpuser_sp_fini(finiarg);
+               rump_sysproxy_fini(finiarg);
                for (;;) {
                        rumpuser_clock_sleep(RUMPUSER_CLOCK_RELWALL, 10, 0);
                }
@@ -391,6 +391,6 @@
        /* this function is __dead, we must exit */
  out:
        printf("halted\n");
-       rumpuser_sp_fini(finiarg);
+       rump_sysproxy_fini(finiarg);
        rumpuser_exit(ruhow);
 }
diff -r c70b4b1716c3 -r 73a53171b0f8 sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c  Sat Jan 03 16:44:14 2015 +0000
+++ b/sys/rump/librump/rumpkern/rump.c  Sat Jan 03 17:23:51 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump.c,v 1.312 2014/08/25 18:44:02 pooka Exp $ */
+/*     $NetBSD: rump.c,v 1.313 2015/01/03 17:23:51 pooka Exp $ */
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.312 2014/08/25 18:44:02 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.313 2015/01/03 17:23:51 pooka Exp $");
 
 #include <sys/systm.h>
 #define ELFSIZE ARCH_ELFSIZE
@@ -101,11 +101,6 @@
 int rump_threads = 1;
 #endif
 
-static int rump_hyp_syscall(int, void *, long *);
-static int rump_hyp_rfork(void *, int, const char *);
-static void rump_hyp_lwpexit(void);
-static void rump_hyp_execnotify(const char *);
-
 static void rump_component_addlocal(void);
 static struct lwp *bootlwp;
 
@@ -154,14 +149,6 @@
            CTL_HW, HW_PAGESIZE, CTL_EOL);
 }
 
-/* there's no convenient kernel entry point for this, so just craft out own */
-static pid_t
-spgetpid(void)
-{
-
-       return curproc->p_pid;
-}
-
 static const struct rumpuser_hyperup hyp = {
        .hyp_schedule           = rump_schedule,
        .hyp_unschedule         = rump_unschedule,
@@ -169,13 +156,13 @@
        .hyp_backend_schedule   = rump_user_schedule,
        .hyp_lwproc_switch      = rump_lwproc_switch,
        .hyp_lwproc_release     = rump_lwproc_releaselwp,
-       .hyp_lwproc_rfork       = rump_hyp_rfork,
+       .hyp_lwproc_rfork       = rump_sysproxy_hyp_rfork,
        .hyp_lwproc_newlwp      = rump_lwproc_newlwp,
        .hyp_lwproc_curlwp      = rump_lwproc_curlwp,
-       .hyp_lwpexit            = rump_hyp_lwpexit,
-       .hyp_syscall            = rump_hyp_syscall,
-       .hyp_execnotify         = rump_hyp_execnotify,
-       .hyp_getpid             = spgetpid,
+       .hyp_lwpexit            = rump_sysproxy_hyp_lwpexit,
+       .hyp_syscall            = rump_sysproxy_hyp_syscall,
+       .hyp_execnotify         = rump_sysproxy_hyp_execnotify,
+       .hyp_getpid             = rump_sysproxy_hyp_getpid,
 };
 
 int
@@ -476,13 +463,6 @@
 /* historic compat */
 __strong_alias(rump__init,rump_init);
 
-int
-rump_init_server(const char *url)
-{
-
-       return rumpuser_sp_init(url, ostype, osrelease, MACHINE);
-}
-
 static int compcounter[RUMP_COMPONENT_MAX];
 static int compinited[RUMP_COMPONENT_MAX];
 
@@ -630,141 +610,6 @@
        return 0;
 }
 
-static int
-rump_hyp_syscall(int num, void *arg, long *retval)
-{
-       register_t regrv[2] = {0, 0};
-       struct lwp *l;
-       struct sysent *callp;
-       int rv;
-
-       if (__predict_false(num >= SYS_NSYSENT))
-               return ENOSYS;
-
-       /* XXX: always uses native syscall vector */
-       callp = rump_sysent + num;
-       l = curlwp;
-       rv = sy_invoke(callp, l, (void *)arg, regrv, num);
-       retval[0] = regrv[0];
-       retval[1] = regrv[1];
-
-       return rv;
-}
-
-static int
-rump_hyp_rfork(void *priv, int flags, const char *comm)
-{
-       struct vmspace *newspace;
-       struct proc *p;
-       struct lwp *l;
-       int error;
-       bool initfds;
-
-       /*
-        * If we are forking off of pid 1, initialize file descriptors.
-        */
-       l = curlwp;
-       if (l->l_proc->p_pid == 1) {
-               KASSERT(flags == RUMP_RFFD_CLEAR);
-               initfds = true;
-       } else {
-               initfds = false;
-       }
-
-       if ((error = rump_lwproc_rfork(flags)) != 0)
-               return error;
-
-       /*
-        * We forked in this routine, so cannot use curlwp (const)
-        */
-       l = rump_lwproc_curlwp();
-       p = l->l_proc;
-
-       /*
-        * Since it's a proxy proc, adjust the vmspace.
-        * Refcount will eternally be 1.
-        */
-       newspace = kmem_zalloc(sizeof(*newspace), KM_SLEEP);
-       newspace->vm_refcnt = 1;
-       newspace->vm_map.pmap = priv;
-       KASSERT(p->p_vmspace == vmspace_kernel());
-       p->p_vmspace = newspace;
-       if (comm)
-               strlcpy(p->p_comm, comm, sizeof(p->p_comm));
-       if (initfds)
-               rump_consdev_init();
-
-       return 0;
-}
-
-/*
- * Order all lwps in a process to exit.  does *not* wait for them to drain.
- */
-static void
-rump_hyp_lwpexit(void)
-{
-       struct proc *p = curproc;
-       uint64_t where;
-       struct lwp *l;
-
-       mutex_enter(p->p_lock);
-       /*
-        * First pass: mark all lwps in the process with LW_RUMP_QEXIT
-        * so that they know they should exit.
-        */
-       LIST_FOREACH(l, &p->p_lwps, l_sibling) {
-               if (l == curlwp)
-                       continue;
-               l->l_flag |= LW_RUMP_QEXIT;
-       }
-       mutex_exit(p->p_lock);
-
-       /*
-        * Next, make sure everyone on all CPUs sees our status
-        * update.  This keeps threads inside cv_wait() and makes
-        * sure we don't access a stale cv pointer later when
-        * we wake up the threads.
-        */
-
-       where = xc_broadcast(0, (xcfunc_t)nullop, NULL, NULL);
-       xc_wait(where);
-
-       /*
-        * Ok, all lwps are either:
-        *  1) not in the cv code
-        *  2) sleeping on l->l_private
-        *  3) sleeping on p->p_waitcv
-        *
-        * Either way, l_private is stable until we set PS_RUMP_LWPEXIT
-        * in p->p_sflag.
-        */
-
-       mutex_enter(p->p_lock);
-       LIST_FOREACH(l, &p->p_lwps, l_sibling) {
-               if (l->l_private)
-                       cv_broadcast(l->l_private);
-       }
-       p->p_sflag |= PS_RUMP_LWPEXIT;
-       cv_broadcast(&p->p_waitcv);
-       mutex_exit(p->p_lock);
-}
-
-/*
- * Notify process that all threads have been drained and exec is complete.
- */
-static void
-rump_hyp_execnotify(const char *comm)
-{
-       struct proc *p = curproc;
-
-       fd_closeexec();
-       mutex_enter(p->p_lock);
-       KASSERT(p->p_nlwps == 1 && p->p_sflag & PS_RUMP_LWPEXIT);
-       p->p_sflag &= ~PS_RUMP_LWPEXIT;
-       mutex_exit(p->p_lock);
-       strlcpy(p->p_comm, comm, sizeof(p->p_comm));
-}
-
 int
 rump_boot_gethowto()
 {
diff -r c70b4b1716c3 -r 73a53171b0f8 sys/rump/librump/rumpkern/rump_private.h
--- a/sys/rump/librump/rumpkern/rump_private.h  Sat Jan 03 16:44:14 2015 +0000
+++ b/sys/rump/librump/rumpkern/rump_private.h  Sat Jan 03 17:23:51 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump_private.h,v 1.85 2014/04/27 16:28:21 pooka Exp $  */
+/*     $NetBSD: rump_private.h,v 1.86 2015/01/03 17:23:51 pooka Exp $  */
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -187,4 +187,18 @@
 void   rump_lwproc_curlwp_set(struct lwp *);
 void   rump_lwproc_curlwp_clear(struct lwp *);
 
+/* in-kernel sysproxy bouncers */
+int    rump_sysproxy_copyin(void *, const void *, void *, size_t);
+int    rump_sysproxy_copyinstr(void *, const void *, void *, size_t *);
+int    rump_sysproxy_copyout(void *, const void *, void *, size_t);
+int    rump_sysproxy_copyoutstr(void *, const void *, void *, size_t *);
+int    rump_sysproxy_anonmmap(void *, size_t, void **);
+int    rump_sysproxy_raise(void *, int);
+void   rump_sysproxy_fini(void *);
+pid_t  rump_sysproxy_hyp_getpid(void);
+int    rump_sysproxy_hyp_syscall(int, void *, long *);
+int    rump_sysproxy_hyp_rfork(void *, int, const char *);
+void   rump_sysproxy_hyp_lwpexit(void);
+void   rump_sysproxy_hyp_execnotify(const char *);
+



Home | Main Index | Thread Index | Old Index