Skip to content

Commit

Permalink
KVM: arm/arm64: vgic-irqfd: Implement kvm_arch_set_irq_inatomic
Browse files Browse the repository at this point in the history
Now that we have a cache of MSI->LPI translations, it is pretty
easy to implement kvm_arch_set_irq_inatomic (this cache can be
parsed without sleeping).

Hopefully, this will improve some LPI-heavy workloads.

Tested-by: Andre Przywara <[email protected]>
Reviewed-by: Eric Auger <[email protected]>
Signed-off-by: Marc Zyngier <[email protected]>
  • Loading branch information
Marc Zyngier committed Aug 18, 2019
1 parent 86a7dae commit 4110817
Showing 1 changed file with 30 additions and 6 deletions.
36 changes: 30 additions & 6 deletions virt/kvm/arm/vgic/vgic-irqfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ int kvm_set_routing_entry(struct kvm *kvm,
return r;
}

static void kvm_populate_msi(struct kvm_kernel_irq_routing_entry *e,
struct kvm_msi *msi)
{
msi->address_lo = e->msi.address_lo;
msi->address_hi = e->msi.address_hi;
msi->data = e->msi.data;
msi->flags = e->msi.flags;
msi->devid = e->msi.devid;
}
/**
* kvm_set_msi: inject the MSI corresponding to the
* MSI routing entry
Expand All @@ -79,21 +88,36 @@ int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
{
struct kvm_msi msi;

msi.address_lo = e->msi.address_lo;
msi.address_hi = e->msi.address_hi;
msi.data = e->msi.data;
msi.flags = e->msi.flags;
msi.devid = e->msi.devid;

if (!vgic_has_its(kvm))
return -ENODEV;

if (!level)
return -1;

kvm_populate_msi(e, &msi);
return vgic_its_inject_msi(kvm, &msi);
}

/**
* kvm_arch_set_irq_inatomic: fast-path for irqfd injection
*
* Currently only direct MSI injection is supported.
*/
int kvm_arch_set_irq_inatomic(struct kvm_kernel_irq_routing_entry *e,
struct kvm *kvm, int irq_source_id, int level,
bool line_status)
{
if (e->type == KVM_IRQ_ROUTING_MSI && vgic_has_its(kvm) && level) {
struct kvm_msi msi;

kvm_populate_msi(e, &msi);
if (!vgic_its_inject_cached_translation(kvm, &msi))
return 0;
}

return -EWOULDBLOCK;
}

int kvm_vgic_setup_default_irq_routing(struct kvm *kvm)
{
struct kvm_irq_routing_entry *entries;
Expand Down

0 comments on commit 4110817

Please sign in to comment.