aboutsummaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorShannon Zhao <zhaoshenglong@huawei.com>2014-11-19 05:11:25 -0500
committerMarc Zyngier <marc.zyngier@arm.com>2014-11-26 05:19:37 -0500
commit016ed39c54b8a3db680e5c6a43419f806133caf2 (patch)
tree4395531d363a4e865df71f9bc689773341fb4c7b /virt
parentb1e952b4e484ebc9ffad674c361d261a1af02a13 (diff)
arm/arm64: KVM: vgic: kick the specific vcpu instead of iterating through 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>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/arm/vgic.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index 631a472e41cf..21e035cc5460 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -1607,7 +1607,7 @@ static int vgic_validate_injection(struct kvm_vcpu *vcpu, int irq, int level)
1607 } 1607 }
1608} 1608}
1609 1609
1610static bool vgic_update_irq_pending(struct kvm *kvm, int cpuid, 1610static int vgic_update_irq_pending(struct kvm *kvm, int cpuid,
1611 unsigned int irq_num, bool level) 1611 unsigned int irq_num, bool level)
1612{ 1612{
1613 struct vgic_dist *dist = &kvm->arch.vgic; 1613 struct vgic_dist *dist = &kvm->arch.vgic;
@@ -1673,7 +1673,7 @@ static bool vgic_update_irq_pending(struct kvm *kvm, int cpuid,
1673out: 1673out:
1674 spin_unlock(&dist->lock); 1674 spin_unlock(&dist->lock);
1675 1675
1676 return ret; 1676 return ret ? cpuid : -EINVAL;
1677} 1677}
1678 1678
1679/** 1679/**
@@ -1693,9 +1693,14 @@ out:
1693int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int irq_num, 1693int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int irq_num,
1694 bool level) 1694 bool level)
1695{ 1695{
1696 if (likely(vgic_initialized(kvm)) && 1696 int vcpu_id;
1697 vgic_update_irq_pending(kvm, cpuid, irq_num, level)) 1697
1698 vgic_kick_vcpus(kvm); 1698 if (likely(vgic_initialized(kvm))) {
1699 vcpu_id = vgic_update_irq_pending(kvm, cpuid, irq_num, level);
1700 if (vcpu_id >= 0)
1701 /* kick the specified vcpu */
1702 kvm_vcpu_kick(kvm_get_vcpu(kvm, vcpu_id));
1703 }
1699 1704
1700 return 0; 1705 return 0;
1701} 1706}