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,
Peter Xu <peterx@redhat.com>,
abologna@redhat.com, qemu-arm@nongnu.org
Subject: [Qemu-devel] [PATCH v2 3/3] arm: implement query-gic-capability
Date: Thu, 3 Mar 2016 16:21:12 +0800 [thread overview]
Message-ID: <1456993272-32292-4-git-send-email-peterx@redhat.com> (raw)
In-Reply-To: <1456993272-32292-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.
if we want to know GIC kernel capabilities, we need to make sure we have
enabled KVM when querying (like, with "-enable-kvm").
Signed-off-by: Peter Xu <peterx@redhat.com>
---
target-arm/machine.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 47 insertions(+), 1 deletion(-)
diff --git a/target-arm/machine.c b/target-arm/machine.c
index b3fa64c..98a4094 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"
@@ -346,9 +347,54 @@ const char *gicv3_class_name(void)
exit(1);
}
+static GICCapability *gic_cap_new(int version)
+{
+ GICCapability *cap = g_new0(GICCapability, 1);
+ cap->version = version;
+ /* by default, support none */
+ cap->emulated = false;
+ cap->kernel = false;
+ return cap;
+}
+
+static GICCapabilityList *gic_cap_list_add(GICCapabilityList *head,
+ GICCapability *cap)
+{
+ GICCapabilityList *item = g_new0(GICCapabilityList, 1);
+ item->value = cap;
+ item->next = head;
+ return item;
+}
+
GICCapabilityList *qmp_query_gic_capability(Error **errp);
GICCapabilityList *qmp_query_gic_capability(Error **errp)
{
- return NULL;
+ GICCapabilityList *head = NULL;
+ GICCapability *v2 = gic_cap_new(2), *v3 = gic_cap_new(3);
+
+ v2->emulated = true;
+ /* FIXME: we'd change to true after we get emulated GICv3 */
+ v3->emulated = false;
+
+#ifdef CONFIG_KVM
+ if (kvm_enabled()) {
+ /* Test KVM GICv2 */
+ if (kvm_create_device(kvm_state, KVM_DEV_TYPE_ARM_VGIC_V2,
+ true) >= 0) {
+ v2->kernel = true;
+ }
+
+ /* Test KVM GICv3 */
+ if (kvm_create_device(kvm_state, KVM_DEV_TYPE_ARM_VGIC_V3,
+ true) >= 0) {
+ v3->kernel = true;
+ }
+ }
+#endif
+
+ head = gic_cap_list_add(head, v2);
+ head = gic_cap_list_add(head, v3);
+
+ return head;
}
--
2.4.3
next prev parent reply other threads:[~2016-03-03 8:22 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-03 8:21 [Qemu-devel] [PATCH v2 0/3] ARM: add query-gic-capability SMP command Peter Xu
2016-03-03 8:21 ` [Qemu-devel] [PATCH v2 1/3] arm: qmp: add GICCapability struct Peter Xu
2016-03-03 8:21 ` [Qemu-devel] [PATCH v2 2/3] arm: qmp: add query-gic-capability interface Peter Xu
2016-03-03 11:55 ` Andrew Jones
2016-03-04 2:22 ` Peter Xu
2016-03-03 8:21 ` Peter Xu [this message]
2016-03-03 12:19 ` [Qemu-devel] [PATCH v2 3/3] arm: implement query-gic-capability Andrea Bolognani
2016-03-04 2:52 ` Peter Xu
2016-03-04 8:43 ` Andrea Bolognani
2016-03-07 4:27 ` Peter Xu
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=1456993272-32292-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-arm@nongnu.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).