From: Boris Ostrovsky Date: Wed, 9 Sep 2015 13:32:00 +0000 (+0200) Subject: x86/VPMU: Set VPMU context pointer to NULL when freeing it X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~2577 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=0b5fd6433f54281f3bffd79f2d759dd0edc1f3ab;p=xen.git x86/VPMU: Set VPMU context pointer to NULL when freeing it Otherwise we may hit assertion in vpmu_initialise() if vcpu is offlined and then onlined again. For tidyness, set priv_context to NULL as well. Signed-off-by: Boris Ostrovsky Reviewed-by: Dietmar Hahn Release-acked-by: Wei Liu --- diff --git a/xen/arch/x86/cpu/vpmu_amd.c b/xen/arch/x86/cpu/vpmu_amd.c index 825be7295f..04da81aae5 100644 --- a/xen/arch/x86/cpu/vpmu_amd.c +++ b/xen/arch/x86/cpu/vpmu_amd.c @@ -438,6 +438,8 @@ static void amd_vpmu_destroy(struct vcpu *v) amd_vpmu_unset_msr_bitmap(v); xfree(vpmu->context); + vpmu->context = NULL; + vpmu->priv_context = NULL; if ( vpmu_is_set(vpmu, VPMU_RUNNING) ) release_pmu_ownship(PMU_OWNER_HVM); diff --git a/xen/arch/x86/cpu/vpmu_intel.c b/xen/arch/x86/cpu/vpmu_intel.c index b3750d7de1..12f80aeb70 100644 --- a/xen/arch/x86/cpu/vpmu_intel.c +++ b/xen/arch/x86/cpu/vpmu_intel.c @@ -828,7 +828,9 @@ static void core2_vpmu_destroy(struct vcpu *v) struct vpmu_struct *vpmu = vcpu_vpmu(v); xfree(vpmu->context); + vpmu->context = NULL; xfree(vpmu->priv_context); + vpmu->priv_context = NULL; if ( has_hvm_container_vcpu(v) && cpu_has_vmx_msr_bitmap ) core2_vpmu_unset_msr_bitmap(v->arch.hvm_vmx.msr_bitmap); release_pmu_ownship(PMU_OWNER_HVM);