diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-11-04 20:08:22 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2017-11-04 20:08:22 +0100 |
commit | 24057fd4f494a00573d34adeaa7042721c1a06a0 (patch) | |
tree | ca69cfd03461c148c60ba0137d20b93976f61b61 /sys/src/9/sgi | |
parent | 04ce485f1b4453335db70b4a1b5d2c96458db3c1 (diff) |
kernel: introduce per process FPU struct (PFPU) for more flexible machine specific fpu handling
introducing the PFPU structue which allows the machine specific
code some flexibility on how to handle the FPU process state.
for example, in the pc and pc64 kernel, the FPsave structure is
arround 512 bytes. with avx512, it could grow up to 2K. instead
of embedding that into the Proc strucutre, it is more effective
to allocate it on first use of the fpu, as most processes do not
use simd or floating point in the first place. also, the FPsave
structure has special 16 byte alignment constraint, which further
favours dynamic allocation.
this gets rid of the memmoves in pc/pc64 kernels for the aligment.
there is also devproc, which is now checking if the fpsave area
is actually valid before reading it, avoiding debuggers to see
garbage data.
the Notsave structure is gone now, as it was not used on any
machine.
Diffstat (limited to 'sys/src/9/sgi')
-rw-r--r-- | sys/src/9/sgi/dat.h | 40 | ||||
-rw-r--r-- | sys/src/9/sgi/fptrap.c | 18 | ||||
-rw-r--r-- | sys/src/9/sgi/main.c | 8 | ||||
-rw-r--r-- | sys/src/9/sgi/trap.c | 8 |
4 files changed, 36 insertions, 38 deletions
diff --git a/sys/src/9/sgi/dat.h b/sys/src/9/sgi/dat.h index 800ed7182..741ca5655 100644 --- a/sys/src/9/sgi/dat.h +++ b/sys/src/9/sgi/dat.h @@ -1,6 +1,7 @@ typedef struct Conf Conf; typedef struct Confmem Confmem; typedef struct FPsave FPsave; +typedef struct PFPU PFPU; typedef struct KMap KMap; typedef struct Lance Lance; typedef struct Lancemem Lancemem; @@ -8,7 +9,6 @@ typedef struct Label Label; typedef struct Lock Lock; typedef struct Mach Mach; typedef struct MMU MMU; -typedef struct Notsave Notsave; typedef struct PMMU PMMU; typedef struct Softtlb Softtlb; typedef struct Ureg Ureg; @@ -73,18 +73,6 @@ struct Conf /* * floating point registers */ -enum -{ - /* floating point state */ - FPinit, - FPactive, - FPinactive, - FPemu, - - /* bit meaning floating point illegal */ - FPillegal= 0x100, -}; - enum { Nfpregs = 32, /* floats; half as many doubles */ }; @@ -111,20 +99,30 @@ struct FPsave int fpcnt; /* how many consecutive at that addr */ }; -/* - * mmu goo in the Proc structure - */ -struct PMMU +struct PFPU { - int pidonmach[MAXMACH]; + int fpstate; + FPsave fpsave[1]; +}; + +enum +{ + /* floating point state */ + FPinit, + FPactive, + FPinactive, + FPemu, + + /* bit meaning floating point illegal */ + FPillegal= 0x100, }; /* - * things saved in the Proc structure during a notify + * mmu goo in the Proc structure */ -struct Notsave +struct PMMU { - ulong nonempty; + int pidonmach[MAXMACH]; }; #include "../port/portdat.h" diff --git a/sys/src/9/sgi/fptrap.c b/sys/src/9/sgi/fptrap.c index 82c61bbd3..9d1c22aec 100644 --- a/sys/src/9/sgi/fptrap.c +++ b/sys/src/9/sgi/fptrap.c @@ -29,7 +29,7 @@ fptrap(Ureg *ur) { ulong iw, npc; - if((up->fpsave.fpstatus&(1<<17)) == 0) + if((up->fpsave->fpstatus&(1<<17)) == 0) return; if(ur->cause & (1<<31)) @@ -41,7 +41,7 @@ fptrap(Ureg *ur) return; if(ur->cause & (1<<31)){ - npc = branch(ur, up->fpsave.fpstatus); + npc = branch(ur, up->fpsave->fpstatus); if(npc == 0) return; ur->pc = npc; @@ -49,7 +49,7 @@ fptrap(Ureg *ur) else ur->pc += 4; - up->fpsave.fpstatus &= ~(1<<17); + up->fpsave->fpstatus &= ~(1<<17); } static void @@ -107,8 +107,8 @@ fpunimp(ulong iw) ft = (iw>>16) & ((1<<5)-1); fs = (iw>>11) & ((1<<5)-1); fd = (iw>>6) & ((1<<5)-1); - unpack(&up->fpsave, fmt, fs, &ss, &es); - unpack(&up->fpsave, fmt, ft, &st, &et); + unpack(up->fpsave, fmt, fs, &ss, &es); + unpack(up->fpsave, fmt, ft, &st, &et); ed = 0; maxe = 0; maxm = 0; @@ -124,11 +124,11 @@ fpunimp(ulong iw) } switch(op){ case ABS: - up->fpsave.reg[fd] &= ~0x80000000; + up->fpsave->reg[fd] &= ~0x80000000; return 1; case NEG: - up->fpsave.reg[fd] ^= 0x80000000; + up->fpsave->reg[fd] ^= 0x80000000; return 1; case SUB: @@ -164,9 +164,9 @@ fpunimp(ulong iw) return 0; } if(ed <= -(maxe-5)){ /* guess: underflow */ - zeroreg(&up->fpsave, fmt, fd, sd); + zeroreg(up->fpsave, fmt, fd, sd); /* Set underflow exception and sticky */ - up->fpsave.fpstatus |= (1<<3)|(1<<13); + up->fpsave->fpstatus |= (1<<3)|(1<<13); return 1; } return 0; diff --git a/sys/src/9/sgi/main.c b/sys/src/9/sgi/main.c index f1c239e3a..dea690f29 100644 --- a/sys/src/9/sgi/main.c +++ b/sys/src/9/sgi/main.c @@ -396,7 +396,7 @@ void procsetup(Proc *p) { p->fpstate = FPinit; - p->fpsave = initfp; + memmove(p->fpsave, &initfp, sizeof(FPsave)); cycles(&p->kentry); p->pcycles = -p->kentry; @@ -413,11 +413,11 @@ procfork(Proc *p) s = splhi(); switch(up->fpstate & ~FPillegal){ case FPactive: - savefpregs(&up->fpsave); + savefpregs(up->fpsave); up->fpstate = FPinactive; /* wet floor */ case FPinactive: - p->fpsave = up->fpsave; + memmove(p->fpsave, up->fpsave, sizeof(FPsave)); p->fpstate = FPinactive; } splx(s); @@ -430,7 +430,7 @@ procsave(Proc *p) if(p->fpstate == FPactive){ if(p->state != Moribund) { - savefpregs(&p->fpsave); + savefpregs(p->fpsave); p->fpstate = FPinactive; } } diff --git a/sys/src/9/sgi/trap.c b/sys/src/9/sgi/trap.c index 4c59730f6..588e6861d 100644 --- a/sys/src/9/sgi/trap.c +++ b/sys/src/9/sgi/trap.c @@ -212,7 +212,7 @@ trap(Ureg *ur) if(!user) goto Default; if(up->fpstate == FPactive){ - savefpregs(&up->fpsave); + savefpregs(up->fpsave); up->fpstate = FPinactive; } clrfpintr(); @@ -257,7 +257,7 @@ trap(Ureg *ur) break; } if(up->fpstate == FPinit || up->fpstate == FPinactive){ - restfpregs(&up->fpsave, up->fpsave.fpstatus&~FPEXPMASK); + restfpregs(up->fpsave, up->fpsave->fpstatus&~FPEXPMASK); up->fpstate = FPactive; ur->status |= CU1; break; @@ -289,7 +289,7 @@ trap(Ureg *ur) } if(fpchk) { - fpfcr31 = up->fpsave.fpstatus; + fpfcr31 = up->fpsave->fpstatus; if((fpfcr31>>12) & ((fpfcr31>>7)|0x20) & 0x3f) { spllo(); fpexcep = fpexcname(ur, fpfcr31, buf1, sizeof buf1); @@ -501,7 +501,7 @@ notify(Ureg *ur) return 0; if(up->fpstate == FPactive){ - savefpregs(&up->fpsave); + savefpregs(up->fpsave); up->fpstate = FPinactive; } up->fpstate |= FPillegal; |