kvm: Decouple 'GSI routing' from 'kernel irqchip'
authorPeter Maydell <peter.maydell@linaro.org>
Thu, 26 Jul 2012 14:35:16 +0000 (15:35 +0100)
committerAvi Kivity <avi@redhat.com>
Thu, 9 Aug 2012 13:16:57 +0000 (16:16 +0300)
Don't assume having an in-kernel irqchip means that GSI
routing is enabled.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Avi Kivity <avi@redhat.com>
kvm-all.c
kvm-stub.c
kvm.h
target-i386/kvm.c

index b9a613ee1502c0775cb344d4cfa8f4376da3e6a9..34b02c1fba4435179392ff4f99f2336d312b407a 100644 (file)
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -103,6 +103,7 @@ bool kvm_kernel_irqchip;
 bool kvm_async_interrupts_allowed;
 bool kvm_irqfds_allowed;
 bool kvm_msi_via_irqfd_allowed;
+bool kvm_gsi_routing_allowed;
 
 static const KVMCapabilityInfo kvm_required_capabilites[] = {
     KVM_CAP_INFO(USER_MEMORY),
@@ -1099,7 +1100,7 @@ int kvm_irqchip_add_msi_route(KVMState *s, MSIMessage msg)
     struct kvm_irq_routing_entry kroute;
     int virq;
 
-    if (!kvm_irqchip_in_kernel()) {
+    if (!kvm_gsi_routing_enabled()) {
         return -ENOSYS;
     }
 
index 158bb7bee8059cbda5da00585a9d88672075cb3f..94c9ea15b031d0a518f9cfbbcfad3681864a726c 100644 (file)
@@ -22,6 +22,7 @@ bool kvm_kernel_irqchip;
 bool kvm_async_interrupts_allowed;
 bool kvm_irqfds_allowed;
 bool kvm_msi_via_irqfd_allowed;
+bool kvm_gsi_routing_allowed;
 
 int kvm_init_vcpu(CPUArchState *env)
 {
diff --git a/kvm.h b/kvm.h
index 34d32c7ccdd6f01d17c27742a1d4d26c2677d194..444ed2e704810bf7c285ee0b0b6f3c1f6fcc32a5 100644 (file)
--- a/kvm.h
+++ b/kvm.h
@@ -27,6 +27,7 @@ extern bool kvm_kernel_irqchip;
 extern bool kvm_async_interrupts_allowed;
 extern bool kvm_irqfds_allowed;
 extern bool kvm_msi_via_irqfd_allowed;
+extern bool kvm_gsi_routing_allowed;
 
 #if defined CONFIG_KVM || !defined NEED_CPU_H
 #define kvm_enabled()           (kvm_allowed)
@@ -60,12 +61,21 @@ extern bool kvm_msi_via_irqfd_allowed;
  */
 #define kvm_msi_via_irqfd_enabled() (kvm_msi_via_irqfd_allowed)
 
+/**
+ * kvm_gsi_routing_enabled:
+ *
+ * Returns: true if GSI routing is enabled (ie the kernel supports
+ * it and we're running in a configuration that permits it).
+ */
+#define kvm_gsi_routing_enabled() (kvm_gsi_routing_allowed)
+
 #else
 #define kvm_enabled()           (0)
 #define kvm_irqchip_in_kernel() (false)
 #define kvm_async_interrupts_enabled() (false)
 #define kvm_irqfds_enabled() (false)
 #define kvm_msi_via_irqfd_enabled() (false)
+#define kvm_gsi_routing_allowed() (false)
 #endif
 
 struct kvm_run;
index 7a874ea73bb3d11c3e07b682a872c38d6bce0c99..696b14a04acad069b4e9a7ecb4dff8b5483d75fd 100644 (file)
@@ -2049,8 +2049,9 @@ void kvm_arch_init_irq_routing(KVMState *s)
     }
     /* We know at this point that we're using the in-kernel
      * irqchip, so we can use irqfds, and on x86 we know
-     * we can use msi via irqfd.
+     * we can use msi via irqfd and GSI routing.
      */
     kvm_irqfds_allowed = true;
     kvm_msi_via_irqfd_allowed = true;
+    kvm_gsi_routing_allowed = true;
 }