KVM: selftests: Verify post-RESET value of PERF_GLOBAL_CTRL in PMCs test
authorSean Christopherson <seanjc@google.com>
Sat, 9 Mar 2024 01:36:41 +0000 (17:36 -0800)
committerSean Christopherson <seanjc@google.com>
Mon, 8 Apr 2024 20:20:28 +0000 (13:20 -0700)
commit08a828249b16f69248652937be7f1b8dab340a22
tree3883fc3d38a867802ad91187d1c849a3d82221a3
parentde120e1d692d73c7eefa3278837b1eb68f90728a
KVM: selftests: Verify post-RESET value of PERF_GLOBAL_CTRL in PMCs test

Add a guest assert in the PMU counters test to verify that KVM stuffs
the vCPU's post-RESET value to globally enable all general purpose
counters.  Per Intel's SDM,

  IA32_PERF_GLOBAL_CTRL:  Sets bits n-1:0 and clears the upper bits.

and

  Where "n" is the number of general-purpose counters available in
  the processor.

For the edge case where there are zero GP counters, follow the spirit
of the architecture, not the SDM's literal wording, which doesn't account
for this possibility and would require the CPU to set _all_ bits in
PERF_GLOBAL_CTRL.

Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Tested-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Link: https://lore.kernel.org/r/20240309013641.1413400-3-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/x86_64/pmu_counters_test.c