public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix a couple of bugs in VMMCALL
@ 2011-04-05 13:28 Avi Kivity
  2011-04-05 13:28 ` [PATCH 1/2] KVM: x86 emulator: Re-add VendorSpecific tag to VMMCALL insn Avi Kivity
  2011-04-05 13:28 ` [PATCH 2/2] KVM: x86 emulator: Drop EFER.SVME requirement from VMMCALL Avi Kivity
  0 siblings, 2 replies; 5+ messages in thread
From: Avi Kivity @ 2011-04-05 13:28 UTC (permalink / raw)
  To: Marcelo Tosatti, kvm, Joerg Roedel

The recent nsvm/emulator work introduced a couple of bugs into VMMCALL
emulation, which the unit tests were kind enough to discover.

Avi Kivity (2):
  KVM: x86 emulator: Re-add VendorSpecific tag to VMMCALL insn
  KVM: x86 emulator: Drop EFER.SVME requirement from VMMCALL

 arch/x86/kvm/emulate.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] KVM: x86 emulator: Re-add VendorSpecific tag to VMMCALL insn
  2011-04-05 13:28 [PATCH 0/2] Fix a couple of bugs in VMMCALL Avi Kivity
@ 2011-04-05 13:28 ` Avi Kivity
  2011-04-05 13:28 ` [PATCH 2/2] KVM: x86 emulator: Drop EFER.SVME requirement from VMMCALL Avi Kivity
  1 sibling, 0 replies; 5+ messages in thread
From: Avi Kivity @ 2011-04-05 13:28 UTC (permalink / raw)
  To: Marcelo Tosatti, kvm, Joerg Roedel

