git: 62646709fd67 - stable/14 - powerpc: Fix inconsistent Altivec handling in set_mcontext
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sun, 19 Nov 2023 21:03:27 UTC
The branch stable/14 has been updated by alfredo: URL: https://cgit.FreeBSD.org/src/commit/?id=62646709fd67d239bba13cb1c59f3720c6f59a3d commit 62646709fd67d239bba13cb1c59f3720c6f59a3d Author: Shawn Anastasio <sanastasio@raptorengineering.com> AuthorDate: 2023-11-03 17:40:18 +0000 Commit: Alfredo Dal'Ava Junior <alfredo@FreeBSD.org> CommitDate: 2023-11-19 20:57:57 +0000 powerpc: Fix inconsistent Altivec handling in set_mcontext When support for fpu_kern_enter/fpu_kern_leave was added to powerpc, set_mcontext was updated to handle Altivec state restoration in the same way that the FPU state by lazily restoring the context on the first trap. However the function was not correctly updated to unconditionally clear the PCB_VEC and PSL_VEC bits from the pcb's flags and srr1 respectively which can sometimes result in a mismatch between a process's MSR[VEC] state and its pcb_flags. Fix this by simply clearing the VEC flags unconditionally in set_mcontext, which is already done for FPU/VSX. Fixes: a6662c37b6ffe ("powerpc: Implement fpu_kern_enter/fpu_kern_leave") Reviewed by: alfredo MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D42417 (cherry picked from commit 270f75cf3433807d124cdf1f0072ab801532f425) --- sys/powerpc/powerpc/exec_machdep.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sys/powerpc/powerpc/exec_machdep.c b/sys/powerpc/powerpc/exec_machdep.c index 05d3a3cf79ba..0b1751a76454 100644 --- a/sys/powerpc/powerpc/exec_machdep.c +++ b/sys/powerpc/powerpc/exec_machdep.c @@ -528,8 +528,8 @@ set_mcontext(struct thread *td, mcontext_t *mcp) * Additionally, ensure VSX is disabled as well, as it is illegal * to leave it turned on when FP or VEC are off. */ - tf->srr1 &= ~(PSL_FP | PSL_VSX); - pcb->pcb_flags &= ~(PCB_FPU | PCB_VSX); + tf->srr1 &= ~(PSL_FP | PSL_VSX | PSL_VEC); + pcb->pcb_flags &= ~(PCB_FPU | PCB_VSX | PCB_VEC); if (mcp->mc_flags & _MC_FP_VALID) { /* enable_fpu() will happen lazily on a fault */ @@ -550,9 +550,6 @@ 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);