From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, bsd@redhat.com
Subject: Re: [PATCH 08/12] KVM: x86: save/load state on SMM switch
Date: Fri, 22 May 2015 16:17:13 +0200 [thread overview]
Message-ID: <20150522141713.GC31183@potion.brq.redhat.com> (raw)
In-Reply-To: <555E4C4E.1010603@redhat.com>
2015-05-21 23:21+0200, Paolo Bonzini:
> On 21/05/2015 19:00, Radim Krčmář wrote:
>> Potentially, an NMI could be latched (while in SMM or upon exit) and
>> serviced upon exit [...]
>>
>> This "Potentially" could be in the sense that the whole 3rd paragraph is
>> only applicable to some ancient SMM design :)
>
> It could also be in the sense that you cannot exclude an NMI coming at
> exactly the wrong time.
Yes, but it is hard to figure out how big the wrong time window is ...
Taken to the extreme, the paragraph says that we must inject NMI that
arrived while in SMM after RSM; regardless of NMI blocking before.
(Which is not how real hardware works.)
> If you want to go full language lawyer, it does mention it whenever
> behavior is specific to a processor family.
True, I don't know of an exception, but that is not a proof for the
contrary here :/
>> The 1st paragraph has quite clear sentence:
>>
>> If NMIs were blocked before the SMI occurred, they are blocked after
>> execution of RSM.
>>
>> so I'd just ignore the 3rd paragraph ...
It's suspicious in other ways ... I'll focus on other part of the
sentence now
Potentially, an NMI could be latched (while in SMM or upon exit)
^^^^^^^^^^^^^^^^^^^^^
A NMI can't be latched in SMM mode and delivered after RSM when we
started with masked NMI.
It was latched in SMM, so we either didn't unmask NMIs or we were
executing a NMI in SMM mode. The first case is covered by
If NMIs were blocked before the SMI occurred, they are blocked after
execution of RSM.
The second case, when we specialize the above, would need to unmask NMIs
with IRET, accept an NMI, and then do RSM before IRET (because IRET
would immediately inject the latched NMI);
if CPU unmasks NMIs in that case, I'd slap someone.
Btw. I had a good laugh on Intel's response to a similar question:
https://software.intel.com/en-us/forums/topic/305672
>> And the APM 2:10.3.3 Exceptions and Interrupts
| [...]
>> makes me think that we should unmask them unconditionally or that SMM
>> doesn't do anything with NMI masking.
>
> Actually I hadn't noticed this paragraph. But I read it the same as the
> Intel manual (i.e. what I implemented): it doesn't say anywhere that RSM
> may cause the processor to *set* the "NMIs masked" flag.
>
> It makes no sense; as you said it's 1 bit of state! But it seems that
> it's the architectural behavior. :(
Ok, it's sad and I'm too lazy to actually try it ...
>> If we can choose, less NMI nesting seems like a good idea.
>
> It would---I'm just preempting future patches from Nadav. :)
Me too :D
> That said,
> even if OVMF does do IRETs in SMM (in 64-bit mode it fills in page
> tables lazily for memory above 4GB), we do not care about asynchronous
> SMIs such as those for power management. So we should never enter SMM
> with NMIs masked, to begin with.
Yeah, it's a stupid corner case, the place where most of time and sanity
is lost.
next prev parent reply other threads:[~2015-05-22 14:17 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-08 11:20 [PATCH 00/12] KVM: x86: SMM support Paolo Bonzini
2015-05-08 11:20 ` [PATCH 01/12] KVM: export __gfn_to_pfn_memslot, drop gfn_to_pfn_async Paolo Bonzini
2015-05-08 11:20 ` [PATCH 02/12] KVM: x86: introduce num_emulated_msrs Paolo Bonzini
2015-05-08 11:20 ` [PATCH 03/12] KVM: remove unnecessary arg from mark_page_dirty_in_slot, export it Paolo Bonzini
2015-05-08 11:20 ` [PATCH 04/12] KVM: x86: pass host_initiated to functions that read MSRs Paolo Bonzini
2015-05-08 11:20 ` [PATCH 05/12] KVM: x86: pass the whole hflags field to emulator and back Paolo Bonzini
2015-05-08 11:20 ` [PATCH 06/12] KVM: x86: API changes for SMM support Paolo Bonzini
2015-05-21 14:49 ` Radim Krčmář
2015-05-21 14:59 ` Paolo Bonzini
2015-05-21 16:26 ` Radim Krčmář
2015-05-21 21:21 ` Paolo Bonzini
2015-05-08 11:20 ` [PATCH 07/12] KVM: x86: stubs " Paolo Bonzini
2015-05-21 14:55 ` Radim Krčmář
2015-05-08 11:20 ` [PATCH 08/12] KVM: x86: save/load state on SMM switch Paolo Bonzini
2015-05-21 16:20 ` Radim Krčmář
2015-05-21 16:21 ` Paolo Bonzini
2015-05-21 16:33 ` Radim Krčmář
2015-05-21 20:24 ` Paolo Bonzini
2015-05-22 13:13 ` Radim Krčmář
2015-05-21 16:23 ` Paolo Bonzini
2015-05-21 17:00 ` Radim Krčmář
2015-05-21 21:21 ` Paolo Bonzini
2015-05-22 14:17 ` Radim Krčmář [this message]
2015-05-25 12:46 ` Paolo Bonzini
2015-05-08 11:20 ` [PATCH 09/12] KVM: x86: add vcpu-specific functions to read/write/translate GFNs Paolo Bonzini
2015-05-08 11:20 ` [PATCH 10/12] KVM: x86: add SMM to the MMU role Paolo Bonzini
2015-05-08 11:20 ` [PATCH 11/12] KVM: x86: add KVM_MEM_X86_SMRAM memory slot flag Paolo Bonzini
2015-05-26 18:45 ` Avi Kivity
2015-05-27 9:26 ` Paolo Bonzini
2015-05-08 11:20 ` [PATCH 12/12] KVM: x86: advertise KVM_CAP_X86_SMM Paolo Bonzini
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=20150522141713.GC31183@potion.brq.redhat.com \
--to=rkrcmar@redhat.com \
--cc=bsd@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).