Skip to content

Commit 9d272bc

Browse files
author
Gavin Shan
committed
KVM: arm64: Use lock guard in vgic_v4_set_forwarding()
JIRA: https://issues.redhat.com/browse/RHEL-93666 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 <sweettea-kernel@dorminy.me> Signed-off-by: Oliver Upton <oliver.upton@linux.dev> Link: https://lore.kernel.org/r/20250523194722.4066715-2-oliver.upton@linux.dev Signed-off-by: Marc Zyngier <maz@kernel.org> (cherry picked from commit 761aabe) Signed-off-by: Gavin Shan <gshan@redhat.com>
1 parent a7bca5f commit 9d272bc

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
@@ -428,7 +428,7 @@ int kvm_vgic_v4_set_forwarding(struct kvm *kvm, int virq,
428428
if (IS_ERR(its))
429429
return 0;
430430

431-
mutex_lock(&its->its_lock);
431+
guard(mutex)(&its->its_lock);
432432

433433
/*
434434
* Perform the actual DevID/EventID -> LPI translation.
@@ -439,11 +439,11 @@ int kvm_vgic_v4_set_forwarding(struct kvm *kvm, int virq,
439439
*/
440440
if (vgic_its_resolve_lpi(kvm, its, irq_entry->msi.devid,
441441
irq_entry->msi.data, &irq))
442-
goto out;
442+
return 0;
443443

444444
/* Silently exit if the vLPI is already mapped */
445445
if (irq->hw)
446-
goto out;
446+
return 0;
447447

448448
/*
449449
* Emit the mapping request. If it fails, the ITS probably
@@ -463,7 +463,7 @@ int kvm_vgic_v4_set_forwarding(struct kvm *kvm, int virq,
463463

464464
ret = its_map_vlpi(virq, &map);
465465
if (ret)
466-
goto out;
466+
return ret;
467467

468468
irq->hw = true;
469469
irq->host_irq = virq;
@@ -487,8 +487,6 @@ int kvm_vgic_v4_set_forwarding(struct kvm *kvm, int virq,
487487
raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
488488
}
489489

490-
out:
491-
mutex_unlock(&its->its_lock);
492490
return ret;
493491
}
494492

0 commit comments

Comments
 (0)