VMMCALL needs the VendorSpecific tag so that #UD emulation
(called if a guest running on AMD was migrated to an Intel host)
is allowed to process the instruction.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch/x86/kvm/emulate.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index 8b1a506..a77c8f6 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -2677,7 +2677,7 @@ static struct opcode group7_rm1[] = {
 
 static struct opcode group7_rm3[] = {
 	DIP(SrcNone | ModRM | Prot | Priv, vmrun,   check_svme_pa),
-	DIP(SrcNone | ModRM | Prot       , vmmcall, check_svme),
+	DIP(SrcNone | ModRM | Prot | VendorSpecific, vmmcall, check_svme),
 	DIP(SrcNone | ModRM | Prot | Priv, vmload,  check_svme_pa),
 	DIP(SrcNone | ModRM | Prot | Priv, vmsave,  check_svme_pa),
 	DIP(SrcNone | ModRM | Prot | Priv, stgi,    check_svme),
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] KVM: x86 emulator: Drop EFER.SVME requirement from VMMCALL
  2011-04-05 13:28 [PATCH 0/2] Fix a couple of bugs in VMMCALL Avi Kivity
  2011-04-05 13:28 ` [PATCH 1/2] KVM: x86 emulator: Re-add VendorSpecific tag to VMMCALL insn Avi Kivity
@ 2011-04-05 13:28 ` Avi Kivity
  2011-04-05 13:41   ` Joerg Roedel
  1 sibling, 1 reply; 5+ messages in thread
From: Avi Kivity @ 2011-04-05 13:28 UTC (permalink / raw)
  To: Marcelo Tosatti, kvm, Joerg Roedel

VMMCALL requires EFER.SVME to be enabled in the host, not in the guest, which
is what check_svme() checks.

Signed-off-by: Avi Kivity <avi@redhat.com>
---
 arch/x86/kvm/emulate.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index a77c8f6..4aa5d65 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -2677,7 +2677,7 @@ static struct opcode group7_rm1[] = {
 
 static struct opcode group7_rm3[] = {
 	DIP(SrcNone | ModRM | Prot | Priv, vmrun,   check_svme_pa),
-	DIP(SrcNone | ModRM | Prot | VendorSpecific, vmmcall, check_svme),
+	DI(SrcNone | ModRM | Prot | VendorSpecific, vmmcall),
 	DIP(SrcNone | ModRM | Prot | Priv, vmload,  check_svme_pa),
 	DIP(SrcNone | ModRM | Prot | Priv, vmsave,  check_svme_pa),
 	DIP(SrcNone | ModRM | Prot | Priv, stgi,    check_svme),
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] KVM: x86 emulator: Drop EFER.SVME requirement from VMMCALL
  2011-04-05 13:28 ` [PATCH 2/2] KVM: x86 emulator: Drop EFER.SVME requirement from VMMCALL Avi Kivity
@ 2011-04-05 13:41   ` Joerg Roedel
  2011-04-05 16:18     ` Avi Kivity
  0 siblings, 1 reply; 5+ messages in thread
From: Joerg Roedel @ 2011-04-05 13:41 UTC (permalink / raw)
  To: Avi Kivity; +Cc: Marcelo Tosatti, kvm, Joerg Roedel

On Tue, Apr 05, 2011 at 04:28:31PM +0300, Avi Kivity wrote:
> VMMCALL requires EFER.SVME to be enabled in the host, not in the guest, which
> is what check_svme() checks.

Well, yes and no. The guest has no dedicated EFER. EFER is switched in
VMRUN which is why SVME must be set in the VMCBs EFER. This value makes
it into the arch.efer too with Nested-SVM.
According to the documentation VMMCALL throws an #UD if SVME is 0 which
is why I added the check. On the other hand, at host-level it throws
always an #UD and in the guest EFER.SVME is always enabled, so the check
doesn't really make sense. I just added it because is is documented.

	Joerg

> 
> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
>  arch/x86/kvm/emulate.c |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index a77c8f6..4aa5d65 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -2677,7 +2677,7 @@ static struct opcode group7_rm1[] = {
>  
>  static struct opcode group7_rm3[] = {
>  	DIP(SrcNone | ModRM | Prot | Priv, vmrun,   check_svme_pa),
> -	DIP(SrcNone | ModRM | Prot | VendorSpecific, vmmcall, check_svme),
> +	DI(SrcNone | ModRM | Prot | VendorSpecific, vmmcall),
>  	DIP(SrcNone | ModRM | Prot | Priv, vmload,  check_svme_pa),
>  	DIP(SrcNone | ModRM | Prot | Priv, vmsave,  check_svme_pa),
>  	DIP(SrcNone | ModRM | Prot | Priv, stgi,    check_svme),
> -- 
> 1.7.1
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] KVM: x86 emulator: Drop EFER.SVME requirement from VMMCALL
  2011-04-05 13:41   ` Joerg Roedel
@ 2011-04-05 16:18     ` Avi Kivity
  0 siblings, 0 replies; 5+ messages in thread
From: Avi Kivity @ 2011-04-05 16:18 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: Marcelo Tosatti, kvm, Joerg Roedel

On 04/05/2011 04:41 PM, Joerg Roedel wrote:
> On Tue, Apr 05, 2011 at 04:28:31PM +0300, Avi Kivity wrote:
> >  VMMCALL requires EFER.SVME to be enabled in the host, not in the guest, which
> >  is what check_svme() checks.
>
> Well, yes and no. The guest has no dedicated EFER. EFER is switched in
> VMRUN which is why SVME must be set in the VMCBs EFER. This value makes
> it into the arch.efer too with Nested-SVM.
> According to the documentation VMMCALL throws an #UD if SVME is 0 which
> is why I added the check. On the other hand, at host-level it throws
> always an #UD and in the guest EFER.SVME is always enabled, so the check
> doesn't really make sense. I just added it because is is documented.

If the guest invokes VMMCALL, EFER.SVME refers to the host (and since 
we're running a guest, it's bound to be on).  However if a nested guest 
invokes VMMCALL, then EFER.SVME refers to the guest.  So the check 
should look something like

   if nested guest and not efer.svme:
        #UD

-- 
error compiling committee.c: too many arguments to function


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-04-05 16:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-05 13:28 [PATCH 0/2] Fix a couple of bugs in VMMCALL Avi Kivity
2011-04-05 13:28 ` [PATCH 1/2] KVM: x86 emulator: Re-add VendorSpecific tag to VMMCALL insn Avi Kivity
2011-04-05 13:28 ` [PATCH 2/2] KVM: x86 emulator: Drop EFER.SVME requirement from VMMCALL Avi Kivity
2011-04-05 13:41   ` Joerg Roedel
2011-04-05 16:18     ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox