From: "Jan Beulich" Subject: Re: [PATCH v14 for-xen-4.5 13/21] x86/VPMU: Initialize PMU for PV(H) guests Date: Mon, 27 Oct 2014 16:38:54 +0000 Message-ID: <544E832E02000078000428F7@mail.emea.novell.com> References: <1413580689-2750-1-git-send-email-boris.ostrovsky@oracle.com> <1413580689-2750-14-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: <1413580689-2750-14-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: 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 17.10.14 at 23:18, wrote: > --- a/xen/arch/x86/hvm/hvm.c > +++ b/xen/arch/x86/hvm/hvm.c > @@ -4811,7 +4811,8 @@ static hvm_hypercall_t *const pvh_hypercall64_table[NR_hypercalls] = { > HYPERCALL(hvm_op), > HYPERCALL(sysctl), > HYPERCALL(domctl), > - [ __HYPERVISOR_arch_1 ] = (hvm_hypercall_t *)paging_domctl_continuation > + [ __HYPERVISOR_arch_1 ] = (hvm_hypercall_t *)paging_domctl_continuation, > + HYPERCALL(xenpmu_op) > }; At least the operations visible in the patch context are all sorted by hypercall number - please don't break this. > +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 ... > --- 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