From: Paolo Bonzini <pbonzini@redhat.com>
To: Kevin O'Connor <kevin@koconnor.net>
Cc: qemu-devel@nongnu.org, marcel.a@redhat.com,
Gerd Hoffmann <kraxel@redhat.com>,
Richard Henderson <rth@twiddle.net>
Subject: Re: [Qemu-devel] [PATCH] SMI handler should set the CPL to zero and save and restore it on rsm.
Date: Tue, 13 May 2014 21:42:06 +0200 [thread overview]
Message-ID: <5372758E.4010304@redhat.com> (raw)
In-Reply-To: <53726AFE.9010001@redhat.com>
Il 13/05/2014 20:57, Paolo Bonzini ha scritto:
> Il 13/05/2014 20:39, Kevin O'Connor ha scritto:
>> That doesn't sound right. What happens if the processor takes an NMI,
>> SMI, or VMEXIT between the point it enables protected mode but before
>> it long jumps? The processor would have to save and restore the CPL
>> somewhere for all of these situations.
>
> For VMEXITs it's up to the hypervisor to make it work properly. I just
> posted today fixes for KVM.
>
> I guess the answer for NMIs is "good luck". But in the case of NMIs,
> wouldn't it be broken anyway, because the IDT format is different
> between real mode and protected mode?
>
> For SMIs, http://www.sandpile.org/x86/smm.htm says that the CPL is
> stored somewhere in SMRAM. I think your patches are an improvement
> anyway, we can build a more complete fix on top of them.
On second thought, the CPL should always be equal to SS.DPL, even during
real mode transitions. Unlike CS.RPL, SS.DPL is hidden in the internal
segment descriptor registers and is always zero.
I say *should*, because of course there is an exception. :) CPL is
forced to 3 by SYSRET, even if it loads SS with a selector whose RPL is
not 3. So we're better off saving CPL in SMRAM (and perhaps make the
SMRAM map equal to that of real processors).
In any case, I think this is an example of how your patches are an
improvement; it would be trivial to make CPL=SS.DPL on top of them.
Paolo
next prev parent reply other threads:[~2014-05-13 19:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20140425171718.GA1591@morn.localdomain>
[not found] ` <535B772D.1020602@redhat.com>
[not found] ` <1398601366.21309.33.camel@localhost.localdomain>
[not found] ` <535D1445.3040905@redhat.com>
[not found] ` <20140427172524.GB28385@morn.localdomain>
2014-05-13 18:24 ` [Qemu-devel] [PATCH] SMI handler should set the CPL to zero and save and restore it on rsm Paolo Bonzini
2014-05-13 18:39 ` Kevin O'Connor
2014-05-13 18:57 ` Paolo Bonzini
2014-05-13 19:42 ` Paolo Bonzini [this message]
2014-05-13 22:07 ` Kevin O'Connor
2014-05-14 8:05 ` Paolo Bonzini
2014-05-15 0:20 ` Kevin O'Connor
2014-05-15 1:32 ` Kevin O'Connor
2014-05-15 6:35 ` 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=5372758E.4010304@redhat.com \
--to=pbonzini@redhat.com \
--cc=kevin@koconnor.net \
--cc=kraxel@redhat.com \
--cc=marcel.a@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/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).