All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: linux-kernel@vger.kernel.org
Cc: jan.kiszka@siemens.com, kvm@vger.kernel.org, gleb@kernel.org,
	avi.kivity@gmail.com
Subject: Re: [PATCH 0/5] KVM: x86: support setting the CPL independent of CS
Date: Wed, 14 May 2014 09:47:51 +0200	[thread overview]
Message-ID: <53731FA7.3070800@redhat.com> (raw)
In-Reply-To: <1399992941-11600-1-git-send-email-pbonzini@redhat.com>

Il 13/05/2014 16:55, Paolo Bonzini ha scritto:
> Until now, KVM used to assume that CS.RPL could always be used as the CPL
> value when KVM_SET_SREGS is called.  Unfortunately this is not the case.
> If userspace decides to call KVM_GET_SREGS/KVM_SET_SREGS exactly after
> CR0.PE has been set to 1, but before the long jump that reloads CS, the
> CPL will be reset to bits 0-1 of CS (aka CS.RPL).  This can work or not,
> depending on the placement of the code that transitions to protected
> mode.  If CS.RPL != 0 the emulator will see CS.RPL != CS.DPL (the DPL
> will always be zero) and fail to fetch the next instruction of the
> transition code.
>
> The same bug exists with SVM, where you don't have the emulator but the
> guest will triple fault.  Strangely, it doesn't occur with Intel's
> unrestricted guest mode.
>
> To trigger this using QEMU, it is enough to send "info cpus" continuously
> while running iPXE (which places its code for real->protected mode in
> the EBDA).  iPXE does a lot of transitions, and the guest will crash
> very quickly.
>
> Avi or Gleb, this is a bit tricky.  Can you review it please?

There's a simpler way to fix this, by using SS.DPL as the CPL.  Patch on 
its way...

Paolo

      parent reply	other threads:[~2014-05-14  7:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-13 14:55 [PATCH 0/5] KVM: x86: support setting the CPL independent of CS Paolo Bonzini
2014-05-13 14:55 ` [PATCH 1/5] KVM: x86: support KVM_ENABLE_CAP on vm file descriptors Paolo Bonzini
2014-05-13 14:55 ` [PATCH 2/5] KVM: x86: retrieve CPL in KVM_GET_SREGS, prepare to be able to set it Paolo Bonzini
2014-05-13 14:55 ` [PATCH 3/5] KVM: vmx: always compute the CPL on KVM_SET_SREGS Paolo Bonzini
2014-05-13 14:55 ` [PATCH 4/5] KVM: vmx: force CPL=0 on real->protected mode transition Paolo Bonzini
2014-05-13 14:55 ` [PATCH 5/5] KVM: x86: add capability to get/set CPL Paolo Bonzini
2014-05-14  7:47 ` Paolo Bonzini [this message]

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=53731FA7.3070800@redhat.com \
    --to=pbonzini@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 \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.