Deleted Added
full compact
ia32_signal.c (216253) ia32_signal.c (216634)
1/*-
2 * Copyright (c) 2003 Peter Wemm
3 * Copyright (c) 1982, 1987, 1990 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * William Jolitz.
8 *

--- 18 unchanged lines hidden (view full) ---

27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2003 Peter Wemm
3 * Copyright (c) 1982, 1987, 1990 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * William Jolitz.
8 *

--- 18 unchanged lines hidden (view full) ---

27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
34#include <sys/cdefs.h>
35__FBSDID("$FreeBSD: head/sys/amd64/ia32/ia32_signal.c 216253 2010-12-07 12:17:43Z kib $");
35__FBSDID("$FreeBSD: head/sys/amd64/ia32/ia32_signal.c 216634 2010-12-22 00:18:42Z jkim $");
36
37#include "opt_compat.h"
38
39#include <sys/param.h>
40#include <sys/exec.h>
41#include <sys/fcntl.h>
42#include <sys/imgact.h>
43#include <sys/kernel.h>

--- 81 unchanged lines hidden (view full) ---

125}
126
127/*
128 * Get machine context.
129 */
130static int
131ia32_get_mcontext(struct thread *td, struct ia32_mcontext *mcp, int flags)
132{
36
37#include "opt_compat.h"
38
39#include <sys/param.h>
40#include <sys/exec.h>
41#include <sys/fcntl.h>
42#include <sys/imgact.h>
43#include <sys/kernel.h>

--- 81 unchanged lines hidden (view full) ---

125}
126
127/*
128 * Get machine context.
129 */
130static int
131ia32_get_mcontext(struct thread *td, struct ia32_mcontext *mcp, int flags)
132{
133 struct pcb *pcb;
133 struct trapframe *tp;
134
134 struct trapframe *tp;
135
136 pcb = td->td_pcb;
135 tp = td->td_frame;
136
137 PROC_LOCK(curthread->td_proc);
138 mcp->mc_onstack = sigonstack(tp->tf_rsp);
139 PROC_UNLOCK(curthread->td_proc);
140 /* Entry into kernel always sets TF_HASSEGS */
141 mcp->mc_gs = tp->tf_gs;
142 mcp->mc_fs = tp->tf_fs;

--- 15 unchanged lines hidden (view full) ---

158 mcp->mc_ebx = tp->tf_rbx;
159 mcp->mc_ecx = tp->tf_rcx;
160 mcp->mc_eip = tp->tf_rip;
161 mcp->mc_cs = tp->tf_cs;
162 mcp->mc_esp = tp->tf_rsp;
163 mcp->mc_ss = tp->tf_ss;
164 mcp->mc_len = sizeof(*mcp);
165 ia32_get_fpcontext(td, mcp);
137 tp = td->td_frame;
138
139 PROC_LOCK(curthread->td_proc);
140 mcp->mc_onstack = sigonstack(tp->tf_rsp);
141 PROC_UNLOCK(curthread->td_proc);
142 /* Entry into kernel always sets TF_HASSEGS */
143 mcp->mc_gs = tp->tf_gs;
144 mcp->mc_fs = tp->tf_fs;

--- 15 unchanged lines hidden (view full) ---

160 mcp->mc_ebx = tp->tf_rbx;
161 mcp->mc_ecx = tp->tf_rcx;
162 mcp->mc_eip = tp->tf_rip;
163 mcp->mc_cs = tp->tf_cs;
164 mcp->mc_esp = tp->tf_rsp;
165 mcp->mc_ss = tp->tf_ss;
166 mcp->mc_len = sizeof(*mcp);
167 ia32_get_fpcontext(td, mcp);
166 mcp->mc_fsbase = td->td_pcb->pcb_fsbase;
167 mcp->mc_gsbase = td->td_pcb->pcb_gsbase;
168 td->td_pcb->pcb_full_iret = 1;
168 mcp->mc_fsbase = pcb->pcb_fsbase;
169 mcp->mc_gsbase = pcb->pcb_gsbase;
170 set_pcb_flags(pcb, PCB_FULL_IRET);
169 return (0);
170}
171
172/*
173 * Set machine context.
174 *
175 * However, we don't set any but the user modifiable flags, and we won't
176 * touch the cs selector.

--- 25 unchanged lines hidden (view full) ---

202 tp->tf_rdx = mcp->mc_edx;
203 tp->tf_rcx = mcp->mc_ecx;
204 tp->tf_rax = mcp->mc_eax;
205 /* trapno, err */
206 tp->tf_rip = mcp->mc_eip;
207 tp->tf_rflags = rflags;
208 tp->tf_rsp = mcp->mc_esp;
209 tp->tf_ss = mcp->mc_ss;
171 return (0);
172}
173
174/*
175 * Set machine context.
176 *
177 * However, we don't set any but the user modifiable flags, and we won't
178 * touch the cs selector.

--- 25 unchanged lines hidden (view full) ---

204 tp->tf_rdx = mcp->mc_edx;
205 tp->tf_rcx = mcp->mc_ecx;
206 tp->tf_rax = mcp->mc_eax;
207 /* trapno, err */
208 tp->tf_rip = mcp->mc_eip;
209 tp->tf_rflags = rflags;
210 tp->tf_rsp = mcp->mc_esp;
211 tp->tf_ss = mcp->mc_ss;
210 td->td_pcb->pcb_full_iret = 1;
212 set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
211 return (0);
212}
213
214/*
215 * The first two fields of a ucontext_t are the signal mask and
216 * the machine context. The next field is uc_link; we want to
217 * avoid destroying the link when copying out contexts.
218 */

