From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boris Ostrovsky Subject: Re: [PATCH v14 for-xen-4.5 13/21] x86/VPMU: Initialize PMU for PV(H) guests Date: Mon, 27 Oct 2014 15:21:38 -0400 Message-ID: <544E9B42.5090207@oracle.com> References: <1413580689-2750-1-git-send-email-boris.ostrovsky@oracle.com> <1413580689-2750-14-git-send-email-boris.ostrovsky@oracle.com> <544E832E02000078000428F7@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <544E832E02000078000428F7@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: kevin.tian@intel.com, keir@xen.org, suravee.suthikulpanit@amd.com, andrew.cooper3@citrix.com, tim@xen.org, dietmar.hahn@ts.fujitsu.com, xen-devel@lists.xen.org, Aravind.Gopalakrishnan@amd.com, jun.nakajima@intel.com, dgdegra@tycho.nsa.gov List-Id: xen-devel@lists.xenproject.org On 10/27/2014 12:38 PM, Jan Beulich wrote: > >> +static void pvpmu_finish(struct domain *d, xen_pmu_params_t *params) >> +{ >> + struct vcpu *v; >> + uint64_t mfn; >> + >> + if ( (params->vcpu >= d->max_vcpus) || (d->vcpu == NULL) || >> + (d->vcpu[params->vcpu] == NULL) ) >> + return; >> + >> + v = d->vcpu[params->vcpu]; >> + if ( v != current ) >> + vcpu_pause(v); >> + >> + if ( v->arch.vpmu.xenpmu_data ) >> + { >> + mfn = domain_page_map_to_mfn(v->arch.vpmu.xenpmu_data); >> + ASSERT(mfn != 0); >> + unmap_domain_page_global(v->arch.vpmu.xenpmu_data); >> + put_page_and_type(mfn_to_page(mfn)); > I think you absolutely need to clear v->arch.vpmu.xenpmu_data > here, or else another call will (likely) crash the hypervisor. Even > more, I think this actually needs serialization (and pvpmu_init() as > well), especially with ... What I should do is to destroy vpmu *before* everything else. And add tests for VPMU_CONTEXT_ALLOCATED at a couple of entry points to arch-specific code (I will need to rework Intel VPMU allocation to happen at initialization time as opposed to current lazy allocation). Then noone will be touching xenpmu_data whine it's not available. Including pvpmu_init(). -boris > >> --- a/xen/include/xsm/dummy.h >> +++ b/xen/include/xsm/dummy.h >> @@ -665,6 +665,9 @@ static XSM_INLINE int xsm_pmu_op (XSM_DEFAULT_ARG struct >> domain *d, int op) >> case XENPMU_feature_set: >> case XENPMU_feature_get: >> return xsm_default_action(XSM_PRIV, d, current->domain); >> + case XENPMU_init: >> + case XENPMU_finish: >> + return xsm_default_action(XSM_HOOK, d, current->domain); > ... this being XSM_HOOK rather than XSM_TARGET. > > Jan >