Re: [PATCH v3 3/4] KVM: X86: Add a capability to configure bus frequency for APIC timer

From: Xiaoyao Li
Date: Thu Dec 28 2023 - 23:41:41 EST


On 12/19/2023 4:34 PM, Isaku Yamahata wrote:
+7.34 KVM_CAP_X86_BUS_FREQUENCY_CONTROL
+--------------------------------------
+
+:Architectures: x86
+:Target: VM
+:Parameters: args[0] is the value of apic bus clock frequency
+:Returns: 0 on success, -EINVAL if args[0] contains invalid value for the
+ frequency, or -ENXIO if virtual local APIC isn't enabled by
+ KVM_CREATE_IRQCHIP, or -EBUSY if any vcpu is created.
+
+This capability sets the APIC bus clock frequency (or core crystal clock
+frequency) for kvm to emulate APIC in the kernel.

Isaku,

you are mixing the `bus clock` and `core crystal clock` frequency. They are different.

- When CPUID 0x15 doesn't exist, or CPUID 0x15 doesn't enumerate core crystal clock frequency, the APIC timer frequency is the processor's bus clock.

- When CPUID 0x15 does enumerate the core crystal clock frequency, the APIC timer frequency is the core crystal clock frequency.

This patch only enables the user-configurable bus clock frequency, or specifically APIC timer frequency. It doesn't enable the configuration of core crystal clock frequency. Userspace can configure core crystal clock frequency by passing a valid CPUID 0x15 leaf into KVM_SET_CPUID2, not by this KVM_CAP.

The default value is 1000000
+(1GHz).