All of lore.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Ingo Molnar <mingo@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	"H. Peter Anvin" <hpa@linux.intel.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>,
	Paul Turner <pjt@google.com>
Subject: Perhaps a side effect regarding NMI returns
Date: Mon, 28 Nov 2011 23:07:53 -0500	[thread overview]
Message-ID: <1322539673.17003.45.camel@frodo> (raw)

I was looking at the return sequence of NMIs in x86_64 and I came across
this in entry_64.S:

	jz paranoid_swapgs
	movq %rsp,%rdi			/* &pt_regs */
	call sync_regs
	movq %rax,%rsp			/* switch stack for scheduling */
	testl $_TIF_NEED_RESCHED,%ebx
	jnz paranoid_schedule
	movl %ebx,%edx			/* arg3: thread flags */
	TRACE_IRQS_ON
	ENABLE_INTERRUPTS(CLBR_NONE)
	xorl %esi,%esi 			/* arg2: oldset */
	movq %rsp,%rdi 			/* arg1: &pt_regs */
	call do_notify_resume
	DISABLE_INTERRUPTS(CLBR_NONE)
	TRACE_IRQS_OFF
	jmp paranoid_userspace
paranoid_schedule:
	TRACE_IRQS_ON
	ENABLE_INTERRUPTS(CLBR_ANY)
	call schedule
	DISABLE_INTERRUPTS(CLBR_ANY)
	TRACE_IRQS_OFF
	jmp paranoid_userspace
	CFI_ENDPROC

Specifically the code after jnz paranoid_schedule.

Just before that jnz, we swap the stack back to the task's stack (no
more NMI stack). If NEED_RESCHED is set, we jump to paranoid_schedule
and enable interrupts and call schedule.

Is there a bit of a side effect here? What happens when you enable
interrupts in NMI context? Can more NMIs come in? If not, we just went
into schedule and went off and running, and NMIs will have to wait till
the next interrupt comes in and calls iretq to re-enable NMIs. If we
lock up here, don't expect NMI watchdog to help you out.

If enabling interrupts also enables NMIs, then there's no side effect.

This email is more of an FYI than anything else. Maybe there's an issue
here, and maybe there isn't. But this is so subtle that I figured I
would bring it to other people's attention. I'll let others do the hard
work to figure out if we should worry about this or not ;-)

-- Steve



             reply	other threads:[~2011-11-29  4:07 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-29  4:07 Steven Rostedt [this message]
2011-11-29  4:53 ` Perhaps a side effect regarding NMI returns Linus Torvalds
2011-11-29  7:33   ` Paul Turner
2011-11-29 20:09   ` Andi Kleen
2011-11-29 20:12     ` Linus Torvalds
2011-11-29 20:31       ` Andi Kleen
2011-11-29 20:36         ` Linus Torvalds
2011-11-29 20:58           ` Steven Rostedt
2011-11-29 21:05             ` Linus Torvalds
2011-11-29 21:22               ` Steven Rostedt
2011-11-29 22:14             ` Jason Baron
2011-11-29 22:51               ` Steven Rostedt
2011-11-30 11:56                 ` Peter Zijlstra
2011-11-29 20:35     ` Steven Rostedt
2011-11-29 20:44       ` Linus Torvalds
2011-12-07 16:36         ` Steven Rostedt
2011-12-07 16:44           ` Linus Torvalds
2011-12-07 17:31             ` Steven Rostedt
2011-12-07 17:48               ` Linus Torvalds
2011-12-07 17:51           ` Andi Kleen
2012-01-08  8:55         ` [tip:perf/core] x86: Do not schedule while still in NMI context tip-bot for Linus Torvalds
2011-11-29 21:28       ` Perhaps a side effect regarding NMI returns Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1322539673.17003.45.camel@frodo \
    --to=rostedt@goodmis.org \
    --cc=fweisbec@gmail.com \
    --cc=hpa@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@polymtl.ca \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=pjt@google.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.