aboutsummaryrefslogtreecommitdiffstats
path: root/virt
diff options
context:
space:
mode:
authorChristoffer Dall <christoffer.dall@linaro.org>2014-12-09 08:35:33 -0500
committerChristoffer Dall <christoffer.dall@linaro.org>2014-12-15 05:36:21 -0500
commitca7d9c829d419c06e450afa5f785d58198c37caa (patch)
tree04f7fd0e5f7e6469c93056534cf5142cfa80ef3b /virt
parent716139df2517fbc3f2306dbe8eba0fa88dca0189 (diff)
arm/arm64: KVM: Initialize the vgic on-demand when injecting IRQs
Userspace assumes that it can wire up IRQ injections after having created all VCPUs and after having created the VGIC, but potentially before starting the first VCPU. This can currently lead to lost IRQs because the state of that IRQ injection is not stored anywhere and we don't return an error to userspace. We haven't seen this problem manifest itself yet, presumably because guests reset the devices on boot, but this could cause issues with migration and other non-standard startup configurations. Reviewed-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>
Diffstat (limited to 'virt')
-rw-r--r--virt/kvm/arm/vgic.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c
index d862ea502167..e373b76c5420 100644
--- a/virt/kvm/arm/vgic.c
+++ b/virt/kvm/arm/vgic.c
@@ -1694,16 +1694,26 @@ out:
1694int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int irq_num, 1694int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int irq_num,
1695 bool level) 1695 bool level)
1696{ 1696{
1697 int ret = 0;
1697 int vcpu_id; 1698 int vcpu_id;
1698 1699
1699 if (likely(vgic_ready(kvm))) { 1700 if (unlikely(!vgic_initialized(kvm))) {
1700 vcpu_id = vgic_update_irq_pending(kvm, cpuid, irq_num, level); 1701 mutex_lock(&kvm->lock);
1701 if (vcpu_id >= 0) 1702 ret = vgic_init(kvm);
1702 /* kick the specified vcpu */ 1703 mutex_unlock(&kvm->lock);
1703 kvm_vcpu_kick(kvm_get_vcpu(kvm, vcpu_id)); 1704
1705 if (ret)
1706 goto out;
1704 } 1707 }
1705 1708
1706 return 0; 1709 vcpu_id = vgic_update_irq_pending(kvm, cpuid, irq_num, level);
1710 if (vcpu_id >= 0) {
1711 /* kick the specified vcpu */
1712 kvm_vcpu_kick(kvm_get_vcpu(kvm, vcpu_id));
1713 }
1714
1715out:
1716 return ret;
1707} 1717}
1708 1718
1709static irqreturn_t vgic_maintenance_handler(int irq, void *data) 1719static irqreturn_t vgic_maintenance_handler(int irq, void *data)