Skip to content

Commit 39084ba

Browse files
ouptonMarc Zyngier
authored andcommitted
KVM: arm64: vgic-v3: Reinterpret user ISPENDR writes as I{C,S}PENDR
User writes to ISPENDR for GICv3 are treated specially, as zeroes actually clear the pending state for interrupts (unlike HW). Reimplement it using the ISPENDR and ICPENDR user accessors. Signed-off-by: Oliver Upton <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 5618514 commit 39084ba

File tree

1 file changed

+5
-30
lines changed

1 file changed

+5
-30
lines changed

arch/arm64/kvm/vgic/vgic-mmio-v3.c

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -357,38 +357,13 @@ static int vgic_v3_uaccess_write_pending(struct kvm_vcpu *vcpu,
357357
gpa_t addr, unsigned int len,
358358
unsigned long val)
359359
{
360-
u32 intid = VGIC_ADDR_TO_INTID(addr, 1);
361-
int i;
362-
unsigned long flags;
363-
364-
for (i = 0; i < len * 8; i++) {
365-
struct vgic_irq *irq = vgic_get_irq(vcpu->kvm, vcpu, intid + i);
366-
367-
raw_spin_lock_irqsave(&irq->irq_lock, flags);
368-
369-
/*
370-
* pending_latch is set irrespective of irq type
371-
* (level or edge) to avoid dependency that VM should
372-
* restore irq config before pending info.
373-
*/
374-
irq->pending_latch = test_bit(i, &val);
375-
376-
if (irq->hw && vgic_irq_is_sgi(irq->intid)) {
377-
irq_set_irqchip_state(irq->host_irq,
378-
IRQCHIP_STATE_PENDING,
379-
irq->pending_latch);
380-
irq->pending_latch = false;
381-
}
382-
383-
if (irq->pending_latch)
384-
vgic_queue_irq_unlock(vcpu->kvm, irq, flags);
385-
else
386-
raw_spin_unlock_irqrestore(&irq->irq_lock, flags);
360+
int ret;
387361

388-
vgic_put_irq(vcpu->kvm, irq);
389-
}
362+
ret = vgic_uaccess_write_spending(vcpu, addr, len, val);
363+
if (ret)
364+
return ret;
390365

391-
return 0;
366+
return vgic_uaccess_write_cpending(vcpu, addr, len, ~val);
392367
}
393368

394369
/* We want to avoid outer shareable. */

0 commit comments

Comments
 (0)