Skip to content

Commit 5fb66da

Browse files
Marc Zyngierchazy
authored andcommitted
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>
1 parent c3c9183 commit 5fb66da

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

‎include/kvm/arm_vgic.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <linux/spinlock.h>
2626
#include <linux/types.h>
2727

28-
#define VGIC_NR_IRQS 256
28+
#define VGIC_NR_IRQS_LEGACY 256
2929
#define VGIC_NR_SGIS 16
3030
#define VGIC_NR_PPIS 16
3131
#define VGIC_NR_PRIVATE_IRQS (VGIC_NR_SGIS + VGIC_NR_PPIS)
@@ -39,11 +39,11 @@
3939
#error Invalid number of CPU interfaces
4040
#endif
4141

42-
#if (VGIC_NR_IRQS & 31)
42+
#if (VGIC_NR_IRQS_LEGACY & 31)
4343
#error "VGIC_NR_IRQS must be a multiple of 32"
4444
#endif
4545

46-
#if (VGIC_NR_IRQS > VGIC_MAX_IRQS)
46+
#if (VGIC_NR_IRQS_LEGACY > VGIC_MAX_IRQS)
4747
#error "VGIC_NR_IRQS must be <= 1024"
4848
#endif
4949

‎virt/kvm/arm/vgic.c‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ static bool handle_mmio_misc(struct kvm_vcpu *vcpu,
439439

440440
case 4: /* GICD_TYPER */
441441
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;
443443
vgic_reg_access(mmio, &reg, word_offset,
444444
ACCESS_READ_VALUE | ACCESS_WRITE_IGNORED);
445445
break;
@@ -1277,13 +1277,14 @@ static void vgic_retire_disabled_irqs(struct kvm_vcpu *vcpu)
12771277
static bool vgic_queue_irq(struct kvm_vcpu *vcpu, u8 sgi_source_id, int irq)
12781278
{
12791279
struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
1280+
struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
12801281
struct vgic_lr vlr;
12811282
int lr;
12821283

12831284
/* Sanitize the input... */
12841285
BUG_ON(sgi_source_id & ~7);
12851286
BUG_ON(sgi_source_id && irq >= VGIC_NR_SGIS);
1286-
BUG_ON(irq >= VGIC_NR_IRQS);
1287+
BUG_ON(irq >= dist->nr_irqs);
12871288

12881289
kvm_debug("Queue IRQ%d\n", irq);
12891290

@@ -1515,7 +1516,7 @@ static void __kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu)
15151516

15161517
vlr = vgic_get_lr(vcpu, lr);
15171518

1518-
BUG_ON(vlr.irq >= VGIC_NR_IRQS);
1519+
BUG_ON(vlr.irq >= dist->nr_irqs);
15191520
vgic_cpu->vgic_irq_lr_map[vlr.irq] = LR_EMPTY;
15201521
}
15211522

@@ -1737,7 +1738,7 @@ int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu)
17371738
if (vcpu->vcpu_id >= dist->nr_cpus)
17381739
return -EBUSY;
17391740

1740-
for (i = 0; i < VGIC_NR_IRQS; i++) {
1741+
for (i = 0; i < dist->nr_irqs; i++) {
17411742
if (i < VGIC_NR_PPIS)
17421743
vgic_bitmap_set_irq_val(&dist->irq_enabled,
17431744
vcpu->vcpu_id, i, 1);
@@ -1802,7 +1803,11 @@ static int vgic_init_maps(struct kvm *kvm)
18021803
int ret, i;
18031804

18041805
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;
18061811

18071812
ret = vgic_init_bitmap(&dist->irq_enabled, nr_cpus, nr_irqs);
18081813
ret |= vgic_init_bitmap(&dist->irq_level, nr_cpus, nr_irqs);
@@ -1886,7 +1891,7 @@ int kvm_vgic_init(struct kvm *kvm)
18861891
goto out;
18871892
}
18881893

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)
18901895
vgic_set_target_reg(kvm, 0, i);
18911896

18921897
kvm->arch.vgic.ready = true;

0 commit comments

Comments
 (0)