Skip to content

Commit 8c5e74c

Browse files
Ricardo KollerMarc Zyngier
authored andcommitted
KVM: arm64: vgic: Undo work in failed ITS restores
Failed ITS restores should clean up all state restored until the failure. There is some cleanup already present when failing to restore some tables, but it's not complete. Add the missing cleanup. Note that this changes the behavior in case of a failed restore of the device tables. restore ioctl: 1. restore collection tables 2. restore device tables With this commit, failures in 2. clean up everything created so far, including state created by 1. Reviewed-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Ricardo Koller <ricarkol@google.com> Reviewed-by: Oliver Upton <oupton@google.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20220510001633.552496-5-ricarkol@google.com
1 parent a1ccfd6 commit 8c5e74c

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2219,8 +2219,10 @@ static int vgic_its_restore_ite(struct vgic_its *its, u32 event_id,
22192219
vcpu = kvm_get_vcpu(kvm, collection->target_addr);
22202220

22212221
irq = vgic_add_lpi(kvm, lpi_id, vcpu);
2222-
if (IS_ERR(irq))
2222+
if (IS_ERR(irq)) {
2223+
its_free_ite(kvm, ite);
22232224
return PTR_ERR(irq);
2225+
}
22242226
ite->irq = irq;
22252227

22262228
return offset;
@@ -2485,6 +2487,9 @@ static int vgic_its_restore_device_tables(struct vgic_its *its)
24852487
if (ret > 0)
24862488
ret = 0;
24872489

2490+
if (ret < 0)
2491+
vgic_its_free_device_list(its->dev->kvm, its);
2492+
24882493
return ret;
24892494
}
24902495

@@ -2615,6 +2620,9 @@ static int vgic_its_restore_collection_table(struct vgic_its *its)
26152620
if (ret > 0)
26162621
return 0;
26172622

2623+
if (ret < 0)
2624+
vgic_its_free_collection_list(its->dev->kvm, its);
2625+
26182626
return ret;
26192627
}
26202628

@@ -2646,7 +2654,10 @@ static int vgic_its_restore_tables_v0(struct vgic_its *its)
26462654
if (ret)
26472655
return ret;
26482656

2649-
return vgic_its_restore_device_tables(its);
2657+
ret = vgic_its_restore_device_tables(its);
2658+
if (ret)
2659+
vgic_its_free_collection_list(its->dev->kvm, its);
2660+
return ret;
26502661
}
26512662

26522663
static int vgic_its_commit_v0(struct vgic_its *its)

0 commit comments

Comments
 (0)