mcexec forward signal to MIC process.
This commit is contained in:
@@ -368,6 +368,8 @@ static void syscall_channel_send(struct ihk_ikc_channel_desc *c,
|
||||
ihk_ikc_send(c, packet, 0);
|
||||
}
|
||||
|
||||
extern unsigned long do_kill(int, int);
|
||||
|
||||
static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
|
||||
void *__packet, void *ihk_os)
|
||||
{
|
||||
@@ -404,6 +406,10 @@ static int syscall_packet_handler(struct ihk_ikc_channel_desc *c,
|
||||
|
||||
//cpu_local_var(next) = (struct process *)packet->arg;
|
||||
return 0;
|
||||
case SCD_MSG_SEND_SIGNAL:
|
||||
rc = do_kill((int)packet->arg, (int)(packet->arg >> 32));
|
||||
kprintf("SCD_MSG_SEND_SIGNAL: %lx, rc=%d\n", packet->arg, rc);
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ struct vm_regions {
|
||||
struct process_vm;
|
||||
|
||||
struct sig_handler {
|
||||
// TODO: lock;
|
||||
int use;
|
||||
ihk_spinlock_t lock;
|
||||
ihk_atomic_t use;
|
||||
struct k_sigaction action[_NSIG];
|
||||
};
|
||||
|
||||
@@ -83,9 +83,12 @@ struct process {
|
||||
} thread;
|
||||
|
||||
int signal;
|
||||
sigset_t sigpend;
|
||||
sigset_t sigmask;
|
||||
struct sig_handler *sighandler;
|
||||
ihk_mc_kernel_context_t sigctx;
|
||||
char sigstack[512];
|
||||
// TODO: backup FR and MMX regs
|
||||
unsigned long sigrc; // return code of rt_sigreturn (x86_64: rax reg.)
|
||||
};
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#define SCD_MSG_INIT_CHANNEL_ACKED 0x6
|
||||
|
||||
#define SCD_MSG_SYSCALL_ONESIDE 0x4
|
||||
#define SCD_MSG_SEND_SIGNAL 0x8
|
||||
|
||||
#define ARCH_SET_GS 0x1001
|
||||
#define ARCH_SET_FS 0x1002
|
||||
|
||||
@@ -141,7 +141,8 @@ static struct ihk_mc_interrupt_handler query_free_mem_handler = {
|
||||
.priv = NULL,
|
||||
};
|
||||
|
||||
void sigsegv(void *);
|
||||
void set_signal(int, unsigned long *);
|
||||
void check_signal(long, unsigned long *);
|
||||
|
||||
static void unhandled_page_fault(struct process *proc, void *fault_addr, void *regs)
|
||||
{
|
||||
@@ -194,7 +195,8 @@ static void unhandled_page_fault(struct process *proc, void *fault_addr, void *r
|
||||
#if 0
|
||||
panic("mem fault");
|
||||
#endif
|
||||
sigsegv(regs);
|
||||
set_signal(SIGSEGV, regs);
|
||||
check_signal(0, regs);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,8 @@ struct process *create_process(unsigned long user_pc)
|
||||
return NULL;
|
||||
}
|
||||
memset(proc->sighandler, '\0', sizeof(struct sig_handler));
|
||||
proc->sighandler->use = 1;
|
||||
ihk_atomic_set(&proc->sighandler->use, 1);
|
||||
ihk_mc_spinlock_init(&proc->sighandler->lock);
|
||||
|
||||
ihk_mc_init_user_process(&proc->ctx, &proc->uctx,
|
||||
((char *)proc) +
|
||||
@@ -106,9 +107,8 @@ struct process *clone_process(struct process *org, unsigned long pc,
|
||||
ihk_atomic_inc(&org->vm->refcount);
|
||||
proc->vm = org->vm;
|
||||
|
||||
// TODO: lock
|
||||
proc->sighandler = org->sighandler;
|
||||
org->sighandler->use++;
|
||||
ihk_atomic_inc(&org->sighandler->use);
|
||||
|
||||
ihk_mc_spinlock_init(&proc->spin_sleep_lock);
|
||||
proc->spin_sleep = 0;
|
||||
@@ -1054,6 +1054,9 @@ void hold_process(struct process *proc)
|
||||
|
||||
void destroy_process(struct process *proc)
|
||||
{
|
||||
if(ihk_atomic_dec_and_test(&proc->sighandler->use)){
|
||||
kfree(proc->sighandler);
|
||||
}
|
||||
ihk_mc_free_pages(proc, KERNEL_STACK_NR_PAGES);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@ static char *syscall_name[] MCKERNEL_UNUSED = {
|
||||
#undef SYSCALL_DELEGATED
|
||||
};
|
||||
|
||||
void check_signal(unsigned long rc, unsigned long *regs);
|
||||
void check_signal(long rc, unsigned long *regs);
|
||||
|
||||
#ifdef DCFA_KMOD
|
||||
static void do_mod_exit(int status);
|
||||
@@ -830,26 +830,14 @@ SYSCALL_DECLARE(set_tid_address)
|
||||
return cpu_local_var(current)->pid;
|
||||
}
|
||||
|
||||
extern unsigned long do_kill(int pid, int sig);
|
||||
|
||||
SYSCALL_DECLARE(kill)
|
||||
{
|
||||
int pid = ihk_mc_syscall_arg0(ctx);
|
||||
int sig = ihk_mc_syscall_arg1(ctx);
|
||||
|
||||
struct process *proc = cpu_local_var(current);
|
||||
|
||||
if(proc->pid == pid){
|
||||
proc->signal = sig;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(pid <= 0) { return -EINVAL; }
|
||||
// search pid
|
||||
// check kill permission
|
||||
if(sig == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
return -EPERM;
|
||||
}
|
||||
return do_kill(pid, sig);
|
||||
}
|
||||
|
||||
// see linux-2.6.34.13/kernel/signal.c
|
||||
@@ -879,14 +867,16 @@ do_sigaction(int sig, struct k_sigaction *act, struct k_sigaction *oact)
|
||||
{
|
||||
struct process *proc = cpu_local_var(current);
|
||||
struct k_sigaction *k;
|
||||
// TODO: sigmask
|
||||
int irqstate;
|
||||
|
||||
irqstate = ihk_mc_spinlock_lock(&proc->sighandler->lock);
|
||||
k = proc->sighandler->action + sig - 1;
|
||||
if(oact)
|
||||
memcpy(oact, k, sizeof(struct k_sigaction));
|
||||
if(act){
|
||||
memcpy(k, act, sizeof(struct k_sigaction));
|
||||
}
|
||||
ihk_mc_spinlock_unlock(&proc->sighandler->lock, irqstate);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -913,9 +903,38 @@ SYSCALL_DECLARE(rt_sigaction)
|
||||
|
||||
SYSCALL_DECLARE(rt_sigprocmask)
|
||||
{
|
||||
// kprintf("sys_rt_sigprocmask called. returning zero...\n");
|
||||
return 0;
|
||||
int how = ihk_mc_syscall_arg0(ctx);
|
||||
const sigset_t *set = (const sigset_t *)ihk_mc_syscall_arg1(ctx);
|
||||
sigset_t *oldset = (sigset_t *)ihk_mc_syscall_arg2(ctx);
|
||||
// kprintf("sys_rt_sigprocmask called. returning zero...\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYSCALL_DECLARE(rt_sigpending)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYSCALL_DECLARE(rt_sigtimedwait)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYSCALL_DECLARE(rt_sigqueueinfo)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYSCALL_DECLARE(rt_sigsuspend)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYSCALL_DECLARE(sigaltstack)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYSCALL_DECLARE(madvise)
|
||||
{
|
||||
// kprintf("sys_madvise called. returning zero...\n");
|
||||
|
||||
Reference in New Issue
Block a user