Re: [PATCH V5 4/4] KVM: selftests: Add test for configure of x86 APIC bus frequency

From: Reinette Chatre
Date: Fri Apr 26 2024 - 19:26:54 EST


Hi Zide,

On 4/26/2024 4:06 PM, Chen, Zide wrote:
>
>
> On 4/25/2024 3:07 PM, Reinette Chatre wrote:
>> diff --git a/tools/testing/selftests/kvm/x86_64/apic_bus_clock_test.c b/tools/testing/selftests/kvm/x86_64/apic_bus_clock_test.c
>> new file mode 100644
>> index 000000000000..5100b28228af
>> --- /dev/null
>> +++ b/tools/testing/selftests/kvm/x86_64/apic_bus_clock_test.c
>> @@ -0,0 +1,166 @@
>> +// SPDX-License-Identifier: GPL-2.0-only
>> +/*
>> + * Test configure of APIC bus frequency.
>> + *
>> + * Copyright (c) 2024 Intel Corporation
>> + *
>> + * To verify if the APIC bus frequency can be configured this test starts
>
> Nit: some typos here?

Apologies but this is not obvious to me. Could you please help
by pointing out all those typos to me?

>
>> +int main(int argc, char *argv[])
>> +{
>> + struct kvm_vcpu *vcpu;
>> + struct kvm_vm *vm;
>> +
>> + TEST_REQUIRE(kvm_has_cap(KVM_CAP_X86_APIC_BUS_CYCLES_NS));
>> +
>> + vm = __vm_create(VM_SHAPE_DEFAULT, 1, 0);
>
> Use vm_create() instead?

Sure. This is easier on the eye while generating exactly the same code.

diff --git a/tools/testing/selftests/kvm/x86_64/apic_bus_clock_test.c b/tools/testing/selftests/kvm/x86_64/apic_bus_clock_test.c
index 5100b28228af..6ed253875971 100644
--- a/tools/testing/selftests/kvm/x86_64/apic_bus_clock_test.c
+++ b/tools/testing/selftests/kvm/x86_64/apic_bus_clock_test.c
@@ -149,7 +149,7 @@ int main(int argc, char *argv[])

TEST_REQUIRE(kvm_has_cap(KVM_CAP_X86_APIC_BUS_CYCLES_NS));

- vm = __vm_create(VM_SHAPE_DEFAULT, 1, 0);
+ vm = vm_create(1);
vm_ioctl(vm, KVM_SET_TSC_KHZ, (void *)(TSC_HZ / 1000));
/*
* KVM_CAP_X86_APIC_BUS_CYCLES_NS expects APIC bus clock rate in


Reinette