ref: 23b52bbf23bcc3f7f64b4d3496993bee83f5f2eb
parent: cd38d4135633fd2dd9ce544aa3c2c86cf5078f8d
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Dec 6 17:05:00 EST 2020
pc64: assign fpsave/fprestore only once in fpuinit()
--- a/sys/src/9/pc64/fpu.c
+++ b/sys/src/9/pc64/fpu.c
@@ -253,25 +253,26 @@
ulong regs[4];
cr4 = getcr4() | CR4Osfxsr|CR4Oxmmex;
- putcr4(cr4);
- fpsave = fpssesave;
- fprestore = fpsserestore;
-
if((m->cpuidcx & (Xsave|Avx)) == (Xsave|Avx) && getconf("*noavx") == nil){
cr4 |= CR4Oxsave;
putcr4(cr4);
m->xcr0 = 7; /* x87, sse, avx */
putxcr0(m->xcr0);
- fpsave = fpxsave;
- fprestore = fpxrestore;
-
cpuid(0xd, 1, regs);
- if(regs[0] & Xsaveopt)
- fpsave = fpxsaveopt;
if(regs[0] & Xsaves){
fpsave = fpxsaves;
fprestore = fpxrestores;
+ } else {
+ if(regs[0] & Xsaveopt)
+ fpsave = fpxsaveopt;
+ else
+ fpsave = fpxsave;
+ fprestore = fpxrestore;
}
+ } else {
+ putcr4(cr4);
+ fpsave = fpssesave;
+ fprestore = fpsserestore;
}
}