Signed-off-by: Andre Przywara <andre.przyw...@arm.com>
---
 virt/kvm/arm/vgic/vgic_mmio.c | 43 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 42 insertions(+), 1 deletion(-)

diff --git a/virt/kvm/arm/vgic/vgic_mmio.c b/virt/kvm/arm/vgic/vgic_mmio.c
index 76657ce..cde153f 100644
--- a/virt/kvm/arm/vgic/vgic_mmio.c
+++ b/virt/kvm/arm/vgic/vgic_mmio.c
@@ -471,6 +471,47 @@ static int vgic_mmio_write_config(struct kvm_vcpu *vcpu,
        return 0;
 }
 
+static int vgic_mmio_read_target(struct kvm_vcpu *vcpu,
+                                struct kvm_io_device *this,
+                                gpa_t addr, int len, void *val)
+{
+       struct vgic_io_device *iodev = container_of(this,
+                                                   struct vgic_io_device, dev);
+       u32 intid = (addr - iodev->base_addr);
+       int i;
+
+       if (iodev->redist_vcpu)
+               vcpu = iodev->redist_vcpu;
+
+       for (i = 0; i < len; i++) {
+               struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i);
+
+               ((u8 *)val)[i] = irq->targets;
+       }
+
+       return 0;
+}
+
+static int vgic_mmio_write_target(struct kvm_vcpu *vcpu,
+                                 struct kvm_io_device *this,
+                                 gpa_t addr, int len, const void *val)
+{
+       struct vgic_io_device *iodev = container_of(this,
+                                                   struct vgic_io_device, dev);
+       u32 intid = (addr - iodev->base_addr);
+       int i;
+
+       /* GICD_ITARGETSR[0-7] are read-only */
+       if (intid < VGIC_NR_PRIVATE_IRQS)
+               return 0;
+
+       for (i = 0; i < len; i++)
+               vgic_v2_irq_change_affinity(vcpu->kvm, intid + i,
+                                           ((u8 *)val)[i]);
+
+       return 0;
+}
+
 struct vgic_register_region vgic_v2_dist_registers[] = {
        REGISTER_DESC_WITH_LENGTH(GIC_DIST_CTRL,
                vgic_mmio_read_v2_misc, vgic_mmio_write_v2_misc, 12),
@@ -491,7 +532,7 @@ struct vgic_register_region vgic_v2_dist_registers[] = {
        REGISTER_DESC_WITH_BITS_PER_IRQ(GIC_DIST_PRI,
                vgic_mmio_read_priority, vgic_mmio_write_priority, 8),
        REGISTER_DESC_WITH_BITS_PER_IRQ(GIC_DIST_TARGET,
-               vgic_mmio_read_nyi, vgic_mmio_write_nyi, 8),
+               vgic_mmio_read_target, vgic_mmio_write_target, 8),
        REGISTER_DESC_WITH_BITS_PER_IRQ(GIC_DIST_CONFIG,
                vgic_mmio_read_config, vgic_mmio_write_config, 2),
        REGISTER_DESC_WITH_LENGTH(GIC_DIST_SOFTINT,
-- 
2.7.3

_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

Reply via email to