[PATCH] KVM: arm64: Register irq_bypass consumers only with GICv4
Jinqian Yang
yangjinqian1 at huawei.com
Mon Nov 9 17:07:00 PST 2026
Hi,
On 2026/11/10 1:04, Oliver Upton wrote:
> Hi,
>
> On Mon, Nov 09, 2026 at 07:20:18PM +0800, Jinqian Yang wrote:
>> kvm_arch_has_irq_bypass() on arm64 returns true unconditionally, so
>> every irqfd assignment registers an irq_bypass consumer even when the
>> hardware cannot perform GICv4 direct MSI forwarding. In that case
>> kvm_vgic_v4_set_forwarding() bails out at its very first check, since
>> vgic_supports_direct_msis() is false without has_gicv4, and the
>> registration becomes pure overhead: every KVM_IRQFD ioctl takes the
>> global irq_bypass mutex, which becomes a contention point when many
>> VMs boot concurrently.
>>
>> Gate the registration on kvm_vgic_global_state.has_gicv4, the way x86
>> gates on enable_device_posted_irqs. Functionally this is a no-op:
>> without GICv4 the consumer registration never did anything beyond
>> acquiring the lock. On a GICv3-only host booting 100 microVMs
>> concurrently this cuts the average boot time by ~5 ms, matching the
>> gain observed with CONFIG_HAVE_KVM_IRQ_BYPASS=n.
>>
>> Signed-off-by: Jinqian Yang <yangjinqian1 at huawei.com>
>> ---
>> arch/arm64/include/asm/kvm_host.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h
>> index 97332ffcb130..785d57388032 100644
>> --- a/arch/arm64/include/asm/kvm_host.h
>> +++ b/arch/arm64/include/asm/kvm_host.h
>> @@ -1744,7 +1744,7 @@ void kvm_set_vm_id_reg(struct kvm *kvm, u32 reg, u64 val);
>>
>> static inline bool kvm_arch_has_irq_bypass(void)
>> {
>> - return true;
>> + return kvm_vgic_global_state.has_gicv4;
>> }
>
> This should just take a pointer on struct kvm then use
> vgic_supports_direct_msis() since having an initialized irqchip is a
> precondition of kvm_irqfd_assign().
>
Yes, vgic_supports_direct_msis() is used as the gate in
kvm_arch_irq_bypass_add_producer->kvm_vgic_v4_set_forwarding, and
kvm_arch_has_irq_bypass should be consistent. This will be modified
in the next version.
Thanks,
Jinqian
More information about the linux-arm-kernel
mailing list