qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: qemu-devel@nongnu.org
Cc: wei@redhat.com, peter.maydell@linaro.org, drjones@redhat.com,
	mdroth@linux.vnet.ibm.com, armbru@redhat.com, peterx@redhat.com,
	abologna@redhat.com
Subject: [Qemu-devel] [PATCH 3/3] arm: implement query-gic-capability
Date: Tue, 23 Feb 2016 18:52:08 +0800	[thread overview]
Message-ID: <1456224728-28163-4-git-send-email-peterx@redhat.com> (raw)
In-Reply-To: <1456224728-28163-1-git-send-email-peterx@redhat.com>

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 <peterx@redhat.com>
---
 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

      parent reply	other threads:[~2016-02-23 10:52 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-23 10:52 [Qemu-devel] [PATCH 0/3] ARM: add query-gic-capability SMP command Peter Xu
2016-02-23 10:52 ` [Qemu-devel] [PATCH 1/3] arm: gic: add GICType Peter Xu
2016-03-01 14:20   ` Andrea Bolognani
2016-03-02  3:34     ` Peter Xu
2016-03-02  7:15       ` Peter Xu
2016-03-02  9:47         ` Markus Armbruster
2016-03-02 10:55           ` Peter Xu
2016-03-02 13:59             ` Markus Armbruster
2016-03-03  4:27               ` Peter Xu
2016-03-03  6:34                 ` Markus Armbruster
2016-03-03  6:58                   ` Peter Xu
2016-03-01 16:46   ` Eric Blake
2016-03-02  4:55     ` Peter Xu
2016-02-23 10:52 ` [Qemu-devel] [PATCH 2/3] arm: gic: add "query-gic-capability" interface Peter Xu
2016-02-23 10:52 ` Peter Xu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1456224728-28163-4-git-send-email-peterx@redhat.com \
    --to=peterx@redhat.com \
    --cc=abologna@redhat.com \
    --cc=armbru@redhat.com \
    --cc=drjones@redhat.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=wei@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).