changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: kernel: clear FPillegal in pexit() and before pprint()

changeset 7376: c6aadaba5c87
parent 7375: 856353183c2a
child 7377: f6b32f6f4b93
author: cinap_lenrek@felloff.net
date: Sun, 08 Sep 2019 19:02:01 +0200
files: sys/src/9/pc64/trap.c sys/src/9/port/proc.c
description: kernel: clear FPillegal in pexit() and before pprint()

pexit() and pprint() can get called outside of a syscall
(from procctl()) with a process that is in active note
handling and require floating point in the kernel on amd64
for aesni (devtls).
     1.1--- a/sys/src/9/pc64/trap.c
     1.2+++ b/sys/src/9/pc64/trap.c
     1.3@@ -877,8 +877,10 @@ notify(Ureg* ureg)
     1.4 
     1.5 	if(n->flag!=NUser && (up->notified || up->notify==0)){
     1.6 		qunlock(&up->debug);
     1.7-		if(n->flag == NDebug)
     1.8+		if(n->flag == NDebug){
     1.9+			up->fpstate &= ~FPillegal;
    1.10 			pprint("suicide: %s\n", n->msg);
    1.11+		}
    1.12 		pexit(n->msg, n->flag!=NDebug);
    1.13 	}
    1.14 
    1.15@@ -901,6 +903,7 @@ if(0) print("%s %lud: notify %#p %#p %#p
    1.16 	if(!okaddr((uintptr)up->notify, 1, 0)
    1.17 	|| !okaddr(sp-ERRMAX-4*BY2WD, sizeof(Ureg)+ERRMAX+4*BY2WD, 1)){
    1.18 		qunlock(&up->debug);
    1.19+		up->fpstate &= ~FPillegal;
    1.20 		pprint("suicide: bad address in notify\n");
    1.21 		pexit("Suicide", 0);
    1.22 	}
     2.1--- a/sys/src/9/port/proc.c
     2.2+++ b/sys/src/9/port/proc.c
     2.3@@ -1094,6 +1094,7 @@ pexit(char *exitstr, int freemem)
     2.4 	Chan *dot;
     2.5 	void (*pt)(Proc*, int, vlong);
     2.6 
     2.7+	up->fpstate &= ~FPillegal;
     2.8 	up->alarm = 0;
     2.9 	timerdel(up);
    2.10 	pt = proctrace;
    2.11@@ -1466,6 +1467,7 @@ procctl(void)
    2.12 	switch(up->procctl) {
    2.13 	case Proc_exitbig:
    2.14 		spllo();
    2.15+		up->fpstate &= ~FPillegal;
    2.16 		pprint("Killed: Insufficient physical memory\n");
    2.17 		pexit("Killed: Insufficient physical memory", 1);
    2.18