Skip to content

Commit

Permalink
arm/arm64: KVM: vgic: kick the specific vcpu instead of iterating thr…
Browse files Browse the repository at this point in the history
…ough all

When call kvm_vgic_inject_irq to inject interrupt, we can known which
vcpu the interrupt for by the irq_num and the cpuid. So we should just
kick this vcpu to avoid iterating through all.

Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
  • Loading branch information
shannonz88 authored and Marc Zyngier committed Nov 26, 2014
1 parent b1e952b commit 016ed39
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions virt/kvm/arm/vgic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1607,7 +1607,7 @@ static int vgic_validate_injection(struct kvm_vcpu *vcpu, int irq, int level)
}
}

static bool vgic_update_irq_pending(struct kvm *kvm, int cpuid,
static int vgic_update_irq_pending(struct kvm *kvm, int cpuid,
unsigned int irq_num, bool level)
{
struct vgic_dist *dist = &kvm->arch.vgic;
Expand Down Expand Up @@ -1673,7 +1673,7 @@ static bool vgic_update_irq_pending(struct kvm *kvm, int cpuid,
out:
spin_unlock(&dist->lock);

return ret;
return ret ? cpuid : -EINVAL;
}

/**
Expand All @@ -1693,9 +1693,14 @@ static bool vgic_update_irq_pending(struct kvm *kvm, int cpuid,
int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int irq_num,
bool level)
{
if (likely(vgic_initialized(kvm)) &&
vgic_update_irq_pending(kvm, cpuid, irq_num, level))
vgic_kick_vcpus(kvm);
int vcpu_id;

if (likely(vgic_initialized(kvm))) {
vcpu_id = vgic_update_irq_pending(kvm, cpuid, irq_num, level);
if (vcpu_id >= 0)
/* kick the specified vcpu */
kvm_vcpu_kick(kvm_get_vcpu(kvm, vcpu_id));
}

return 0;
}
Expand Down

0 comments on commit 016ed39

Please sign in to comment.