From patchwork Fri May 7 02:42:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Xu, Dongxiao" X-Patchwork-Id: 97564 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o472iEQS006593 for ; Fri, 7 May 2010 02:44:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753211Ab0EGCoM (ORCPT ); Thu, 6 May 2010 22:44:12 -0400 Received: from mga02.intel.com ([134.134.136.20]:50302 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753008Ab0EGCoL convert rfc822-to-8bit (ORCPT ); Thu, 6 May 2010 22:44:11 -0400 Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 06 May 2010 19:42:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.52,345,1270450800"; d="scan'208";a="619613791" Received: from pgsmsx603.gar.corp.intel.com ([10.221.43.87]) by orsmga001.jf.intel.com with ESMTP; 06 May 2010 19:43:51 -0700 Received: from shsmsx601.ccr.corp.intel.com (10.239.4.112) by pgsmsx603.gar.corp.intel.com (10.221.43.87) with Microsoft SMTP Server (TLS) id 8.2.176.0; Fri, 7 May 2010 10:43:00 +0800 Received: from shsmsx501.ccr.corp.intel.com ([10.239.4.141]) by shsmsx601.ccr.corp.intel.com ([10.239.4.112]) with mapi; Fri, 7 May 2010 10:42:53 +0800 From: "Xu, Dongxiao" To: "kvm@vger.kernel.org" CC: Avi Kivity , Marcelo Tosatti , Alexander Graf Date: Fri, 7 May 2010 10:42:56 +0800 Subject: [PATCH 3/4 v3] KVM: VMX: VMCLEAR/VMPTRLD usage changes. Thread-Topic: [PATCH 3/4 v3] KVM: VMX: VMCLEAR/VMPTRLD usage changes. Thread-Index: Acrtjv/2WgJGwIAKQ/e/8ZAiRnoAuw== Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US MIME-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Fri, 07 May 2010 02:44:15 +0000 (UTC) diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index 49b0850..c536b9d 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -62,6 +62,9 @@ module_param_named(unrestricted_guest, static int __read_mostly emulate_invalid_guest_state = 0; module_param(emulate_invalid_guest_state, bool, S_IRUGO); +static int __read_mostly vmm_exclusive = 1; +module_param(vmm_exclusive, bool, S_IRUGO); + #define KVM_GUEST_CR0_MASK_UNRESTRICTED_GUEST \ (X86_CR0_WP | X86_CR0_NE | X86_CR0_NW | X86_CR0_CD) #define KVM_GUEST_CR0_MASK \ @@ -784,7 +787,7 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu) struct vcpu_vmx *vmx = to_vmx(vcpu); u64 tsc_this, delta, new_offset; - if (vcpu->cpu != cpu) + if (vmm_exclusive && vcpu->cpu != cpu) vcpu_clear(vmx); if (per_cpu(current_vmcs, cpu) != vmx->vmcs) { @@ -830,6 +833,8 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu) static void vmx_vcpu_put(struct kvm_vcpu *vcpu) { __vmx_load_host_state(to_vmx(vcpu)); + if (!vmm_exclusive) + __vcpu_clear(to_vmx(vcpu)); } static void vmx_fpu_activate(struct kvm_vcpu *vcpu)