From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55984) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYAaK-0007EN-7E for qemu-devel@nongnu.org; Tue, 23 Feb 2016 05:52:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYAaH-0001f9-1C for qemu-devel@nongnu.org; Tue, 23 Feb 2016 05:52:52 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39624) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYAaG-0001f4-Sl for qemu-devel@nongnu.org; Tue, 23 Feb 2016 05:52:48 -0500 From: Peter Xu Date: Tue, 23 Feb 2016 18:52:08 +0800 Message-Id: <1456224728-28163-4-git-send-email-peterx@redhat.com> In-Reply-To: <1456224728-28163-1-git-send-email-peterx@redhat.com> References: <1456224728-28163-1-git-send-email-peterx@redhat.com> Subject: [Qemu-devel] [PATCH 3/3] arm: implement query-gic-capability List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 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 --- 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 #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