Skip to content

Commit 6249f2a

Browse files
author
Marc Zyngier
committed
KVM: arm/arm64: vgic-v3: Add core support for Group0 SGIs
Although vgic-v3 now supports Group0 interrupts, it still doesn't deal with Group0 SGIs. As usually with the GIC, nothing is simple: - ICC_SGI1R can signal SGIs of both groups, since GICD_CTLR.DS==1 with KVM (as per 8.1.10, Non-secure EL1 access) - ICC_SGI0R can only generate Group0 SGIs - ICC_ASGI1R sees its scope refocussed to generate only Group0 SGIs (as per the note at the bottom of Table 8-14) We only support Group1 SGIs so far, so no material change. Reviewed-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Christoffer Dall <christoffer.dall@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
1 parent e22fa39 commit 6249f2a

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

arch/arm/kvm/coproc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ static bool access_gic_sgi(struct kvm_vcpu *vcpu,
253253
reg = (u64)*vcpu_reg(vcpu, p->Rt2) << 32;
254254
reg |= *vcpu_reg(vcpu, p->Rt1) ;
255255

256-
vgic_v3_dispatch_sgi(vcpu, reg);
256+
vgic_v3_dispatch_sgi(vcpu, reg, true);
257257

258258
return true;
259259
}

arch/arm64/kvm/sys_regs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ static bool access_gic_sgi(struct kvm_vcpu *vcpu,
255255
if (!p->is_write)
256256
return read_from_write_only(vcpu, p, r);
257257

258-
vgic_v3_dispatch_sgi(vcpu, p->regval);
258+
vgic_v3_dispatch_sgi(vcpu, p->regval, true);
259259

260260
return true;
261261
}

include/kvm/arm_vgic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ void kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu);
373373
void kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu);
374374
void kvm_vgic_reset_mapped_irq(struct kvm_vcpu *vcpu, u32 vintid);
375375

376-
void vgic_v3_dispatch_sgi(struct kvm_vcpu *vcpu, u64 reg);
376+
void vgic_v3_dispatch_sgi(struct kvm_vcpu *vcpu, u64 reg, bool allow_group1);
377377

378378
/**
379379
* kvm_vgic_get_max_vcpus - Get the maximum number of VCPUs allowed by HW

virt/kvm/arm/vgic/vgic-mmio-v3.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,8 @@ static int match_mpidr(u64 sgi_aff, u16 sgi_cpu_mask, struct kvm_vcpu *vcpu)
900900
/**
901901
* vgic_v3_dispatch_sgi - handle SGI requests from VCPUs
902902
* @vcpu: The VCPU requesting a SGI
903-
* @reg: The value written into the ICC_SGI1R_EL1 register by that VCPU
903+
* @reg: The value written into ICC_{ASGI1,SGI0,SGI1}R by that VCPU
904+
* @allow_group1: Does the sysreg access allow generation of G1 SGIs
904905
*
905906
* With GICv3 (and ARE=1) CPUs trigger SGIs by writing to a system register.
906907
* This will trap in sys_regs.c and call this function.
@@ -910,7 +911,7 @@ static int match_mpidr(u64 sgi_aff, u16 sgi_cpu_mask, struct kvm_vcpu *vcpu)
910911
* check for matching ones. If this bit is set, we signal all, but not the
911912
* calling VCPU.
912913
*/
913-
void vgic_v3_dispatch_sgi(struct kvm_vcpu *vcpu, u64 reg)
914+
void vgic_v3_dispatch_sgi(struct kvm_vcpu *vcpu, u64 reg, bool allow_group1)
914915
{
915916
struct kvm *kvm = vcpu->kvm;
916917
struct kvm_vcpu *c_vcpu;
@@ -959,9 +960,19 @@ void vgic_v3_dispatch_sgi(struct kvm_vcpu *vcpu, u64 reg)
959960
irq = vgic_get_irq(vcpu->kvm, c_vcpu, sgi);
960961

961962
spin_lock_irqsave(&irq->irq_lock, flags);
962-
irq->pending_latch = true;
963963

964-
vgic_queue_irq_unlock(vcpu->kvm, irq, flags);
964+
/*
965+
* An access targetting Group0 SGIs can only generate
966+
* those, while an access targetting Group1 SGIs can
967+
* generate interrupts of either group.
968+
*/
969+
if (!irq->group || allow_group1) {
970+
irq->pending_latch = true;
971+
vgic_queue_irq_unlock(vcpu->kvm, irq, flags);
972+
} else {
973+
spin_unlock_irqrestore(&irq->irq_lock, flags);
974+
}
975+
965976
vgic_put_irq(vcpu->kvm, irq);
966977
}
967978
}

0 commit comments

Comments
 (0)