[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v14 for-xen-4.5 13/21] x86/VPMU: Initialize PMU for PV(H) guests

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().


--- 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.


Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.