Source-Changes-HG archive

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

[src/trunk]: src/sys/rump Move all signal-related from emul.c to signals.c. ...



details:   https://anonhg.NetBSD.org/src/rev/e89e5713002f
branches:  trunk
changeset: 754132:e89e5713002f
user:      pooka <pooka%NetBSD.org@localhost>
date:      Wed Apr 21 11:38:05 2010 +0000

description:
Move all signal-related from emul.c to signals.c.  Additionally,
define a few alternate signal models for the rump kernel, including
ones where signals are ignored or sent to host processes.

diffstat:

 sys/rump/include/rump/rump.h                |   10 +-
 sys/rump/librump/rumpkern/Makefile.rumpkern |    6 +-
 sys/rump/librump/rumpkern/emul.c            |   76 +-----------
 sys/rump/librump/rumpkern/signals.c         |  182 ++++++++++++++++++++++++++++
 4 files changed, 197 insertions(+), 77 deletions(-)

diffs (truncated from 356 to 300 lines):

diff -r c8d44645f073 -r e89e5713002f sys/rump/include/rump/rump.h
--- a/sys/rump/include/rump/rump.h      Wed Apr 21 11:19:44 2010 +0000
+++ b/sys/rump/include/rump/rump.h      Wed Apr 21 11:38:05 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: rump.h,v 1.38 2010/04/14 14:12:48 pooka Exp $  */
+/*     $NetBSD: rump.h,v 1.39 2010/04/21 11:38:05 pooka Exp $  */
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -65,6 +65,13 @@
 enum rump_uiorw { RUMPUIO_READ, RUMPUIO_WRITE };
 typedef int (*rump_sysproxy_t)(int, void *, uint8_t *, size_t, register_t *);
 
+enum rump_sigmodel {
+       RUMP_SIGMODEL_PANIC,
+       RUMP_SIGMODEL_IGNORE,
+       RUMP_SIGMODEL_HOST,
+       RUMP_SIGMODEL_RAISE,
+};
+
 /* rumpvfs */
 #define RUMPCN_FREECRED  0x02
 #define RUMPCN_FORCEFREE 0x04
@@ -85,6 +92,7 @@
 
 int    rump_boot_gethowto(void);
 void   rump_boot_sethowto(int);
+void   rump_boot_setsigmodel(enum rump_sigmodel);
 
 void   rump_schedule(void);
 void   rump_unschedule(void);
diff -r c8d44645f073 -r e89e5713002f sys/rump/librump/rumpkern/Makefile.rumpkern
--- a/sys/rump/librump/rumpkern/Makefile.rumpkern       Wed Apr 21 11:19:44 2010 +0000
+++ b/sys/rump/librump/rumpkern/Makefile.rumpkern       Wed Apr 21 11:38:05 2010 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.rumpkern,v 1.77 2010/04/14 14:49:05 pooka Exp $
+#      $NetBSD: Makefile.rumpkern,v 1.78 2010/04/21 11:38:05 pooka Exp $
 #
 
 .include "${RUMPTOP}/Makefile.rump"
@@ -16,8 +16,8 @@
 # Source modules, first the ones specifically implemented for librump.
 # 
 SRCS=  rump.c rumpcopy.c emul.c intr.c locks.c ltsleep.c       \
-       memalloc.c scheduler.c sleepq.c sysproxy_socket.c       \
-       threads.c vm.c
+       memalloc.c scheduler.c signals.c sleepq.c               \
+       sysproxy_socket.c threads.c vm.c
 
 vers.c: ${RUMPTOP}/../conf/newvers.sh ${RUMPTOP}/../conf/osrelease.sh
        ${_MKMSG_CREATE} vers.c
diff -r c8d44645f073 -r e89e5713002f sys/rump/librump/rumpkern/emul.c
--- a/sys/rump/librump/rumpkern/emul.c  Wed Apr 21 11:19:44 2010 +0000
+++ b/sys/rump/librump/rumpkern/emul.c  Wed Apr 21 11:38:05 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: emul.c,v 1.129 2010/04/19 11:26:33 pooka Exp $ */
+/*     $NetBSD: emul.c,v 1.130 2010/04/21 11:38:05 pooka Exp $ */
 
 /*
  * Copyright (c) 2007 Antti Kantee.  All Rights Reserved.
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.129 2010/04/19 11:26:33 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: emul.c,v 1.130 2010/04/21 11:38:05 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/null.h>
@@ -83,8 +83,6 @@
 const char *domainname;
 int domainnamelen;
 
-const struct filterops sig_filtops;
-
 #define DEVSW_SIZE 255
 const struct bdevsw *bdevsw0[DEVSW_SIZE]; /* XXX storage size */
 const struct bdevsw **bdevsw = bdevsw0;
@@ -143,39 +141,6 @@
        panic("%s: not implemented", __func__);
 }
 
