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.
This commit is contained in:
pooka 2010-04-21 11:38:05 +00:00
parent 2f75110c81
commit 77c91f3324
4 changed files with 197 additions and 77 deletions

View File

@ -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);

View File

@ -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

View File

@ -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 *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)
{
@ -366,24 +317,3 @@ calcru(struct proc *p, struct timeval *up, struct timeval *sp,
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__);
}

View File

@ -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?");
}