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()

This commit is contained in:
aiju 2017-06-13 00:10:36 +00:00
parent e8082c1d1f
commit 13869bab11
6 changed files with 17 additions and 8 deletions

View file

@ -258,6 +258,8 @@ struct Mach
uvlong tscticks;
int pdballoc;
int pdbfree;
u32int dr7; /* shadow copy of dr7 */
int stack[1];
};

View file

@ -844,8 +844,10 @@ procrestore(Proc *p)
{
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 @@ procsave(Proc *p)
{
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;

View file

@ -387,8 +387,6 @@ mmurelease(Proc* proc)
proc->ldt = nil;
proc->nldt = 0;
}
if(proc->dr[7] != 0)
putdr7(0);
}
/*

View file

@ -223,6 +223,8 @@ struct Mach
int havepge;
int havewatchpt8;
uvlong tscticks;
u64int dr7; /* shadow copy of dr7 */
uintptr stack[1];
};

View file

@ -798,8 +798,10 @@ procrestore(Proc *p)
{
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 @@ procsave(Proc *p)
{
uvlong t;
if(p->dr[7] != 0)
if(m->dr7 != 0){
m->dr7 = 0;
putdr7(0);
}
cycles(&t);
p->kentry -= t;

View file

@ -425,8 +425,6 @@ mmurelease(Proc *proc)
proc->kmapcount = proc->kmapindex = 0;
}
mmufree(proc);
if(proc->dr[7] != 0)
putdr7(0);
taskswitch((uintptr)m+MACHSIZE);
}