summaryrefslogtreecommitdiffstats
path: root/sys/amd64/ia32
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2010-12-22 00:18:42 +0000
committerjkim <jkim@FreeBSD.org>2010-12-22 00:18:42 +0000
commit24b08bca030970592bc5241517b0462f603b05b1 (patch)
tree38bd55300c4f19ade4f88947688e903fcf6ef97c /sys/amd64/ia32
parentf4e75b41ae7145e275808cc561d4cacf0f9a51a7 (diff)
downloadFreeBSD-src-24b08bca030970592bc5241517b0462f603b05b1.zip
FreeBSD-src-24b08bca030970592bc5241517b0462f603b05b1.tar.gz
Improve PCB flags handling and make it more robust. Add two new functions
for manipulating pcb_flags. These inline functions are very similar to atomic_set_char(9) and atomic_clear_char(9) but without unnecessary LOCK prefix for SMP. Add comments about the rationale[1]. Use these functions wherever possible. Although there are some places where it is not strictly necessary (e.g., a PCB is copied to create a new PCB), it is done across the board for sake of consistency. Turn pcb_full_iret into a PCB flag as it is safe now. Move rarely used fields before pcb_flags and reduce size of pcb_flags to one byte. Fix some style(9) nits in pcb.h while I am in the neighborhood. Reviewed by: kib Submitted by: kib[1] MFC after: 2 months
Diffstat (limited to 'sys/amd64/ia32')
-rw-r--r--sys/amd64/ia32/ia32_reg.c2
-rw-r--r--sys/amd64/ia32/ia32_signal.c23
2 files changed, 13 insertions, 12 deletions
diff --git a/sys/amd64/ia32/ia32_reg.c b/sys/amd64/ia32/ia32_reg.c
index da6eb0f..279df9a 100644
--- a/sys/amd64/ia32/ia32_reg.c
+++ b/sys/amd64/ia32/ia32_reg.c
@@ -125,7 +125,7 @@ set_regs32(struct thread *td, struct reg32 *regs)
tp->tf_fs = regs->r_fs;
tp->tf_es = regs->r_es;
tp->tf_ds = regs->r_ds;
- td->td_pcb->pcb_full_iret = 1;
+ set_pcb_flags(pcb, PCB_FULL_IRET);
tp->tf_flags = TF_HASSEGS;
tp->tf_rdi = regs->r_edi;
tp->tf_rsi = regs->r_esi;
diff --git a/sys/amd64/ia32/ia32_signal.c b/sys/amd64/ia32/ia32_signal.c
index e0f30e2..808790b 100644
--- a/sys/amd64/ia32/ia32_signal.c
+++ b/sys/amd64/ia32/ia32_signal.c
@@ -130,8 +130,10 @@ ia32_set_fpcontext(struct thread *td, const struct ia32_mcontext *mcp)
static int
ia32_get_mcontext(struct thread *td, struct ia32_mcontext *mcp, int flags)
{
+ struct pcb *pcb;
struct trapframe *tp;
+ pcb = td->td_pcb;
tp = td->td_frame;
PROC_LOCK(curthread->td_proc);
@@ -163,9 +165,9 @@ ia32_get_mcontext(struct thread *td, struct ia32_mcontext *mcp, int flags)
mcp->mc_ss = tp->tf_ss;
mcp->mc_len = sizeof(*mcp);
ia32_get_fpcontext(td, mcp);
- mcp->mc_fsbase = td->td_pcb->pcb_fsbase;
- mcp->mc_gsbase = td->td_pcb->pcb_gsbase;
- td->td_pcb->pcb_full_iret = 1;
+ mcp->mc_fsbase = pcb->pcb_fsbase;
+ mcp->mc_gsbase = pcb->pcb_gsbase;
+ set_pcb_flags(pcb, PCB_FULL_IRET);
return (0);
}
@@ -207,7 +209,7 @@ ia32_set_mcontext(struct thread *td, const struct ia32_mcontext *mcp)
tp->tf_rflags = rflags;
tp->tf_rsp = mcp->mc_esp;
tp->tf_ss = mcp->mc_ss;
- td->td_pcb->pcb_full_iret = 1;
+ set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
return (0);
}
@@ -397,7 +399,7 @@ freebsd4_ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
regs->tf_ss = _udatasel;
regs->tf_ds = _udatasel;
regs->tf_es = _udatasel;
- td->td_pcb->pcb_full_iret = 1;
+ set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
/* leave user %fs and %gs untouched */
PROC_LOCK(p);
mtx_lock(&psp->ps_mtx);
@@ -518,7 +520,7 @@ ia32_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
regs->tf_ss = _udatasel;
regs->tf_ds = _udatasel;
regs->tf_es = _udatasel;
- td->td_pcb->pcb_full_iret = 1;
+ set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
/* XXXKIB leave user %fs and %gs untouched */
PROC_LOCK(p);
mtx_lock(&psp->ps_mtx);
@@ -613,7 +615,7 @@ freebsd4_freebsd32_sigreturn(td, uap)
regs->tf_gs = ucp->uc_mcontext.mc_gs;
kern_sigprocmask(td, SIG_SETMASK, &ucp->uc_sigmask, NULL, 0);
- td->td_pcb->pcb_full_iret = 1;
+ set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
return (EJUSTRETURN);
}
#endif /* COMPAT_FREEBSD4 */
@@ -702,7 +704,7 @@ freebsd32_sigreturn(td, uap)
regs->tf_flags = TF_HASSEGS;
kern_sigprocmask(td, SIG_SETMASK, &ucp->uc_sigmask, NULL, 0);
- td->td_pcb->pcb_full_iret = 1;
+ set_pcb_flags(td->td_pcb, PCB_FULL_IRET);
return (EJUSTRETURN);
}
@@ -742,8 +744,7 @@ ia32_setregs(struct thread *td, struct image_params *imgp, u_long stack)
fpstate_drop(td);
/* Return via doreti so that we can change to a different %cs */
- pcb->pcb_flags |= PCB_32BIT;
- pcb->pcb_flags &= ~PCB_GS32BIT;
- td->td_pcb->pcb_full_iret = 1;
+ set_pcb_flags(pcb, PCB_32BIT | PCB_FULL_IRET);
+ clear_pcb_flags(pcb, PCB_GS32BIT);
td->td_retval[1] = 0;
}
OpenPOWER on IntegriCloud