Skip to content

Commit 77bb184

Browse files
committed
KVM: Fold kvm_arch_irqfd_route_changed() into kvm_arch_update_irqfd_routing()
Fold kvm_arch_irqfd_route_changed() into kvm_arch_update_irqfd_routing(). Calling arch code to know whether or not to call arch code is absurd. Reviewed-by: Oliver Upton <oliver.upton@linux.dev> Link: https://lore.kernel.org/r/20250611224604.313496-35-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent b33252b commit 77bb184

File tree

4 files changed

+11
-31
lines changed

4 files changed

+11
-31
lines changed

arch/arm64/kvm/arm.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2761,20 +2761,15 @@ void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *cons,
27612761
kvm_vgic_v4_unset_forwarding(irqfd->kvm, prod->irq);
27622762
}
27632763

2764-
bool kvm_arch_irqfd_route_changed(struct kvm_kernel_irq_routing_entry *old,
2765-
struct kvm_kernel_irq_routing_entry *new)
2766-
{
2767-
if (old->type != KVM_IRQ_ROUTING_MSI ||
2768-
new->type != KVM_IRQ_ROUTING_MSI)
2769-
return true;
2770-
2771-
return memcmp(&old->msi, &new->msi, sizeof(new->msi));
2772-
}
2773-
27742764
void kvm_arch_update_irqfd_routing(struct kvm_kernel_irqfd *irqfd,
27752765
struct kvm_kernel_irq_routing_entry *old,
27762766
struct kvm_kernel_irq_routing_entry *new)
27772767
{
2768+
if (old->type == KVM_IRQ_ROUTING_MSI &&
2769+
new->type == KVM_IRQ_ROUTING_MSI &&
2770+
!memcmp(&old->msi, &new->msi, sizeof(new->msi)))
2771+
return;
2772+
27782773
/*
27792774
* Remapping the vLPI requires taking the its_lock mutex to resolve
27802775
* the new translation. We're in spinlock land at this point, so no

arch/x86/kvm/irq.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -610,17 +610,12 @@ void kvm_arch_update_irqfd_routing(struct kvm_kernel_irqfd *irqfd,
610610
struct kvm_kernel_irq_routing_entry *old,
611611
struct kvm_kernel_irq_routing_entry *new)
612612
{
613-
kvm_pi_update_irte(irqfd, new);
614-
}
615-
616-
bool kvm_arch_irqfd_route_changed(struct kvm_kernel_irq_routing_entry *old,
617-
struct kvm_kernel_irq_routing_entry *new)
618-
{
619-
if (old->type != KVM_IRQ_ROUTING_MSI ||
620-
new->type != KVM_IRQ_ROUTING_MSI)
621-
return true;
613+
if (old->type == KVM_IRQ_ROUTING_MSI &&
614+
new->type == KVM_IRQ_ROUTING_MSI &&
615+
!memcmp(&old->msi, &new->msi, sizeof(new->msi)))
616+
return;
622617

623-
return !!memcmp(&old->msi, &new->msi, sizeof(new->msi));
618+
kvm_pi_update_irte(irqfd, new);
624619
}
625620

626621
#ifdef CONFIG_KVM_IOAPIC

include/linux/kvm_host.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2413,8 +2413,6 @@ void kvm_arch_irq_bypass_start(struct irq_bypass_consumer *);
24132413
void kvm_arch_update_irqfd_routing(struct kvm_kernel_irqfd *irqfd,
24142414
struct kvm_kernel_irq_routing_entry *old,
24152415
struct kvm_kernel_irq_routing_entry *new);
2416-
bool kvm_arch_irqfd_route_changed(struct kvm_kernel_irq_routing_entry *,
2417-
struct kvm_kernel_irq_routing_entry *);
24182416
#endif /* CONFIG_HAVE_KVM_IRQ_BYPASS */
24192417

24202418
#ifdef CONFIG_HAVE_KVM_INVALID_WAKEUPS

virt/kvm/eventfd.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,6 @@ void __weak kvm_arch_update_irqfd_routing(struct kvm_kernel_irqfd *irqfd,
291291
{
292292

293293
}
294-
295-
bool __attribute__((weak)) kvm_arch_irqfd_route_changed(
296-
struct kvm_kernel_irq_routing_entry *old,
297-
struct kvm_kernel_irq_routing_entry *new)
298-
{
299-
return true;
300-
}
301294
#endif
302295

303296
static int
@@ -616,8 +609,7 @@ void kvm_irq_routing_update(struct kvm *kvm)
616609
irqfd_update(kvm, irqfd);
617610

618611
#if IS_ENABLED(CONFIG_HAVE_KVM_IRQ_BYPASS)
619-
if (irqfd->producer &&
620-
kvm_arch_irqfd_route_changed(&old, &irqfd->irq_entry))
612+
if (irqfd->producer)
621613
kvm_arch_update_irqfd_routing(irqfd, &old, &irqfd->irq_entry);
622614
#endif
623615
}

0 commit comments

Comments
 (0)