本文整理汇总了C++中sigexit函数的典型用法代码示例。如果您正苦于以下问题:C++ sigexit函数的具体用法?C++ sigexit怎么用?C++ sigexit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sigexit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: sendsig_siginfo
static void
sendsig_siginfo(const ksiginfo_t *ksi, const sigset_t *mask)
{
struct lwp *l = curlwp;
struct proc *p = l->l_proc;
struct sigacts *ps = p->p_sigacts;
struct trapframe *tf = l->l_md.md_regs;
int sig = ksi->ksi_signo, error;
sig_t catcher = SIGACTION(p, sig).sa_handler;
struct sigframe_siginfo *fp, frame;
int onstack;
switch (ps->sa_sigdesc[sig].sd_vers) {
case 0: /* FALLTHROUGH */ /* handled by sendsig_sigcontext */
case 1: /* FALLTHROUGH */ /* handled by sendsig_sigcontext */
default: /* unknown version */
printf("sendsig_siginfo: bad version %d\n",
ps->sa_sigdesc[sig].sd_vers);
sigexit(l, SIGILL);
/* NOTREACHED */
case 2:
break;
}
fp = getframe(l, sig, &onstack);
--fp;
frame.sf_si._info = ksi->ksi_info;
frame.sf_uc.uc_link = l->l_ctxlink;
frame.sf_uc.uc_sigmask = *mask;
frame.sf_uc.uc_flags = _UC_SIGMASK;
frame.sf_uc.uc_flags |= (l->l_sigstk.ss_flags & SS_ONSTACK)
? _UC_SETSTACK : _UC_CLRSTACK;
memset(&frame.sf_uc.uc_stack, 0, sizeof(frame.sf_uc.uc_stack));
sendsig_reset(l, sig);
mutex_exit(p->p_lock);
cpu_getmcontext(l, &frame.sf_uc.uc_mcontext, &frame.sf_uc.uc_flags);
error = copyout(&frame, fp, sizeof(frame));
mutex_enter(p->p_lock);
if (error != 0) {
/*
* Process has trashed its stack; give it an illegal
* instruction to halt it in its tracks.
*/
sigexit(l, SIGILL);
/* NOTREACHED */
}
tf->tf_r4 = sig; /* "signum" argument for handler */
tf->tf_r5 = (int)&fp->sf_si; /* "sip" argument for handler */
tf->tf_r6 = (int)&fp->sf_uc; /* "ucp" argument for handler */
tf->tf_spc = (int)catcher;
tf->tf_r15 = (int)fp;
tf->tf_pr = (int)ps->sa_sigdesc[sig].sd_tramp;
/* Remember if we're now on the signal stack. */
if (onstack)
l->l_sigstk.ss_flags |= SS_ONSTACK;
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:60,代码来源:sh3_machdep.c
示例2: cpu_upcall
/*
* void cpu_upcall(struct lwp *l, int type, int nevents, int ninterrupted,
* void *sas, void *ap, void *sp, sa_upcall_t upcall):
*
* Send an upcall to userland.
*/
void
cpu_upcall(struct lwp *l, int type, int nevents, int ninterrupted, void *sas,
void *ap, void *sp, sa_upcall_t upcall)
{
struct trapframe *tf;
struct saframe *sf, frame;
tf = l->l_md.md_regs;
/* Build the stack frame. */
#if 0 /* First 4 args in regs (see below). */
frame.sa_type = type;
frame.sa_sas = sas;
frame.sa_events = nevents;
frame.sa_interrupted = ninterrupted;
#endif
frame.sa_arg = ap;
sf = (struct saframe *)sp - 1;
if (copyout(&frame, sf, sizeof(frame)) != 0) {
/* Copying onto the stack didn't work. Die. */
sigexit(l, SIGILL);
/* NOTREACHED */
}
tf->tf_r4 = type;
tf->tf_r5 = (int) sas;
tf->tf_r6 = nevents;
tf->tf_r7 = ninterrupted;
tf->tf_spc = (int) upcall;
tf->tf_pr = 0; /* no return */
tf->tf_r15 = (int) sf;
}
开发者ID:lacombar,项目名称:netbsd-alc,代码行数:40,代码来源:sh3_machdep.c
示例3: cpu_upcall
/*
* cpu_upcall:
*
* Send an an upcall to userland.
*/
void
cpu_upcall(struct lwp *l, int type, int nevents, int ninterrupted, void *sas,
void *ap, void *sp, sa_upcall_t upcall)
{
struct trapframe *tf;
struct saframe *sf, frame;
tf = process_frame(l);
/* Finally, copy out the rest of the frame. */
#if 0 /* First 4 args in regs (see below). */
frame.sa_type = type;
frame.sa_sas = sas;
frame.sa_events = nevents;
frame.sa_interrupted = ninterrupted;
#endif
frame.sa_arg = ap;
sf = (struct saframe *)sp - 1;
if (copyout(&frame, sf, sizeof(frame)) != 0) {
/* Copying onto the stack didn't work. Die. */
sigexit(l, SIGILL);
/* NOTREACHED */
}
tf->tf_r0 = type;
tf->tf_r1 = (int) sas;
tf->tf_r2 = nevents;
tf->tf_r3 = ninterrupted;
tf->tf_pc = (int) upcall;
tf->tf_usr_sp = (int) sf;
tf->tf_usr_lr = 0; /* no return */
}
开发者ID:MarginC,项目名称:kame,代码行数:38,代码来源:arm_machdep.c
示例4: setupstack_siginfo3
static vaddr_t
setupstack_siginfo3(const ksiginfo_t *ksi, const sigset_t *mask, int vers,
struct lwp *l, struct trapframe *tf, vaddr_t sp, int onstack,
vaddr_t handler)
{
struct trampoline3 tramp;
ucontext_t uc;
/*
* Arguments given to the signal handler.
*/
tramp.narg = 3;
tramp.sig = ksi->ksi_signo;
sp -= sizeof(uc); tramp.ucp = sp;
sp -= sizeof(siginfo_t); tramp.sip = sp;
sp -= sizeof(tramp);
/* Save register context. */
uc.uc_flags = _UC_SIGMASK;
uc.uc_sigmask = *mask;
uc.uc_link = NULL;
memset(&uc.uc_stack, 0, sizeof(uc.uc_stack));
cpu_getmcontext(l, &uc.uc_mcontext, &uc.uc_flags);
tf->fp = handler;
/* Copy the context to the stack. */
if (copyout(&uc, (char *)tramp.ucp, sizeof(uc)) != 0 ||
copyout(&ksi->ksi_info, (char *)tramp.sip, sizeof(ksi->ksi_info)) != 0 ||
copyout(&tramp, (char *)sp, sizeof(tramp)) != 0)
sigexit(l, SIGILL);
return sp;
};
开发者ID:MarginC,项目名称:kame,代码行数:34,代码来源:sig_machdep.c
示例5: sendsig_siginfo
/*
* Send a signal to process.
*/
void
sendsig_siginfo(const ksiginfo_t *ksi, const sigset_t *mask)
{
struct lwp * const l = curlwp;
struct proc * const p = l->l_proc;
struct sigacts * const sa = p->p_sigacts;
struct trapframe * const tf = l->l_md.md_utf;
const int signo = ksi->ksi_signo;
const sig_t catcher = SIGACTION(p, signo).sa_handler;
bool onstack;
struct COMPATNAME2(sigframe_siginfo) *sf =
cpu_sendsig_getframe(l, signo, &onstack);
struct COMPATNAME2(sigframe_siginfo) ksf;
sf--; // allocate sigframe
COPY_SIGINFO(&ksf, ksi);
ksf.sf_uc.uc_flags = _UC_SIGMASK
| (l->l_sigstk.ss_flags & SS_ONSTACK ? _UC_SETSTACK : _UC_CLRSTACK);
ksf.sf_uc.uc_sigmask = *mask;
UCLINK_SET(&ksf.sf_uc, l->l_ctxlink);
memset(&ksf.sf_uc.uc_stack, 0, sizeof(ksf.sf_uc.uc_stack));
sendsig_reset(l, signo);
mutex_exit(p->p_lock);
COMPATNAME2(cpu_getmcontext)(l, &ksf.sf_uc.uc_mcontext,
&ksf.sf_uc.uc_flags);
int error = copyout(&ksf, sf, sizeof(ksf));
mutex_enter(p->p_lock);
if (error != 0) {
/*
* Process has trashed its stack; give it an illegal
* instruction to halt it in its tracks.
*/
sigexit(l, SIGILL);
/* NOTREACHED */
}
/*
* Set up the registers to directly invoke the signal
* handler. The return address will be set up to point
* to the signal trampoline to bounce us back.
*/
tf->tf_a0 = signo;
tf->tf_a1 = (intptr_t)&sf->sf_si;
tf->tf_a2 = (intptr_t)&sf->sf_uc;
tf->tf_pc = (intptr_t)catcher;
tf->tf_sp = (intptr_t)sf;
tf->tf_ra = (intptr_t)sa->sa_sigdesc[signo].sd_tramp;
/* Remember that we're now on the signal stack. */
if (onstack)
l->l_sigstk.ss_flags |= SS_ONSTACK;
}
开发者ID:goroutines,项目名称:rumprun,代码行数:59,代码来源:sig_machdep.c
示例6: stackgap_init
caddr_t
stackgap_init(struct proc *p)
{
struct process *pr = p->p_p;
if (pr->ps_stackgap == 0) {
if (uvm_map(&pr->ps_vmspace->vm_map, &pr->ps_stackgap,
round_page(STACKGAPLEN), NULL, 0, 0,
UVM_MAPFLAG(PROT_READ | PROT_WRITE, PROT_READ | PROT_WRITE,
MAP_INHERIT_COPY, MADV_RANDOM, UVM_FLAG_COPYONW)))
sigexit(p, SIGILL);
}
return (caddr_t)pr->ps_stackgap;
}
开发者ID:orumin,项目名称:openbsd-efivars,代码行数:15,代码来源:compat_util.c
示例7: sendsig
void
sendsig(const ksiginfo_t *ksi, const sigset_t *mask)
{
struct lwp *l = curlwp;
struct proc *p = l->l_proc;
struct trapframe *tf = l->l_addr->u_pcb.framep;
struct sigaltstack *ss = &p->p_sigctx.ps_sigstk;
const struct sigact_sigdesc *sd =
&p->p_sigacts->sa_sigdesc[ksi->ksi_signo];
vaddr_t sp;
int onstack;
sig_setupstack_t setup;
/* Figure what stack we are running on. */
onstack = (ss->ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 &&
(sd->sd_sigact.sa_flags & SA_ONSTACK) != 0;
sp = onstack ? ((vaddr_t)ss->ss_sp + ss->ss_size) : tf->sp;
if (sd->sd_vers > 3 || (setup = sig_setupstacks[sd->sd_vers]) == NULL)
goto nosupport;
sp = (*setup)(ksi, mask, sd->sd_vers, l, tf, sp, onstack,
(vaddr_t)sd->sd_sigact.sa_handler);
if (sp == 0)
goto nosupport;
if (sd->sd_vers == 0)
tf->pc = (register_t)p->p_sigctx.ps_sigcode;
else
tf->pc = (register_t)sd->sd_tramp;
tf->psl = PSL_U | PSL_PREVU;
tf->sp = sp;
tf->ap = sp;
if (onstack)
ss->ss_flags |= SS_ONSTACK;
return;
nosupport:
/* Don't know what trampoline version; kill it. */
printf("sendsig(sig %d): bad version %d\n",
ksi->ksi_signo, sd->sd_vers);
sigexit(l, SIGILL);
}
开发者ID:MarginC,项目名称:kame,代码行数:45,代码来源:sig_machdep.c
示例8: vm86_return
void
vm86_return(struct proc *p, int retval)
{
union sigval sv;
/*
* We can't set the virtual flags in our real trap frame,
* since it's used to jump to the signal handler. Instead we
* let sendsig() pull in the vm86_eflags bits.
*/
if (p->p_sigmask & sigmask(SIGURG)) {
#ifdef DIAGNOSTIC
printf("pid %d killed on VM86 protocol screwup (SIGURG blocked)\n",
p->p_pid);
#endif
sigexit(p, SIGILL);
/* NOTREACHED */
}
sv.sival_int = 0;
trapsignal(p, SIGURG, retval, 0, sv);
}
开发者ID:repos-holder,项目名称:openbsd-patches,代码行数:21,代码来源:vm86.c
示例9: netbsd32_sendsig_siginfo
static void
netbsd32_sendsig_siginfo(const ksiginfo_t *ksi, const sigset_t *mask)
{
struct lwp *l = curlwp;
struct proc *p = l->l_proc;
struct sigacts *ps = p->p_sigacts;
int onstack;
int sig = ksi->ksi_signo;
ucontext32_t uc;
struct sparc32_sigframe_siginfo *fp;
siginfo32_t si32;
netbsd32_intptr_t catcher;
struct trapframe64 *tf = l->l_md.md_tf;
struct rwindow32 *oldsp, *newsp;
register32_t sp;
int ucsz, error;
/* Need to attempt to zero extend this 32-bit pointer */
oldsp = (struct rwindow32*)(u_long)(u_int)tf->tf_out[6];
/* Do we need to jump onto the signal stack? */
onstack =
(l->l_sigstk.ss_flags & (SS_DISABLE | SS_ONSTACK)) == 0 &&
(SIGACTION(p, sig).sa_flags & SA_ONSTACK) != 0;
/* Allocate space for the signal handler context. */
if (onstack)
fp = (struct sparc32_sigframe_siginfo *)
((char *)l->l_sigstk.ss_sp +
l->l_sigstk.ss_size);
else
fp = (struct sparc32_sigframe_siginfo *)oldsp;
fp = (struct sparc32_sigframe_siginfo*)((u_long)(fp - 1) & ~7);
/*
* Build the signal context to be used by sigreturn.
*/
memset(&uc, 0, sizeof uc);
uc.uc_flags = _UC_SIGMASK |
((l->l_sigstk.ss_flags & SS_ONSTACK)
? _UC_SETSTACK : _UC_CLRSTACK);
uc.uc_sigmask = *mask;
uc.uc_link = (uint32_t)(uintptr_t)l->l_ctxlink;
sendsig_reset(l, sig);
/*
* Now copy the stack contents out to user space.
* We need to make sure that when we start the signal handler,
* its %i6 (%fp), which is loaded from the newly allocated stack area,
* joins seamlessly with the frame it was in when the signal occurred,
* so that the debugger and _longjmp code can back up through it.
* Since we're calling the handler directly, allocate a full size
* C stack frame.
*/
mutex_exit(p->p_lock);
cpu_getmcontext32(l, &uc.uc_mcontext, &uc.uc_flags);
netbsd32_si_to_si32(&si32, (const siginfo_t *)&ksi->ksi_info);
ucsz = (int)(intptr_t)&uc.__uc_pad - (int)(intptr_t)&uc;
newsp = (struct rwindow32*)((intptr_t)fp - sizeof(struct frame32));
sp = NETBSD32PTR32I(oldsp);
error = (copyout(&si32, &fp->sf_si, sizeof si32) ||
copyout(&uc, &fp->sf_uc, ucsz) ||
copyout(&sp, &newsp->rw_in[6], sizeof(sp)));
mutex_enter(p->p_lock);
if (error) {
/*
* Process has trashed its stack; give it an illegal
* instruction to halt it in its tracks.
*/
sigexit(l, SIGILL);
/* NOTREACHED */
}
switch (ps->sa_sigdesc[sig].sd_vers) {
default:
/* Unsupported trampoline version; kill the process. */
sigexit(l, SIGILL);
case 2:
/*
* Arrange to continue execution at the user's handler.
* It needs a new stack pointer, a return address and
* three arguments: (signo, siginfo *, ucontext *).
*/
catcher = (intptr_t)SIGACTION(p, sig).sa_handler;
tf->tf_pc = catcher;
tf->tf_npc = catcher + 4;
tf->tf_out[0] = sig;
tf->tf_out[1] = (intptr_t)&fp->sf_si;
tf->tf_out[2] = (intptr_t)&fp->sf_uc;
tf->tf_out[6] = (intptr_t)newsp;
tf->tf_out[7] = (intptr_t)ps->sa_sigdesc[sig].sd_tramp - 8;
break;
}
/* Remember that we're now on the signal stack. */
if (onstack)
l->l_sigstk.ss_flags |= SS_ONSTACK;
}
开发者ID:ycui1984,项目名称:netbsd-src,代码行数:99,代码来源:netbsd32_machdep.c
示例10: cpu_setmcontext32
int
cpu_setmcontext32(struct lwp *l, const mcontext32_t *mcp, unsigned int flags)
{
struct trapframe *tf = l->l_md.md_tf;
const __greg32_t *gr = mcp->__gregs;
struct proc *p = l->l_proc;
int error;
/* First ensure consistent stack state (see sendsig). */
write_user_windows();
if (rwindow_save(l)) {
mutex_enter(p->p_lock);
sigexit(l, SIGILL);
}
/* Restore register context, if any. */
if ((flags & _UC_CPU) != 0) {
error = cpu_mcontext32_validate(l, mcp);
if (error)
return error;
/* Restore general register context. */
/* take only tstate CCR (and ASI) fields */
tf->tf_tstate = (tf->tf_tstate & ~TSTATE_CCR) |
PSRCC_TO_TSTATE(gr[_REG32_PSR]);
tf->tf_pc = (uint64_t)gr[_REG32_PC];
tf->tf_npc = (uint64_t)gr[_REG32_nPC];
tf->tf_y = (uint64_t)gr[_REG32_Y];
tf->tf_global[1] = (uint64_t)gr[_REG32_G1];
tf->tf_global[2] = (uint64_t)gr[_REG32_G2];
tf->tf_global[3] = (uint64_t)gr[_REG32_G3];
tf->tf_global[4] = (uint64_t)gr[_REG32_G4];
tf->tf_global[5] = (uint64_t)gr[_REG32_G5];
tf->tf_global[6] = (uint64_t)gr[_REG32_G6];
/* done in lwp_setprivate */
/* tf->tf_global[7] = (uint64_t)gr[_REG32_G7]; */
tf->tf_out[0] = (uint64_t)gr[_REG32_O0];
tf->tf_out[1] = (uint64_t)gr[_REG32_O1];
tf->tf_out[2] = (uint64_t)gr[_REG32_O2];
tf->tf_out[3] = (uint64_t)gr[_REG32_O3];
tf->tf_out[4] = (uint64_t)gr[_REG32_O4];
tf->tf_out[5] = (uint64_t)gr[_REG32_O5];
tf->tf_out[6] = (uint64_t)gr[_REG32_O6];
tf->tf_out[7] = (uint64_t)gr[_REG32_O7];
/* %asi restored above; %fprs not yet supported. */
if (flags & _UC_TLSBASE)
lwp_setprivate(l, (void *)(uintptr_t)gr[_REG32_G7]);
/* XXX mcp->__gwins */
}
/* Restore floating point register context, if any. */
if ((flags & _UC_FPU) != 0) {
#ifdef notyet
struct fpstate64 *fsp;
const __fpregset_t *fpr = &mcp->__fpregs;
/*
* If we're the current FPU owner, simply reload it from
* the supplied context. Otherwise, store it into the
* process' FPU save area (which is used to restore from
* by lazy FPU context switching); allocate it if necessary.
*/
if ((fsp = l->l_md.md_fpstate) == NULL) {
fsp = pool_cache_get(fpstate_cache, PR_WAITOK);
l->l_md.md_fpstate = fsp;
} else {
/* Drop the live context on the floor. */
fpusave_lwp(l, false);
}
/* Note: sizeof fpr->__fpu_fr <= sizeof fsp->fs_regs. */
memcpy(fsp->fs_regs, &fpr->__fpu_fr, sizeof (fpr->__fpu_fr));
fsp->fs_fsr = mcp->__fpregs.__fpu_fsr;
fsp->fs_qsize = 0;
#if 0
/* Need more info! */
mcp->__fpregs.__fpu_q = NULL; /* `Need more info.' */
mcp->__fpregs.__fpu_qcnt = 0 /*fs.fs_qsize*/; /* See above */
#endif
#endif
}
#ifdef _UC_SETSTACK
mutex_enter(p->p_lock);
if (flags & _UC_SETSTACK)
l->l_sigstk.ss_flags |= SS_ONSTACK;
if (flags & _UC_CLRSTACK)
l->l_sigstk.ss_flags &= ~SS_ONSTACK;
mutex_exit(p->p_lock);
#endif
return (0);
}
开发者ID:ycui1984,项目名称:netbsd-src,代码行数:93,代码来源:netbsd32_machdep.c
示例11: netbsd32_sendsig_sigcontext
//.........这里部分代码省略.........
printf("sendsig: %s[%d] sig %d newusp %p scp %p oldsp %p\n",
p->p_comm, p->p_pid, sig, fp, &fp->sf_sc, oldsp);
if (sigdebug & SDB_DDB) Debugger();
}
#endif
/*
* Now set up the signal frame. We build it in kernel space
* and then copy it out. We probably ought to just build it
* directly in user space....
*/
sf.sf_signo = sig;
sf.sf_code = (u_int)ksi->ksi_trap;
#if defined(COMPAT_SUNOS) || defined(MODULAR)
sf.sf_scp = (u_long)&fp->sf_sc;
#endif
sf.sf_addr = 0; /* XXX */
/*
* Build the signal context to be used by sigreturn.
*/
sf.sf_sc.sc_onstack = onstack;
sf.sf_sc.sc_mask = *mask;
sf.sf_sc.sc_sp = (u_long)oldsp;
sf.sf_sc.sc_pc = tf->tf_pc;
sf.sf_sc.sc_npc = tf->tf_npc;
sf.sf_sc.sc_psr = TSTATECCR_TO_PSR(tf->tf_tstate); /* XXX */
sf.sf_sc.sc_g1 = tf->tf_global[1];
sf.sf_sc.sc_o0 = tf->tf_out[0];
/*
* Put the stack in a consistent state before we whack away
* at it. Note that write_user_windows may just dump the
* registers into the pcb; we need them in the process's memory.
* We also need to make sure that when we start the signal handler,
* its %i6 (%fp), which is loaded from the newly allocated stack area,
* joins seamlessly with the frame it was in when the signal occurred,
* so that the debugger and _longjmp code can back up through it.
*/
sendsig_reset(l, sig);
mutex_exit(p->p_lock);
newsp = (struct rwindow32 *)((long)fp - sizeof(struct rwindow32));
write_user_windows();
#ifdef DEBUG
if ((sigdebug & SDB_KSTACK))
printf("sendsig: saving sf to %p, setting stack pointer %p to %p\n",
fp, &(((struct rwindow32 *)newsp)->rw_in[6]), oldsp);
#endif
sp = NETBSD32PTR32I(oldsp);
error = (rwindow_save(l) ||
copyout(&sf, fp, sizeof sf) ||
copyout(&sp, &(((struct rwindow32 *)newsp)->rw_in[6]),
sizeof(sp)));
mutex_enter(p->p_lock);
if (error) {
/*
* Process has trashed its stack; give it an illegal
* instruction to halt it in its tracks.
*/
#ifdef DEBUG
mutex_exit(p->p_lock);
if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid)
printf("sendsig: window save or copyout error\n");
printf("sendsig: stack was trashed trying to send sig %d, sending SIGILL\n", sig);
if (sigdebug & SDB_DDB) Debugger();
mutex_enter(p->p_lock);
#endif
sigexit(l, SIGILL);
/* NOTREACHED */
}
#ifdef DEBUG
if (sigdebug & SDB_FOLLOW) {
printf("sendsig: %s[%d] sig %d scp %p\n",
p->p_comm, p->p_pid, sig, &fp->sf_sc);
}
#endif
/*
* Arrange to continue execution at the code copied out in exec().
* It needs the function to call in %g1, and a new stack pointer.
*/
addr = p->p_psstrp - szsigcode;
tf->tf_global[1] = (long)catcher;
tf->tf_pc = addr;
tf->tf_npc = addr + 4;
tf->tf_out[6] = (uint64_t)(u_int)(u_long)newsp;
/* Remember that we're now on the signal stack. */
if (onstack)
l->l_sigstk.ss_flags |= SS_ONSTACK;
#ifdef DEBUG
if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) {
mutex_exit(p->p_lock);
printf("sendsig: about to return to catcher %p thru %p\n",
catcher, addr);
if (sigdebug & SDB_DDB) Debugger();
mutex_enter(p->p_lock);
}
#endif
}
开发者ID:ycui1984,项目名称:netbsd-src,代码行数:101,代码来源:netbsd32_machdep.c
示例12: linux_sys_rt_sigreturn
int
linux_sys_rt_sigreturn(struct lwp *l, const void *v, register_t *retval)
{
struct linux_ucontext *luctx;
struct trapframe *tf = l->l_md.md_regs;
struct linux_sigcontext *lsigctx;
struct linux_rt_sigframe frame, *fp;
ucontext_t uctx;
mcontext_t *mctx;
int error;
fp = (struct linux_rt_sigframe *)(tf->tf_regs[_R_SP]);
if ((error = copyin(fp, &frame, sizeof(frame))) != 0) {
mutex_enter(l->l_proc->p_lock);
sigexit(l, SIGILL);
return error;
}
luctx = &frame.lrs_uc;
lsigctx = &luctx->luc_mcontext;
bzero(&uctx, sizeof(uctx));
mctx = (mcontext_t *)&uctx.uc_mcontext;
/*
* Set the flags. Linux always have CPU, stack and signal state,
* FPU is optional. uc_flags is not used to tell what we have.
*/
uctx.uc_flags = (_UC_SIGMASK|_UC_CPU|_UC_STACK);
uctx.uc_link = NULL;
/*
* Signal set.
*/
linux_to_native_sigset(&uctx.uc_sigmask, &luctx->luc_sigmask);
/*
* CPU state.
*/
memcpy(mctx->__gregs, lsigctx->lsc_regs, sizeof(lsigctx->lsc_regs));
/*
* And the stack.
*/
uctx.uc_stack.ss_flags = 0;
if (luctx->luc_stack.ss_flags & LINUX_SS_ONSTACK)
uctx.uc_stack.ss_flags |= SS_ONSTACK;
if (luctx->luc_stack.ss_flags & LINUX_SS_DISABLE)
uctx.uc_stack.ss_flags |= SS_DISABLE;
uctx.uc_stack.ss_sp = luctx->luc_stack.ss_sp;
uctx.uc_stack.ss_size = luctx->luc_stack.ss_size;
/*
* And let setucontext deal with that.
*/
mutex_enter(l->l_proc->p_lock);
error = setucontext(l, &uctx);
mutex_exit(l->l_proc->p_lock);
if (error)
return error;
return (EJUSTRETURN);
}
开发者ID:Tommmster,项目名称:netbsd-avr32,代码行数:65,代码来源:linux_machdep.c
示例13: sendsig
void
sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
{
struct thread *td;
struct proc *p;
struct trapframe *tf;
struct sigframe *fp, frame;
struct sigacts *psp;
int code, onstack, sig;
td = curthread;
p = td->td_proc;
PROC_LOCK_ASSERT(p, MA_OWNED);
sig = ksi->ksi_signo;
code = ksi->ksi_code;
psp = p->p_sigacts;
mtx_assert(&psp->ps_mtx, MA_OWNED);
tf = td->td_frame;
onstack = sigonstack(tf->tf_sp);
CTR4(KTR_SIG, "sendsig: td=%p (%s) catcher=%p sig=%d", td, p->p_comm,
catcher, sig);
/* Allocate and validate space for the signal handler context. */
if ((td->td_pflags & TDP_ALTSTACK) != 0 && !onstack &&
SIGISMEMBER(psp->ps_sigonstack, sig)) {
fp = (struct sigframe *)(td->td_sigstk.ss_sp +
td->td_sigstk.ss_size);
#if defined(COMPAT_43)
td->td_sigstk.ss_flags |= SS_ONSTACK;
#endif
} else {
fp = (struct sigframe *)td->td_frame->tf_sp;
}
/* Make room, keeping the stack aligned */
fp--;
fp = (struct sigframe *)STACKALIGN(fp);
/* Fill in the frame to copy out */
get_mcontext(td, &frame.sf_uc.uc_mcontext, 0);
get_fpcontext(td, &frame.sf_uc.uc_mcontext);
frame.sf_si = ksi->ksi_info;
frame.sf_uc.uc_sigmask = *mask;
frame.sf_uc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK) ?
((onstack) ? SS_ONSTACK : 0) : SS_DISABLE;
frame.sf_uc.uc_stack = td->td_sigstk;
mtx_unlock(&psp->ps_mtx);
PROC_UNLOCK(td->td_proc);
/* Copy the sigframe out to the user's stack. */
if (copyout(&frame, fp, sizeof(*fp)) != 0) {
/* Process has trashed its stack. Kill it. */
CTR2(KTR_SIG, "sendsig: sigexit td=%p fp=%p", td, fp);
PROC_LOCK(p);
sigexit(td, SIGILL);
}
tf->tf_x[0]= sig;
tf->tf_x[1] = (register_t)&fp->sf_si;
tf->tf_x[2] = (register_t)&fp->sf_uc;
tf->tf_elr = (register_t)catcher;
tf->tf_sp = (register_t)fp;
tf->tf_lr = (register_t)(PS_STRINGS - *(p->p_sysent->sv_szsigcode));
CTR3(KTR_SIG, "sendsig: return td=%p pc=%#x sp=%#x", td, tf->tf_elr,
tf->tf_sp);
PROC_LOCK(p);
mtx_lock(&psp->ps_mtx);
}
开发者ID:ralphost,项目名称:NextBSD,代码行数:74,代码来源:machdep.c
示例14: netbsd32_cpu_setmcontext
int
netbsd32_cpu_setmcontext(
struct lwp *l,
/* XXX const netbsd32_*/mcontext_t *mcp,
unsigned int flags)
{
#ifdef NOT_YET
/* XXX */
greg32_t *gr = mcp->__gregs;
struct trapframe64 *tf = l->l_md.md_tf;
/* First ensure consistent stack state (see sendsig). */
write_user_windows();
if (rwindow_save(p)) {
mutex_enter(l->l_proc->p_lock);
sigexit(p, SIGILL);
}
if ((flags & _UC_CPU) != 0) {
/*
* Only the icc bits in the psr are used, so it need not be
* verified. pc and npc must be multiples of 4. This is all
* that is required; if it holds, just do it.
*/
if (((gr[_REG_PC] | gr[_REG_nPC]) & 3) != 0 ||
gr[_REG_PC] == 0 || gr[_REG_nPC] == 0)
return (EINVAL);
/* Restore general register context. */
/* take only tstate CCR (and ASI) fields */
tf->tf_tstate = (tf->tf_tstate & ~TSTATE_CCR) |
PSRCC_TO_TSTATE(gr[_REG_PSR]);
tf->tf_pc = (uint64_t)gr[_REG_PC];
tf->tf_npc = (uint64_t)gr[_REG_nPC];
tf->tf_y = (uint64_t)gr[_REG_Y];
tf->tf_global[1] = (uint64_t)gr[_REG_G1];
tf->tf_global[2] = (uint64_t)gr[_REG_G2];
tf->tf_global[3] = (uint64_t)gr[_REG_G3];
tf->tf_global[4] = (uint64_t)gr[_REG_G4];
tf->tf_global[5] = (uint64_t)gr[_REG_G5];
tf->tf_global[6] = (uint64_t)gr[_REG_G6];
tf->tf_global[7] = (uint64_t)gr[_REG_G7];
tf->tf_out[0] = (uint64_t)gr[_REG_O0];
tf->tf_out[1] = (uint64_t)gr[_REG_O1];
tf->tf_out[2] = (uint64_t)gr[_REG_O2];
tf->tf_out[3] = (uint64_t)gr[_REG_O3];
tf->tf_out[4] = (uint64_t)gr[_REG_O4];
tf->tf_out[5] = (uint64_t)gr[_REG_O5];
tf->tf_out[6] = (uint64_t)gr[_REG_O6];
tf->tf_out[7] = (uint64_t)gr[_REG_O7];
/* %asi restored above; %fprs not yet supported. */
/* XXX mcp->__gwins */
}
/* Restore FP register context, if any. */
if ((flags & _UC_FPU) != 0 && mcp->__fpregs.__fpu_en != 0) {
struct fpstate *fsp;
const netbsd32_fpregset_t *fpr = &mcp->__fpregs;
int reload = 0;
/*
* If we're the current FPU owner, simply reload it from
* the supplied context. Otherwise, store it into the
* process' FPU save area (which is used to restore from
* by lazy FPU context switching); allocate it if necessary.
*/
/*
* XXX Should we really activate the supplied FPU context
* XXX immediately or just fault it in later?
*/
if ((fsp = l->l_md.md_fpstate) == NULL) {
fsp = pool_cache_get(fpstate_cache, PR_WAITOK);
l->l_md.md_fpstate = fsp;
} else {
/* Drop the live context on the floor. */
fpusave_lwp(l, false);
reload = 1;
}
/* Note: sizeof fpr->__fpu_fr <= sizeof fsp->fs_regs. */
memcpy(fsp->fs_regs, fpr->__fpu_fr, sizeof (fpr->__fpu_fr));
fsp->fs_fsr = fpr->__fpu_fsr; /* don't care about fcc1-3 */
fsp->fs_qsize = 0;
#if 0
/* Need more info! */
mcp->__fpregs.__fpu_q = NULL; /* `Need more info.' */
mcp->__fpregs.__fpu_qcnt = 0 /*fs.fs_qsize*/; /* See above */
#endif
/* Reload context again, if necessary. */
if (reload)
loadfpstate(fsp);
}
/* XXX mcp->__xrs */
/* XXX mcp->__asrs */
#endif
return (0);
}
开发者ID:ycui1984,项目名称:netbsd-src,代码行数:100,代码来源:netbsd32_machdep.c
示例15: cheriabi_sendsig
//.........这里部分代码省略.........
/* XXXRW: sf.sf_uc.uc_mcontext.sr seems never to be set? */
sf.sf_uc.uc_mcontext.cause = regs->cause;
cheri_trapframe_to_cheriframe(&td->td_pcb->pcb_regs,
&sf.sf_uc.uc_mcontext.mc_cheriframe);
/*
* Allocate and validate space for the signal handler context. For
* CheriABI purposes, 'sp' from this point forward is relocated
* relative to any pertinent stack capability. For an alternative
* signal context, we need to recalculate stackbase for later use in
* calculating a new $sp for the signal-handling context.
*
* XXXRW: It seems like it would be nice to both the regular and
* alternative stack calculations in the same place. However, we need
* oonstack sooner. We should clean this up later.
*/
if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack &&
SIGISMEMBER(psp->ps_sigonstack, sig)) {
stackbase = (vm_offset_t)td->td_sigstk.ss_sp;
sp = (vm_offset_t)(stackbase + td->td_sigstk.ss_size);
} else {
/*
* Signals delivered when a CHERI sandbox is present must be
* delivered on the alternative stack rather than a local one.
* If an alternative stack isn't present, then terminate or
* risk leaking capabilities (and control) to the sandbox (or
* just crashing the sandbox).
*/
if (cheri_is_sandboxed) {
mtx_unlock(&psp->ps_mtx);
printf("pid %d, tid %d: signal in sandbox without "
"alternative stack defined\n", td->td_proc->p_pid,
td->td_tid);
sigexit(td, SIGILL);
/* NOTREACHED */
}
sp = (vm_offset_t)(stackbase + regs->sp);
}
sp -= sizeof(struct sigframe_c);
/* For CHERI, keep the stack pointer capability aligned. */
sp &= ~(CHERICAP_SIZE - 1);
sfp = (void *)sp;
/* Build the argument list for the signal handler. */
regs->a0 = sig;
if (SIGISMEMBER(psp->ps_siginfo, sig)) {
/*
* Signal handler installed with SA_SIGINFO.
*
* XXXRW: We would ideally synthesise these from the
* user-originated stack capability, rather than $kdc, to be
* on the safe side.
*/
cheri_capability_set(®s->c3, CHERI_CAP_USER_DATA_PERMS,
(void *)(intptr_t)&sfp->sf_si, sizeof(sfp->sf_si), 0);
cheri_capability_set(®s->c4, CHERI_CAP_USER_DATA_PERMS,
(void *)(intptr_t)&sfp->sf_uc, sizeof(sfp->sf_uc), 0);
/* sf.sf_ahu.sf_action = (__siginfohandler_t *)catcher; */
/* fill siginfo structure */
sf.sf_si.si_signo = sig;
sf.sf_si.si_code = ksi->ksi_code;
/*
* Write out badvaddr, but don't create a valid capability
* since that might allow privilege amplification.
*
开发者ID:RichardsonAlex,项目名称:cheribsd,代码行数:67,代码来源:cheriabi_machdep.c
示例16: ia32_sendsig
//.........这里部分代码省略.........
/* Save user context. */
bzero(&sf, sizeof(sf));
sf.sf_uc.uc_sigmask = *mask;
sf.sf_uc.uc_stack.ss_sp = (uintptr_t)td->td_sigstk.ss_sp;
sf.sf_uc.uc_stack.ss_size = td->td_sigstk.ss_size;
sf.sf_uc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK)
? ((oonstack) ? SS_ONSTACK : 0) : SS_DISABLE;
sf.sf_uc.uc_mcontext.mc_onstack = (oonstack) ? 1 : 0;
sf.sf_uc.uc_mcontext.mc_edi = regs->tf_rdi;
sf.sf_uc.uc_mcontext.mc_esi = regs->tf_rsi;
sf.sf_uc.uc_mcontext.mc_ebp = regs->tf_rbp;
sf.sf_uc.uc_mcontext.mc_isp = regs->tf_rsp; /* XXX */
sf.sf_uc.uc_mcontext.mc_ebx = regs->tf_rbx;
sf.sf_uc.uc_mcontext.mc_edx = regs->tf_rdx;
sf.sf_uc.uc_mcontext.mc_ecx = regs->tf_rcx;
sf.sf_uc.uc_mcontext.mc_eax = regs->tf_rax;
sf.sf_uc.uc_mcontext.mc_trapno = regs->tf_trapno;
sf.sf_uc.uc_mcontext.mc_err = regs->tf_err;
sf.sf_uc.uc_mcontext.mc_eip = regs->tf_rip;
sf.sf_uc.uc_mcontext.mc_cs = regs->tf_cs;
sf.sf_uc.uc_mcontext.mc_eflags = regs->tf_rflags;
sf.sf_uc.uc_mcontext.mc_esp = regs->tf_rsp;
sf.sf_uc.uc_mcontext.mc_ss = regs->tf_ss;
sf.sf_uc.uc_mcontext.mc_ds = regs->tf_ds;
sf.sf_uc.uc_mcontext.mc_es = regs->tf_es;
sf.sf_uc.uc_mcontext.mc_fs = regs->tf_fs;
sf.sf_uc.uc_mcontext.mc_gs = regs->tf_gs;
sf.sf_uc.uc_mcontext.mc_len = sizeof(sf.sf_uc.uc_mcontext); /* magic */
ia32_get_fpcontext(td, &sf.sf_uc.uc_mcontext, xfpusave, xfpusave_len);
fpstate_drop(td);
sf.sf_uc.uc_mcontext.mc_fsbase = td->td_pcb->pcb_fsbase;
sf.sf_uc.uc_mcontext.mc_gsbase = td->td_pcb->pcb_gsbase;
bzero(sf.sf_uc.__spare__, sizeof(sf.sf_uc.__spare__));
/* Allocate space for the signal handler context. */
if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack &&
SIGISMEMBER(psp->ps_sigonstack, sig))
sp = td->td_sigstk.ss_sp + td->td_sigstk.ss_size;
else
sp = (char *)regs->tf_rsp;
if (xfpusave != NULL) {
sp -= xfpusave_len;
sp = (char *)((unsigned long)sp & ~0x3Ful);
sf.sf_uc.uc_mcontext.mc_xfpustate = (register_t)sp;
}
sp -= sizeof(sf);
/* Align to 16 bytes. */
sfp = (struct ia32_sigframe *)((uintptr_t)sp & ~0xF);
PROC_UNLOCK(p);
/* Translate the signal if appropriate. */
if (p->p_sysent->sv_sigtbl && sig <= p->p_sysent->sv_sigsize)
sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)];
/* Build the argument list for the signal handler. */
sf.sf_signum = sig;
sf.sf_ucontext = (register_t)&sfp->sf_uc;
bzero(&sf.sf_si, sizeof(sf.sf_si));
if (SIGISMEMBER(psp->ps_siginfo, sig)) {
/* Signal handler installed with SA_SIGINFO. */
sf.sf_siginfo = (u_int32_t)(uintptr_t)&sfp->sf_si;
sf.sf_ah = (u_int32_t)(uintptr_t)catcher;
/* Fill in POSIX parts */
sf.sf_si = siginfo;
sf.sf_si.si_signo = sig;
} else {
/* Old FreeBSD-style arguments. */
sf.sf_siginfo = siginfo.si_code;
sf.sf_addr = (u_int32_t)siginfo.si_addr;
sf.sf_ah = (u_int32_t)(uintptr_t)catcher;
}
mtx_unlock(&psp->ps_mtx);
/*
* Copy the sigframe out to the user's stack.
*/
if (copyout(&sf, sfp, sizeof(*sfp)) != 0 ||
(xfpusave != NULL && copyout(xfpusave,
PTRIN(sf.sf_uc.uc_mcontext.mc_xfpustate), xfpusave_len)
!= 0)) {
#ifdef DEBUG
printf("process %ld has trashed its stack\n", (long)p->p_pid);
#endif
PROC_LOCK(p);
sigexit(td, SIGILL);
}
regs->tf_rsp = (uintptr_t)sfp;
regs->tf_rip = p->p_sysent->sv_sigcode_base;
regs->tf_rflags &= ~(PSL_T | PSL_D);
regs->tf_cs = _ucode32sel;
regs->tf_ss = _udatasel;
regs->tf_ds = _udatasel;
regs->tf_es = _udatasel;
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
/* XXXKIB leave user %fs and %gs untouched */
PROC_LOCK(p);
mtx_lock(&psp->ps_mtx);
}
开发者ID:BillTheBest,项目名称:libuinet,代码行数:101,代码来源:ia32_signal.c
示例17: freebsd4_ia32_sendsig
static void
freebsd4_ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
{
struct ia32_sigframe4 sf, *sfp;
struct siginfo32 siginfo;
struct proc *p;
struct thread *td;
struct sigacts *psp;
struct trapframe *regs;
int oonstack;
int sig;
td = curthread;
p = td->td_proc;
siginfo_to_siginfo32(&ksi->ksi_info, &siginfo);
PROC_LOCK_ASSERT(p, MA_OWNED);
sig = siginfo.si_signo;
psp = p->p_sigacts;
mtx_assert(&psp->ps_mtx, MA_OWNED);
regs = td->td_frame;
oonstack = sigonstack(regs->tf_rsp);
/* Save user context. */
bzero(&sf, sizeof(sf));
sf.sf_uc.uc_sigmask = *mask;
sf.sf_uc.uc_stack.ss_sp = (uintptr_t)td->td_sigstk.ss_sp;
sf.sf_uc.uc_stack.ss_size = td->td_sigstk.ss_size;
sf.sf_uc.uc_stack.ss_flags = (td->td_pflags & TDP_ALTSTACK)
? ((oonstack) ? SS_ONSTACK : 0) : SS_DISABLE;
sf.sf_uc.uc_mcontext.mc_onstack = (oonstack) ? 1 : 0;
sf.sf_uc.uc_mcontext.mc_edi = regs->tf_rdi;
sf.sf_uc.uc_mcontext.mc_esi = regs->tf_rsi;
sf.sf_uc.uc_mcontext.mc_ebp = regs->tf_rbp;
sf.sf_uc.uc_mcontext.mc_isp = regs->tf_rsp; /* XXX */
sf.sf_uc.uc_mcontext.mc_ebx = regs->tf_rbx;
sf.sf_uc.uc_mcontext.mc_edx = regs->tf_rdx;
sf.sf_uc.uc_mcontext.mc_ecx = regs->tf_rcx;
sf.sf_uc.uc_mcontext.mc_eax = regs->tf_rax;
sf.sf_uc.uc_mcontext.mc_trapno = regs->tf_trapno;
sf.sf_uc.uc_mcontext.mc_err = regs->tf_err;
sf.sf_uc.uc_mcontext.mc_eip = regs->tf_rip;
sf.sf_uc.uc_mcontext.mc_cs = regs->tf_cs;
sf.sf_uc.uc_mcontext.mc_eflags = regs->tf_rflags;
sf.sf_uc.uc_mcontext.mc_esp = regs->tf_rsp;
sf.sf_uc.uc_mcontext.mc_ss = regs->tf_ss;
sf.sf_uc.uc_mcontext.mc_ds = regs->tf_ds;
sf.sf_uc.uc_mcontext.mc_es = regs->tf_es;
sf.sf_uc.uc_mcontext.mc_fs = regs->tf_fs;
sf.sf_uc.uc_mcontext.mc_gs = regs->tf_gs;
bzero(sf.sf_uc.uc_mcontext.mc_fpregs,
sizeof(sf.sf_uc.uc_mcontext.mc_fpregs));
bzero(sf.sf_uc.uc_mcontext.__spare__,
sizeof(sf.sf_uc.uc_mcontext.__spare__));
bzero(sf.sf_uc.__spare__, sizeof(sf.sf_uc.__spare__));
/* Allocate space for the signal handler context. */
if ((td->td_pflags & TDP_ALTSTACK) != 0 && !oonstack &&
SIGISMEMBER(psp->ps_sigonstack, sig)) {
sfp = (struct ia32_sigframe4 *)(td->td_sigstk.ss_sp +
td->td_sigstk.ss_size - sizeof(sf));
} else
sfp = (struct ia32_sigframe4 *)regs->tf_rsp - 1;
PROC_UNLOCK(p);
/* Translate the signal if appropriate. */
if (p->p_sysent->sv_sigtbl && sig <= p->p_sysent->sv_sigsize)
sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)];
/* Build the argument list for the signal handler. */
sf.sf_signum = sig;
sf.sf_ucontext = (register_t)&sfp->sf_uc;
bzero(&sf.sf_si, sizeof(sf.sf_si));
if (SIGISMEMBER(psp->ps_siginfo, sig)) {
/* Signal handler installed with SA_SIGINFO. */
sf.sf_siginfo = (u_int32_t)(uintptr_t)&sfp->sf_si;
sf.sf_ah = (u_int32_t)(uintptr_t)catcher;
/* Fill in POSIX parts */
sf.sf_si = siginfo;
sf.sf_si.si_signo = sig;
} else {
/* Old FreeBSD-style arguments. */
sf.sf_siginfo = siginfo.si_code;
sf.sf_addr = (u_int32_t)siginfo.si_addr;
sf.sf_ah = (u_int32_t)(uintptr_t)catcher;
}
mtx_unlock(&psp->ps_mtx);
/*
* Copy the sigframe out to the user's stack.
*/
if (copyout(&sf, sfp, sizeof(*sfp)) != 0) {
#ifdef DEBUG
printf("process %ld has trashed its stack\n", (long)p->p_pid);
#endif
PROC_LOCK(p);
sigexit(td, SIGILL);
}
//.........这里部分代码省略.........
开发者ID:BillTheBest,项目名称:libuinet,代码行数:101,代码来源:ia32_signal.c
示例18: linux_sendsig
//.........这里部分代码省略.........
sig = ksi->ksi_signo;
code = ksi->ksi_code;
PROC_LOCK_ASSERT(p, MA_OWNED);
psp = p->p_sigacts;
mtx_assert(&psp->ps_mtx, MA_OWNED);
if (SIGISMEMBER(psp->ps_siginfo, sig)) {
/* Signal handler installed with SA_SIGINFO. */
linux_rt_sendsig(catcher, ksi, mask);
return;
}
regs = td->td_frame;
oonstack = sigonstack(regs->tf_rsp);
#ifdef DEBUG
if (ldebug(sendsig))
printf(ARGS(sendsig, "%p, %d, %p, %u"),
catcher, sig, (void*)mask, code);
#endif
/*
* Allocate space for the signal handler context.
*/
if ((td->td_pflags & TDP_ALTSTACK) && !oonstack &&
SIGISMEMBER(psp->ps_sigonstack, sig)) {
fp = (struct l_sigframe *)(td->td_sigstk.ss_sp +
td->td_sigstk.ss_size - sizeof(struct l_sigframe));
} else
fp = (struct l_sigframe *)regs->tf_rsp - 1;
mtx_unlock(&psp->ps_mtx);
PROC_UNLOCK(p);
/*
* Build the argument list for the signal handler.
*/
if (p->p_sysent->sv_sigtbl)
if (sig <= p->p_sysent->sv_sigsize)
sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)];
bzero(&frame, sizeof(frame));
frame.sf_handler = PTROUT(catcher);
frame.sf_sig = sig;
bsd_to_linux_sigset(mask, &lmask);
/*
* Build the signal context to be used by sigreturn.
*/
frame.sf_sc.sc_mask = lmask.__bits[0];
frame.sf_sc.sc_gs = regs->tf_gs;
frame.sf_sc.sc_fs = regs->tf_fs;
frame.sf_sc.sc_es = regs->tf_es;
frame.sf_sc.sc_ds = regs->tf_ds;
frame.sf_sc.sc_edi = regs->tf_rdi;
frame.sf_sc.sc_esi = regs->tf_rsi;
frame.sf_sc.sc_ebp = regs->tf_rbp;
frame.sf_sc.sc_ebx = regs->tf_rbx;
frame.sf_sc.sc_edx = regs->tf_rdx;
frame.sf_sc.sc_ecx = regs->tf_rcx;
frame.sf_sc.sc_eax = regs->tf_rax;
frame.sf_sc.sc_eip = regs->tf_rip;
frame.sf_sc.sc_cs = regs->tf_cs;
frame.sf_sc.sc_eflags = regs->tf_rflags;
frame.sf_sc.sc_esp_at_signal = regs->tf_rsp;
frame.sf_sc.sc_ss = regs->tf_ss;
frame.sf_sc.sc_err = regs->tf_err;
frame.sf_sc.sc_cr2 = (u_int32_t)(uintptr_t)ksi->ksi_addr;
frame.sf_sc.sc_trapno = bsd_to_linux_trapcode(code);
for (i = 0; i < (LINUX_NSIG_WORDS-1); i++)
frame.sf_extramask[i] = lmask.__bits[i+1];
if (copyout(&frame, fp, sizeof(frame)) != 0) {
/*
* Process has trashed its stack; give it an illegal
* instruction to halt it in its tracks.
*/
PROC_LOCK(p);
sigexit(td, SIGILL);
}
/*
* Build context to run handler in.
*/
regs->tf_rsp = PTROUT(fp);
regs->tf_rip = p->p_sysent->sv_sigcode_base;
regs->tf_rflags &= ~(PSL_T | PSL_D);
regs->tf_cs = _ucode32sel;
regs->tf_ss = _udatasel;
regs->tf_ds = _udatasel;
regs->tf_es = _udatasel;
regs->tf_fs = _ufssel;
regs->tf_gs = _ugssel;
regs->tf_flags = TF_HASSEGS;
set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
PROC_LOCK(p);
mtx_lock(&psp->ps_mtx);
}
开发者ID:Alkzndr,项目名称:freebsd,代码行数:101,代码来源:linux32_sysvec.c
|
请发表评论