Re: [PATCH v4 05/30] KVM: x86: Move local APIC specific helpers out of asm/kvm_host.h

From: Binbin Wu

Date: Mon Jun 15 2026 - 01:48:03 EST


On 6/13/2026 8:03 AM, Sean Christopherson wrote:
> Move single-use local APIC IRQ helpers out of asm/kvm_host.h so that they

Nit:
Not sure if it's accurate to say kvm_lapic_irq_dest_mode() is a single-use
helper.

> are co-located with their user, and not exposed to the broader world.
>
> No functional change intended.
>
> Reviewed-by: Kai Huang <kai.huang@xxxxxxxxx>
> Reviewed-by: Yosry Ahmed <yosry@xxxxxxxxxx>
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>

Reviewed-by: Binbin Wu <binbin.wu@xxxxxxxxxxxxxxx>

> ---
> arch/x86/include/asm/kvm_host.h | 12 ------------
> arch/x86/kvm/irq.c | 7 +++++++
> arch/x86/kvm/lapic.h | 5 +++++
> 3 files changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index 3886b536c8a5..71e575d011e7 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -1772,11 +1772,6 @@ struct kvm_lapic_irq {
> bool msi_redir_hint;
> };
>
> -static inline u16 kvm_lapic_irq_dest_mode(bool dest_mode_logical)
> -{
> - return dest_mode_logical ? APIC_DEST_LOGICAL : APIC_DEST_PHYSICAL;
> -}
> -
> enum kvm_x86_run_flags {
> KVM_RUN_FORCE_IMMEDIATE_EXIT = BIT(0),
> KVM_RUN_LOAD_GUEST_DR6 = BIT(1),
> @@ -2509,13 +2504,6 @@ void __user *__x86_set_memory_region(struct kvm *kvm, int id, gpa_t gpa,
> bool kvm_vcpu_is_reset_bsp(struct kvm_vcpu *vcpu);
> bool kvm_vcpu_is_bsp(struct kvm_vcpu *vcpu);
>
> -static inline bool kvm_irq_is_postable(struct kvm_lapic_irq *irq)
> -{
> - /* We can only post Fixed and LowPrio IRQs */
> - return (irq->delivery_mode == APIC_DM_FIXED ||
> - irq->delivery_mode == APIC_DM_LOWEST);
> -}
> -
> static inline void kvm_arch_vcpu_blocking(struct kvm_vcpu *vcpu)
> {
> kvm_x86_call(vcpu_blocking)(vcpu);
> diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c
> index 8c62c6d4d5c1..727245a6ab34 100644
> --- a/arch/x86/kvm/irq.c
> +++ b/arch/x86/kvm/irq.c
> @@ -423,6 +423,13 @@ void kvm_arch_irq_routing_update(struct kvm *kvm)
> kvm_make_scan_ioapic_request(kvm);
> }
>
> +static bool kvm_irq_is_postable(struct kvm_lapic_irq *irq)
> +{
> + /* We can only post Fixed and LowPrio IRQs */
> + return (irq->delivery_mode == APIC_DM_FIXED ||
> + irq->delivery_mode == APIC_DM_LOWEST);
> +}
> +
> static int kvm_pi_update_irte(struct kvm_kernel_irqfd *irqfd,
> struct kvm_kernel_irq_routing_entry *entry)
> {
> diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h
> index 71970213dc1f..32f09b25884a 100644
> --- a/arch/x86/kvm/lapic.h
> +++ b/arch/x86/kvm/lapic.h
> @@ -237,6 +237,11 @@ static inline int kvm_lapic_latched_init(struct kvm_vcpu *vcpu)
> return lapic_in_kernel(vcpu) && test_bit(KVM_APIC_INIT, &vcpu->arch.apic->pending_events);
> }
>
> +static inline u16 kvm_lapic_irq_dest_mode(bool dest_mode_logical)
> +{
> + return dest_mode_logical ? APIC_DEST_LOGICAL : APIC_DEST_PHYSICAL;
> +}
> +
> bool kvm_apic_pending_eoi(struct kvm_vcpu *vcpu, int vector);
>
> bool kvm_lapic_suppress_eoi_broadcast(struct kvm_lapic *apic);