shithub: riscv

Download patch

ref: 8a0cefb237a90ab08baf5b062991f6dc7e78bcde
parent: 6a3f1f1bca8389f378a30d97c87505f9f92d8786
parent: 5d59a44c21a14ed30034c27681f76efe1856b993
author: cinap_lenrek <[email protected]>
date: Mon Dec 2 18:33:29 EST 2019

merge

--- a/sys/src/9/pc/main.c
+++ b/sys/src/9/pc/main.c
@@ -585,13 +585,18 @@
 	p->fpstate = FPinit;
 	fpoff();
 
-	cycles(&p->kentry);
-	p->pcycles = -p->kentry;
-
 	memset(p->gdt, 0, sizeof(p->gdt));
 	p->nldt = 0;
 	
+	/* clear debug registers */
 	memset(p->dr, 0, sizeof(p->dr));
+	if(m->dr7 != 0){
+		m->dr7 = 0;
+		putdr7(0);
+	}
+
+	cycles(&p->kentry);
+	p->pcycles = -p->kentry;
 }
 
 void
@@ -624,9 +629,6 @@
 		memmove(p->fpsave, up->fpsave, sizeof(FPsave));
 		p->fpstate = FPinactive;
 	}
-	
-	/* clear debug registers */
-	memset(p->dr, 0, sizeof(p->dr));
 	splx(s);
 }
 
@@ -659,15 +661,17 @@
 {
 	uvlong t;
 	
+	cycles(&t);
+	p->kentry -= t;
+	p->pcycles += t;
+
 	/* we could just always putdr7(0) but accessing DR7 might be slow in a VM */
 	if(m->dr7 != 0){
 		m->dr7 = 0;
 		putdr7(0);
 	}
-
-	cycles(&t);
-	p->kentry -= t;
-	p->pcycles += t;
+	if(p->state == Moribund)
+		p->dr[7] = 0;
 
 	if(p->fpstate == FPactive){
 		if(p->state == Moribund)
--- a/sys/src/9/pc64/main.c
+++ b/sys/src/9/pc64/main.c
@@ -581,6 +581,14 @@
 {
 	p->fpstate = FPinit;
 	_stts();
+
+	/* clear debug registers */
+	memset(p->dr, 0, sizeof(p->dr));
+	if(m->dr7 != 0){
+		m->dr7 = 0;
+		putdr7(0);
+	}
+
 	cycles(&p->kentry);
 	p->pcycles = -p->kentry;
 }
@@ -639,14 +647,16 @@
 {
 	uvlong t;
 	
+	cycles(&t);
+	p->kentry -= t;
+	p->pcycles += t;
+
 	if(m->dr7 != 0){
 		m->dr7 = 0;
 		putdr7(0);
 	}
-
-	cycles(&t);
-	p->kentry -= t;
-	p->pcycles += t;
+	if(p->state == Moribund)
+		p->dr[7] = 0;
 
 	switch(p->fpstate & ~(FPnouser|FPkernel|FPindexm)){
 	case FPactive	| FPpush: