Skip to content

Commit 571fc28

Browse files
committed
KVM: selftests: Track unavailable_mask for PMU events as 32-bit value
Track the mask of "unavailable" PMU events as a 32-bit value. While bits 31:9 are currently reserved, silently truncating those bits is unnecessary and asking for missed coverage. To avoid running afoul of the sanity check in vcpu_set_cpuid_property(), explicitly adjust the mask based on the non-reserved bits as reported by KVM's supported CPUID. Opportunistically update the "all ones" testcase to pass -1u instead of 0xff. Reviewed-by: Dapeng Mi <[email protected]> Tested-by: Dapeng Mi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 210b09f commit 571fc28

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

tools/testing/selftests/kvm/x86/pmu_counters_test.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ static void guest_test_arch_events(void)
311311
}
312312

313313
static void test_arch_events(uint8_t pmu_version, uint64_t perf_capabilities,
314-
uint8_t length, uint8_t unavailable_mask)
314+
uint8_t length, uint32_t unavailable_mask)
315315
{
316316
struct kvm_vcpu *vcpu;
317317
struct kvm_vm *vm;
@@ -320,6 +320,9 @@ static void test_arch_events(uint8_t pmu_version, uint64_t perf_capabilities,
320320
if (!pmu_version)
321321
return;
322322

323+
unavailable_mask &= GENMASK(X86_PROPERTY_PMU_EVENTS_MASK.hi_bit,
324+
X86_PROPERTY_PMU_EVENTS_MASK.lo_bit);
325+
323326
vm = pmu_vm_create_with_one_vcpu(&vcpu, guest_test_arch_events,
324327
pmu_version, perf_capabilities);
325328

@@ -630,7 +633,7 @@ static void test_intel_counters(void)
630633
*/
631634
for (j = 0; j <= NR_INTEL_ARCH_EVENTS + 1; j++) {
632635
test_arch_events(v, perf_caps[i], j, 0);
633-
test_arch_events(v, perf_caps[i], j, 0xff);
636+
test_arch_events(v, perf_caps[i], j, -1u);
634637

635638
for (k = 0; k < NR_INTEL_ARCH_EVENTS; k++)
636639
test_arch_events(v, perf_caps[i], j, BIT(k));

0 commit comments

Comments
 (0)