public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: linux-kernel@vger.kernel.org, jan.kiszka@siemens.com,
	kvm@vger.kernel.org, gleb@kernel.org, avi.kivity@gmail.com
Subject: Re: [PATCH v2 4/4] KVM: x86: get CPL from SS.DPL
Date: Mon, 26 May 2014 13:10:10 -0300	[thread overview]
Message-ID: <20140526161009.GA30582@amt.cnet> (raw)
In-Reply-To: <1400172691-27030-5-git-send-email-pbonzini@redhat.com>

On Thu, May 15, 2014 at 06:51:31PM +0200, Paolo Bonzini wrote:
> CS.RPL is not equal to the CPL in the few instructions between
> setting CR0.PE and reloading CS.  And CS.DPL is also not equal
> to the CPL for conforming code segments.
> 
> However, SS.DPL *is* always equal to the CPL except for the weird
> case of SYSRET on AMD processors, which sets SS.DPL=SS.RPL from the
> value in the STAR MSR, but force CPL=3 (Intel instead forces
> SS.DPL=SS.RPL=CPL=3).
> 
> So this patch:
> 
> - modifies SVM to update the CPL from SS.DPL rather than CS.RPL;
> the above case with SYSRET is not broken further, and the way
> to fix it would be to pass the CPL to userspace and back
> 
> - modifies VMX to always return the CPL from SS.DPL (except
> forcing it to 0 if we are emulating real mode via vm86 mode;
> in vm86 mode all DPLs have to be 3, but real mode does allow
> privileged instructions).  It also removes the CPL cache,
> which becomes a duplicate of the SS access rights cache.
> 
> This fixes doing KVM_IOCTL_SET_SREGS exactly after setting
> CR0.PE=1 but before CS has been reloaded.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>


Reviewed-by: Marcelo Tosatti <mtosatti@redhat.com>

  reply	other threads:[~2014-05-26 16:10 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-15 16:51 [PATCH v2 0/4] KVM: x86: get CPL from SS.DPL Paolo Bonzini
2014-05-15 16:51 ` [PATCH v2 1/4] KVM: x86: use new CS.RPL as CPL during task switch Paolo Bonzini
2014-05-16 22:19   ` Paolo Bonzini
2014-05-26 16:55   ` Marcelo Tosatti
2014-05-15 16:51 ` [PATCH v2 2/4] KVM: x86: drop set_rflags callback Paolo Bonzini
2014-05-15 16:51 ` [PATCH v2 3/4] KVM: x86: check CS.DPL against RPL during task switch Paolo Bonzini
2014-05-26 17:01   ` Marcelo Tosatti
2014-05-15 16:51 ` [PATCH v2 4/4] KVM: x86: get CPL from SS.DPL Paolo Bonzini
2014-05-26 16:10   ` Marcelo Tosatti [this message]
     [not found] <CALeycy_c4P+vvWBXVYts5WaZOB-=-ovMgA1eK+A9Dk1Zs1Sptw@mail.gmail.com>
2014-05-25 23:21 ` Wei Huang
2014-05-26 12:38   ` Paolo Bonzini
2014-05-27  5:22     ` Wei Huang

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=20140526161009.GA30582@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=avi.kivity@gmail.com \
    --cc=gleb@kernel.org \
    --cc=jan.kiszka@siemens.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