From 31091dea96f8e90aeb71ca51a271d7aac184142f Mon Sep 17 00:00:00 2001 From: Justin Hibbits Date: Thu, 6 Feb 2020 01:25:30 +0000 Subject: [PATCH] powerpc: Fix altivec disabling in set_mcontext() We somewhat blindly copy the srr1 from the new context to the trap frame, but disable FPU and VSX unconditionally, relying on the trap to re-enable them. This works because the FPU manages the VSX extended FP registers, which is governed by the PCB_FPFREGS flag. However, with altivec, we would blindly disable PSL_VEC, without touching PCB_VEC. Handle this case by disabling altivec in both srr1 and pcb_flags, if the mcontext doesn't have _MC_AV_VALID set. Reported by: pkubaj --- sys/powerpc/powerpc/exec_machdep.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/powerpc/powerpc/exec_machdep.c b/sys/powerpc/powerpc/exec_machdep.c index 903d8e91fff..e67a6a3349f 100644 --- a/sys/powerpc/powerpc/exec_machdep.c +++ b/sys/powerpc/powerpc/exec_machdep.c @@ -526,6 +526,9 @@ set_mcontext(struct thread *td, mcontext_t *mcp) pcb->pcb_vec.vscr = mcp->mc_vscr; pcb->pcb_vec.vrsave = mcp->mc_vrsave; memcpy(pcb->pcb_vec.vr, mcp->mc_avec, sizeof(mcp->mc_avec)); + } else { + tf->srr1 &= ~PSL_VEC; + pcb->pcb_flags &= ~PCB_VEC; } return (0);