Re: [PATCH v3 33/40] KVM: x86: Move kvm_cpu_get_apicid() from kvm_host.h => avic.c
From: Huang, Kai
Date: Fri Jun 05 2026 - 03:14:06 EST
On Fri, 2026-05-29 at 15:22 -0700, Sean Christopherson wrote:
> Opportunistically drop the CONFIG_X86_LOCAL_APIC=n stub, as KVM hard
> depends on CONFIG_X86_LOCAL_APIC=y (the stub was there purely to deal
> with kvm_host.h being included by non-KVM code).
Seems you forgot to mention the code movement part?
>
> No functional change intended.
>
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> ---
> arch/x86/include/asm/kvm_host.h | 10 ----------
> arch/x86/kvm/svm/avic.c | 5 +++++
> 2 files changed, 5 insertions(+), 10 deletions(-)
>
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index 3e0884a862d7..989294c7501b 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -2427,16 +2427,6 @@ static inline void kvm_arch_vcpu_unblocking(struct kvm_vcpu *vcpu)
> kvm_x86_call(vcpu_unblocking)(vcpu);
> }
>
> -static inline int kvm_cpu_get_apicid(int mps_cpu)
> -{
> -#ifdef CONFIG_X86_LOCAL_APIC
> - return default_cpu_present_to_apicid(mps_cpu);
> -#else
> - WARN_ON_ONCE(1);
> - return BAD_APICID;
> -#endif
> -}
> -
> int memslot_rmap_alloc(struct kvm_memory_slot *slot, unsigned long npages);
>
> #define KVM_CLOCK_VALID_FLAGS \
> diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c
> index b7083cd692ad..9264c8ef1fa1 100644
> --- a/arch/x86/kvm/svm/avic.c
> +++ b/arch/x86/kvm/svm/avic.c
> @@ -146,6 +146,11 @@ static void avic_set_x2apic_msr_interception(struct vcpu_svm *svm,
> svm->x2avic_msrs_intercepted = intercept;
> }
>
> +static int kvm_cpu_get_apicid(int mps_cpu)
> +{
> + return default_cpu_present_to_apicid(mps_cpu);
> +}
> +
>
Looks it is only used by AMD (svm/avic.c). I don't know why, but it would be
nice if you can mention this in changelog, since this function seems pretty
common to both Intel and AMD.
That being said, since you are moving it to svm/avic.c (not lapic.h), and it's
just a wrapper of calling default_cpu_present_to_apicid(). Should we just
remove this and make avic.c call default_cpu_present_to_apicid() directly?