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/xen | |
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/xen')
-rw-r--r-- | sys/src/9/xen/main.c | 22 | ||||
-rw-r--r-- | sys/src/9/xen/trap.c | 4 |
2 files changed, 15 insertions, 11 deletions
diff --git a/sys/src/9/xen/main.c b/sys/src/9/xen/main.c index f5e0adf07..e28716a28 100644 --- a/sys/src/9/xen/main.c +++ b/sys/src/9/xen/main.c @@ -450,7 +450,7 @@ mathnote(void) ulong status; char *msg, note[ERRMAX]; - status = up->fpsave.status; + status = up->fpsave->status; /* * Some attention should probably be paid here to the @@ -473,7 +473,7 @@ mathnote(void) msg = "invalid operation"; } snprint(note, sizeof note, "sys: fp: %s fppc=0x%lux status=0x%lux", - msg, up->fpsave.pc, status); + msg, up->fpsave->pc, status); postnote(up, 1, note, NDebug); } @@ -493,12 +493,12 @@ matherror(Ureg *ur, void*) /* * save floating point state to check out error */ - fpenv(&up->fpsave); + fpenv(up->fpsave); mathnote(); if(ur->pc & KZERO) panic("fp: status %ux fppc=0x%lux pc=0x%lux", - up->fpsave.status, up->fpsave.pc, ur->pc); + up->fpsave->status, up->fpsave->pc, ur->pc); } /* @@ -515,6 +515,8 @@ mathemu(Ureg *ureg, void*) switch(up->fpstate){ case FPinit: fpinit(); + while(up->fpsave == nil) + up->fpsave = mallocalign(sizeof(FPsave), FPalign, 0, 0); up->fpstate = FPactive; break; case FPinactive: @@ -525,11 +527,11 @@ mathemu(Ureg *ureg, void*) * More attention should probably be paid here to the * exception masks and error summary. */ - if((up->fpsave.status & ~up->fpsave.control) & 0x07F){ + if((up->fpsave->status & ~up->fpsave->control) & 0x07F){ mathnote(); break; } - fprestore(&up->fpsave); + fprestore(up->fpsave); up->fpstate = FPactive; break; case FPactive: @@ -580,10 +582,12 @@ procfork(Proc *p) s = splhi(); switch(up->fpstate & ~FPillegal){ case FPactive: - fpsave(&up->fpsave); + fpsave(up->fpsave); up->fpstate = FPinactive; case FPinactive: - p->fpsave = up->fpsave; + while(p->fpsave == nil) + p->fpsave = mallocalign(sizeof(FPsave), FPalign, 0, 0); + memmove(p->fpsave, up->fpsave, sizeof(FPsave)); p->fpstate = FPinactive; } splx(s); @@ -622,7 +626,7 @@ procsave(Proc *p) * until the process runs again and generates an * emulation fault to activate the FPU. */ - fpsave(&p->fpsave); + fpsave(p->fpsave); } p->fpstate = FPinactive; } diff --git a/sys/src/9/xen/trap.c b/sys/src/9/xen/trap.c index d524b403c..1ab080c60 100644 --- a/sys/src/9/xen/trap.c +++ b/sys/src/9/xen/trap.c @@ -674,7 +674,7 @@ syscall(Ureg* ureg) scallnr = ureg->ax; up->scallnr = scallnr; if(scallnr == RFORK && up->fpstate == FPactive){ - fpsave(&up->fpsave); + fpsave(up->fpsave); up->fpstate = FPinactive; } spllo(); @@ -764,7 +764,7 @@ notify(Ureg* ureg) return 0; if(up->fpstate == FPactive){ - fpsave(&up->fpsave); + fpsave(up->fpsave); up->fpstate = FPinactive; } up->fpstate |= FPillegal; |