diff options
author | marcel <marcel@FreeBSD.org> | 2003-07-24 07:48:11 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2003-07-24 07:48:11 +0000 |
commit | fd57f45daa7a7e971d66d61ce6c75aa7d347c0a0 (patch) | |
tree | 224448cb58b6b4c4e3941b43b5a7cbfea8e3a05e | |
parent | 660b2e52a158376e51f7a60e15d689f67b7ed702 (diff) | |
download | FreeBSD-src-fd57f45daa7a7e971d66d61ce6c75aa7d347c0a0.zip FreeBSD-src-fd57f45daa7a7e971d66d61ce6c75aa7d347c0a0.tar.gz |
In get_mcontext() and set_mcontext() save and restore the current
thread pointer.
-rw-r--r-- | sys/alpha/alpha/machdep.c | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/sys/alpha/alpha/machdep.c b/sys/alpha/alpha/machdep.c index 5bd7623..1139205 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. |