correct sighandler breaks registers

This commit is contained in:
Tomoki Shirasawa
2013-07-26 12:24:00 +09:00
parent 221f2c0517
commit af1c0b1352

View File

@ -75,9 +75,11 @@ int obtain_clone_cpuid() {
SYSCALL_DECLARE(rt_sigreturn) SYSCALL_DECLARE(rt_sigreturn)
{ {
struct process *proc = cpu_local_var(current); struct process *proc = cpu_local_var(current);
char *kspbottom; unsigned long *regs;
asm volatile ("movq %%gs:132,%0" : "=r" (kspbottom));
memcpy(kspbottom - 120, proc->sigstack, 120); asm volatile ("movq %%gs:132,%0" : "=r" (regs));
regs -= 16;
memcpy(regs, proc->sigstack, 128);
return proc->sigrc; return proc->sigrc;
} }
@ -106,22 +108,15 @@ check_signal(unsigned long rc, unsigned long *regs)
} }
else if(k->sa.sa_handler){ else if(k->sa.sa_handler){
unsigned long *usp; /* user stack */ unsigned long *usp; /* user stack */
long w;
usp = (void *)regs[14]; usp = (void *)regs[14];
memcpy(proc->sigstack, regs, 128); memcpy(proc->sigstack, regs, 128);
proc->sigrc = rc; proc->sigrc = rc;
usp--; usp--;
*usp = (unsigned long)k->sa.sa_restorer; *usp = (unsigned long)k->sa.sa_restorer;
w = 56 + 3;
asm volatile ("pushq %0" :: "r" (w)); regs[11] = (unsigned long)k->sa.sa_handler;
asm volatile ("pushq %0" :: "r" (usp)); regs[14] = (unsigned long)usp;
w = 1 << 9;
asm volatile ("pushq %0" :: "r" (w));
w = 48 + 3;
asm volatile ("pushq %0" :: "r" (w));
asm volatile ("pushq %0" :: "r" (k->sa.sa_handler));
asm volatile ("iretq");
} }
else{ else{
if(sig == SIGCHLD || sig == SIGURG) if(sig == SIGCHLD || sig == SIGURG)