Skip to contentSkip to conversation

x86/VPMU: Set VPMU context pointer to NULL when freeing it

PATCH In review Boris Ostrovsky 4 participants 4 messages Sep 9, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 xen/arch/x86/cpu/vpmu_amd.c   | 2 ++
 xen/arch/x86/cpu/vpmu_intel.c | 2 ++
 2 files changed, 4 insertions(+)
xen/arch/x86/cpu/vpmu_amd.c +2 -0
index 825be72..04da81a 100644
@@ -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);
xen/arch/x86/cpu/vpmu_intel.c +2 -0
index b3750d7..12f80ae 100644
@@ -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);
Signature · 1 line
1.8.1.4
Reviewed-by on v1 1/1
#2 lore raw
In reply to Boris Ostrovsky

Am Dienstag 08 September 2015, 22:55:52 schrieb Boris Ostrovsky:

Quoted 4 lines

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.

Quoted 35 lines
---
 xen/arch/x86/cpu/vpmu_amd.c   | 2 ++
 xen/arch/x86/cpu/vpmu_intel.c | 2 ++
 2 files changed, 4 insertions(+)
xen/arch/x86/cpu/vpmu_amd.c +2 -0
index 825be72..04da81a 100644
@@ -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);
xen/arch/x86/cpu/vpmu_intel.c +2 -0
index b3750d7..12f80ae 100644
@@ -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);
Signature · 1 line
Company details: http://ts.fujitsu.com/imprint.html
#3 lore raw
In reply to Boris Ostrovsky
Quoted 6 lines · Boris Ostrovsky

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.

Quoted 34 lines
---
 xen/arch/x86/cpu/vpmu_amd.c   | 2 ++
 xen/arch/x86/cpu/vpmu_intel.c | 2 ++
 2 files changed, 4 insertions(+)
xen/arch/x86/cpu/vpmu_amd.c +2 -0
index 825be72..04da81a 100644
@@ -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);
xen/arch/x86/cpu/vpmu_intel.c +2 -0
index b3750d7..12f80ae 100644
@@ -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);
Signature · 1 line
1.8.1.4