From 6e1e13b5e0ae17f828d9c89cdbbef1f97bfd19d4 Mon Sep 17 00:00:00 2001 From: Jake Burkholder Date: Tue, 1 Apr 2003 23:18:13 +0000 Subject: [PATCH] - Set the version number in the mcontext in get_mcontext and check it in set_mcontext. - Don't make assumptions about the alignment of the mcontext inside of the ucontext; we have to save the floating point registers to the pcb and then copy to the mcontext. --- sys/sparc64/sparc64/machdep.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/sys/sparc64/sparc64/machdep.c b/sys/sparc64/sparc64/machdep.c index 45d6c7cea166..9cfdfc5688b1 100644 --- a/sys/sparc64/sparc64/machdep.c +++ b/sys/sparc64/sparc64/machdep.c @@ -518,15 +518,17 @@ get_mcontext(struct thread *td, mcontext_t *mc) struct trapframe *tf; struct pcb *pcb; - if (((uintptr_t)mc & (64 - 1)) != 0) - return (EINVAL); tf = td->td_frame; pcb = td->td_pcb; bcopy(tf, mc, sizeof(*tf)); + mc->mc_flags = _MC_VERSION; critical_enter(); - if ((tf->tf_fprs & FPRS_FEF) != 0) - savefpctx(mc->mc_fp); - else if ((pcb->pcb_flags & PCB_FEF) != 0) { + if ((tf->tf_fprs & FPRS_FEF) != 0) { + savefpctx(pcb->pcb_ufp); + tf->tf_fprs &= ~FPRS_FEF; + pcb->pcb_flags |= PCB_FEF; + } + if ((pcb->pcb_flags & PCB_FEF) != 0) { bcopy(pcb->pcb_ufp, mc->mc_fp, sizeof(*mc->mc_fp)); mc->mc_fprs |= FPRS_FEF; } @@ -541,7 +543,8 @@ set_mcontext(struct thread *td, const mcontext_t *mc) struct pcb *pcb; uint64_t wstate; - if (!TSTATE_SECURE(mc->mc_tstate)) + if (!TSTATE_SECURE(mc->mc_tstate) || + (mc->mc_flags & ((1L << _MC_VERSION_BITS) - 1)) != _MC_VERSION) return (EINVAL); tf = td->td_frame; pcb = td->td_pcb;