qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 3/3] arm: implement query-gic-capability


From: Peter Xu
Subject: [Qemu-devel] [PATCH 3/3] arm: implement query-gic-capability
Date: Tue, 23 Feb 2016 18:52:08 +0800

For emulated ARM VM, only gicv2 is supported. We need to add gicv3 in
when emulated gicv3 ready. For KVM accelerated ARM VM, we detect the
capability bits using ioctls.

Signed-off-by: Peter Xu <address@hidden>
---
 target-arm/machine.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/target-arm/machine.c b/target-arm/machine.c
index 9e10232..7915096 100644
--- a/target-arm/machine.c
+++ b/target-arm/machine.c
@@ -1,3 +1,4 @@
+#include <linux/kvm.h>
 #include "qemu/osdep.h"
 #include "hw/hw.h"
 #include "hw/boards.h"
@@ -348,9 +349,38 @@ const char *gicv3_class_name(void)
     exit(1);
 }
 
+static GICTypeList *gic_capability_add(GICTypeList *head, GICType type)
+{
+    GICTypeList *item = g_new0(GICTypeList, 1);
+    item->value = type;
+    item->next = head;
+    return item;
+}
+
 GICTypeList *qmp_query_gic_capability(Error **errp);
 
 GICTypeList *qmp_query_gic_capability(Error **errp)
 {
-    return NULL;
+    /* We by default support emulated gicv2 */
+    GICTypeList *head = gic_capability_add(NULL, GIC_TYPE_GICV2);
+
+    /* TODO: add emulated gicv3 type when ready */
+
+#ifdef CONFIG_KVM
+    if (kvm_enabled()) {
+        /* Test KVM GICv2 */
+        if (kvm_create_device(kvm_state, KVM_DEV_TYPE_ARM_VGIC_V2,
+                              true) >= 0) {
+            head = gic_capability_add(head, GIC_TYPE_GICV2_KVM);
+        }
+
+        /* Test KVM GICv3 */
+        if (kvm_create_device(kvm_state, KVM_DEV_TYPE_ARM_VGIC_V3,
+                              true) >= 0) {
+            head = gic_capability_add(head, GIC_TYPE_GICV3_KVM);
+        }
+    }
+#endif
+
+    return head;
 }
-- 
2.4.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]