Skip to content

Commit 481c9ee

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: arm64: vgic-its: Get rid of the lpi_list_lock
The last genuine use case for the lpi_list_lock was the global LPI translation cache, which has been removed in favor of a per-ITS xarray. Remove a layer from the locking puzzle by getting rid of it. vgic_add_lpi() still has a critical section that needs to protect against the insertion of other LPIs; change it to take the LPI xarray's xa_lock to retain this property. Signed-off-by: Oliver Upton <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent ec39bbf commit 481c9ee

File tree

4 files changed

+5
-10
lines changed

4 files changed

+5
-10
lines changed

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ void kvm_vgic_early_init(struct kvm *kvm)
5353
{
5454
struct vgic_dist *dist = &kvm->arch.vgic;
5555

56-
raw_spin_lock_init(&dist->lpi_list_lock);
5756
xa_init_flags(&dist->lpi_xa, XA_FLAGS_LOCK_IRQ);
5857
}
5958

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid,
6969
irq->target_vcpu = vcpu;
7070
irq->group = 1;
7171

72-
raw_spin_lock_irqsave(&dist->lpi_list_lock, flags);
72+
xa_lock_irqsave(&dist->lpi_xa, flags);
7373

7474
/*
7575
* There could be a race with another vgic_add_lpi(), so we need to
@@ -84,14 +84,14 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid,
8484
goto out_unlock;
8585
}
8686

87-
ret = xa_err(xa_store(&dist->lpi_xa, intid, irq, 0));
87+
ret = xa_err(__xa_store(&dist->lpi_xa, intid, irq, 0));
8888
if (ret) {
8989
xa_release(&dist->lpi_xa, intid);
9090
kfree(irq);
9191
}
9292

9393
out_unlock:
94-
raw_spin_unlock_irqrestore(&dist->lpi_list_lock, flags);
94+
xa_unlock_irqrestore(&dist->lpi_xa, flags);
9595

9696
if (ret)
9797
return ERR_PTR(ret);

arch/arm64/kvm/vgic/vgic.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ struct vgic_global kvm_vgic_global_state __ro_after_init = {
2929
* its->cmd_lock (mutex)
3030
* its->its_lock (mutex)
3131
* vgic_cpu->ap_list_lock must be taken with IRQs disabled
32-
* kvm->lpi_list_lock must be taken with IRQs disabled
33-
* vgic_dist->lpi_xa.xa_lock must be taken with IRQs disabled
34-
* vgic_irq->irq_lock must be taken with IRQs disabled
32+
* vgic_dist->lpi_xa.xa_lock must be taken with IRQs disabled
33+
* vgic_irq->irq_lock must be taken with IRQs disabled
3534
*
3635
* As the ap_list_lock might be taken from the timer interrupt handler,
3736
* we have to disable IRQs before taking this lock and everything lower

include/kvm/arm_vgic.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -280,9 +280,6 @@ struct vgic_dist {
280280
*/
281281
u64 propbaser;
282282

283-
/* Protects the lpi_list. */
284-
raw_spinlock_t lpi_list_lock;
285-
286283
#define LPI_XA_MARK_DEBUG_ITER XA_MARK_0
287284
struct xarray lpi_xa;
288285

0 commit comments

Comments
 (0)