Re: [PATCH v3] KVM: x86: Add x2APIC "features" to control EOI broadcast suppression

From: David Woodhouse
Date: Tue Dec 02 2025 - 12:11:19 EST


On Tue, 2025-12-02 at 08:36 -0800, Sean Christopherson wrote:
>
> Hmm, I suppose that could work for uAPI.  Having both an ENABLE and a DISABLE
> is obviously a bit odd, but slowing down the reader might actually be a good
> thing in this case.  And the documentation should be easy enough to write.
>
> I was worried that having ENABLE and DISABLE controls would lead to confusing code
> internally, but there's no reason KVM's internal tracking needs to match uAPI.
>
> How about this?
>
> ---
>  arch/x86/include/asm/kvm_host.h |  7 +++++++
>  arch/x86/include/uapi/asm/kvm.h |  6 ++++--
>  arch/x86/kvm/lapic.c            | 16 +++++++++++++++-
>  arch/x86/kvm/x86.c              | 15 ++++++++++++---
>  4 files changed, 38 insertions(+), 6 deletions(-)
>
> diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h
> index 5a3bfa293e8b..b4c41255f01d 100644
> --- a/arch/x86/include/asm/kvm_host.h
> +++ b/arch/x86/include/asm/kvm_host.h
> @@ -1226,6 +1226,12 @@ enum kvm_irqchip_mode {
>   KVM_IRQCHIP_SPLIT,        /* created with KVM_CAP_SPLIT_IRQCHIP */
>  };
>  
> +enum kvm_suppress_eoi_broadcast_mode {
> + KVM_SUPPRESS_EOI_QUIRKED,
> + KVM_SUPPRESS_EOI_ENABLED,
> + KVM_SUPPRESS_EOI_DISABLED,
> +};
> +

Looks good. I'd probably call it KVM_SUPPRESS_EOI_LEGACY though?

And just for clarity I wouldn't embed the explicit checks against e.g
arch.suppress_eoi_broadcast != KVM_SUPPRESS_EOI_LEGACY. I'd make static
inline functions like

static inline bool kvm_lapic_advertise_directed_eoi(kvm)
{
/* Legacy behaviour was to advertise this feature but it
didn't
* actually work. */
return kvm->arch.suppress_eoi_broadcast != KVM_SUPPRESS_EOI_DISABLED;
}

static inline bool kvm_lapic_suppress_directed_eoi(kvm)
{
/* Legacy behaviour advertised this feature but didn't
actually
* suppress the EOI. */
return kvm->arch.suppress_eoi_broadcast == KVM_SUPPRESS_EOI_ENABLED;
}

Because it keeps the batshittery in one place and clearly documented?

I note your version did actually suppress the broadcast even in the
DISABLED case if the guest had managed to set that bit in SPIV, but I
don't think it *can* so that difference doesn't matter anyway, right?

Attachment: smime.p7s
Description: S/MIME cryptographic signature