Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754587AbbGXNal (ORCPT ); Fri, 24 Jul 2015 09:30:41 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:36197 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752552AbbGXNaj (ORCPT ); Fri, 24 Jul 2015 09:30:39 -0400 Date: Fri, 24 Jul 2015 15:30:13 +0200 From: Peter Zijlstra To: Willy Tarreau Cc: Steven Rostedt , Linus Torvalds , Andy Lutomirski , X86 ML , "linux-kernel@vger.kernel.org" , Borislav Petkov , Thomas Gleixner , Brian Gerst Subject: Re: Dealing with the NMI mess Message-ID: <20150724133013.GI19282@twins.programming.kicks-ass.net> References: <20150723173105.6795c0dc@gandalf.local.home> <20150724081326.GO25159@twins.programming.kicks-ass.net> <20150724075841.40f209f4@gandalf.local.home> <20150724124304.GH19282@twins.programming.kicks-ass.net> <20150724090342.6d11e16d@gandalf.local.home> <20150724132128.GA3612@1wt.eu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150724132128.GA3612@1wt.eu> User-Agent: Mutt/1.5.21 (2012-12-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2376 Lines: 53 On Fri, Jul 24, 2015 at 03:21:28PM +0200, Willy Tarreau wrote: > On Fri, Jul 24, 2015 at 09:03:42AM -0400, Steven Rostedt wrote: > > On Fri, 24 Jul 2015 14:43:04 +0200 > > Peter Zijlstra wrote: > > > > > > > > I'm not too familiar with how to use hw breakpoints, but I'm guessing > > > > (correct me if I'm wrong) that breakpoints on code that trigger when > > > > executed, but watchpoints on data trigger when accessed. Then > > > > copy_from_user_inatomic() would only trigger on watchpoints (it's not > > > > executing that code, at least I hope it isn't!), and those wont bother > > > > us. > > > > > > These things can be: RW, W, X. > > > > > > Sure, hitting a user X watchpoint is going to be 'interesting', but its > > > fairly easy to hit a RW one. > > > > But do we care if we do hit one? The return from the #DB handler can > > use a RET. Right? Look at do_debug(), it has lovely bits like: preempt_conditional_sti(); in it, we do _NOT_ want to be re-enabling interrupts if we're called from an !IF context, that'd be _bad_. > My understanding is that by using RET we can't set the RF flag and #DB > will immediately strike again when the operation is attempted again. Thus > we have to completely disable the breakpoints on leaving after the first > one strikes, resulting in some userland breakpoints being missed. Maybe > it can be accepted as a limitation when perf is running. I don't know if > the output of perf is that relevant when a debugger is present BTW. The patch I posted will re-enable the breakpoints before returning to userspace. So userspace will only 'miss' events generated by the kernel. Missing reads from the kernel is not a problem -- and maybe even expected, but certainly unavoidable. Missing updates from the kernel might be a problem, you'd get a variable change content even though you have a W watchpoint on it, that'd be surprising. Then again, I suppose we can argue the variable changed through another mapping and watchpoints work on the virtual address, so tough cookies or somesuch -- the kernel could in fact do this on highmem kernel anyway. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/