Skip to content

Commit 8df3c8f

Browse files
christofferdall-armMarc Zyngier
authored andcommitted
KVM: arm/arm64: vgic: Add group field to struct irq
In preparation for proper group 0 and group 1 support in the vgic, we add a field in the struct irq to store the group of all interrupts. We initialize the group to group 0 when emulating GICv2 and to group 1 when emulating GICv3, just like we treat them today. LPIs are always group 1. We also continue to ignore writes from the guest, preserving existing functionality, for now. Finally, we also add this field to the vgic debug logic to show the group for all interrupts. Reviewed-by: Andrew Jones <[email protected]> Signed-off-by: Christoffer Dall <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent dd6251e commit 8df3c8f

File tree

4 files changed

+24
-5
lines changed

4 files changed

+24
-5
lines changed

include/kvm/arm_vgic.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ struct vgic_irq {
133133
u8 source; /* GICv2 SGIs only */
134134
u8 active_source; /* GICv2 SGIs only */
135135
u8 priority;
136+
u8 group; /* 0 == group 0, 1 == group 1 */
136137
enum vgic_irq_config config; /* Level or edge */
137138

138139
/*

virt/kvm/arm/vgic/vgic-debug.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ static void print_dist_state(struct seq_file *s, struct vgic_dist *dist)
166166

167167
seq_printf(s, "P=pending_latch, L=line_level, A=active\n");
168168
seq_printf(s, "E=enabled, H=hw, C=config (level=1, edge=0)\n");
169+
seq_printf(s, "G=group\n");
169170
}
170171

171172
static void print_header(struct seq_file *s, struct vgic_irq *irq,
@@ -180,8 +181,8 @@ static void print_header(struct seq_file *s, struct vgic_irq *irq,
180181
}
181182

182183
seq_printf(s, "\n");
183-
seq_printf(s, "%s%2d TYP ID TGT_ID PLAEHC HWID TARGET SRC PRI VCPU_ID\n", hdr, id);
184-
seq_printf(s, "---------------------------------------------------------------\n");
184+
seq_printf(s, "%s%2d TYP ID TGT_ID PLAEHCG HWID TARGET SRC PRI VCPU_ID\n", hdr, id);
185+
seq_printf(s, "----------------------------------------------------------------\n");
185186
}
186187

187188
static void print_irq_state(struct seq_file *s, struct vgic_irq *irq,
@@ -202,7 +203,7 @@ static void print_irq_state(struct seq_file *s, struct vgic_irq *irq,
202203

203204
seq_printf(s, " %s %4d "
204205
" %2d "
205-
"%d%d%d%d%d%d "
206+
"%d%d%d%d%d%d%d "
206207
"%8d "
207208
"%8x "
208209
" %2x "
@@ -217,6 +218,7 @@ static void print_irq_state(struct seq_file *s, struct vgic_irq *irq,
217218
irq->enabled,
218219
irq->hw,
219220
irq->config == VGIC_CONFIG_LEVEL,
221+
irq->group,
220222
irq->hwintid,
221223
irq->mpidr,
222224
irq->source,

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,13 @@ static int kvm_vgic_dist_init(struct kvm *kvm, unsigned int nr_spis)
175175
irq->vcpu = NULL;
176176
irq->target_vcpu = vcpu0;
177177
kref_init(&irq->refcount);
178-
if (dist->vgic_model == KVM_DEV_TYPE_ARM_VGIC_V2)
178+
if (dist->vgic_model == KVM_DEV_TYPE_ARM_VGIC_V2) {
179179
irq->targets = 0;
180-
else
180+
irq->group = 0;
181+
} else {
181182
irq->mpidr = 0;
183+
irq->group = 1;
184+
}
182185
}
183186
return 0;
184187
}
@@ -227,6 +230,18 @@ int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu)
227230
/* PPIs */
228231
irq->config = VGIC_CONFIG_LEVEL;
229232
}
233+
234+
/*
235+
* GICv3 can only be created via the KVM_DEVICE_CREATE API and
236+
* so we always know the emulation type at this point as it's
237+
* either explicitly configured as GICv3, or explicitly
238+
* configured as GICv2, or not configured yet which also
239+
* implies GICv2.
240+
*/
241+
if (dist->vgic_model == KVM_DEV_TYPE_ARM_VGIC_V3)
242+
irq->group = 1;
243+
else
244+
irq->group = 0;
230245
}
231246

232247
if (!irqchip_in_kernel(vcpu->kvm))

virt/kvm/arm/vgic/vgic-its.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid,
7171
kref_init(&irq->refcount);
7272
irq->intid = intid;
7373
irq->target_vcpu = vcpu;
74+
irq->group = 1;
7475

7576
spin_lock_irqsave(&dist->lpi_list_lock, flags);
7677

0 commit comments

Comments
 (0)