git: 270f75cf3433 - main - powerpc: Fix inconsistent Altivec handling in set_mcontext
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 03 Nov 2023 17:55:46 UTC
The branch main has been updated by alfredo:
URL: https://cgit.FreeBSD.org/src/commit/?id=270f75cf3433807d124cdf1f0072ab801532f425
commit 270f75cf3433807d124cdf1f0072ab801532f425
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-03 17:55:04 +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
---
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);