diff mbox

[2/6] Nested VMX patch 2 implements vmclear

Message ID 1251905916-2834-3-git-send-email-oritw@il.ibm.com (mailing list archive)
State New, archived
Headers show

Commit Message

oritw@il.ibm.com Sept. 2, 2009, 3:38 p.m. UTC
From: Orit Wasserman <oritw@il.ibm.com>

---
 arch/x86/kvm/vmx.c |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)

Comments

Avi Kivity Sept. 2, 2009, 7:38 p.m. UTC | #1
On 09/02/2009 06:38 PM, oritw@il.ibm.com wrote:
> From: Orit Wasserman<oritw@il.ibm.com>
>
> ---
>   arch/x86/kvm/vmx.c |   24 +++++++++++++++++++++++-
>   1 files changed, 23 insertions(+), 1 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> index abba325..2b1fc3b 100644
> --- a/arch/x86/kvm/vmx.c
> +++ b/arch/x86/kvm/vmx.c
> @@ -70,6 +70,8 @@ struct vmcs {
>   struct nested_vmx {
>   	/* Has the level1 guest done vmon? */
>   	bool vmon;
> +	/* Has the level1 guest done vmclear? */
> +	bool vmclear;
>   };
>    

Doesn't seem these two belong in the same structure - vmclear is 
per-vmcs... but you're probably aware of that with the multi-guest 
support coming.
oritw@il.ibm.com Sept. 3, 2009, 1:54 p.m. UTC | #2
Avi Kivity <avi@redhat.com> wrote on 02/09/2009 22:38:22:

> From:
>
> Avi Kivity <avi@redhat.com>
>
> To:
>
> Orit Wasserman/Haifa/IBM@IBMIL
>
> Cc:
>
> kvm@vger.kernel.org, Ben-Ami Yassour1/Haifa/IBM@IBMIL, Muli Ben-
> Yehuda/Haifa/IBM@IBMIL, Abel Gordon/Haifa/IBM@IBMIL,
> aliguori@us.ibm.com, mmday@us.ibm.com
>
> Date:
>
> 02/09/2009 23:01
>
> Subject:
>
> Re: [PATCH 2/6] Nested VMX patch 2 implements vmclear
>
> On 09/02/2009 06:38 PM, oritw@il.ibm.com wrote:
> > From: Orit Wasserman<oritw@il.ibm.com>
> >
> > ---
> >   arch/x86/kvm/vmx.c |   24 +++++++++++++++++++++++-
> >   1 files changed, 23 insertions(+), 1 deletions(-)
> >
> > diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
> > index abba325..2b1fc3b 100644
> > --- a/arch/x86/kvm/vmx.c
> > +++ b/arch/x86/kvm/vmx.c
> > @@ -70,6 +70,8 @@ struct vmcs {
> >   struct nested_vmx {
> >      /* Has the level1 guest done vmon? */
> >      bool vmon;
> > +   /* Has the level1 guest done vmclear? */
> > +   bool vmclear;
> >   };
> >
>
> Doesn't seem these two belong in the same structure - vmclear is
> per-vmcs... but you're probably aware of that with the multi-guest
> support coming.
You are right vmclear flag is part of the L2 guest state.
>
>
> --
> I have a truly marvellous patch that fixes the bug which this
> signature is too narrow to contain.
>

--
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
diff mbox

Patch

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index abba325..2b1fc3b 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -70,6 +70,8 @@  struct vmcs {
 struct nested_vmx {
 	/* Has the level1 guest done vmon? */
 	bool vmon;
+	/* Has the level1 guest done vmclear? */
+	bool vmclear;
 };
 
 struct vcpu_vmx {
@@ -3229,6 +3231,26 @@  static int nested_vmx_check_permission(struct kvm_vcpu *vcpu)
 	return 1;
 }
 
+static void clear_rflags_cf_zf(struct kvm_vcpu *vcpu)
+{
+	unsigned long rflags;
+	rflags = vmx_get_rflags(vcpu);
+	rflags &= ~(X86_EFLAGS_CF | X86_EFLAGS_ZF);
+	vmx_set_rflags(vcpu, rflags);
+}
+
+static int handle_vmclear(struct kvm_vcpu *vcpu)
+{
+	if (!nested_vmx_check_permission(vcpu))
+		return 1;
+
+	to_vmx(vcpu)->nested.vmclear = 1;
+
+	skip_emulated_instruction(vcpu);
+	clear_rflags_cf_zf(vcpu);
+
+	return 1;
+}
 
 static int handle_vmx_insn(struct kvm_vcpu *vcpu)
 {
@@ -3552,7 +3574,7 @@  static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = {
 	[EXIT_REASON_HLT]                     = handle_halt,
 	[EXIT_REASON_INVLPG]		      = handle_invlpg,
 	[EXIT_REASON_VMCALL]                  = handle_vmcall,
-	[EXIT_REASON_VMCLEAR]	              = handle_vmx_insn,
+	[EXIT_REASON_VMCLEAR]	              = handle_vmclear,
 	[EXIT_REASON_VMLAUNCH]                = handle_vmx_insn,
 	[EXIT_REASON_VMPTRLD]                 = handle_vmx_insn,
 	[EXIT_REASON_VMPTRST]                 = handle_vmx_insn,