x86/debug: Change thread.debugreg6 to thread.virtual_dr6
Current usage of thread.debugreg6 is convoluted at best. It starts life as a copy of the hardware DR6 value, but then various bits are cleared and set. Replace this with a new variable thread.virtual_dr6 that is initialized to 0 when DR6 is read and only gains bits, at the same time the actual (on stack) dr6 value which is read from the hardware only gets bits cleared. Suggested-by: Andy Lutomirski <luto@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Daniel Thompson <daniel.thompson@linaro.org> Link: https://lore.kernel.org/r/20200902133201.415372940@infradead.org
This commit is contained in:

committed by
Thomas Gleixner

parent
f4956cf83e
commit
d53d9bc0cf
@@ -454,7 +454,7 @@ void flush_ptrace_hw_breakpoint(struct task_struct *tsk)
|
||||
t->ptrace_bps[i] = NULL;
|
||||
}
|
||||
|
||||
t->debugreg6 = 0;
|
||||
t->virtual_dr6 = 0;
|
||||
t->ptrace_dr7 = 0;
|
||||
}
|
||||
|
||||
@@ -489,8 +489,8 @@ static int hw_breakpoint_handler(struct die_args *args)
|
||||
{
|
||||
int i, rc = NOTIFY_STOP;
|
||||
struct perf_event *bp;
|
||||
unsigned long dr6;
|
||||
unsigned long *dr6_p;
|
||||
unsigned long dr6;
|
||||
|
||||
/* The DR6 value is pointed by args->err */
|
||||
dr6_p = (unsigned long *)ERR_PTR(args->err);
|
||||
@@ -504,12 +504,6 @@ static int hw_breakpoint_handler(struct die_args *args)
|
||||
if ((dr6 & DR_TRAP_BITS) == 0)
|
||||
return NOTIFY_DONE;
|
||||
|
||||
/*
|
||||
* Reset the DRn bits in the virtualized register value.
|
||||
* The ptrace trigger routine will add in whatever is needed.
|
||||
*/
|
||||
current->thread.debugreg6 &= ~DR_TRAP_BITS;
|
||||
|
||||
/* Handle all the breakpoints that were triggered */
|
||||
for (i = 0; i < HBP_NUM; ++i) {
|
||||
if (likely(!(dr6 & (DR_TRAP0 << i))))
|
||||
@@ -554,7 +548,7 @@ static int hw_breakpoint_handler(struct die_args *args)
|
||||
* breakpoints (to generate signals) and b) when the system has
|
||||
* taken exception due to multiple causes
|
||||
*/
|
||||
if ((current->thread.debugreg6 & DR_TRAP_BITS) ||
|
||||
if ((current->thread.virtual_dr6 & DR_TRAP_BITS) ||
|
||||
(dr6 & (~DR_TRAP_BITS)))
|
||||
rc = NOTIFY_DONE;
|
||||
|
||||
|
Reference in New Issue
Block a user