From: "Jan Beulich" Subject: Re: [PATCH v4 for 4.5] x86/VPMU: Clear last_vcpu when destroying VPMU Date: Fri, 19 Dec 2014 13:41:17 +0000 Message-ID: <5494390D020000780005104E@mail.emea.novell.com> References: <1418926000-5953-1-git-send-email-boris.ostrovsky@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1418926000-5953-1-git-send-email-boris.ostrovsky@oracle.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Boris Ostrovsky Cc: keir@xen.org, xen-devel@lists.xen.org List-Id: xen-devel@lists.xenproject.org >>> On 18.12.14 at 19:06, wrote: > We need to make sure that last_vcpu is not pointing to VCPU whose > VPMU is being destroyed. Otherwise we may try to dereference it in > the future, when VCPU is gone. > > We have to do this via IPI since otherwise there is a (somewheat > theoretical) chance that between test and subsequent clearing > of last_vcpu the remote processor (i.e. vpmu->last_pcpu) might do > both vpmu_load() and then vpmu_save() for another VCPU. The former > will clear last_vcpu and the latter will set it to something else. > > Performing this operation via IPI will guarantee that nothing can > happen on the remote processor between testing and clearing of > last_vcpu. > > We should also check for VPMU_CONTEXT_ALLOCATED in vpmu_destroy() to > avoid unnecessary percpu tests and arch-specific destroy ops. Thus > checks in AMD and Intel routines are no longer needed. > > Signed-off-by: Boris Ostrovsky Acked-by: Jan Beulich