From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 10.25.208.211 with SMTP id h202csp502088lfg; Thu, 24 Mar 2016 02:17:04 -0700 (PDT) X-Received: by 10.55.80.131 with SMTP id e125mr8985113qkb.62.1458811023828; Thu, 24 Mar 2016 02:17:03 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id u19si5781945qka.36.2016.03.24.02.17.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 24 Mar 2016 02:17:03 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from localhost ([::1]:48769 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj1O3-0008Vx-66 for alex.bennee@linaro.org; Thu, 24 Mar 2016 05:17:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33026) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj1O0-0008Vo-M2 for qemu-arm@nongnu.org; Thu, 24 Mar 2016 05:17:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aj1Nv-0004jp-M6 for qemu-arm@nongnu.org; Thu, 24 Mar 2016 05:17:00 -0400 Received: from mail-lb0-x235.google.com ([2a00:1450:4010:c04::235]:33819) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj1Nv-0004jf-DF; Thu, 24 Mar 2016 05:16:55 -0400 Received: by mail-lb0-x235.google.com with SMTP id k12so26294436lbb.1; Thu, 24 Mar 2016 02:16:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=iAncjgr1EQQFI2Zy+MQgMMDSLLoQXStIhO+CgVHrCBo=; b=r64Dhv8OCcWoiAkhwYzic0peHFMO3rLOxag0ZUwXOs7cU4hng0YvFNbL8MR6viSiPP FL5Lnm1p7sxdw6YO0gsXKcQGvfIsC6XXLDh/wNIGN/7t8JWFc/sQyc2s4K1ISLVUh4fm I96ZLx0PfjPOhSb6fERdaTKhqmTp73wwCBWqeW7t5snEnuYfZS9oLSmSw3Ux43uDZbdV XJkgNirFAgE1UbZzUUo6UGYYlNYLDFiMTJWApBcDsHwBaUBU0QAEAxpZ42qOrUJm3spW G1beQGMCWxQ2reX7t29aKK0r2gmyCX0+WEOLAmStfAOEBHTz+lw4GglAf1c7Fe7hCAWE nCLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=iAncjgr1EQQFI2Zy+MQgMMDSLLoQXStIhO+CgVHrCBo=; b=FwcsfGH4WRL4oMuuXJSC040gxlMIkM18oxZW8a9SHFiFXSXjkb6JVDC9dl5g0UyUj3 bosvHPmNjsIYPLNo4BtB03MqQCHhSZS7VypvX6oMF/cVYcVb02C881jE3VyX6RhR3pwl 8722titBtv3Ed1DArh2iZQwvSK7yFHGE+Gbit+V7PEpYdLvAY94wCkzqp7M5MpomI+GI 18dxW9wUCMimoUb5SwtFwDuSmFtFVGkvMAwnWzfKgTLyTmPil2dqOoZyZyD31wNff/tc D3SK/wfhKL8QziS4Bi2fO8e3csQaGLQqng3Y61zzuXSCvzikIaoaWYUcVyFNu16XPP9d 8lBQ== X-Gm-Message-State: AD7BkJL93IlBegba+j/tylZxSKvvOqPC8wJejTPD2Uhm+N5FfD2hOxXhCE1GRM66xSJ1iQ== X-Received: by 10.112.235.5 with SMTP id ui5mr3048687lbc.111.1458811014598; Thu, 24 Mar 2016 02:16:54 -0700 (PDT) Received: from [192.168.0.56] ([195.91.132.170]) by smtp.gmail.com with ESMTPSA id k137sm1077010lfg.16.2016.03.24.02.16.53 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 24 Mar 2016 02:16:53 -0700 (PDT) To: Peter Xu , qemu-devel@nongnu.org References: <1458788142-17509-1-git-send-email-peterx@redhat.com> <1458788142-17509-5-git-send-email-peterx@redhat.com> From: Sergey Fedorov Message-ID: <56F3B084.2050604@gmail.com> Date: Thu, 24 Mar 2016 12:16:52 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <1458788142-17509-5-git-send-email-peterx@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c04::235 Cc: peter.maydell@linaro.org, drjones@redhat.com, mdroth@linux.vnet.ibm.com, libvir-list@redhat.com, armbru@redhat.com, abologna@redhat.com, qemu-arm@nongnu.org, eblake@redhat.com, christoffer.dall@linaro.org Subject: Re: [Qemu-arm] [PATCH v7 4/4] arm: implement query-gic-capabilities X-BeenThere: qemu-arm@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-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: QMvOrv8tC6gt On 24/03/16 05:55, Peter Xu wrote: > For emulated GIC capabilities, currently only gicv2 is supported. We > need to add gicv3 in when emulated gicv3 ready. For KVM accelerated ARM > VM, we detect the capability bits by creating a scratch VM. > > Signed-off-by: Peter Xu Acked-by: Sergey Fedorov Kind regards, Sergey > --- > target-arm/monitor.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 57 insertions(+), 1 deletion(-) > > diff --git a/target-arm/monitor.c b/target-arm/monitor.c > index 4c9bef3..1ee59a2 100644 > --- a/target-arm/monitor.c > +++ b/target-arm/monitor.c > @@ -21,8 +21,64 @@ > */ > #include "qemu/osdep.h" > #include "qmp-commands.h" > +#include "hw/boards.h" > +#include "kvm_arm.h" > + > +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; > +} > + > +static inline void gic_cap_kvm_probe(GICCapability *v2, GICCapability *v3) > +{ > +#ifdef CONFIG_KVM > + int fdarray[3]; > + > + if (!kvm_arm_create_scratch_host_vcpu(NULL, fdarray, NULL)) { > + return; > + } > + > + /* Test KVM GICv2 */ > + if (kvm_device_supported(fdarray[1], KVM_DEV_TYPE_ARM_VGIC_V2)) { > + v2->kernel = true; > + } > + > + /* Test KVM GICv3 */ > + if (kvm_device_supported(fdarray[1], KVM_DEV_TYPE_ARM_VGIC_V3)) { > + v3->kernel = true; > + } > + > + kvm_arm_destroy_scratch_host_vcpu(fdarray); > +#endif > +} > > GICCapabilityList *qmp_query_gic_capabilities(Error **errp) > { > - return NULL; > + GICCapabilityList *head = NULL; > + GICCapability *v2 = gic_cap_new(2), *v3 = gic_cap_new(3); > + > + v2->emulated = true; > + /* TODO: we'd change to true after we get emulated GICv3. */ > + v3->emulated = false; > + > + gic_cap_kvm_probe(v2, v3); > + > + head = gic_cap_list_add(head, v2); > + head = gic_cap_list_add(head, v3); > + > + return head; > } From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aj1O5-00005u-OA for qemu-devel@nongnu.org; Thu, 24 Mar 2016 05:17:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aj1O1-0004mh-Mu for qemu-devel@nongnu.org; Thu, 24 Mar 2016 05:17:05 -0400 References: <1458788142-17509-1-git-send-email-peterx@redhat.com> <1458788142-17509-5-git-send-email-peterx@redhat.com> From: Sergey Fedorov Message-ID: <56F3B084.2050604@gmail.com> Date: Thu, 24 Mar 2016 12:16:52 +0300 MIME-Version: 1.0 In-Reply-To: <1458788142-17509-5-git-send-email-peterx@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH v7 4/4] arm: implement query-gic-capabilities List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Xu , qemu-devel@nongnu.org Cc: wei@redhat.com, peter.maydell@linaro.org, drjones@redhat.com, mdroth@linux.vnet.ibm.com, libvir-list@redhat.com, armbru@redhat.com, abologna@redhat.com, qemu-arm@nongnu.org, christoffer.dall@linaro.org On 24/03/16 05:55, Peter Xu wrote: > For emulated GIC capabilities, currently only gicv2 is supported. We > need to add gicv3 in when emulated gicv3 ready. For KVM accelerated ARM > VM, we detect the capability bits by creating a scratch VM. > > Signed-off-by: Peter Xu Acked-by: Sergey Fedorov Kind regards, Sergey > --- > target-arm/monitor.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 57 insertions(+), 1 deletion(-) > > diff --git a/target-arm/monitor.c b/target-arm/monitor.c > index 4c9bef3..1ee59a2 100644 > --- a/target-arm/monitor.c > +++ b/target-arm/monitor.c > @@ -21,8 +21,64 @@ > */ > #include "qemu/osdep.h" > #include "qmp-commands.h" > +#include "hw/boards.h" > +#include "kvm_arm.h" > + > +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; > +} > + > +static inline void gic_cap_kvm_probe(GICCapability *v2, GICCapability *v3) > +{ > +#ifdef CONFIG_KVM > + int fdarray[3]; > + > + if (!kvm_arm_create_scratch_host_vcpu(NULL, fdarray, NULL)) { > + return; > + } > + > + /* Test KVM GICv2 */ > + if (kvm_device_supported(fdarray[1], KVM_DEV_TYPE_ARM_VGIC_V2)) { > + v2->kernel = true; > + } > + > + /* Test KVM GICv3 */ > + if (kvm_device_supported(fdarray[1], KVM_DEV_TYPE_ARM_VGIC_V3)) { > + v3->kernel = true; > + } > + > + kvm_arm_destroy_scratch_host_vcpu(fdarray); > +#endif > +} > > GICCapabilityList *qmp_query_gic_capabilities(Error **errp) > { > - return NULL; > + GICCapabilityList *head = NULL; > + GICCapability *v2 = gic_cap_new(2), *v3 = gic_cap_new(3); > + > + v2->emulated = true; > + /* TODO: we'd change to true after we get emulated GICv3. */ > + v3->emulated = false; > + > + gic_cap_kvm_probe(v2, v3); > + > + head = gic_cap_list_add(head, v2); > + head = gic_cap_list_add(head, v3); > + > + return head; > }