All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Nadav Amit <namit@cs.technion.ac.il>
Cc: gleb@kernel.org, tglx@linutronix.de, mingo@redhat.com,
	hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org,
	kvm@vger.kernel.org, joro@8bytes.org
Subject: Re: [PATCH 2/3] KVM: x86: Emulator support for #UD on CPL>0
Date: Wed, 18 Jun 2014 18:29:18 +0200	[thread overview]
Message-ID: <53A1BE5E.3060809@redhat.com> (raw)
In-Reply-To: <1403101176-23664-3-git-send-email-namit@cs.technion.ac.il>

Il 18/06/2014 16:19, Nadav Amit ha scritto:
> Certain instructions (e.g., mwait and monitor) cause a #UD exception when they
> are executed in privilaged mode.

It's actually "non-privileged mode" (Priv means the instruction is 
privileged, not the mode).  So I've renamed the flag to PrivUD.

Paolo

  This is in contrast to the regular privilaged
> instructions which cause #GP. In order not to mess with SVM interception of
> mwait and monitor which assumes privilage level assertions take place before
> interception, a flag has been added.
>
> Signed-off-by: Nadav Amit <namit@cs.technion.ac.il>
> ---
>  arch/x86/kvm/emulate.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index f90194d..ef7a5a0 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -163,6 +163,7 @@
>  #define SrcWrite    ((u64)1 << 46)  /* Write back src operand */
>  #define NoMod	    ((u64)1 << 47)  /* Mod field is ignored */
>  #define NoBigReal   ((u64)1 << 48)  /* No big real mode */
> +#define UDOnPriv    ((u64)1 << 49)  /* #UD instead of #GP on CPL > 0 */
>
>  #define DstXacc     (DstAccLo | SrcAccHi | SrcWrite)
>
> @@ -4560,7 +4561,10 @@ int x86_emulate_insn(struct x86_emulate_ctxt *ctxt)
>
>  	/* Privileged instruction can be executed only in CPL=0 */
>  	if ((ctxt->d & Priv) && ops->cpl(ctxt)) {
> -		rc = emulate_gp(ctxt, 0);
> +		if (ctxt->d & UDOnPriv)
> +			rc = emulate_ud(ctxt);
> +		else
> +			rc = emulate_gp(ctxt, 0);
>  		goto done;
>  	}
>
>

  reply	other threads:[~2014-06-18 16:29 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-18 14:19 [PATCH 0/3] Correct monitor-mwait emulation as nop Nadav Amit
2014-06-18 14:19 ` [PATCH 1/3] KVM: x86: Emulator flag for instruction with no big real mode Nadav Amit
2014-06-18 14:19 ` [PATCH 2/3] KVM: x86: Emulator support for #UD on CPL>0 Nadav Amit
2014-06-18 16:29   ` Paolo Bonzini [this message]
2014-06-18 14:19 ` [PATCH 3/3] KVM: x86: correct mwait and monitor emulation Nadav Amit
2014-06-18 16:32   ` Paolo Bonzini
2014-06-18 16:43   ` Bandan Das
2014-06-18 16:44     ` Paolo Bonzini
2014-06-18 17:33       ` Bandan Das
2014-06-18 17:59   ` Eric Northup
2014-06-18 18:23     ` Nadav Amit
2014-06-18 18:30       ` Eric Northup
2014-06-18 18:59         ` Gabriel L. Somlo
2014-06-18 18:46     ` Gabriel L. Somlo
2014-06-18 19:09       ` Bandan Das
2014-06-19 10:18       ` Michael S. Tsirkin
     [not found]         ` <1B06E887-9D07-4E85-AE06-75B01787C488@gmail.com>
2014-06-19 11:23           ` Gleb Natapov
2014-06-19 11:52             ` Nadav Amit
2014-06-19 12:01               ` Michael S. Tsirkin
2014-06-19 12:07               ` Gleb Natapov
2014-06-19 12:10                 ` Nadav Amit
2014-06-19 12:16                   ` Gleb Natapov
2014-06-19 12:17                   ` Michael S. Tsirkin
2014-06-19 12:28                     ` Nadav Amit
2014-06-19 11:34     ` 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=53A1BE5E.3060809@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=gleb@kernel.org \
    --cc=hpa@zytor.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=namit@cs.technion.ac.il \
    --cc=tglx@linutronix.de \
    --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 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.