提交 5fb66da6 编写于 作者: M Marc Zyngier 提交者: Christoffer Dall

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: NChristoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: NMarc Zyngier <marc.zyngier@arm.com>
上级 c3c91836
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/types.h> #include <linux/types.h>
#define VGIC_NR_IRQS 256 #define VGIC_NR_IRQS_LEGACY 256
#define VGIC_NR_SGIS 16 #define VGIC_NR_SGIS 16
#define VGIC_NR_PPIS 16 #define VGIC_NR_PPIS 16
#define VGIC_NR_PRIVATE_IRQS (VGIC_NR_SGIS + VGIC_NR_PPIS) #define VGIC_NR_PRIVATE_IRQS (VGIC_NR_SGIS + VGIC_NR_PPIS)
...@@ -39,11 +39,11 @@ ...@@ -39,11 +39,11 @@
#error Invalid number of CPU interfaces #error Invalid number of CPU interfaces
#endif #endif
#if (VGIC_NR_IRQS & 31) #if (VGIC_NR_IRQS_LEGACY & 31)
#error "VGIC_NR_IRQS must be a multiple of 32" #error "VGIC_NR_IRQS must be a multiple of 32"
#endif #endif
#if (VGIC_NR_IRQS > VGIC_MAX_IRQS) #if (VGIC_NR_IRQS_LEGACY > VGIC_MAX_IRQS)
#error "VGIC_NR_IRQS must be <= 1024" #error "VGIC_NR_IRQS must be <= 1024"
#endif #endif
......
...@@ -439,7 +439,7 @@ static bool handle_mmio_misc(struct kvm_vcpu *vcpu, ...@@ -439,7 +439,7 @@ static bool handle_mmio_misc(struct kvm_vcpu *vcpu,
case 4: /* GICD_TYPER */ case 4: /* GICD_TYPER */
reg = (atomic_read(&vcpu->kvm->online_vcpus) - 1) << 5; reg = (atomic_read(&vcpu->kvm->online_vcpus) - 1) << 5;
reg |= (VGIC_NR_IRQS >> 5) - 1; reg |= (vcpu->kvm->arch.vgic.nr_irqs >> 5) - 1;
vgic_reg_access(mmio, &reg, word_offset, vgic_reg_access(mmio, &reg, word_offset,
ACCESS_READ_VALUE | ACCESS_WRITE_IGNORED); ACCESS_READ_VALUE | ACCESS_WRITE_IGNORED);
break; break;
...@@ -1277,13 +1277,14 @@ static void vgic_retire_disabled_irqs(struct kvm_vcpu *vcpu) ...@@ -1277,13 +1277,14 @@ static void vgic_retire_disabled_irqs(struct kvm_vcpu *vcpu)
static bool vgic_queue_irq(struct kvm_vcpu *vcpu, u8 sgi_source_id, int irq) static bool vgic_queue_irq(struct kvm_vcpu *vcpu, u8 sgi_source_id, int irq)
{ {
struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu; struct vgic_cpu *vgic_cpu = &vcpu->arch.vgic_cpu;
struct vgic_dist *dist = &vcpu->kvm->arch.vgic;
struct vgic_lr vlr; struct vgic_lr vlr;
int lr; int lr;
/* Sanitize the input... */ /* Sanitize the input... */
BUG_ON(sgi_source_id & ~7); BUG_ON(sgi_source_id & ~7);
BUG_ON(sgi_source_id && irq >= VGIC_NR_SGIS); BUG_ON(sgi_source_id && irq >= VGIC_NR_SGIS);
BUG_ON(irq >= VGIC_NR_IRQS); BUG_ON(irq >= dist->nr_irqs);
kvm_debug("Queue IRQ%d\n", irq); kvm_debug("Queue IRQ%d\n", irq);
...@@ -1515,7 +1516,7 @@ static void __kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu) ...@@ -1515,7 +1516,7 @@ static void __kvm_vgic_sync_hwstate(struct kvm_vcpu *vcpu)
vlr = vgic_get_lr(vcpu, lr); vlr = vgic_get_lr(vcpu, lr);
BUG_ON(vlr.irq >= VGIC_NR_IRQS); BUG_ON(vlr.irq >= dist->nr_irqs);
vgic_cpu->vgic_irq_lr_map[vlr.irq] = LR_EMPTY; vgic_cpu->vgic_irq_lr_map[vlr.irq] = LR_EMPTY;
} }
...@@ -1737,7 +1738,7 @@ int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu) ...@@ -1737,7 +1738,7 @@ int kvm_vgic_vcpu_init(struct kvm_vcpu *vcpu)
if (vcpu->vcpu_id >= dist->nr_cpus) if (vcpu->vcpu_id >= dist->nr_cpus)
return -EBUSY; return -EBUSY;
for (i = 0; i < VGIC_NR_IRQS; i++) { for (i = 0; i < dist->nr_irqs; i++) {
if (i < VGIC_NR_PPIS) if (i < VGIC_NR_PPIS)
vgic_bitmap_set_irq_val(&dist->irq_enabled, vgic_bitmap_set_irq_val(&dist->irq_enabled,
vcpu->vcpu_id, i, 1); vcpu->vcpu_id, i, 1);
...@@ -1802,7 +1803,11 @@ static int vgic_init_maps(struct kvm *kvm) ...@@ -1802,7 +1803,11 @@ static int vgic_init_maps(struct kvm *kvm)
int ret, i; int ret, i;
nr_cpus = dist->nr_cpus = KVM_MAX_VCPUS; nr_cpus = dist->nr_cpus = KVM_MAX_VCPUS;
nr_irqs = dist->nr_irqs = VGIC_NR_IRQS;
if (!dist->nr_irqs)
dist->nr_irqs = VGIC_NR_IRQS_LEGACY;
nr_irqs = dist->nr_irqs;
ret = vgic_init_bitmap(&dist->irq_enabled, nr_cpus, nr_irqs); ret = vgic_init_bitmap(&dist->irq_enabled, nr_cpus, nr_irqs);
ret |= vgic_init_bitmap(&dist->irq_level, nr_cpus, nr_irqs); ret |= vgic_init_bitmap(&dist->irq_level, nr_cpus, nr_irqs);
...@@ -1886,7 +1891,7 @@ int kvm_vgic_init(struct kvm *kvm) ...@@ -1886,7 +1891,7 @@ int kvm_vgic_init(struct kvm *kvm)
goto out; goto out;
} }
for (i = VGIC_NR_PRIVATE_IRQS; i < VGIC_NR_IRQS; i += 4) for (i = VGIC_NR_PRIVATE_IRQS; i < kvm->arch.vgic.nr_irqs; i += 4)
vgic_set_target_reg(kvm, 0, i); vgic_set_target_reg(kvm, 0, i);
kvm->arch.vgic.ready = true; kvm->arch.vgic.ready = true;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册