Module Name: src Committed By: pooka Date: Wed Apr 21 11:38:05 UTC 2010
Modified Files: src/sys/rump/include/rump: rump.h src/sys/rump/librump/rumpkern: Makefile.rumpkern emul.c Added Files: src/sys/rump/librump/rumpkern: signals.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/sys/rump/include/rump/rump.h cvs rdiff -u -r1.77 -r1.78 src/sys/rump/librump/rumpkern/Makefile.rumpkern cvs rdiff -u -r1.129 -r1.130 src/sys/rump/librump/rumpkern/emul.c cvs rdiff -u -r0 -r1.1 src/sys/rump/librump/rumpkern/signals.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/rump/include/rump/rump.h diff -u src/sys/rump/include/rump/rump.h:1.38 src/sys/rump/include/rump/rump.h:1.39 --- src/sys/rump/include/rump/rump.h:1.38 Wed Apr 14 14:12:48 2010 +++ src/sys/rump/include/rump/rump.h Wed Apr 21 11:38:05 2010 @@ -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); Index: src/sys/rump/librump/rumpkern/Makefile.rumpkern diff -u src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.77 src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.78 --- src/sys/rump/librump/rumpkern/Makefile.rumpkern:1.77 Wed Apr 14 14:49:05 2010 +++ src/sys/rump/librump/rumpkern/Makefile.rumpkern Wed Apr 21 11:38:05 2010 @@ -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 Index: src/sys/rump/librump/rumpkern/emul.c diff -u src/sys/rump/librump/rumpkern/emul.c:1.129 src/sys/rump/librump/rumpkern/emul.c:1.130 --- src/sys/rump/librump/rumpkern/emul.c:1.129 Mon Apr 19 11:26:33 2010 +++ src/sys/rump/librump/rumpkern/emul.c Wed Apr 21 11:38:05 2010 @@ -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,28 +312,7 @@ void calcru(struct proc *p, struct timeval *up, struct timeval *sp, - 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) + struct timeval *ip, struct timeval *rp) { panic("%s unimplemented", __func__); Added files: Index: src/sys/rump/librump/rumpkern/signals.c diff -u /dev/null src/sys/rump/librump/rumpkern/signals.c:1.1 --- /dev/null Wed Apr 21 11:38:05 2010 +++ src/sys/rump/librump/rumpkern/signals.c Wed Apr 21 11:38:05 2010 @@ -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); +} + +void +pgsignal(struct pgrp *pgrp, int sig, int checktty) +{ + + rumpsig(-pgrp->pg_id, sig); +} + +void +kpsignal(struct proc *p, ksiginfo_t *ksi, void *data) +{ + + rumpsig(p->p_pid, ksi->ksi_signo); +} + +void +kpgsignal(struct pgrp *pgrp, ksiginfo_t *ksi, void *data, int checkctty) +{ + + rumpsig(-pgrp->pg_id, ksi->ksi_signo); +} + +int +sigispending(struct lwp *l, int signo) +{ + + return 0; +} + +void +sigpending1(struct lwp *l, sigset_t *ss) +{ + + sigemptyset(ss); +} + +int +sigismasked(struct lwp *l, int sig) +{ + + return 0; +} + +void +sigclearall(struct proc *p, const sigset_t *mask, ksiginfoq_t *kq) +{ + + /* nada */ +} + +void +ksiginfo_queue_drain0(ksiginfoq_t *kq) +{ + + if (!(CIRCLEQ_EMPTY(kq))) + panic("how did that get there?"); +}