The patch set includes all the changes on my side (SPR PEBS and AMD PerfMonV2 are included, except for Arch lbr), which helps to keep the review time focused. There are no major changes in the test logic. A considerable number of helpers have been added to lib/x86/pmu.[c,h], which really helps the readability of the code, while hiding some hardware differentiation details. These are divided into three parts, the first part (01 - 08) is bug fixing, the second part (09 - 18) is code refactoring, and the third part is the addition of new test cases. It may also be good to split up and merge in sequence. They get passed on AMD Zen3/4, Intel ICX/SPR machines. Please feel free to test them in your own CI environment. v3: https://lore.kernel.org/kvm/20220819110939.78013-1-likexu@xxxxxxxxxxx/ v3 -> v4 Changelog: - Add more helpers to the new lib/x86/pmu.h and lib/x86/pmu.c; (pmu_cap, perf_capabilities other pmu related stuff) - Refine commit message and report_ messages; - Code style fixes (curly braces, #defeine, GENMASK_ULL, ternary operator); - Add more message for "the expected init cnt.count for fixed counter 0" (measure_for_overflow() is applied); - Rename PC_VECTOR to PMI_VECTOR; - Snapshot pebs_has_baseline() to avoid RDMSR on every touch; - Drop the idea about is_the_count_reproducible() for AMD; - Add X86_FEATURE_* in the KUT world; Like Xu (24): x86/pmu: Add PDCM check before accessing PERF_CAP register x86/pmu: Test emulation instructions on full-width counters x86/pmu: Pop up FW prefix to avoid out-of-context propagation x86/pmu: Report SKIP when testing Intel LBR on AMD platforms x86/pmu: Fix printed messages for emulated instruction test x86/pmu: Introduce __start_event() to drop all of the manual zeroing x86/pmu: Introduce multiple_{one, many}() to improve readability x86/pmu: Reset the expected count of the fixed counter 0 when i386 x86: create pmu group for quick pmu-scope testing x86/pmu: Refine info to clarify the current support x86/pmu: Update rdpmc testcase to cover #GP path x86/pmu: Rename PC_VECTOR to PMI_VECTOR for better readability x86/pmu: Add lib/x86/pmu.[c.h] and move common code to header files x86/pmu: Read cpuid(10) in the pmu_init() to reduce VM-Exit x86/pmu: Initialize PMU perf_capabilities at pmu_init() x86/pmu: Add GP counter related helpers x86/pmu: Add GP/Fixed counters reset helpers x86/pmu: Add a set of helpers related to global registers x86: Add tests for Guest Processor Event Based Sampling (PEBS) x86/pmu: Add global helpers to cover Intel Arch PMU Version 1 x86/pmu: Add gp_events pointer to route different event tables x86/pmu: Add nr_gp_counters to limit the number of test counters x86/pmu: Update testcases to cover AMD PMU x86/pmu: Add AMD Guest PerfMonV2 testcases lib/x86/msr.h | 30 +++ lib/x86/pmu.c | 36 ++++ lib/x86/pmu.h | 306 +++++++++++++++++++++++++++++++ lib/x86/processor.h | 80 ++------ lib/x86/smp.c | 2 + x86/Makefile.common | 1 + x86/Makefile.x86_64 | 1 + x86/pmu.c | 297 ++++++++++++++++++------------ x86/pmu_lbr.c | 20 +- x86/pmu_pebs.c | 433 ++++++++++++++++++++++++++++++++++++++++++++ x86/unittests.cfg | 10 + x86/vmx_tests.c | 1 + 12 files changed, 1022 insertions(+), 195 deletions(-) create mode 100644 lib/x86/pmu.c create mode 100644 lib/x86/pmu.h create mode 100644 x86/pmu_pebs.c -- 2.38.1