Re: [PATCH v4 27/30] KVM: x86: Add KVM_VCPU_TSC_EFFECTIVE_FREQ attribute
From: David Woodhouse
Date: Fri May 22 2026 - 09:34:04 EST
On Fri, 2026-05-22 at 05:49 -0700, Sean Christopherson wrote:
>
> Oh, that's just an oversight, definitely not intentional. Easy enough to fix:
Want me to roll that into the series? As you eloquently put it the
other day, what's one more patch...?
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 1616b2eec6e7..cd4a244ca0c5 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -2235,7 +2235,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
> r = tdp_enabled;
> break;
> case KVM_CAP_X86_APIC_BUS_CYCLES_NS:
> - r = APIC_BUS_CYCLE_NS_DEFAULT;
> + r = kvm ? kvm->arch.apic_bus_cycle_ns : APIC_BUS_CYCLE_NS_DEFAULT;
> break;
> case KVM_CAP_EXIT_HYPERCALL:
> r = KVM_EXIT_HYPERCALL_VALID_MASK;
Please tell me that can never be zero. Because we divide by it when
reading HV_X64_MSR_APIC_FREQUENCY.
... checks ... it does look like it's initialised to
APIC_BUS_CYCLE_NS_DEFAULT in kvm_arch_init_vm(), and we don't allow
userspace to set it to zero.
Attachment:
smime.p7s
Description: S/MIME cryptographic signature