--- 173 unchanged lines hidden (view full) ---

392
393 regs->tf_rsp = (uintptr_t)sfp;
394 regs->tf_rip = p->p_sysent->sv_psstrings - sz_freebsd4_ia32_sigcode;
395 regs->tf_rflags &= ~(PSL_T | PSL_D);
396 regs->tf_cs = _ucode32sel;
397 regs->tf_ss = _udatasel;
398 regs->tf_ds = _udatasel;
399 regs->tf_es = _udatasel;
213 return (0);
214}
215
216/*
217 * The first two fields of a ucontext_t are the signal mask and
218 * the machine context. The next field is uc_link; we want to
219 * avoid destroying the link when copying out contexts.
220 */

--- 173 unchanged lines hidden (view full) ---

394
395 regs->tf_rsp = (uintptr_t)sfp;
396 regs->tf_rip = p->p_sysent->sv_psstrings - sz_freebsd4_ia32_sigcode;
397 regs->tf_rflags &= ~(PSL_T | PSL_D);
398 regs->tf_cs = _ucode32sel;
399 regs->tf_ss = _udatasel;
400 regs->tf_ds = _udatasel;
401 regs->tf_es = _udatasel;
400 td->td_pcb->pcb_full_iret = 1;
402 set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
401 /* leave user %fs and %gs untouched */
402 PROC_LOCK(p);
403 mtx_lock(&psp->ps_mtx);
404}
405#endif /* COMPAT_FREEBSD4 */
406
407void
408ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)

--- 104 unchanged lines hidden (view full) ---

513
514 regs->tf_rsp = (uintptr_t)sfp;
515 regs->tf_rip = p->p_sysent->sv_psstrings - *(p->p_sysent->sv_szsigcode);
516 regs->tf_rflags &= ~(PSL_T | PSL_D);
517 regs->tf_cs = _ucode32sel;
518 regs->tf_ss = _udatasel;
519 regs->tf_ds = _udatasel;
520 regs->tf_es = _udatasel;
403 /* leave user %fs and %gs untouched */
404 PROC_LOCK(p);
405 mtx_lock(&psp->ps_mtx);
406}
407#endif /* COMPAT_FREEBSD4 */
408
409void
410ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)

--- 104 unchanged lines hidden (view full) ---

