diff options
author | Marc Zyngier <marc.zyngier@arm.com> | 2014-07-08 07:09:02 -0400 |
---|---|---|
committer | Christoffer Dall <christoffer.dall@linaro.org> | 2014-09-18 21:48:56 -0400 |
commit | fb65ab63b8cae510ea1e43e68b5da2f9980aa6d5 (patch) | |
tree | 65b921f5021b04afdc09cdd64498d115ce1fb6dd /virt | |
parent | c1bfb577addd4867a82c4f235824a315d5afb94a (diff) |
arm/arm64: KVM: vgic: Parametrize VGIC_NR_SHARED_IRQS
Having a dynamic number of supported interrupts means that we
cannot relly on VGIC_NR_SHARED_IRQS being fixed anymore.
Instead, make it take the distributor structure as a parameter,
so it can return the right value.
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.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 08db8764496a..7d64dc242afc 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c | |||
@@ -1086,11 +1086,17 @@ static void vgic_dispatch_sgi(struct kvm_vcpu *vcpu, u32 reg) | |||
1086 | } | 1086 | } |
1087 | } | 1087 | } |
1088 | 1088 | ||
1089 | static int vgic_nr_shared_irqs(struct vgic_dist *dist) | ||
1090 | { | ||
1091 | return dist->nr_irqs - VGIC_NR_PRIVATE_IRQS; | ||
1092 | } | ||
1093 | |||
1089 | static int compute_pending_for_cpu(struct kvm_vcpu *vcpu) | 1094 | static int compute_pending_for_cpu(struct kvm_vcpu *vcpu) |
1090 | { | 1095 | { |
1091 | struct vgic_dist *dist = &vcpu->kvm->arch.vgic; | 1096 | struct vgic_dist *dist = &vcpu->kvm->arch.vgic; |
1092 | unsigned long *pending, *enabled, *pend_percpu, *pend_shared; | 1097 | unsigned long *pending, *enabled, *pend_percpu, *pend_shared; |
1093 | unsigned long pending_private, pending_shared; | 1098 | unsigned long pending_private, pending_shared; |
1099 | int nr_shared = vgic_nr_shared_irqs(dist); | ||
1094 | int vcpu_id; | 1100 | int vcpu_id; |
1095 | 1101 | ||
1096 | vcpu_id = vcpu->vcpu_id; | 1102 | vcpu_id = vcpu->vcpu_id; |
@@ -1103,15 +1109,15 @@ static int compute_pending_for_cpu(struct kvm_vcpu *vcpu) | |||
1103 | 1109 | ||
1104 | pending = vgic_bitmap_get_shared_map(&dist->irq_pending); | 1110 | pending = vgic_bitmap_get_shared_map(&dist->irq_pending); |
1105 | enabled = vgic_bitmap_get_shared_map(&dist->irq_enabled); | 1111 | enabled = vgic_bitmap_get_shared_map(&dist->irq_enabled); |
1106 | bitmap_and(pend_shared, pending, enabled, VGIC_NR_SHARED_IRQS); | 1112 | bitmap_and(pend_shared, pending, enabled, nr_shared); |
1107 | bitmap_and(pend_shared, pend_shared, | 1113 | bitmap_and(pend_shared, pend_shared, |
1108 | vgic_bitmap_get_shared_map(&dist->irq_spi_target[vcpu_id]), | 1114 | vgic_bitmap_get_shared_map(&dist->irq_spi_target[vcpu_id]), |
1109 | VGIC_NR_SHARED_IRQS); | 1115 | nr_shared); |
1110 | 1116 | ||
1111 | pending_private = find_first_bit(pend_percpu, VGIC_NR_PRIVATE_IRQS); | 1117 | pending_private = find_first_bit(pend_percpu, VGIC_NR_PRIVATE_IRQS); |
1112 | pending_shared = find_first_bit(pend_shared, VGIC_NR_SHARED_IRQS); | 1118 | pending_shared = find_first_bit(pend_shared, nr_shared); |
1113 | return (pending_private < VGIC_NR_PRIVATE_IRQS || | 1119 | return (pending_private < VGIC_NR_PRIVATE_IRQS || |
1114 | pending_shared < VGIC_NR_SHARED_IRQS); | 1120 | pending_shared < vgic_nr_shared_irqs(dist)); |
1115 | } | 1121 | } |
1116 | 1122 | ||
1117 | /* | 1123 | /* |
@@ -1368,7 +1374,7 @@ static void __kvm_vgic_flush_hwstate(struct kvm_vcpu *vcpu) | |||
1368 | } | 1374 | } |
1369 | 1375 | ||
1370 | /* SPIs */ | 1376 | /* SPIs */ |
1371 | for_each_set_bit(i, vgic_cpu->pending_shared, VGIC_NR_SHARED_IRQS) { | 1377 | for_each_set_bit(i, vgic_cpu->pending_shared, vgic_nr_shared_irqs(dist)) { |
1372 | if (!vgic_queue_hwirq(vcpu, i + VGIC_NR_PRIVATE_IRQS)) | 1378 | if (!vgic_queue_hwirq(vcpu, i + VGIC_NR_PRIVATE_IRQS)) |
1373 | overflow = 1; | 1379 | overflow = 1; |
1374 | } | 1380 | } |