mcexec forward signal to MIC process.
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
#include <registers.h>
|
||||
#include <cpulocal.h>
|
||||
#include <march.h>
|
||||
#include <signal.h>
|
||||
|
||||
#define LAPIC_ID 0x020
|
||||
#define LAPIC_TIMER 0x320
|
||||
@ -341,6 +342,8 @@ void setup_x86_ap(void (*next_func)(void))
|
||||
}
|
||||
|
||||
void arch_show_interrupt_context(const void *reg);
|
||||
void set_signal(int, void *);
|
||||
void check_signal(long, void *);
|
||||
|
||||
void handle_interrupt(int vector, struct x86_regs *regs)
|
||||
{
|
||||
@ -371,16 +374,17 @@ void handle_interrupt(int vector, struct x86_regs *regs)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sigill(void *);
|
||||
check_signal(0, regs);
|
||||
}
|
||||
|
||||
void gpe_handler(struct x86_regs *regs)
|
||||
{
|
||||
kprintf("General protection fault (err: %lx, %lx:%lx)\n",
|
||||
regs->error, regs->cs, regs->rip);
|
||||
arch_show_interrupt_context(regs);
|
||||
sigill(regs);
|
||||
set_signal(SIGILL, regs);
|
||||
check_signal(0, regs);
|
||||
// panic("GPF");
|
||||
}
|
||||
|
||||
|
||||
@ -49,6 +49,11 @@ SYSCALL_DELEGATED(107, geteuid)
|
||||
SYSCALL_DELEGATED(108, getegid)
|
||||
SYSCALL_DELEGATED(110, getppid)
|
||||
SYSCALL_DELEGATED(111, getpgrp)
|
||||
SYSCALL_HANDLED(127, rt_sigpending)
|
||||
SYSCALL_HANDLED(128, rt_sigtimedwait)
|
||||
SYSCALL_HANDLED(129, rt_sigqueueinfo)
|
||||
SYSCALL_HANDLED(130, rt_sigsuspend)
|
||||
SYSCALL_HANDLED(131, sigaltstack)
|
||||
SYSCALL_HANDLED(158, arch_prctl)
|
||||
SYSCALL_DELEGATED(201, time)
|
||||
SYSCALL_HANDLED(202, futex)
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include <syscall.h>
|
||||
#include <process.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
void terminate(int, int, ihk_mc_user_context_t *);
|
||||
|
||||
@ -91,8 +92,12 @@ check_signal(unsigned long rc, unsigned long *regs)
|
||||
struct k_sigaction *k;
|
||||
int sig = proc->signal;
|
||||
|
||||
if(proc == NULL || proc->pid == 0)
|
||||
return;
|
||||
|
||||
proc->signal = 0;
|
||||
if(sig){
|
||||
int irqstate = ihk_mc_spinlock_lock(&proc->sighandler->lock);
|
||||
if(regs == NULL){ /* call from syscall */
|
||||
asm volatile ("movq %%gs:132,%0" : "=r" (regs));
|
||||
regs -= 16;
|
||||
@ -104,6 +109,7 @@ check_signal(unsigned long rc, unsigned long *regs)
|
||||
k = proc->sighandler->action + sig - 1;
|
||||
|
||||
if(k->sa.sa_handler == (void *)1){
|
||||
ihk_mc_spinlock_unlock(&proc->sighandler->lock, irqstate);
|
||||
return;
|
||||
}
|
||||
else if(k->sa.sa_handler){
|
||||
@ -118,8 +124,10 @@ check_signal(unsigned long rc, unsigned long *regs)
|
||||
regs[4] = (unsigned long)sig;
|
||||
regs[11] = (unsigned long)k->sa.sa_handler;
|
||||
regs[14] = (unsigned long)usp;
|
||||
ihk_mc_spinlock_unlock(&proc->sighandler->lock, irqstate);
|
||||
}
|
||||
else{
|
||||
ihk_mc_spinlock_unlock(&proc->sighandler->lock, irqstate);
|
||||
if(sig == SIGCHLD || sig == SIGURG)
|
||||
return;
|
||||
terminate(0, sig, (ihk_mc_user_context_t *)regs[14]);
|
||||
@ -127,20 +135,38 @@ check_signal(unsigned long rc, unsigned long *regs)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sigsegv(unsigned long *regs)
|
||||
extern unsigned long do_kill(int pid, int sig);
|
||||
|
||||
unsigned long
|
||||
do_kill(int pid, int sig)
|
||||
{
|
||||
struct process *proc = cpu_local_var(current);
|
||||
|
||||
proc->signal = SIGSEGV;
|
||||
check_signal(0, regs);
|
||||
if(proc == NULL || proc->pid == 0){
|
||||
return -ESRCH;
|
||||
}
|
||||
if(proc->pid == pid){
|
||||
proc->signal = sig;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if(pid <= 0){
|
||||
return -EINVAL;
|
||||
}
|
||||
if(sig == 0){
|
||||
return 0;
|
||||
}
|
||||
else{
|
||||
return -EPERM;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
sigill(unsigned long *regs)
|
||||
set_signal(int sig, unsigned long *regs)
|
||||
{
|
||||
struct process *proc = cpu_local_var(current);
|
||||
|
||||
proc->signal = SIGILL;
|
||||
check_signal(0, regs);
|
||||
if(proc == NULL || proc->pid == 0)
|
||||
return;
|
||||
proc->signal = sig;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user