Re: [PATCH v3 07/11] KVM: selftests: Test Intel supported fixed counters bit mask

From: Sean Christopherson
Date: Thu Aug 17 2023 - 19:19:58 EST


On Mon, Aug 14, 2023, Jinrong Liang wrote:
> +static void intel_test_fixed_counters(void)
> +{
> + uint8_t nr_fixed_counters = kvm_cpu_property(X86_PROPERTY_PMU_NR_FIXED_COUNTERS);
> + struct kvm_vcpu *vcpu;
> + struct kvm_vm *vm;
> + uint32_t ecx;
> + uint8_t edx;
> +
> + for (edx = 0; edx <= nr_fixed_counters; edx++) {
> + /* KVM doesn't emulate more fixed counters than it can support. */
> + for (ecx = 0; ecx <= (BIT_ULL(nr_fixed_counters) - 1); ecx++) {
> + vm = pmu_vm_create_with_one_vcpu(&vcpu,
> + intel_guest_run_fixed_counters);
> + test_fixed_counters_setup(vcpu, ecx, edx);
> + kvm_vm_free(vm);

Same comments as a previous patch, either use a helper or open code, don't mix
both.

> + }
> + }
> +}
> +
> int main(int argc, char *argv[])
> {
> TEST_REQUIRE(get_kvm_param_bool("enable_pmu"));
> @@ -293,6 +352,7 @@ int main(int argc, char *argv[])
>
> intel_test_arch_events();
> intel_test_counters_num();
> + intel_test_fixed_counters();
>
> return 0;
> }
> --
> 2.39.3
>