From 77c91f3324b13bcb2caeb2821764b9ebef2c5f52 Mon Sep 17 00:00:00 2001 From: pooka Date: Wed, 21 Apr 2010 11:38:05 +0000 Subject: [PATCH] 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. --- 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(-) create mode 100644 sys/rump/librump/rumpkern/signals.c diff --git a/sys/rump/include/rump/rump.h b/sys/rump/include/rump/rump.h index 42615fc6bf36..bb3e47a4b62d 100644 --- a/sys/rump/include/rump/rump.h +++ b/sys/rump/include/rump/rump.h @@ -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 @@ typedef struct prop_dictionary *prop_dictionary_t; 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 @@ _BEGIN_DECLS 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 --git a/sys/rump/librump/rumpkern/Makefile.rumpkern b/sys/rump/librump/rumpkern/Makefile.rumpkern index 0234ced62fb7..fdc85b179a00 100644 --- a/sys/rump/librump/rumpkern/Makefile.rumpkern +++ b/sys/rump/librump/rumpkern/Makefile.rumpkern @@ -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 @@ LIB= rump # 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 --git a/sys/rump/librump/rumpkern/emul.c b/sys/rump/librump/rumpkern/emul.c index 6322a3438c13..77c9733e9b34 100644 --- a/sys/rump/librump/rumpkern/emul.c +++ b/sys/rump/librump/rumpkern/emul.c @@ -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 -__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 #include @@ -83,8 +83,6 @@ const char *panicstr; 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 @@ pg_find(pid_t pid, uint flags) 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) { @@ -183,20 +148,6 @@ pgid_in_session(struct proc *p, pid_t pg_id) panic("%s: not implemented", __func__); } -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) { @@ -361,28 +312,7 @@ cpu_reboot(int howto, char *bootstr) 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__); diff --git a/sys/rump/librump/rumpkern/signals.c b/sys/rump/librump/rumpkern/signals.c new file mode 100644 index 000000000000..3de25c05cd3d --- /dev/null +++ b/sys/rump/librump/rumpkern/signals.c @@ -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 +__KERNEL_RCSID(0, "$NetBSD: signals.c,v 1.1 2010/04/21 11:38:05 pooka Exp $"); + +#include +#include +#include +#include +#include + +#include +#include + +#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?"); +}