Re: [PATCH] x86/apic: KVM: Use cpu_physical_id() to get APIC ID of running vCPU for AVIC

From: Huang, Kai

Date: Sun Jun 14 2026 - 22:00:58 EST


On Fri, 2026-06-12 at 11:54 -0700, Sean Christopherson wrote:
> 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@xxxxxxxxx>
> Cc: Yosry Ahmed <yosry@xxxxxxxxxx>
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>

Reviewed-by: Kai Huang <kai.huang@xxxxxxxxx>