aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm
diff options
context:
space:
mode:
authorChristoffer Dall <christoffer.dall@arm.com>2018-07-16 09:06:21 -0400
committerMarc Zyngier <marc.zyngier@arm.com>2018-07-21 11:02:24 -0400
commit8df3c8f33f46adbaa811c0d57fb1d7eb421b88a9 (patch)
tree57a41a550b2236a994df36f54a23d095d17e07d5 /virt/kvm
parentdd6251e463d3d8ea55ac2c5944e24bd6ed8f423b (diff)
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 <drjones@redhat.com> Signed-off-by: Christoffer Dall <christoffer.dall@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'virt/kvm')
-rw-r--r--virt/kvm/arm/vgic/vgic-debug.c8
-rw-r--r--virt/kvm/arm/vgic/vgic-init.c19
-rw-r--r--virt/kvm/arm/vgic/vgic-its.c1
3 files changed, 23 insertions, 5 deletions
diff --git a/virt/kvm/arm/vgic/vgic-debug.c b/virt/kvm/arm/vgic/vgic-debug.c
index 9279e35fefb1..07aa900bac56 100644
--- a/virt/kvm/arm/vgic/vgic-debug.c
+++ b/virt/kvm/arm/vgic/vgic-debug.c
@@ -166,6 +166,7 @@ static void print_dist_state(struct seq_file *s, struct vgic_dist *dist)
166 166
167 seq_printf(s, "P=pending_latch, L=line_level, A=active\n"); 167 seq_printf(s, "P=pending_latch, L=line_level, A=active\n");
168 seq_printf(s, "E=enabled, H=hw, C=config (level=1, edge=0)\n"); 168 seq_printf(s, "E=enabled, H=hw, C=config (level=1, edge=0)\n");
169 seq_printf(s, "G=group\n");
169} 170}
170 171
171static void print_header(struct seq_file *s, struct vgic_irq *irq, 172static 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,
180 } 181 }
181 182
182 seq_printf(s, "\n"); 183 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, "%s%2d TYP ID TGT_ID PLAEHCG HWID TARGET SRC PRI VCPU_ID\n", hdr, id);
184 seq_printf(s, "---------------------------------------------------------------\n"); 185 seq_printf(s, "----------------------------------------------------------------\n");
185} 186}
186 187
187static void print_irq_state(struct seq_file *s, struct vgic_irq *irq, 188static 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,
202 203
203 seq_printf(s, " %s %4d " 204 seq_printf(s, " %s %4d "
204 " %2d " 205 " %2d "
205 "%d%d%d%d%d%d " 206 "%d%d%d%d%d%d%d "
206 "%8d " 207 "%8d "
207 "%8x " 208 "%8x "
208 " %2x " 209 " %2x "
@@ -217,6 +218,7 @@ static void print_irq_state(struct seq_file *s, struct vgic_irq *irq,
217 irq->enabled, 218 irq->enabled,
218 irq->hw, 219 irq->hw,
219 irq->config == VGIC_CONFIG_LEVEL, 220 irq->config == VGIC_CONFIG_LEVEL,
221 irq->group,
220 irq->hwintid, 222 irq->hwintid,
221 irq->mpidr, 223 irq->mpidr,
222 irq->source, 224 irq->source,
diff --git a/virt/kvm/arm/vgic/vgic-init.c b/virt/kvm/arm/vgic/vgic-init.c
index 230c9221fe70..a7c19cda5835 100644
--- a/virt/kvm/arm/vgic/vgic-init.c
+++ b/virt/kvm/arm/vgic/vgic-init.c
@@ -175,10 +175,13 @@ static int kvm_vgic_dist_init(struct kvm *kvm, unsigned int nr_spis)
175 irq->vcpu = NULL; 175 irq->vcpu = NULL;
176 irq->target_vcpu = vcpu0; 176 irq->target_vcpu = vcpu0;
177 kref_init(&irq->refcount); 177 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) {
179 irq->targets = 0; 179 irq->targets = 0;
180 else 180 irq->group = 0;
181 } else {
181 irq->mpidr = 0; 182 irq->mpidr = 0;
183 irq->group = 1;
184 }
182 } 185 }
183 return 0; 186 return 0;
184} 187}
@@ -227,6 +230,18 @@ int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu)
227 /* PPIs */ 230 /* PPIs */
228 irq->config = VGIC_CONFIG_LEVEL; 231 irq->config = VGIC_CONFIG_LEVEL;
229 } 232 }
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;
230 } 245 }
231 246
232 if (!irqchip_in_kernel(vcpu->kvm)) 247 if (!irqchip_in_kernel(vcpu->kvm))
diff --git a/virt/kvm/arm/vgic/vgic-its.c b/virt/kvm/arm/vgic/vgic-its.c
index cee2c3c5519c..12502251727e 100644
--- a/virt/kvm/arm/vgic/vgic-its.c
+++ b/virt/kvm/arm/vgic/vgic-its.c
@@ -71,6 +71,7 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid,
71 kref_init(&irq->refcount); 71 kref_init(&irq->refcount);
72 irq->intid = intid; 72 irq->intid = intid;
73 irq->target_vcpu = vcpu; 73 irq->target_vcpu = vcpu;
74 irq->group = 1;
74 75
75 spin_lock_irqsave(&dist->lpi_list_lock, flags); 76 spin_lock_irqsave(&dist->lpi_list_lock, flags);
76 77