From: Alexander Graf <agraf@suse.de>
To: Alexander Graf <agraf@suse.de>
Cc: Avi Kivity <avi@redhat.com>,
x86@kernel.org, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org
Subject: Re: [PATCH] x86, nmi: workaround sti; hlt race vs nmi; intr
Date: Mon, 27 Sep 2010 11:15:23 +0200 [thread overview]
Message-ID: <61284934-1AD3-4F7A-9488-D46FCEE9B753@suse.de> (raw)
In-Reply-To: <768A5DC0-131A-4BC8-ADDD-044D8169545E@suse.de>
On 27.09.2010, at 11:13, Alexander Graf wrote:
>
> On 27.09.2010, at 10:38, Avi Kivity wrote:
>
>> On 09/19/2010 06:28 PM, Avi Kivity wrote:
>>> On machines without monitor/mwait we use an sti; hlt sequence to atomically
>>> enable interrupts and put the cpu to sleep. The sequence uses the "interrupt
>>> shadow" property of the sti instruction: interrupts are enabled only after
>>> the instruction following sti has been executed. This means an interrupt
>>> cannot happen in the middle of the sequence, which would leave us with
>>> the interrupt processed but the cpu halted.
>>>
>>> The interrupt shadow, however, can be broken by an nmi; the following
>>> sequence
>>>
>>> sti
>>> nmi ... iret
>>> # interrupt shadow disabled
>>> intr ... iret
>>> hlt
>>>
>>> puts the cpu to sleep, even though the interrupt may need additional processing
>>> after the hlt (like scheduling a task).
>>>
>>> sti is explicitly documented not to force an interrupt shadow; though many
>>> processors do inhibit nmi immediately after sti.
>>>
>>> Avoid the race by checking, during an nmi, if we hit the safe halt sequence.
>>> If we did, increment the instruction pointer past the hlt instruction; this
>>> allows an immediately following interrupt to return to a safe place.
>>>
>>> Signed-off-by: Avi Kivity<avi@redhat.com>
>>
>> Ping.
>
> Wow, this is incredibly ugly :). Can't we just mask NMIs when the interrupt shadow is active?
Yeah, that's me writing without thinking. So this means that the race can also happen on real hardware?
Alex
next prev parent reply other threads:[~2010-09-27 9:15 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-19 16:28 Avi Kivity
2010-09-27 8:38 ` Avi Kivity
2010-09-27 9:13 ` Alexander Graf
2010-09-27 9:15 ` Alexander Graf [this message]
2010-09-27 9:17 ` Avi Kivity
2010-09-27 9:22 ` Alexander Graf
2010-09-27 9:27 ` Avi Kivity
2010-09-27 9:36 ` Alexander Graf
2010-09-27 21:55 ` H. Peter Anvin
2010-09-28 8:50 ` Avi Kivity
2010-09-28 9:22 ` Roedel, Joerg
2010-09-28 15:34 ` H. Peter Anvin
2010-09-28 16:30 ` Avi Kivity
2010-09-27 10:31 ` Joerg Roedel
2010-09-27 14:17 ` Avi Kivity
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=61284934-1AD3-4F7A-9488-D46FCEE9B753@suse.de \
--to=agraf@suse.de \
--cc=avi@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=x86@kernel.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®