Skip to contentSkip to conversation

kvm-irqchip: only commit route when irqchip is used

PATCH Applied Peter Xu 2 participants 2 messages Aug 3, 2016

lore
Share & tools
lore

Peter Xu

author
#0 lore raw

PATCH v2 1/1 kvm-irqchip: only commit route when irqchip is used

Reported from Alexey Kardashevskiy:

3f1fea0fb5bf "kvm-irqchip: do explicit commit when update irq" produces a crash on pseries guest running with VFIO on POWER8 machine as it does not support KVM_CAP_IRQCHIP (KVM_CAP_IRQ_XICS is there instead). At the result, KVMState::irq_routes is NULL when VFIO calls kvm_irqchip_commit_routes.

This makes the routing update conditional.

---
 kvm-all.c | 8 ++++++++
 1 file changed, 8 insertions(+)
kvm-all.c +8 -0
index ef81ca5..65608de 100644
@@ -1047,6 +1047,14 @@ void kvm_irqchip_commit_routes(KVMState *s)
 {
     int ret;
 
+    if (kvm_gsi_direct_mapping()) {
+        return;
+    }
+
+    if (!kvm_gsi_routing_enabled()) {
+        return;
+    }
+
     s->irq_routes->flags = 0;
     trace_kvm_irqchip_commit_routes();
     ret = kvm_vm_ioctl(s, KVM_SET_GSI_ROUTING, s->irq_routes);
Signature · 1 line
2.7.4
Applied
#1 lore raw
Quoted 8 lines · Peter Xu

Reported from Alexey Kardashevskiy:

3f1fea0fb5bf "kvm-irqchip: do explicit commit when update irq" produces a crash on pseries guest running with VFIO on POWER8 machine as it does not support KVM_CAP_IRQCHIP (KVM_CAP_IRQ_XICS is there instead). At the result, KVMState::irq_routes is NULL when VFIO calls kvm_irqchip_commit_routes.

Quoted 5 lines

This makes the routing update conditional.

Applied to ppc-for-2.7, thanks.

Quoted 23 lines
---
 kvm-all.c | 8 ++++++++
 1 file changed, 8 insertions(+)
kvm-all.c +8 -0
index ef81ca5..65608de 100644
@@ -1047,6 +1047,14 @@ void kvm_irqchip_commit_routes(KVMState *s)
 {
     int ret;
 
+    if (kvm_gsi_direct_mapping()) {
+        return;
+    }
+
+    if (!kvm_gsi_routing_enabled()) {
+        return;
+    }
+
     s->irq_routes->flags = 0;
     trace_kvm_irqchip_commit_routes();
     ret = kvm_vm_ioctl(s, KVM_SET_GSI_ROUTING, s->irq_routes);
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson