Skip to content

Commit aa075b0

Browse files
christofferdall-armMarc Zyngier
authored andcommitted
KVM: arm/arm64: vgic: Keep track of implementation revision
As we are about to tweak implementation aspects of the VGIC emulation, while still preserving some level of backwards compatibility support, add a field to keep track of the implementation revision field which is reported to the VM and to userspace. Reviewed-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Christoffer Dall <christoffer.dall@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
1 parent a2dca21 commit aa075b0

4 files changed

Lines changed: 12 additions & 4 deletions

File tree

‎include/kvm/arm_vgic.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,9 @@ struct vgic_dist {
217217
/* vGIC model the kernel emulates for the guest (GICv2 or GICv3) */
218218
u32 vgic_model;
219219

220+
/* Implementation revision as reported in the GICD_IIDR */
221+
u32 implementation_rev;
222+
220223
/* Do injected MSIs require an additional device ID? */
221224
bool msis_require_devid;
222225

‎virt/kvm/arm/vgic/vgic-init.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ int vgic_init(struct kvm *kvm)
298298

299299
vgic_debug_init(kvm);
300300

301+
dist->implementation_rev = 0;
301302
dist->initialized = true;
302303

303304
out:

‎virt/kvm/arm/vgic/vgic-mmio-v2.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,21 @@
2525
static unsigned long vgic_mmio_read_v2_misc(struct kvm_vcpu *vcpu,
2626
gpa_t addr, unsigned int len)
2727
{
28+
struct vgic_dist *vgic = &vcpu->kvm->arch.vgic;
2829
u32 value;
2930

3031
switch (addr & 0x0c) {
3132
case GIC_DIST_CTRL:
32-
value = vcpu->kvm->arch.vgic.enabled ? GICD_ENABLE : 0;
33+
value = vgic->enabled ? GICD_ENABLE : 0;
3334
break;
3435
case GIC_DIST_CTR:
35-
value = vcpu->kvm->arch.vgic.nr_spis + VGIC_NR_PRIVATE_IRQS;
36+
value = vgic->nr_spis + VGIC_NR_PRIVATE_IRQS;
3637
value = (value >> 5) - 1;
3738
value |= (atomic_read(&vcpu->kvm->online_vcpus) - 1) << 5;
3839
break;
3940
case GIC_DIST_IIDR:
4041
value = (PRODUCT_ID_KVM << GICD_IIDR_PRODUCT_ID_SHIFT) |
42+
(vgic->implementation_rev << GICD_IIDR_REVISION_SHIFT) |
4143
(IMPLEMENTER_ARM << GICD_IIDR_IMPLEMENTER_SHIFT);
4244
break;
4345
default:

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,17 @@ bool vgic_supports_direct_msis(struct kvm *kvm)
6262
static unsigned long vgic_mmio_read_v3_misc(struct kvm_vcpu *vcpu,
6363
gpa_t addr, unsigned int len)
6464
{
65+
struct vgic_dist *vgic = &vcpu->kvm->arch.vgic;
6566
u32 value = 0;
6667

6768
switch (addr & 0x0c) {
6869
case GICD_CTLR:
69-
if (vcpu->kvm->arch.vgic.enabled)
70+
if (vgic->enabled)
7071
value |= GICD_CTLR_ENABLE_SS_G1;
7172
value |= GICD_CTLR_ARE_NS | GICD_CTLR_DS;
7273
break;
7374
case GICD_TYPER:
74-
value = vcpu->kvm->arch.vgic.nr_spis + VGIC_NR_PRIVATE_IRQS;
75+
value = vgic->nr_spis + VGIC_NR_PRIVATE_IRQS;
7576
value = (value >> 5) - 1;
7677
if (vgic_has_its(vcpu->kvm)) {
7778
value |= (INTERRUPT_ID_BITS_ITS - 1) << 19;
@@ -82,6 +83,7 @@ static unsigned long vgic_mmio_read_v3_misc(struct kvm_vcpu *vcpu,
8283
break;
8384
case GICD_IIDR:
8485
value = (PRODUCT_ID_KVM << GICD_IIDR_PRODUCT_ID_SHIFT) |
86+
(vgic->implementation_rev << GICD_IIDR_REVISION_SHIFT) |
8587
(IMPLEMENTER_ARM << GICD_IIDR_IMPLEMENTER_SHIFT);
8688
break;
8789
default:

0 commit comments

Comments
 (0)