From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755272AbcHSBmq (ORCPT ); Thu, 18 Aug 2016 21:42:46 -0400 Received: from smtprelay0124.hostedemail.com ([216.40.44.124]:44668 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753576AbcHSBmo (ORCPT ); Thu, 18 Aug 2016 21:42:44 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::,RULES_HIT:41:355:379:541:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2553:2559:2562:2693:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:4250:5007:6261:7875:7939:10004:10400:10450:10455:10848:10967:11232:11658:11914:12517:12519:12740:13069:13311:13357:13439:14096:14097:14180:14181:14659:14721:19904:19999:21060:21080:21433:30041:30051:30054:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: women74_2f9b0daea9f09 X-Filterd-Recvd-Size: 1933 Date: Thu, 18 Aug 2016 11:48:45 -0400 From: Steven Rostedt To: Andy Lutomirski Cc: LKML , Jiri Olsa Subject: Re: Question: Outer NMI can nest if from user mode? Message-ID: <20160818114845.24e0473e@gandalf.local.home> In-Reply-To: <20160818112155.634bebcb@gandalf.local.home> References: <20160818112155.634bebcb@gandalf.local.home> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 18 Aug 2016 11:21:55 -0400 Steven Rostedt wrote: > Hi Andy, > > I was reading some of the comments in nmi.c and came across this: > > /* > * NMIs can page fault or hit breakpoints which will cause it to lose > * its NMI context with the CPU when the breakpoint or page fault does an IRET. > * > * As a result, NMIs can nest if NMIs get unmasked due an IRET during > * NMI processing. On x86_64, the asm glue protects us from nested NMIs > * if the outer NMI came from kernel mode, but we can still nest if the > * outer NMI came from user mode. > > > What confuses me is "but we can still nest if the outer NMI came from > user mode". > > How can that happen? You mean do_nmi() can be called nested even on > x86_64 if the first NMI happened in user mode? Never mind. Jiri pointed out this patch (which I forgot about :-p) 9b6e6a8334d56 x86/nmi/64: Switch stacks on userspace NMI entry Which switches the stack to the kernel stack from the NMI stack if we came from user mode. That explains how the asm glue wont catch it. -- Steve