From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nikunj A Dadhania Subject: Re: [PATCH v3 6/8] KVM-HV: Add flush_on_enter before guest enter Date: Fri, 03 Aug 2012 11:07:13 +0530 Message-ID: <87d3387cza.fsf@abhimanyu.in.ibm.com> References: <20120731104312.16662.27889.stgit@abhimanyu.in.ibm.com> <20120731104859.16662.8738.stgit@abhimanyu.in.ibm.com> <20120802201402.GA772@amt.cnet> <20120802201641.GB772@amt.cnet> Mime-Version: 1.0 Content-Type: text/plain Cc: peterz@infradead.org, avi@redhat.com, raghukt@linux.vnet.ibm.com, alex.shi@intel.com, mingo@elte.hu, kvm@vger.kernel.org, hpa@zytor.com To: Marcelo Tosatti Return-path: Received: from e23smtp07.au.ibm.com ([202.81.31.140]:39074 "EHLO e23smtp07.au.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750794Ab2HCFiH (ORCPT ); Fri, 3 Aug 2012 01:38:07 -0400 Received: from /spool/local by e23smtp07.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 3 Aug 2012 15:37:32 +1000 Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96]) by d23relay05.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q735TTvg26476750 for ; Fri, 3 Aug 2012 15:29:29 +1000 Received: from d23av01.au.ibm.com (loopback [127.0.0.1]) by d23av01.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q735bu0U026308 for ; Fri, 3 Aug 2012 15:37:57 +1000 In-Reply-To: <20120802201641.GB772@amt.cnet> Sender: kvm-owner@vger.kernel.org List-ID: On Thu, 2 Aug 2012 17:16:41 -0300, Marcelo Tosatti wrote: > On Thu, Aug 02, 2012 at 05:14:02PM -0300, Marcelo Tosatti wrote: > > On Tue, Jul 31, 2012 at 04:19:02PM +0530, Nikunj A. Dadhania wrote: > > > From: Nikunj A. Dadhania > > > > > > static void kvm_set_vcpu_state(struct kvm_vcpu *vcpu) > > > { > > > @@ -1584,7 +1573,8 @@ static void kvm_set_vcpu_state(struct kvm_vcpu *vcpu) > > > kaddr = kmap_atomic(vcpu->arch.v_state.vs_page); > > > kaddr += vcpu->arch.v_state.vs_offset; > > > vs = kaddr; > > > - kvm_set_atomic(&vs->state, 0, 1 << KVM_VCPU_STATE_IN_GUEST_MODE); > > > + if (xchg(&vs->state, VS_IN_GUEST) == VS_SHOULD_FLUSH) > > > + kvm_x86_ops->tlb_flush(vcpu); > > > kunmap_atomic(kaddr); > > > } > > > > > > @@ -1600,7 +1590,8 @@ static void kvm_clear_vcpu_state(struct kvm_vcpu *vcpu) > > > kaddr = kmap_atomic(vcpu->arch.v_state.vs_page); > > > kaddr += vcpu->arch.v_state.vs_offset; > > > vs = kaddr; > > > - kvm_set_atomic(&vs->state, 1 << KVM_VCPU_STATE_IN_GUEST_MODE, 0); > > > + if (xchg(&vs->state, VS_NOT_IN_GUEST) == VS_SHOULD_FLUSH) > > > + kvm_x86_ops->tlb_flush(vcpu); > > > kunmap_atomic(kaddr); > > > } > > > > Nevermind the early comment (the other comments on that message are > > valid). I assume the above is related to kvm_set_atomic comment in the [3/8] > > Ah, so the pseucode mentions flush-on-exit because we can be clearing > the flag on xchg. Setting KVM_REQ_TLB_FLUSH instead should be enough > (please verify). > Yes, that will work while exiting. In the vm_enter case, we need to do a kvm_x86_ops->tlb_flush(vcpu), as we have already passed the phase of checking the request. Nikunj