git: 9745bab3cd30 - stable/14 - powerpc: save and restore VRSAVE with the vector state
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 24 Nov 2026 17:21:31 UTC
The branch stable/14 has been updated by pkubaj:
URL: https://cgit.FreeBSD.org/src/commit/?id=9745bab3cd30d715fd2173dc72346b85f5522df0
commit 9745bab3cd30d715fd2173dc72346b85f5522df0
Author: Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2026-10-18 10:41:40 +0000
Commit: Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2026-11-24 16:11:12 +0000
powerpc: save and restore VRSAVE with the vector state
VRSAVE was never saved or restored, although user code can write it
and the mcontext carries it, so every process saw the value the
previous process on that CPU had left there.
Two processes pinned to the same CPU and writing different values to
VRSAVE each read back the other's; each reads back its own now.
Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61544
(cherry picked from commit 26b47fd4b63c4e67a952f9a4f0ceb89bcb6a24ac)
---
sys/powerpc/powerpc/altivec.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/sys/powerpc/powerpc/altivec.c b/sys/powerpc/powerpc/altivec.c
index e0f807cc0b53..25622988320b 100644
--- a/sys/powerpc/powerpc/altivec.c
+++ b/sys/powerpc/powerpc/altivec.c
@@ -40,8 +40,10 @@
#include <sys/limits.h>
#include <machine/altivec.h>
+#include <machine/cpufunc.h>
#include <machine/pcb.h>
#include <machine/psl.h>
+#include <machine/spr.h>
static void
save_vec_int(struct thread *td)
@@ -81,6 +83,7 @@ save_vec_int(struct thread *td)
*/
__asm __volatile("mfvscr 0; vspltw 0,0,3; stvewx 0,0,%0"
:: "b"(&pcb->pcb_vec.vscr));
+ pcb->pcb_vec.vrsave = mfspr(SPR_VRSAVE);
/*
* Disable vector unit again
@@ -127,6 +130,8 @@ enable_vec(struct thread *td)
msr = mfmsr();
mtmsr(msr | PSL_VEC);
+ mtspr(SPR_VRSAVE, pcb->pcb_vec.vrsave);
+
/*
* Restore VSCR by first loading it into a vector and then into VSCR.
* (this needs to done before loading the user's vector registers