Google Cloud has a customer that needs accurate virtualization of two architected PMU events on Intel hardware: "instructions retired" and "branch instructions retired." The existing PMU virtualization code fails to account for instructions that are emulated by kvm. Accurately virtualizing all PMU events for all microarchitectures is a herculean task, but there are only 8 architected events, so maybe we can at least try to get those right. Eric Hankland wrote this code originally, but his plate is full, so I've volunteered to shepherd the changes through upstream acceptance. Jim Mattson (2): KVM: x86: Update vPMCs when retiring instructions KVM: x86: Update vPMCs when retiring branch instructions arch/x86/kvm/emulate.c | 57 +++++++++++++++++++++----------------- arch/x86/kvm/kvm_emulate.h | 1 + arch/x86/kvm/pmu.c | 31 +++++++++++++++++++++ arch/x86/kvm/pmu.h | 1 + arch/x86/kvm/vmx/nested.c | 6 +++- arch/x86/kvm/x86.c | 5 ++++ 6 files changed, 75 insertions(+), 26 deletions(-) -- 2.34.0.rc1.387.gb447b232ab-goog