Skip to content

Commit 2798683

Browse files
committed
KVM: arm64: vgic-its: Walk the LPI xarray in vgic_copy_lpi_list()
Start iterating the LPI xarray in anticipation of removing the LPI linked-list. Reviewed-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent 49f0a46 commit 2798683

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,8 @@ static int update_lpi_config(struct kvm *kvm, struct vgic_irq *irq,
327327
return 0;
328328
}
329329

330+
#define GIC_LPI_MAX_INTID ((1 << INTERRUPT_ID_BITS_ITS) - 1)
331+
330332
/*
331333
* Create a snapshot of the current LPIs targeting @vcpu, so that we can
332334
* enumerate those LPIs without holding any lock.
@@ -335,6 +337,7 @@ static int update_lpi_config(struct kvm *kvm, struct vgic_irq *irq,
335337
int vgic_copy_lpi_list(struct kvm *kvm, struct kvm_vcpu *vcpu, u32 **intid_ptr)
336338
{
337339
struct vgic_dist *dist = &kvm->arch.vgic;
340+
XA_STATE(xas, &dist->lpi_xa, GIC_LPI_OFFSET);
338341
struct vgic_irq *irq;
339342
unsigned long flags;
340343
u32 *intids;
@@ -353,14 +356,18 @@ int vgic_copy_lpi_list(struct kvm *kvm, struct kvm_vcpu *vcpu, u32 **intid_ptr)
353356
return -ENOMEM;
354357

355358
raw_spin_lock_irqsave(&dist->lpi_list_lock, flags);
356-
list_for_each_entry(irq, &dist->lpi_list_head, lpi_list) {
359+
rcu_read_lock();
360+
361+
xas_for_each(&xas, irq, GIC_LPI_MAX_INTID) {
357362
if (i == irq_count)
358363
break;
359364
/* We don't need to "get" the IRQ, as we hold the list lock. */
360365
if (vcpu && irq->target_vcpu != vcpu)
361366
continue;
362367
intids[i++] = irq->intid;
363368
}
369+
370+
rcu_read_unlock();
364371
raw_spin_unlock_irqrestore(&dist->lpi_list_lock, flags);
365372

366373
*intid_ptr = intids;

0 commit comments

Comments
 (0)