From: Steven Rostedt <rostedt@goodmis.org>
To: Brian Gerst <brgerst@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Avi Kivity <avi@redhat.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@elte.hu>, "H. Peter Anvin" <hpa@zytor.com>,
Thomas Gleixner <tglx@linutronix.de>,
Paul Turner <pjt@google.com>,
Peter Zijlstra <peterz@infradead.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Subject: Re: NMI vs #PF clash
Date: Wed, 23 May 2012 04:32:20 -0400 [thread overview]
Message-ID: <1337761940.13348.138.camel@gandalf.stny.rr.com> (raw)
In-Reply-To: <CAMzpN2hWhcYBT0noFSc24e_fH-sVwK+Da97Byvge4tsF3_vRTQ@mail.gmail.com>
On Tue, 2012-05-22 at 21:26 -0400, Brian Gerst wrote:
> > @@ -1734,6 +1748,13 @@ end_repeat_nmi:
> > nmi_swapgs:
> > SWAPGS_UNSAFE_STACK
> > nmi_restore:
> > + /* Test if the cr2 reg changed */
> > + movq ORIG_RAX-R15+(12*8)(%rsp), %rdx
> > + movq %cr2, %rcx
> > + cmp %rdx, %rcx
> > + je 1f
> > + movq %rdx, %cr2
> > +1:
> > RESTORE_ALL 8
> > /* Clear the NMI executing stack variable */
> > movq $0, 10*8(%rsp)
>
> You could save cr2 in a callee-saved register (like r12) instead of
> putting it on the stack.
>
You know, I thought about that but decided against it. My rational was
that I wanted the store of the cr2 in the first NMI where it would do it
again if it had to do a repeated NMI. At first I thought that a repeated
NMI would corrupt the cr2, but that is not the case as the cr2 would
have been restored before repeating the NMI.
I guess I also wanted to limit the number of reads of the cr2 as well.
But as repeated NMIs is such a seldom case (requires a fault and then
another NMI to come in), that this optimization is practically useless.
I agree, it would be better to just use one of the non-clobbered regs.
Thanks, I'll try that out and this should make the patch much simpler.
-- Steve
next prev parent reply other threads:[~2012-05-23 8:32 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-22 12:53 Avi Kivity
2012-05-22 13:30 ` Steven Rostedt
2012-05-22 13:45 ` Avi Kivity
2012-05-22 14:09 ` Steven Rostedt
2012-05-22 14:20 ` Avi Kivity
2012-05-22 14:27 ` Steven Rostedt
2012-05-22 14:37 ` Avi Kivity
2012-05-22 14:50 ` Steven Rostedt
2012-05-22 15:22 ` Mathieu Desnoyers
2012-05-22 15:33 ` Linus Torvalds
2012-05-22 15:45 ` Avi Kivity
2012-05-22 15:47 ` H. Peter Anvin
2012-05-23 0:39 ` Steven Rostedt
2012-05-23 1:26 ` Brian Gerst
2012-05-23 8:32 ` Steven Rostedt [this message]
2012-05-23 8:56 ` Steven Rostedt
2012-06-11 4:22 ` [tip:x86/debug] x86: Save cr2 in NMI in case NMIs take a page fault tip-bot for Steven Rostedt
2012-06-11 4:24 ` [tip:x86/debug] x86: Save cr2 in NMI in case NMIs take a page fault (for i386) tip-bot for Steven Rostedt
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=1337761940.13348.138.camel@gandalf.stny.rr.com \
--to=rostedt@goodmis.org \
--cc=avi@redhat.com \
--cc=brgerst@gmail.com \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=mingo@elte.hu \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®