From patchwork Wed Sep 2 15:38:32 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: oritw@il.ibm.com X-Patchwork-Id: 45230 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n82Fcksa004316 for ; Wed, 2 Sep 2009 15:38:46 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752792AbZIBPij (ORCPT ); Wed, 2 Sep 2009 11:38:39 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752684AbZIBPij (ORCPT ); Wed, 2 Sep 2009 11:38:39 -0400 Received: from mtagate5.de.ibm.com ([195.212.17.165]:38857 "EHLO mtagate5.de.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752630AbZIBPii (ORCPT ); Wed, 2 Sep 2009 11:38:38 -0400 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate5.de.ibm.com (8.13.1/8.13.1) with ESMTP id n82FceSA001692 for ; Wed, 2 Sep 2009 15:38:40 GMT Received: from d12av01.megacenter.de.ibm.com (d12av01.megacenter.de.ibm.com [9.149.165.212]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id n82FcdK22728000 for ; Wed, 2 Sep 2009 17:38:39 +0200 Received: from d12av01.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av01.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n82FcdN9007856 for ; Wed, 2 Sep 2009 17:38:39 +0200 Received: from localhost.localdomain (cluwyn.haifa.ibm.com [9.148.27.75]) by d12av01.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id n82Fca9H007813; Wed, 2 Sep 2009 17:38:38 +0200 From: oritw@il.ibm.com To: kvm@vger.kernel.org Cc: oritw@il.ibm.com, benami@il.ibm.com, muli@il.ibm.com, abelg@il.ibm.com, aliguori@us.ibm.com, mmday@us.ibm.com Subject: [PATCH 2/6] Nested VMX patch 2 implements vmclear Date: Wed, 2 Sep 2009 18:38:32 +0300 Message-Id: <1251905916-2834-3-git-send-email-oritw@il.ibm.com> X-Mailer: git-send-email 1.6.0.4 In-Reply-To: <1251905916-2834-2-git-send-email-oritw@il.ibm.com> References: <1251905916-2834-1-git-send-email-oritw@il.ibm.com> <1251905916-2834-2-git-send-email-oritw@il.ibm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Orit Wasserman --- 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; }; 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,