-void
-psignal(struct proc *p, int signo)
-{
-
-       switch (signo) {
-       case SIGSYS:
-               break;
-       default:
-               panic("unhandled signal %d", signo);
-       }
-}
-
-void
-pgsignal(struct pgrp *pgrp, int sig, int checktty)
-{
-
-       panic("%s: not implemented", __func__);
-}
-
-void
-kpsignal(struct proc *p, ksiginfo_t *ksi, void *data)
-{
-
-       panic("%s: not implemented", __func__);
-}
-
-void
-kpgsignal(struct pgrp *pgrp, ksiginfo_t *ksi, void *data, int checkctty)
-{
-
-       panic("%s: not implemented", __func__);
-}
-
 int
 pgid_in_session(struct proc *p, pid_t pg_id)
 {
@@ -184,20 +149,6 @@
 }
 
 int
-sigispending(struct lwp *l, int signo)
-{
-
-       return 0;
-}
-
-void
-sigpending1(struct lwp *l, sigset_t *ss)
-{
-
-       panic("%s: not implemented", __func__);
-}
-
-int
 kpause(const char *wmesg, bool intr, int timeo, kmutex_t *mtx)
 {
        extern int hz;
@@ -361,29 +312,8 @@
 
 void
 calcru(struct proc *p, struct timeval *up, struct timeval *sp,
-       struct timeval *ip, struct timeval *rp)
+        struct timeval *ip, struct timeval *rp)
 {
 
        panic("%s unimplemented", __func__);
 }
-
-int
-sigismasked(struct lwp *l, int sig)
-{
-
-       return 0;
-}
-
-void
-sigclearall(struct proc *p, const sigset_t *mask, ksiginfoq_t *kq)
-{
-
-       panic("%s unimplemented", __func__);
-}
-
-void
-ksiginfo_queue_drain0(ksiginfoq_t *kq)
-{
-
-       panic("%s unimplemented", __func__);
-}
diff -r c8d44645f073 -r e89e5713002f sys/rump/librump/rumpkern/signals.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/rump/librump/rumpkern/signals.c       Wed Apr 21 11:38:05 2010 +0000
@@ -0,0 +1,182 @@
+/*     $NetBSD: signals.c,v 1.1 2010/04/21 11:38:05 pooka Exp $        */
+
+/*
+ * Copyright (c) 2010 Antti Kantee.  All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+ * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__KERNEL_RCSID(0, "$NetBSD: signals.c,v 1.1 2010/04/21 11:38:05 pooka Exp $");
+
+#include <sys/param.h>
+#include <sys/atomic.h>
+#include <sys/event.h>
+#include <sys/proc.h>
+#include <sys/signal.h>
+
+#include <rump/rump.h>
+#include <rump/rumpuser.h>
+
+#include "rumpkern_if_priv.h"
+
+const struct filterops sig_filtops;
+
+/* RUMP_SIGMODEL_PANIC */
+
+static void
+rumpsig_panic(pid_t target, int signo)
+{
+
+       switch (signo) {
+       case SIGSYS:
+               break;
+       default:
+               panic("unhandled signal %d", signo);
+       }
+}
+
+/* RUMP_SIGMODEL_IGNORE */
+
+static void
+rumpsig_ignore(pid_t target, int signo)
+{
+
+       return;
+}
+
+/* RUMP_SIGMODEL_HOST */
+
+static void
+rumpsig_host(pid_t target, int signo)
+{
+       int error;
+
+       rumpuser_kill(target, signo, &error);
+}
+
+/* RUMP_SIGMODEL_RAISE */
+
+static void
+rumpsig_raise(pid_t target, int signo)
+{
+       int error;
+
+       rumpuser_kill(RUMPUSER_PID_SELF, signo, &error);
+}
+
+typedef void (*rumpsig_fn)(pid_t pid, int sig);
+
+rumpsig_fn rumpsig = rumpsig_panic;
+
+/*
+ * Set signal delivery model.  It would be nice if we could
+ * take a functional argument.  But then we'd need some
+ * OS independent way to represent a signal number and also
+ * a method for easy processing (parsing is boring).
+ *
+ * Plus, upcalls from the rump kernel into process space except
+ * via rumpuser is a somewhat gray area now.
+ */
+void
+rump_boot_setsigmodel(enum rump_sigmodel model)
+{
+
+       switch (model) {
+       case RUMP_SIGMODEL_PANIC:
+               atomic_swap_ptr(&rumpsig, rumpsig_panic);
+               break;
+       case RUMP_SIGMODEL_IGNORE:
+               atomic_swap_ptr(&rumpsig, rumpsig_ignore);
+               break;
+       case RUMP_SIGMODEL_HOST:
+               atomic_swap_ptr(&rumpsig, rumpsig_host);
+               break;
+       case RUMP_SIGMODEL_RAISE:
+               atomic_swap_ptr(&rumpsig, rumpsig_raise);
+               break;
+       }
+}
+
+void
+psignal(struct proc *p, int sig)
+{
+
+       rumpsig(p->p_pid, sig);
+}
+



Home | Main Index | Thread Index | Old Index