515
516 regs->tf_rsp = (uintptr_t)sfp;
517 regs->tf_rip = p->p_sysent->sv_psstrings - *(p->p_sysent->sv_szsigcode);
518 regs->tf_rflags &= ~(PSL_T | PSL_D);
519 regs->tf_cs = _ucode32sel;
520 regs->tf_ss = _udatasel;
521 regs->tf_ds = _udatasel;
522 regs->tf_es = _udatasel;
521 td->td_pcb->pcb_full_iret = 1;
523 set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
522 /* XXXKIB leave user %fs and %gs untouched */
523 PROC_LOCK(p);
524 mtx_lock(&psp->ps_mtx);
525}
526
527/*
528 * System call to cleanup state after a signal
529 * has been taken. Reset signal mask and

--- 78 unchanged lines hidden (view full) ---

608 regs->tf_rsp = ucp->uc_mcontext.mc_esp;
609 regs->tf_ss = ucp->uc_mcontext.mc_ss;
610 regs->tf_ds = ucp->uc_mcontext.mc_ds;
611 regs->tf_es = ucp->uc_mcontext.mc_es;
612 regs->tf_fs = ucp->uc_mcontext.mc_fs;
613 regs->tf_gs = ucp->uc_mcontext.mc_gs;
614
615 kern_sigprocmask(td, SIG_SETMASK, &ucp->uc_sigmask, NULL, 0);
524 /* XXXKIB leave user %fs and %gs untouched */
525 PROC_LOCK(p);
526 mtx_lock(&psp->ps_mtx);
527}
528
529/*
530 * System call to cleanup state after a signal
531 * has been taken. Reset signal mask and

--- 78 unchanged lines hidden (view full) ---

610 regs->tf_rsp = ucp->uc_mcontext.mc_esp;
611 regs->tf_ss = ucp->uc_mcontext.mc_ss;
612 regs->tf_ds = ucp->uc_mcontext.mc_ds;
613 regs->tf_es = ucp->uc_mcontext.mc_es;
614 regs->tf_fs = ucp->uc_mcontext.mc_fs;
615 regs->tf_gs = ucp->uc_mcontext.mc_gs;
616
617 kern_sigprocmask(td, SIG_SETMASK, &ucp->uc_sigmask, NULL, 0);
616 td->td_pcb->pcb_full_iret = 1;
618 set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
617 return (EJUSTRETURN);
618}
619#endif /* COMPAT_FREEBSD4 */
620
621/*
622 * MPSAFE
623 */
624int

--- 72 unchanged lines hidden (view full) ---

697 regs->tf_ss = ucp->uc_mcontext.mc_ss;
698 regs->tf_ds = ucp->uc_mcontext.mc_ds;
699 regs->tf_es = ucp->uc_mcontext.mc_es;
700 regs->tf_fs = ucp->uc_mcontext.mc_fs;
701 regs->tf_gs = ucp->uc_mcontext.mc_gs;
702 regs->tf_flags = TF_HASSEGS;
703
704 kern_sigprocmask(td, SIG_SETMASK, &ucp->uc_sigmask, NULL, 0);
619 return (EJUSTRETURN);
620}
621#endif /* COMPAT_FREEBSD4 */
622
623/*
624 * MPSAFE
625 */
626int

--- 72 unchanged lines hidden (view full) ---

699 regs->tf_ss = ucp->uc_mcontext.mc_ss;
700 regs->tf_ds = ucp->uc_mcontext.mc_ds;
701 regs->tf_es = ucp->uc_mcontext.mc_es;
702 regs->tf_fs = ucp->uc_mcontext.mc_fs;
703 regs->tf_gs = ucp->uc_mcontext.mc_gs;
704 regs->tf_flags = TF_HASSEGS;
705
706 kern_sigprocmask(td, SIG_SETMASK, &ucp->uc_sigmask, NULL, 0);
705 td->td_pcb->pcb_full_iret = 1;
707 set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
706 return (EJUSTRETURN);
707}
708
709/*
710 * Clear registers on exec
711 */
712void
713ia32_setregs(struct thread *td, struct image_params *imgp, u_long stack)

--- 23 unchanged lines hidden (view full) ---

737 regs->tf_fs = _ufssel;
738 regs->tf_gs = _ugssel;
739 regs->tf_flags = TF_HASSEGS;
740
741 load_cr0(rcr0() | CR0_MP | CR0_TS);
742 fpstate_drop(td);
743
744 /* Return via doreti so that we can change to a different %cs */
708 return (EJUSTRETURN);
709}
710
711/*
712 * Clear registers on exec
713 */
714void
715ia32_setregs(struct thread *td, struct image_params *imgp, u_long stack)

--- 23 unchanged lines hidden (view full) ---

739 regs->tf_fs = _ufssel;
740 regs->tf_gs = _ugssel;
741 regs->tf_flags = TF_HASSEGS;
742
743 load_cr0(rcr0() | CR0_MP | CR0_TS);
744 fpstate_drop(td);
745
746 /* Return via doreti so that we can change to a different %cs */
745 pcb->pcb_flags |= PCB_32BIT;
746 pcb->pcb_flags &= ~PCB_GS32BIT;
747 td->td_pcb->pcb_full_iret = 1;
747 set_pcb_flags(pcb, PCB_32BIT | PCB_FULL_IRET);
748 clear_pcb_flags(pcb, PCB_GS32BIT);
748 td->td_retval[1] = 0;
749}
749 td->td_retval[1] = 0;
750}