From: Xiong Zhang <xiong.y.zhang@xxxxxxxxxxxxxxx> Add correct PMU context switch at VM_entry/exit boundary. Signed-off-by: Dapeng Mi <dapeng1.mi@xxxxxxxxxxxxxxx> Signed-off-by: Xiong Zhang <xiong.y.zhang@xxxxxxxxxxxxxxx> Tested-by: Yongwei Ma <yongwei.ma@xxxxxxxxx> Signed-off-by: Mingwei Zhang <mizhang@xxxxxxxxxx> --- arch/x86/kvm/x86.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index dd6d2c334d90..70274c0da017 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -11050,6 +11050,9 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) set_debugreg(0, 7); } + if (is_passthrough_pmu_enabled(vcpu)) + kvm_pmu_restore_pmu_context(vcpu); + guest_timing_enter_irqoff(); for (;;) { @@ -11078,6 +11081,9 @@ static int vcpu_enter_guest(struct kvm_vcpu *vcpu) ++vcpu->stat.exits; } + if (is_passthrough_pmu_enabled(vcpu)) + kvm_pmu_save_pmu_context(vcpu); + /* * Do this here before restoring debug registers on the host. And * since we do this before handling the vmexit, a DR access vmexit -- 2.46.0.rc1.232.g9752f9e123-goog