aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm/arm/vgic.c
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2013-08-29 06:08:22 -0400
committerGleb Natapov <gleb@redhat.com>2013-08-30 09:03:07 -0400
commit986af8e0789a41ac4844e6eefed4a33e86524918 (patch)
tree1f4471fa52051d9fce4077c53bbc25ad0debda62 /virt/kvm/arm/vgic.c
parenta9f6cf965e00dd3370229417675eb0127d580f96 (diff)
ARM: KVM: vgic: simplify vgic_get_target_reg
vgic_get_target_reg is quite complicated, for no good reason. Actually, it is fairly easy to write it in a much more efficient way by using the target CPU array instead of the bitmap. Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Gleb Natapov <gleb@redhat.com>
Diffstat (limited to 'virt/kvm/arm/vgic.c')
-rw-r--r--virt/kvm/arm/vgic.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 17c5ac7d10ed..a2d478aec046 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -432,19 +432,13 @@ static bool handle_mmio_priority_reg(struct kvm_vcpu *vcpu,
432static u32 vgic_get_target_reg(struct kvm *kvm, int irq) 432static u32 vgic_get_target_reg(struct kvm *kvm, int irq)
433{ 433{
434 struct vgic_dist *dist = &kvm->arch.vgic; 434 struct vgic_dist *dist = &kvm->arch.vgic;
435 struct kvm_vcpu *vcpu; 435 int i;
436 int i, c;
437 unsigned long *bmap;
438 u32 val = 0; 436 u32 val = 0;
439 437
440 irq -= VGIC_NR_PRIVATE_IRQS; 438 irq -= VGIC_NR_PRIVATE_IRQS;
441 439
442 kvm_for_each_vcpu(c, vcpu, kvm) { 440 for (i = 0; i < GICD_IRQS_PER_ITARGETSR; i++)
443 bmap = vgic_bitmap_get_shared_map(&dist->irq_spi_target[c]); 441 val |= 1 << (dist->irq_spi_cpu[irq + i] + i * 8);
444 for (i = 0; i < GICD_IRQS_PER_ITARGETSR; i++)
445 if (test_bit(irq + i, bmap))
446 val |= 1 << (c + i * 8);
447 }
448 442
449 return val; 443 return val;
450} 444}