Skip to content

Commit 761aabe

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: arm64: Use lock guard in vgic_v4_set_forwarding()
The locking dance is about to get more interesting, switch the its_lock over to a lock guard to make it a bit easier to handle. Tested-by: Sweet Tea Dorminy <[email protected]> Signed-off-by: Oliver Upton <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent 6673047 commit 761aabe

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ int kvm_vgic_v4_set_forwarding(struct kvm *kvm, int virq,
444444
if (IS_ERR(its))
445445
return 0;
446446

447-
mutex_lock(&its->its_lock);
447+
guard(mutex)(&its->its_lock);
448448

449449
/*
450450
* Perform the actual DevID/EventID -> LPI translation.
@@ -455,11 +455,11 @@ int kvm_vgic_v4_set_forwarding(struct kvm *kvm, int virq,
455455
*/
456456
if (vgic_its_resolve_lpi(kvm, its, irq_entry->msi.devid,
457457
irq_entry->msi.data, &irq))
458-
goto out;
458+
return 0;
459459

460460
/* Silently exit if the vLPI is already mapped */
461461
if (irq->hw)
462-
goto out;
462+
return 0;
463463

464464
/*
465465
* Emit the mapping request. If it fails, the ITS probably
@@ -479,7 +479,7 @@ int kvm_vgic_v4_set_forwarding(struct kvm *kvm, int virq,
479479

480480
ret = its_map_vlpi(virq, &map);
481481
if (ret)
482-
goto out;
482+
return ret;
483483

484484
irq->hw = true;
485485
irq->host_irq = virq;
@@ -503,8 +503,6 @@ int kvm_vgic_v4_set_forwarding(struct kvm *kvm, int virq,
503503
raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
504504
}
505505

506-
out:
507-
mutex_unlock(&its->its_lock);
508506
return ret;
509507
}
510508

0 commit comments

Comments
 (0)