Skip to content

Commit 86e2de1

Browse files
sean-jcbonzini
authored andcommitted
KVM: x86: Return the VM's configured APIC bus frequency when queried
When KVM_CAP_X86_APIC_BUS_CYCLES_NS is queried on a specific VM, return the VM's configured APIC bus frequency, not KVM's default. Aside from the fact that returning the default frequency is blatantly wrong if userspace has changed the frequency, returning the configured frequency means userspace can blindly trust the result, e.g. when filling PV CPUID information that communicates the APIC bus frequency to the guest. Fixes: 6fef518 ("KVM: x86: Add a capability to configure bus frequency for APIC timer") Reported-by: David Woodhouse <dwmw2@infradead.org> Closes: https://lore.kernel.org/all/ab84153e33fbe7c25667f595c56b310d4d5a93ef.camel@infradead.org Signed-off-by: Sean Christopherson <seanjc@google.com> Message-ID: <20260522173526.3539407-2-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 2d42c7c commit 86e2de1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

arch/x86/kvm/x86.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4876,7 +4876,7 @@ int kvm_vm_ioctl_check_extension(struct kvm *kvm, long ext)
48764876
r = tdp_enabled;
48774877
break;
48784878
case KVM_CAP_X86_APIC_BUS_CYCLES_NS:
4879-
r = APIC_BUS_CYCLE_NS_DEFAULT;
4879+
r = kvm ? kvm->arch.apic_bus_cycle_ns : APIC_BUS_CYCLE_NS_DEFAULT;
48804880
break;
48814881
case KVM_CAP_EXIT_HYPERCALL:
48824882
r = KVM_EXIT_HYPERCALL_VALID_MASK;

0 commit comments

Comments
 (0)