KVM: arm/arm64: vgic-its: Invalidate MSI-LPI translation cache on specific commands
authorMarc Zyngier <maz@kernel.org>
Mon, 18 Mar 2019 10:23:16 +0000 (10:23 +0000)
committerMarc Zyngier <maz@kernel.org>
Sun, 18 Aug 2019 17:38:45 +0000 (18:38 +0100)
The LPI translation cache needs to be discarded when an ITS command
may affect the translation of an LPI (DISCARD, MAPC and MAPD with V=0)
or the routing of an LPI to a redistributor with disabled LPIs (MOVI,
MOVALL).

We decide to perform a full invalidation of the cache, irrespective
of the LPI that is affected. Commands are supposed to be rare enough
that it doesn't matter.

Tested-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
virt/kvm/arm/vgic/vgic-its.c

index cc6b5e4..09a1798 100644 (file)
@@ -722,6 +722,8 @@ static int vgic_its_cmd_handle_discard(struct kvm *kvm, struct vgic_its *its,
                 * don't bother here since we clear the ITTE anyway and the
                 * pending state is a property of the ITTE struct.
                 */
+               vgic_its_invalidate_cache(kvm);
+
                its_free_ite(kvm, ite);
                return 0;
        }
@@ -757,6 +759,8 @@ static int vgic_its_cmd_handle_movi(struct kvm *kvm, struct vgic_its *its,
        ite->collection = collection;
        vcpu = kvm_get_vcpu(kvm, collection->target_addr);
 
+       vgic_its_invalidate_cache(kvm);
+
        return update_affinity(ite->irq, vcpu);
 }
 
@@ -985,6 +989,8 @@ static void vgic_its_free_device(struct kvm *kvm, struct its_device *device)
        list_for_each_entry_safe(ite, temp, &device->itt_head, ite_list)
                its_free_ite(kvm, ite);
 
+       vgic_its_invalidate_cache(kvm);
+
        list_del(&device->dev_list);
        kfree(device);
 }
@@ -1090,6 +1096,7 @@ static int vgic_its_cmd_handle_mapc(struct kvm *kvm, struct vgic_its *its,
 
        if (!valid) {
                vgic_its_free_collection(its, coll_id);
+               vgic_its_invalidate_cache(kvm);
        } else {
                collection = find_collection(its, coll_id);
 
@@ -1238,6 +1245,8 @@ static int vgic_its_cmd_handle_movall(struct kvm *kvm, struct vgic_its *its,
                vgic_put_irq(kvm, irq);
        }
 
+       vgic_its_invalidate_cache(kvm);
+
        kfree(intids);
        return 0;
 }