ref: 13869bab113881f28ac72de7d8a68bb8bb5d9c38
parent: e8082c1d1f09c04afb399ecdd63a79446e3bc390
author: aiju <devnull@localhost>
date: Mon Jun 12 20:10:36 EDT 2017
pc/pc64: keep shadow copy of DR7 in Mach and use that to check whether we need to reset DR7 in procsave(); remove superfluous reset of DR7 in mmurelease()
--- a/sys/src/9/pc/dat.h
+++ b/sys/src/9/pc/dat.h
@@ -258,6 +258,8 @@
uvlong tscticks;
int pdballoc;
int pdbfree;
+
+ u32int dr7; /* shadow copy of dr7 */
int stack[1];
};
--- a/sys/src/9/pc/main.c
+++ b/sys/src/9/pc/main.c
@@ -844,8 +844,10 @@
{
uvlong t;
- if(p->dr[7] != 0)
+ if(p->dr[7] != 0){
+ m->dr7 = p->dr[7];
putdr(p->dr);
+ }
if(p->kp)
return;
@@ -863,8 +865,11 @@
{
uvlong t;
- if(p->dr[7] != 0)
+ /* 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;
--- a/sys/src/9/pc/mmu.c
+++ b/sys/src/9/pc/mmu.c
@@ -387,8 +387,6 @@
proc->ldt = nil;
proc->nldt = 0;
}
- if(proc->dr[7] != 0)
- putdr7(0);
}
/*
--- a/sys/src/9/pc64/dat.h
+++ b/sys/src/9/pc64/dat.h
@@ -223,6 +223,8 @@
int havepge;
int havewatchpt8;
uvlong tscticks;
+
+ u64int dr7; /* shadow copy of dr7 */
uintptr stack[1];
};
--- a/sys/src/9/pc64/main.c
+++ b/sys/src/9/pc64/main.c
@@ -798,8 +798,10 @@
{
uvlong t;
- if(p->dr[7] != 0)
+ if(p->dr[7] != 0){
+ m->dr7 = p->dr[7];
putdr(p->dr);
+ }
if(p->kp)
return;
@@ -814,8 +816,10 @@
{
uvlong t;
- if(p->dr[7] != 0)
+ if(m->dr7 != 0){
+ m->dr7 = 0;
putdr7(0);
+ }
cycles(&t);
p->kentry -= t;
--- a/sys/src/9/pc64/mmu.c
+++ b/sys/src/9/pc64/mmu.c
@@ -425,8 +425,6 @@
proc->kmapcount = proc->kmapindex = 0;
}
mmufree(proc);
- if(proc->dr[7] != 0)
- putdr7(0);
taskswitch((uintptr)m+MACHSIZE);
}