[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150724150511.72a09300@gandalf.local.home>
Date: Fri, 24 Jul 2015 15:05:11 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Linus Torvalds <torvalds@...ux-foundation.org>
Cc: Peter Zijlstra <peterz@...radead.org>, Willy Tarreau <w@....eu>,
Andy Lutomirski <luto@...capital.net>, X86 ML <x86@...nel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
Borislav Petkov <bp@...en8.de>,
Thomas Gleixner <tglx@...utronix.de>,
Brian Gerst <brgerst@...il.com>
Subject: Re: Dealing with the NMI mess
On Fri, 24 Jul 2015 11:41:55 -0700
Linus Torvalds <torvalds@...ux-foundation.org> wrote:
> On Fri, Jul 24, 2015 at 11:29 AM, Linus Torvalds
> <torvalds@...ux-foundation.org> wrote:
> >
> > So in the #DB handler, we would basically only clear instruction
> > breakpoints, and only when they trigger. If we have a data breakpoint
> > that triggers (even in kernel mode, and with interrupts disabled), let
> > it trigger and return with "ret" anyway. No biggie.
>
> So we'd not only look at "which breakpoint triggered", we'd also look
> at the actual debug register and check that "R/Wn == 0", and only
> disable it for that case.
>
> So you'd read %dr6 and %dr7, and then iterate 0..3 and check whether
> it triggerd (bit #n in %dr6), and that R/Wn (bits 16-17+n*4 of %dr7)
> is zero, and if so, clear LGn bits (bits 0-1+n*2) in %dr7.
>
> Something like
>
> unsigned long mask = 0;
> unsigned int dr6 = debug_read(6);
> unsigned int dr7 = debug_read(7)
> int i;
>
> for (i = 0; i < 4; i++) {
> if ((dr6 >> i) & 1) {
> if (!((dr7 >> (4*i+16)) & 3))
> mask |= 3 << (i*2);
> }
> }
>
> if (mask)
> debug_write(dr7 & ~mask, 7);
Macros would be nice for readability.
for (i = 0; i < 4; i++) {
if ((dr6 >> i) & 1) {
int shift = DR_CONTROL_SIZE * i + DR_CONTROL_SHIFT;
if (!((dr7 >> shift) & DR_RW_READ))
mask |= (DR_LOCAL_ENABLE|DR_GLOBAL_ENABLE) << (i * DR_ENABLE_SIZE);
}
}
-- Steve
>
> (yeah, I could easily have screwed that up)
>
> But the above should only clear bits in dr7 that are actually
> associated with the instruction breakpoint that triggered, and since
> it's a _kernel_ instruction breakpoint, not a user one, we can clear
> it and forget it. No need to re-enable at all.
>
> Hmm?
>
> Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists