From patchwork Tue Feb 23 10:52:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 586811 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9628414033E for ; Tue, 23 Feb 2016 21:54:31 +1100 (AEDT) Received: from localhost ([::1]:55974 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYAbs-0001hE-Ez for incoming@patchwork.ozlabs.org; Tue, 23 Feb 2016 05:54:28 -0500 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 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id 6F0A6627CF; Tue, 23 Feb 2016 10:52:48 +0000 (UTC) Received: from pxdev.xzpeter.org.com (vpn1-4-236.pek2.redhat.com [10.72.4.236]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u1NAqFHq019776; Tue, 23 Feb 2016 05:52:40 -0500 From: Peter Xu To: qemu-devel@nongnu.org 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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 23 Feb 2016 10:52:48 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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; }