]> www.infradead.org Git - users/jedix/linux-maple.git/commit
KVM: Setup empty IRQ routing when creating a VM
authorYi Wang <foxywang@tencent.com>
Mon, 6 May 2024 10:17:49 +0000 (18:17 +0800)
committerSean Christopherson <seanjc@google.com>
Tue, 11 Jun 2024 21:18:34 +0000 (14:18 -0700)
commitfbe4a7e881d4408bfabbb4fd538f10fd686cd8ab
tree104d9dd3cfe88d4f5b9a9c713f483aecf9d6bcd0
parentf2362c04752ca23ee65d476795f4e2ea444f1809
KVM: Setup empty IRQ routing when creating a VM

Setup empty IRQ routing during VM creation so that x86 and s390 don't need
to set empty/dummy IRQ routing during KVM_CREATE_IRQCHIP (in future
patches).  Initializing IRQ routing before there are any potential readers
allows KVM to avoid the synchronize_srcu() in kvm_set_irq_routing(), which
can introduces 20+ milliseconds of latency in the VM creation path.

Ensuring that all VMs have non-NULL IRQ routing also hardens KVM against
misbehaving userspace VMMs, e.g. RISC-V dynamically instantiates its
interrupt controller, but doesn't override kvm_arch_intc_initialized() or
kvm_arch_irqfd_allowed(), and so can likely reach kvm_irq_map_gsi()
without fully initialized IRQ routing.

Signed-off-by: Yi Wang <foxywang@tencent.com>
Acked-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Link: https://lore.kernel.org/r/20240506101751.3145407-2-foxywang@tencent.com
[sean: init refcount after IRQ routing, fix stub, massage changelog]
Signed-off-by: Sean Christopherson <seanjc@google.com>
include/linux/kvm_host.h
virt/kvm/irqchip.c
virt/kvm/kvm_main.c