From 825c466dc85b3bc901935118626fa37403e65b0f Mon Sep 17 00:00:00 2001 From: Boris Ostrovsky Date: Wed, 11 Jun 2014 10:55:43 +0200 Subject: [PATCH] x86/VPMU: mark context LOADED before registers are loaded Because a PMU interrupt may be generated as soon as PMU registers are loaded (or, more precisely, as soon as HW PMU is "armed") we don't want to delay marking context as LOADED until after registers are loaded. Otherwise during interrupt handling VPMU_CONTEXT_LOADED may not be set and this could be confusing. (Technically, only SVM needs this change right now since VMX will "arm" PMU later, during VMRUN when global control register is loaded from VMCS. However, both AMD and Intel code will require this patch when we introduce PV VPMU.) Signed-off-by: Boris Ostrovsky Acked-by: Kevin Tian Reviewed-by: Dietmar Hahn Tested-by: Dietmar Hahn Reviewed-by: Andrew Cooper --- xen/arch/x86/hvm/svm/vpmu.c | 2 ++ xen/arch/x86/hvm/vmx/vpmu_core2.c | 2 ++ xen/arch/x86/hvm/vpmu.c | 3 +-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/svm/vpmu.c b/xen/arch/x86/hvm/svm/vpmu.c index 66a381525c..3ac7d537eb 100644 --- a/xen/arch/x86/hvm/svm/vpmu.c +++ b/xen/arch/x86/hvm/svm/vpmu.c @@ -203,6 +203,8 @@ static void amd_vpmu_load(struct vcpu *v) return; } + vpmu_set(vpmu, VPMU_CONTEXT_LOADED); + context_load(v); } diff --git a/xen/arch/x86/hvm/vmx/vpmu_core2.c b/xen/arch/x86/hvm/vmx/vpmu_core2.c index 3129ebd5c4..ccd14d923b 100644 --- a/xen/arch/x86/hvm/vmx/vpmu_core2.c +++ b/xen/arch/x86/hvm/vmx/vpmu_core2.c @@ -369,6 +369,8 @@ static void core2_vpmu_load(struct vcpu *v) if ( vpmu_is_set(vpmu, VPMU_CONTEXT_LOADED) ) return; + vpmu_set(vpmu, VPMU_CONTEXT_LOADED); + __core2_vpmu_load(v); } diff --git a/xen/arch/x86/hvm/vpmu.c b/xen/arch/x86/hvm/vpmu.c index 21fbabaa95..63765fa2fe 100644 --- a/xen/arch/x86/hvm/vpmu.c +++ b/xen/arch/x86/hvm/vpmu.c @@ -211,10 +211,9 @@ void vpmu_load(struct vcpu *v) if ( vpmu->arch_vpmu_ops && vpmu->arch_vpmu_ops->arch_vpmu_load ) { apic_write_around(APIC_LVTPC, vpmu->hw_lapic_lvtpc); + /* Arch code needs to set VPMU_CONTEXT_LOADED */ vpmu->arch_vpmu_ops->arch_vpmu_load(v); } - - vpmu_set(vpmu, VPMU_CONTEXT_LOADED); } void vpmu_initialise(struct vcpu *v) -- 2.30.2