KVM x86/pmu changes for 6.4. Hiding in the pile of selftests changes are a a handful of small-but-important fixes. Note, this superficially conflicts with the PRED_CMD/FLUSH_CMD changes sitting in kvm/next due to "KVM: VMX: Refactor intel_pmu_{g,}set_msr() to align with other helpers". The resolution I have been using when preparing kvm-x86/next for linux-next is to replace a "return 0" with a "break". The following changes since commit d8708b80fa0e6e21bc0c9e7276ad0bccef73b6e7: KVM: Change return type of kvm_arch_vm_ioctl() to "int" (2023-03-16 10:18:07 -0400) are available in the Git repository at: https://github.com/kvm-x86/linux.git tags/kvm-x86-pmu-6.4 for you to fetch changes up to 457bd7af1a17182e7f1f97eeb5d9107f8699e99d: KVM: selftests: Test the PMU event "Instructions retired" (2023-04-14 13:21:38 -0700) ---------------------------------------------------------------- KVM x86 PMU changes for 6.4: - Disallow virtualizing legacy LBRs if architectural LBRs are available, the two are mutually exclusive in hardware - Disallow writes to immutable feature MSRs (notably PERF_CAPABILITIES) after KVM_RUN, and overhaul the vmx_pmu_caps selftest to better validate PERF_CAPABILITIES - Apply PMU filters to emulated events and add test coverage to the pmu_event_filter selftest - Misc cleanups and fixes ---------------------------------------------------------------- Aaron Lewis (5): KVM: x86/pmu: Prevent the PMU from counting disallowed events KVM: selftests: Add a common helper for the PMU event filter guest code KVM: selftests: Add helpers for PMC asserts in PMU event filter test KVM: selftests: Print detailed info in PMU event filter asserts KVM: selftests: Test the PMU event "Instructions retired" Like Xu (4): KVM: x86/pmu: Zero out pmu->all_valid_pmc_idx each time it's refreshed KVM: x86/pmu: Rename pmc_is_enabled() to pmc_is_globally_enabled() KVM: x86/pmu: Rewrite reprogram_counters() to improve performance KVM: x86/pmu: Fix a typo in kvm_pmu_request_counter_reprogam() Mathias Krause (1): KVM: x86: Shrink struct kvm_pmu Sean Christopherson (25): KVM: x86/pmu: Disallow legacy LBRs if architectural LBRs are available KVM: x86: Rename kvm_init_msr_list() to clarify it inits multiple lists KVM: x86: Add a helper to query whether or not a vCPU has ever run KVM: x86: Add macros to track first...last VMX feature MSRs KVM: x86: Generate set of VMX feature MSRs using first/last definitions KVM: selftests: Split PMU caps sub-tests to avoid writing MSR after KVM_RUN KVM: x86: Disallow writes to immutable feature MSRs after KVM_RUN KVM: x86/pmu: WARN and bug the VM if PMU is refreshed after vCPU has run KVM: x86/pmu: Zero out LBR capabilities during PMU refresh KVM: selftests: Move 0/initial value PERF_CAPS checks to dedicated sub-test KVM: selftests: Assert that full-width PMC writes are supported if PDCM=1 KVM: selftests: Print out failing MSR and value in vcpu_set_msr() KVM: selftests: Verify KVM preserves userspace writes to "durable" MSRs KVM: selftests: Drop now-redundant checks on PERF_CAPABILITIES writes KVM: selftests: Test all fungible features in PERF_CAPABILITIES KVM: selftests: Test all immutable non-format bits in PERF_CAPABILITIES KVM: selftests: Expand negative testing of guest writes to PERF_CAPABILITIES KVM: selftests: Test post-KVM_RUN writes to PERF_CAPABILITIES KVM: selftests: Drop "all done!" printf() from PERF_CAPABILITIES test KVM: selftests: Refactor LBR_FMT test to avoid use of separate macro KVM: selftests: Add negative testcase for PEBS format in PERF_CAPABILITIES KVM: selftests: Verify LBRs are disabled if vPMU is disabled KVM: VMX: Refactor intel_pmu_{g,}set_msr() to align with other helpers KVM: selftests: Use error codes to signal errors in PMU event filter test KVM: selftests: Copy full counter values from guest in PMU event filter test arch/x86/include/asm/kvm_host.h | 2 +- arch/x86/kvm/cpuid.c | 2 +- arch/x86/kvm/mmu/mmu.c | 2 +- arch/x86/kvm/pmu.c | 21 +- arch/x86/kvm/pmu.h | 2 +- arch/x86/kvm/svm/pmu.c | 2 +- arch/x86/kvm/svm/svm.c | 2 +- arch/x86/kvm/vmx/pmu_intel.c | 135 ++++++----- arch/x86/kvm/vmx/vmx.c | 16 +- arch/x86/kvm/x86.c | 102 ++++++--- arch/x86/kvm/x86.h | 13 ++ .../selftests/kvm/include/x86_64/processor.h | 41 +++- .../selftests/kvm/x86_64/pmu_event_filter_test.c | 252 ++++++++++++--------- .../selftests/kvm/x86_64/vmx_pmu_caps_test.c | 248 ++++++++++++++++---- 14 files changed, 565 insertions(+), 275 deletions(-)