aboutsummaryrefslogtreecommitdiff
path: root/sys/alpha
diff options
context:
space:
mode:
authorMarcel Moolenaar <marcel@FreeBSD.org>2003-07-24 07:48:11 +0000
committerMarcel Moolenaar <marcel@FreeBSD.org>2003-07-24 07:48:11 +0000
commit8af2fbd6fb900bbc34511445738f64b0a0774293 (patch)
tree224448cb58b6b4c4e3941b43b5a7cbfea8e3a05e /sys/alpha
parent44dde923fc87d6a6ff58edd30943412978b6fb10 (diff)
downloadsrc-8af2fbd6fb900bbc34511445738f64b0a0774293.tar.gz
src-8af2fbd6fb900bbc34511445738f64b0a0774293.zip
In get_mcontext() and set_mcontext() save and restore the current
thread pointer.
Notes
Notes: svn path=/head/; revision=117957
Diffstat (limited to 'sys/alpha')
-rw-r--r--sys/alpha/alpha/machdep.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/sys/alpha/alpha/machdep.c b/sys/alpha/alpha/machdep.c
index 5bd7623bcc40..1139205bff85 100644
--- a/sys/alpha/alpha/machdep.c
+++ b/sys/alpha/alpha/machdep.c
@@ -2024,8 +2024,11 @@ get_mcontext(struct thread *td, mcontext_t *mcp, int clear_ret)
* When the thread is the current thread, the user stack pointer
* is not in the PCB; it must be read from the PAL.
*/
- if (td == curthread)
+ if (td == curthread) {
mcp->mc_regs[FRAME_SP] = alpha_pal_rdusp();
+ mcp->mc_thrptr = alpha_pal_rdunique();
+ } else
+ mcp->mc_thrptr = td->td_pcb->pcb_hw.apcb_unique;
mcp->mc_format = _MC_REV0_TRAPFRAME;
PROC_LOCK(curthread->td_proc);
@@ -2047,6 +2050,12 @@ set_mcontext(struct thread *td, const mcontext_t *mcp)
else if ((ret = set_fpcontext(td, mcp)) != 0)
return (ret);
+ /*
+ * NOTE: We only need to restore mc_thrptr when the ucontext format
+ * is _MC_REV0_TRAPFRAME. Only get_mcontext() above creates such
+ * contexts and that's also the only place where we save the thread
+ * pointer in the context.
+ */
if (mcp->mc_format == _MC_REV0_SIGFRAME) {
set_regs(td, (struct reg *)&mcp->mc_regs);
val = (mcp->mc_regs[R_PS] | ALPHA_PSL_USERSET) &
@@ -2056,10 +2065,13 @@ set_mcontext(struct thread *td, const mcontext_t *mcp)
td->td_frame->tf_regs[FRAME_FLAGS] = 0;
if (td == curthread)
alpha_pal_wrusp(mcp->mc_regs[R_SP]);
-
} else {
- if (td == curthread)
+ if (td == curthread) {
alpha_pal_wrusp(mcp->mc_regs[FRAME_SP]);
+ alpha_pal_wrunique(mcp->mc_thrptr);
+ } else
+ td->td_pcb->pcb_hw.apcb_unique = mcp->mc_thrptr;
+
/*
* The context is a trapframe, so just copy it over the
* threads frame.