]> git.ipfire.org Git - thirdparty/linux.git/commit
x86/apic: KVM: Use cpu_physical_id() to get APIC ID of running vCPU for AVIC
authorSean Christopherson <seanjc@google.com>
Fri, 12 Jun 2026 18:54:59 +0000 (11:54 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 24 Jun 2026 11:52:24 +0000 (07:52 -0400)
commit098e32cba334da0f3fa8cfd4e022ae7c72341400
treef3a302d6c348a89f7dd6474f23f0b97ea0c9d4a6
parent02953418a1378514d1f4086180f14004f5d08ea5
x86/apic: KVM: Use cpu_physical_id() to get APIC ID of running vCPU for AVIC

Use cpu_physical_id() instead of default_cpu_present_to_apicid() when
getting the APIC ID of the pCPU on which a vCPU is running/loaded, as the
kernel has gone way off the rails if a vCPU is loaded on a pCPU that has
been physically removed from the system.  Even if the impossible were to
happen, the absolutely worst case scenario is that hardware will ring the
AIVC doorbell on the wrong pCPU, i.e. a severely broken system will
experience mild performance issues.

Kill off KVM's superfluous kvm_cpu_get_apicid() wrapper along with the
for-KVM export of default_cpu_present_to_apicid(), as they existed purely
for the wonky AVIC usage.

Cc: Kai Huang <kai.huang@intel.com>
Cc: Yosry Ahmed <yosry@kernel.org>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Acked-by: Naveen N Rao (AMD) <naveen@kernel.org>
Reviewed-by: Kai Huang <kai.huang@intel.com>
Reviewed-by: Yosry Ahmed <yosry@kernel.org>
Message-ID: <20260612185459.591892-1-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kernel/apic/apic_common.c
arch/x86/kvm/svm/avic.c