aboutsummaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2014-07-08 07:09:05 -0400
committerChristoffer Dall <christoffer.dall@linaro.org>2014-09-18 21:48:57 -0400
commit5fb66da64064d0cb8dcce4cc8bf4cb1b921b13a0 (patch)
tree2c7bccc3459029a9c55bd356fcdbe68369bf4acc /virt
parentc3c918361adcceb816c92b21dd95d2b46fb96a8f (diff)
arm/arm64: KVM: vgic: kill VGIC_NR_IRQS
Nuke VGIC_NR_IRQS entierly, now that the distributor instance contains the number of IRQ allocated to this GIC. Also add VGIC_NR_IRQS_LEGACY to preserve the current API. Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/arm/vgic.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 973eaf7ebe98..725d829ad1d9 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -439,7 +439,7 @@ static bool handle_mmio_misc(struct kvm_vcpu *vcpu,
439 439
440 case 4: /* GICD_TYPER */ 440 case 4: /* GICD_TYPER */
441 reg = (atomic_read(&vcpu->kvm->online_vcpus) - 1) << 5; 441 reg = (atomic_read(&vcpu->kvm->online_vcpus) - 1) << 5;
442 reg |= (VGIC_NR_IRQS >> 5) - 1; 442 reg |= (vcpu->kvm->arch.vgic.nr_irqs >> 5) - 1;
443 vgic_reg_access(mmio, &reg, word_offset, 443 vgic_reg_access(mmio, &reg, word_offset,
444 ACCESS_READ_VALUE | ACCESS_WRITE_IGNORED); 444 ACCESS_READ_VALUE | ACCESS_WRITE_IGNORED);
445 break; 445 break;
@@ -1277,13 +1277,14 @@ static void vgic_retire_disabled_irqs(struct kvm_vcpu *vcpu)
1277static bool vgic_queue_irq(struct kvm_vcpu *vcpu, u8 sgi_source_id, int irq) 1277static bool vgic_queue_irq(struct kvm_vcpu *vcpu, u8 sgi_source_id, int irq)
1278{ 1278{
1279 struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; 1279 struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
1280 struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
1280 struct vgic_lr vlr; 1281 struct vgic_lr vlr;
1281 int lr; 1282 int lr;
1282 1283
1283 /* Sanitize the input... */ 1284 /* Sanitize the input... */
1284 BUG_ON(sgi_source_id & ~7); 1285 BUG_ON(sgi_source_id & ~7);
1285 BUG_ON(sgi_source_id && irq >= VGIC_NR_SGIS); 1286 BUG_ON(sgi_source_id && irq >= VGIC_NR_SGIS);
1286 BUG_ON(irq >= VGIC_NR_IRQS); 1287 BUG_ON(irq >= dist->nr_irqs);
1287 1288
1288 kvm_debug("Queue IRQ%d\n", irq); 1289 kvm_debug("Queue IRQ%d\n", irq);
1289 1290
@@ -1515,7 +1516,7 @@ static void __kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu)
1515 1516
1516 vlr = vgic_get_lr(vcpu, lr); 1517 vlr = vgic_get_lr(vcpu, lr);
1517 1518
1518 BUG_ON(vlr.irq >= VGIC_NR_IRQS); 1519 BUG_ON(vlr.irq >= dist->nr_irqs);
1519 vgic_cpu->vgic_irq_lr_map[vlr.irq] = LR_EMPTY; 1520 vgic_cpu->vgic_irq_lr_map[vlr.irq] = LR_EMPTY;
1520 } 1521 }
1521 1522
@@ -1737,7 +1738,7 @@ int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu)
1737 if (vcpu->vcpu_id >= dist->nr_cpus) 1738 if (vcpu->vcpu_id >= dist->nr_cpus)
1738 return -EBUSY; 1739 return -EBUSY;
1739 1740
1740 for (i = 0; i < VGIC_NR_IRQS; i++) { 1741 for (i = 0; i < dist->nr_irqs; i++) {
1741 if (i < VGIC_NR_PPIS) 1742 if (i < VGIC_NR_PPIS)
1742 vgic_bitmap_set_irq_val(&dist->irq_enabled, 1743 vgic_bitmap_set_irq_val(&dist->irq_enabled,
1743 vcpu->vcpu_id, i, 1); 1744 vcpu->vcpu_id, i, 1);
@@ -1802,7 +1803,11 @@ static int vgic_init_maps(struct kvm *kvm)
1802 int ret, i; 1803 int ret, i;
1803 1804
1804 nr_cpus = dist->nr_cpus = KVM_MAX_VCPUS; 1805 nr_cpus = dist->nr_cpus = KVM_MAX_VCPUS;
1805 nr_irqs = dist->nr_irqs = VGIC_NR_IRQS; 1806
1807 if (!dist->nr_irqs)
1808 dist->nr_irqs = VGIC_NR_IRQS_LEGACY;
1809
1810 nr_irqs = dist->nr_irqs;
1806 1811
1807 ret = vgic_init_bitmap(&dist->irq_enabled, nr_cpus, nr_irqs); 1812 ret = vgic_init_bitmap(&dist->irq_enabled, nr_cpus, nr_irqs);
1808 ret |= vgic_init_bitmap(&dist->irq_level, nr_cpus, nr_irqs); 1813 ret |= vgic_init_bitmap(&dist->irq_level, nr_cpus, nr_irqs);
@@ -1886,7 +1891,7 @@ int kvm_vgic_init(struct kvm *kvm)
1886 goto out; 1891 goto out;
1887 } 1892 }
1888 1893
1889 for (i = VGIC_NR_PRIVATE_IRQS; i < VGIC_NR_IRQS; i += 4) 1894 for (i = VGIC_NR_PRIVATE_IRQS; i < kvm->arch.vgic.nr_irqs; i += 4)
1890 vgic_set_target_reg(kvm, 0, i); 1895 vgic_set_target_reg(kvm, 0, i);
1891 1896
1892 kvm->arch.vgic.ready = true; 1897 kvm->arch.vgic.ready = true;