amd64: FP: always use enough to fit AVX state and align to 64 bytes
This commit is contained in:
parent
66b6185845
commit
334c5e1134
4 changed files with 4 additions and 6 deletions
|
@ -242,7 +242,6 @@ struct Mach
|
||||||
u64int dr7; /* shadow copy of dr7 */
|
u64int dr7; /* shadow copy of dr7 */
|
||||||
u64int xcr0;
|
u64int xcr0;
|
||||||
u32int fpsavesz;
|
u32int fpsavesz;
|
||||||
u32int fpalign;
|
|
||||||
|
|
||||||
void* vmx;
|
void* vmx;
|
||||||
|
|
||||||
|
|
|
@ -16,8 +16,7 @@ fpuinit(void)
|
||||||
uintptr cr4;
|
uintptr cr4;
|
||||||
ulong regs[4];
|
ulong regs[4];
|
||||||
|
|
||||||
m->fpsavesz = sizeof(FPssestate);
|
m->fpsavesz = sizeof(FPsave); /* always enough to fit sse+avx */
|
||||||
m->fpalign = 16;
|
|
||||||
if((m->cpuiddx & (Sse|Fxsr)) == (Sse|Fxsr)){ /* have sse fp? */
|
if((m->cpuiddx & (Sse|Fxsr)) == (Sse|Fxsr)){ /* have sse fp? */
|
||||||
cr4 = getcr4() | CR4Osfxsr|CR4Oxmmex;
|
cr4 = getcr4() | CR4Osfxsr|CR4Oxmmex;
|
||||||
putcr4(cr4);
|
putcr4(cr4);
|
||||||
|
@ -34,7 +33,6 @@ fpuinit(void)
|
||||||
|
|
||||||
cpuid(0xd, 0, regs);
|
cpuid(0xd, 0, regs);
|
||||||
m->fpsavesz = regs[1];
|
m->fpsavesz = regs[1];
|
||||||
m->fpalign = 64;
|
|
||||||
|
|
||||||
cpuid(0xd, 1, regs);
|
cpuid(0xd, 1, regs);
|
||||||
if(regs[0] & Xsaveopt)
|
if(regs[0] & Xsaveopt)
|
||||||
|
|
|
@ -488,7 +488,7 @@ mathemu(Ureg *ureg, void*)
|
||||||
up->fpstate |= FPkernel;
|
up->fpstate |= FPkernel;
|
||||||
}
|
}
|
||||||
while(up->fpslot[index] == nil)
|
while(up->fpslot[index] == nil)
|
||||||
up->fpslot[index] = mallocalign(m->fpsavesz, m->fpalign, 0, 0);
|
up->fpslot[index] = mallocalign(m->fpsavesz, FPalign, 0, 0);
|
||||||
up->fpsave = up->fpslot[index];
|
up->fpsave = up->fpslot[index];
|
||||||
up->fpstate = FPactive | (up->fpstate & (FPnouser|FPkernel|FPindexm));
|
up->fpstate = FPactive | (up->fpstate & (FPnouser|FPkernel|FPindexm));
|
||||||
break;
|
break;
|
||||||
|
@ -574,7 +574,7 @@ procfork(Proc *p)
|
||||||
case FPinactive | FPpush:
|
case FPinactive | FPpush:
|
||||||
case FPinactive:
|
case FPinactive:
|
||||||
while(p->fpslot[0] == nil)
|
while(p->fpslot[0] == nil)
|
||||||
p->fpslot[0] = mallocalign(m->fpsavesz, m->fpalign, 0, 0);
|
p->fpslot[0] = mallocalign(m->fpsavesz, FPalign, 0, 0);
|
||||||
memmove(p->fpsave = p->fpslot[0], up->fpslot[0], m->fpsavesz);
|
memmove(p->fpsave = p->fpslot[0], up->fpslot[0], m->fpsavesz);
|
||||||
p->fpstate = FPinactive;
|
p->fpstate = FPinactive;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#define ROUND(s, sz) (((s)+((sz)-1))&~((sz)-1))
|
#define ROUND(s, sz) (((s)+((sz)-1))&~((sz)-1))
|
||||||
#define PGROUND(s) ROUND(s, BY2PG)
|
#define PGROUND(s) ROUND(s, BY2PG)
|
||||||
#define BLOCKALIGN 8
|
#define BLOCKALIGN 8
|
||||||
|
#define FPalign 64
|
||||||
|
|
||||||
#define MAXMACH 128 /* max # cpus system can run */
|
#define MAXMACH 128 /* max # cpus system can run */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue