Skip to content

Commit

Permalink
ARM: KVM: vgic: simplify vgic_get_target_reg
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Gleb Natapov <[email protected]>
  • Loading branch information
Marc Zyngier authored and Gleb Natapov committed Aug 30, 2013
1 parent a9f6cf9 commit 986af8e
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions virt/kvm/arm/vgic.c
Original file line number Diff line number Diff line change
Expand Up @@ -432,19 +432,13 @@ static bool handle_mmio_priority_reg(struct kvm_vcpu *vcpu,
static u32 vgic_get_target_reg(struct kvm *kvm, int irq)
{
struct vgic_dist *dist = &kvm->arch.vgic;
struct kvm_vcpu *vcpu;
int i, c;
unsigned long *bmap;
int i;
u32 val = 0;

irq -= VGIC_NR_PRIVATE_IRQS;

kvm_for_each_vcpu(c, vcpu, kvm) {
bmap = vgic_bitmap_get_shared_map(&dist->irq_spi_target[c]);
for (i = 0; i < GICD_IRQS_PER_ITARGETSR; i++)
if (test_bit(irq + i, bmap))
val |= 1 << (c + i * 8);
}
for (i = 0; i < GICD_IRQS_PER_ITARGETSR; i++)
val |= 1 << (dist->irq_spi_cpu[irq + i] + i * 8);

return val;
}
Expand Down

0 comments on commit 986af8e

Please sign in to comment.