Skip to content

Commit dedfcd1

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: arm64: vgic-its: Spin off helper for finding ITS by doorbell addr
The fast path will soon need to find an ITS by doorbell address, as the translation caches will become local to an ITS. Spin off a helper to do just that. Signed-off-by: Oliver Upton <oliver.upton@linux.dev> Link: https://lore.kernel.org/r/20240422200158.2606761-10-oliver.upton@linux.dev Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 8201d10 commit dedfcd1

1 file changed

Lines changed: 21 additions & 14 deletions

File tree

arch/arm64/kvm/vgic/vgic-its.c

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -511,9 +511,29 @@ static unsigned long vgic_mmio_read_its_idregs(struct kvm *kvm,
511511
return 0;
512512
}
513513

514+
static struct vgic_its *__vgic_doorbell_to_its(struct kvm *kvm, gpa_t db)
515+
{
516+
struct kvm_io_device *kvm_io_dev;
517+
struct vgic_io_device *iodev;
518+
519+
kvm_io_dev = kvm_io_bus_get_dev(kvm, KVM_MMIO_BUS, db);
520+
if (!kvm_io_dev)
521+
return ERR_PTR(-EINVAL);
522+
523+
if (kvm_io_dev->ops != &kvm_io_gic_ops)
524+
return ERR_PTR(-EINVAL);
525+
526+
iodev = container_of(kvm_io_dev, struct vgic_io_device, dev);
527+
if (iodev->iodev_type != IODEV_ITS)
528+
return ERR_PTR(-EINVAL);
529+
530+
return iodev->its;
531+
}
532+
514533
static unsigned long vgic_its_cache_key(u32 devid, u32 eventid)
515534
{
516535
return (((unsigned long)devid) << VITS_TYPER_IDBITS) | eventid;
536+
517537
}
518538

519539
static struct vgic_irq *__vgic_its_check_cache(struct vgic_dist *dist,
@@ -721,8 +741,6 @@ int vgic_its_resolve_lpi(struct kvm *kvm, struct vgic_its *its,
721741
struct vgic_its *vgic_msi_to_its(struct kvm *kvm, struct kvm_msi *msi)
722742
{
723743
u64 address;
724-
struct kvm_io_device *kvm_io_dev;
725-
struct vgic_io_device *iodev;
726744

727745
if (!vgic_has_its(kvm))
728746
return ERR_PTR(-ENODEV);
@@ -732,18 +750,7 @@ struct vgic_its *vgic_msi_to_its(struct kvm *kvm, struct kvm_msi *msi)
732750

733751
address = (u64)msi->address_hi << 32 | msi->address_lo;
734752

735-
kvm_io_dev = kvm_io_bus_get_dev(kvm, KVM_MMIO_BUS, address);
736-
if (!kvm_io_dev)
737-
return ERR_PTR(-EINVAL);
738-
739-
if (kvm_io_dev->ops != &kvm_io_gic_ops)
740-
return ERR_PTR(-EINVAL);
741-
742-
iodev = container_of(kvm_io_dev, struct vgic_io_device, dev);
743-
if (iodev->iodev_type != IODEV_ITS)
744-
return ERR_PTR(-EINVAL);
745-
746-
return iodev->its;
753+
return __vgic_doorbell_to_its(kvm, address);
747754
}
748755

749756
/*

0 commit comments

Comments
 (0)