summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSigrid <ftrvxmtrx@gmail.com>2020-12-06 19:31:56 +0100
committerSigrid <ftrvxmtrx@gmail.com>2020-12-06 19:31:56 +0100
commit334c5e1134719a02c35c72ec5435a967a74846f8 (patch)
tree6a81a47f847e9025945a5ac4ef3c6ebba07fc721
parent66b6185845e85258f1408271d5f705aacfa6ffdb (diff)
downloadplan9front-334c5e1134719a02c35c72ec5435a967a74846f8.tar.xz
amd64: FP: always use enough to fit AVX state and align to 64 bytes
-rw-r--r--sys/src/9/pc64/dat.h1
-rw-r--r--sys/src/9/pc64/fpu.c4
-rw-r--r--sys/src/9/pc64/main.c4
-rw-r--r--sys/src/9/pc64/mem.h1
4 files changed, 4 insertions, 6 deletions
diff --git a/sys/src/9/pc64/dat.h b/sys/src/9/pc64/dat.h
index 7cfc6e5c2..b9b9fc147 100644
--- a/sys/src/9/pc64/dat.h
+++ b/sys/src/9/pc64/dat.h
@@ -242,7 +242,6 @@ struct Mach
u64int dr7; /* shadow copy of dr7 */
u64int xcr0;
u32int fpsavesz;
- u32int fpalign;
void* vmx;
diff --git a/sys/src/9/pc64/fpu.c b/sys/src/9/pc64/fpu.c
index 4326f51a7..6ac8819d7 100644
--- a/sys/src/9/pc64/fpu.c
+++ b/sys/src/9/pc64/fpu.c
@@ -16,8 +16,7 @@ fpuinit(void)
uintptr cr4;
ulong regs[4];
- m->fpsavesz = sizeof(FPssestate);
- m->fpalign = 16;
+ m->fpsavesz = sizeof(FPsave); /* always enough to fit sse+avx */
if((m->cpuiddx & (Sse|Fxsr)) == (Sse|Fxsr)){ /* have sse fp? */
cr4 = getcr4() | CR4Osfxsr|CR4Oxmmex;
putcr4(cr4);
@@ -34,7 +33,6 @@ fpuinit(void)
cpuid(0xd, 0, regs);
m->fpsavesz = regs[1];
- m->fpalign = 64;
cpuid(0xd, 1, regs);
if(regs[0] & Xsaveopt)
diff --git a/sys/src/9/pc64/main.c b/sys/src/9/pc64/main.c
index 4026ee151..803799ab9 100644
--- a/sys/src/9/pc64/main.c
+++ b/sys/src/9/pc64/main.c
@@ -488,7 +488,7 @@ mathemu(Ureg *ureg, void*)
up->fpstate |= FPkernel;
}
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->fpstate = FPactive | (up->fpstate & (FPnouser|FPkernel|FPindexm));
break;
@@ -574,7 +574,7 @@ procfork(Proc *p)
case FPinactive | FPpush:
case FPinactive:
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);
p->fpstate = FPinactive;
}
diff --git a/sys/src/9/pc64/mem.h b/sys/src/9/pc64/mem.h
index f02e042a6..4541a62a0 100644
--- a/sys/src/9/pc64/mem.h
+++ b/sys/src/9/pc64/mem.h
@@ -26,6 +26,7 @@
#define ROUND(s, sz) (((s)+((sz)-1))&~((sz)-1))
#define PGROUND(s) ROUND(s, BY2PG)
#define BLOCKALIGN 8
+#define FPalign 64
#define MAXMACH 128 /* max # cpus system can run */