Skip to content

Commit 720f73b

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: arm64: vgic-its: Walk LPI xarray in its_sync_lpi_pending_table()
The new LPI xarray makes it possible to walk the VM's LPIs without holding a lock, meaning that vgic_copy_lpi_list() is no longer necessary. Prepare for the deletion by walking the LPI xarray directly in its_sync_lpi_pending_table(). Signed-off-by: Oliver Upton <oliver.upton@linux.dev> Link: https://lore.kernel.org/r/20240422200158.2606761-3-oliver.upton@linux.dev Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent ea54dd3 commit 720f73b

1 file changed

Lines changed: 10 additions & 17 deletions

File tree

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

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -446,23 +446,18 @@ static u32 max_lpis_propbaser(u64 propbaser)
446446
static int its_sync_lpi_pending_table(struct kvm_vcpu *vcpu)
447447
{
448448
gpa_t pendbase = GICR_PENDBASER_ADDRESS(vcpu->arch.vgic_cpu.pendbaser);
449+
struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
450+
unsigned long intid, flags;
449451
struct vgic_irq *irq;
450452
int last_byte_offset = -1;
451453
int ret = 0;
452-
u32 *intids;
453-
int nr_irqs, i;
454-
unsigned long flags;
455454
u8 pendmask;
456455

457-
nr_irqs = vgic_copy_lpi_list(vcpu->kvm, vcpu, &intids);
458-
if (nr_irqs < 0)
459-
return nr_irqs;
460-
461-
for (i = 0; i < nr_irqs; i++) {
456+
xa_for_each(&dist->lpi_xa, intid, irq) {
462457
int byte_offset, bit_nr;
463458

464-
byte_offset = intids[i] / BITS_PER_BYTE;
465-
bit_nr = intids[i] % BITS_PER_BYTE;
459+
byte_offset = intid / BITS_PER_BYTE;
460+
bit_nr = intid % BITS_PER_BYTE;
466461

467462
/*
468463
* For contiguously allocated LPIs chances are we just read
@@ -472,25 +467,23 @@ static int its_sync_lpi_pending_table(struct kvm_vcpu *vcpu)
472467
ret = kvm_read_guest_lock(vcpu->kvm,
473468
pendbase + byte_offset,
474469
&pendmask, 1);
475-
if (ret) {
476-
kfree(intids);
470+
if (ret)
477471
return ret;
478-
}
472+
479473
last_byte_offset = byte_offset;
480474
}
481475

482-
irq = vgic_get_irq(vcpu->kvm, NULL, intids[i]);
476+
irq = vgic_get_irq(vcpu->kvm, NULL, intid);
483477
if (!irq)
484478
continue;
485479

486480
raw_spin_lock_irqsave(&irq->irq_lock, flags);
487-
irq->pending_latch = pendmask & (1U << bit_nr);
481+
if (irq->target_vcpu == vcpu)
482+
irq->pending_latch = pendmask & (1U << bit_nr);
488483
vgic_queue_irq_unlock(vcpu->kvm, irq, flags);
489484
vgic_put_irq(vcpu->kvm, irq);
490485
}
491486

492-
kfree(intids);
493-
494487
return ret;
495488
}
496489

0 commit comments

Comments
 (0)