summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShannon Zhao <zhaoshenglong@huawei.com>2015-05-04 09:25:15 +0800
committerSasha Levin <sasha.levin@oracle.com>2015-05-11 07:07:33 -0400
commitd4d53f72fa6bcb4a92a134bed97b07ea3e154840 (patch)
tree6ca61d1447c22f9887aa1f99ab7fe2f7deff4e7e
parentc0a5bdaba1bc306b9fe5f69813948efc6f6396b4 (diff)
downloadlwn-d4d53f72fa6bcb4a92a134bed97b07ea3e154840.tar.gz
lwn-d4d53f72fa6bcb4a92a134bed97b07ea3e154840.zip
arm/arm64: KVM: vgic: kick the specific vcpu instead of iterating through all
commit 016ed39c54b8a3db680e5c6a43419f806133caf2 upstream. 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> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
-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 91e6bfc9a5cf..12c10f26901f 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -1608,7 +1608,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;
@@ -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;
}
/**
@@ -1693,9 +1693,14 @@ out:
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;
}