From patchwork Wed Mar 11 11:16:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 1252794 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ZNPfoxs9; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48cqDv47Vwz9sPg for ; Wed, 11 Mar 2020 22:17:34 +1100 (AEDT) Received: from localhost ([::1]:49732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBzMh-0001wm-V2 for incoming@patchwork.ozlabs.org; Wed, 11 Mar 2020 07:17:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55507) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBzLw-0001di-0D for qemu-devel@nongnu.org; Wed, 11 Mar 2020 07:16:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBzLv-0000FN-0R for qemu-devel@nongnu.org; Wed, 11 Mar 2020 07:16:43 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:25152 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBzLu-0000Ez-Tu for qemu-devel@nongnu.org; Wed, 11 Mar 2020 07:16:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583925402; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ciFZ44sKcymmMsByHtfMv1caU+62zP76aEdlZZZJYII=; b=ZNPfoxs9z3p9lv4cKO4FtRwVBDtomvcB3H6ESEqUDtTCFlQ96CjXU3Qg2O6N6GR3Mt79UZ 3wk3MpYVR62IOpHqMfs1G4vkG23BreYHxD+sbnoRBop/lnhKm2uUZJgrnYABpwQtuKH2w/ D6KMVLBRaeV72MGH9eK+v/EC6Ql2imQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-477-YHHCSZh3OEq2zOIzMWW7ng-1; Wed, 11 Mar 2020 07:16:41 -0400 X-MC-Unique: YHHCSZh3OEq2zOIzMWW7ng-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AB707100550E; Wed, 11 Mar 2020 11:16:39 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.36.118.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1ECFC92D24; Wed, 11 Mar 2020 11:16:36 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org Subject: [PATCH v4 1/6] hw/arm/virt: Document 'max' value in gic-version property description Date: Wed, 11 Mar 2020 12:16:21 +0100 Message-Id: <20200311111626.5705-2-eric.auger@redhat.com> In-Reply-To: <20200311111626.5705-1-eric.auger@redhat.com> References: <20200311111626.5705-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: maz@kernel.org, drjones@redhat.com, richard.henderson@linaro.org, philmd@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Mention 'max' value in the gic-version property description. Signed-off-by: Eric Auger Reviewed-by: Richard Henderson Reviewed-by: Andrew Jones --- hw/arm/virt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 32d865a488..7c38c6c7f9 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2146,7 +2146,8 @@ static void virt_instance_init(Object *obj) virt_set_gic_version, NULL); object_property_set_description(obj, "gic-version", "Set GIC version. " - "Valid values are 2, 3 and host", NULL); + "Valid values are 2, 3, host and max", + NULL); vms->highmem_ecam = !vmc->no_highmem_ecam; From patchwork Wed Mar 11 11:16:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 1252796 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=K4RwkzDO; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48cqF56DrPz9sPg for ; Wed, 11 Mar 2020 22:17:45 +1100 (AEDT) Received: from localhost ([::1]:49752 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBzMt-0002Rp-M9 for incoming@patchwork.ozlabs.org; Wed, 11 Mar 2020 07:17:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55550) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBzM2-0001pt-B6 for qemu-devel@nongnu.org; Wed, 11 Mar 2020 07:16:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBzM0-0000HU-R8 for qemu-devel@nongnu.org; Wed, 11 Mar 2020 07:16:50 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:54005 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBzM0-0000HI-Nn for qemu-devel@nongnu.org; Wed, 11 Mar 2020 07:16:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583925408; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NWsKxrm6MCuJ+bbq6H3eDVrINh3UM09rwzqXJQV8W0o=; b=K4RwkzDOJ+k3TOrx09CHVMz9xyYWnlFfOwH/XC5/IBV2gEiLD8yWjTyKvzqG3g16fSy712 L0Pcrlmy3kgUNLEXYmCdzq/wm7iVmZPMSxBWquiZp9bPXr+vnOSXp9R1q2eOrFja6p2B1X 7Q9JUvoFp0MvDZa9ixVjEPWD/nbTMqg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-110-dPuseGGWPSqa1v8NwhXdxg-1; Wed, 11 Mar 2020 07:16:44 -0400 X-MC-Unique: dPuseGGWPSqa1v8NwhXdxg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 74CC4800D48; Wed, 11 Mar 2020 11:16:43 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.36.118.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 41F2791D91; Wed, 11 Mar 2020 11:16:39 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org Subject: [PATCH v4 2/6] hw/arm/virt: Introduce VirtGICType enum type Date: Wed, 11 Mar 2020 12:16:22 +0100 Message-Id: <20200311111626.5705-3-eric.auger@redhat.com> In-Reply-To: <20200311111626.5705-1-eric.auger@redhat.com> References: <20200311111626.5705-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: maz@kernel.org, drjones@redhat.com, richard.henderson@linaro.org, philmd@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" We plan to introduce yet another value for the gic version (nosel). As we already use exotic values such as 0 and -1, let's introduce a dedicated enum type and let vms->gic_version take this type. Signed-off-by: Eric Auger Reviewed-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Andrew Jones --- v3 -> v4: - added R-bs v2 -> v3: - replaced defines by enum VirtGICType - use that new type for vms->gic_version --- include/hw/arm/virt.h | 11 +++++++++-- hw/arm/virt.c | 30 +++++++++++++++--------------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 02f500cb8e..c0827cacdf 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -95,6 +95,13 @@ typedef enum VirtIOMMUType { VIRT_IOMMU_VIRTIO, } VirtIOMMUType; +typedef enum VirtGICType { + VIRT_GIC_VERSION_MAX, + VIRT_GIC_VERSION_HOST, + VIRT_GIC_VERSION_2, + VIRT_GIC_VERSION_3, +} VirtGICType; + typedef struct MemMapEntry { hwaddr base; hwaddr size; @@ -123,7 +130,7 @@ typedef struct { bool highmem_ecam; bool its; bool virt; - int32_t gic_version; + VirtGICType gic_version; VirtIOMMUType iommu; uint16_t virtio_iommu_bdf; struct arm_boot_info bootinfo; @@ -162,7 +169,7 @@ static inline int virt_gicv3_redist_region_count(VirtMachineState *vms) uint32_t redist0_capacity = vms->memmap[VIRT_GIC_REDIST].size / GICV3_REDIST_SIZE; - assert(vms->gic_version == 3); + assert(vms->gic_version == VIRT_GIC_VERSION_3); return vms->smp_cpus > redist0_capacity ? 2 : 1; } diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 7c38c6c7f9..4ed1f0cb2e 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -299,7 +299,7 @@ static void fdt_add_timer_nodes(const VirtMachineState *vms) irqflags = GIC_FDT_IRQ_FLAGS_EDGE_LO_HI; } - if (vms->gic_version == 2) { + if (vms->gic_version == VIRT_GIC_VERSION_2) { irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START, GIC_FDT_IRQ_PPI_CPU_WIDTH, (1 << vms->smp_cpus) - 1); @@ -440,7 +440,7 @@ static void fdt_add_gic_node(VirtMachineState *vms) qemu_fdt_setprop_cell(vms->fdt, nodename, "#address-cells", 0x2); qemu_fdt_setprop_cell(vms->fdt, nodename, "#size-cells", 0x2); qemu_fdt_setprop(vms->fdt, nodename, "ranges", NULL, 0); - if (vms->gic_version == 3) { + if (vms->gic_version == VIRT_GIC_VERSION_3) { int nb_redist_regions = virt_gicv3_redist_region_count(vms); qemu_fdt_setprop_string(vms->fdt, nodename, "compatible", @@ -519,7 +519,7 @@ static void fdt_add_pmu_nodes(const VirtMachineState *vms) } } - if (vms->gic_version == 2) { + if (vms->gic_version == VIRT_GIC_VERSION_2) { irqflags = deposit32(irqflags, GIC_FDT_IRQ_PPI_CPU_START, GIC_FDT_IRQ_PPI_CPU_WIDTH, (1 << vms->smp_cpus) - 1); @@ -1470,7 +1470,7 @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState *vms, int idx) * purposes are to make TCG consistent (with 64-bit KVM hosts) * and to improve SGI efficiency. */ - if (vms->gic_version == 3) { + if (vms->gic_version == VIRT_GIC_VERSION_3) { clustersz = GICV3_TARGETLIST_BITS; } else { clustersz = GIC_TARGETLIST_BITS; @@ -1561,15 +1561,15 @@ static void machvirt_init(MachineState *machine) /* We can probe only here because during property set * KVM is not available yet */ - if (vms->gic_version <= 0) { - /* "host" or "max" */ + if (vms->gic_version == VIRT_GIC_VERSION_HOST || + vms->gic_version == VIRT_GIC_VERSION_MAX) { if (!kvm_enabled()) { - if (vms->gic_version == 0) { + if (vms->gic_version == VIRT_GIC_VERSION_HOST) { error_report("gic-version=host requires KVM"); exit(1); } else { /* "max": currently means 3 for TCG */ - vms->gic_version = 3; + vms->gic_version = VIRT_GIC_VERSION_3; } } else { vms->gic_version = kvm_arm_vgic_probe(); @@ -1628,7 +1628,7 @@ static void machvirt_init(MachineState *machine) /* The maximum number of CPUs depends on the GIC version, or on how * many redistributors we can fit into the memory map. */ - if (vms->gic_version == 3) { + if (vms->gic_version == VIRT_GIC_VERSION_3) { virt_max_cpus = vms->memmap[VIRT_GIC_REDIST].size / GICV3_REDIST_SIZE; virt_max_cpus += @@ -1856,7 +1856,7 @@ static void virt_set_its(Object *obj, bool value, Error **errp) static char *virt_get_gic_version(Object *obj, Error **errp) { VirtMachineState *vms = VIRT_MACHINE(obj); - const char *val = vms->gic_version == 3 ? "3" : "2"; + const char *val = vms->gic_version == VIRT_GIC_VERSION_3 ? "3" : "2"; return g_strdup(val); } @@ -1866,13 +1866,13 @@ static void virt_set_gic_version(Object *obj, const char *value, Error **errp) VirtMachineState *vms = VIRT_MACHINE(obj); if (!strcmp(value, "3")) { - vms->gic_version = 3; + vms->gic_version = VIRT_GIC_VERSION_3; } else if (!strcmp(value, "2")) { - vms->gic_version = 2; + vms->gic_version = VIRT_GIC_VERSION_2; } else if (!strcmp(value, "host")) { - vms->gic_version = 0; /* Will probe later */ + vms->gic_version = VIRT_GIC_VERSION_HOST; /* Will probe later */ } else if (!strcmp(value, "max")) { - vms->gic_version = -1; /* Will probe later */ + vms->gic_version = VIRT_GIC_VERSION_MAX; /* Will probe later */ } else { error_setg(errp, "Invalid gic-version value"); error_append_hint(errp, "Valid values are 3, 2, host, max.\n"); @@ -2141,7 +2141,7 @@ static void virt_instance_init(Object *obj) "physical address space above 32 bits", NULL); /* Default GIC type is v2 */ - vms->gic_version = 2; + vms->gic_version = VIRT_GIC_VERSION_2; object_property_add_str(obj, "gic-version", virt_get_gic_version, virt_set_gic_version, NULL); object_property_set_description(obj, "gic-version", From patchwork Wed Mar 11 11:16:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 1252797 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=Qmk/zYSe; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48cqF630xKz9sPk for ; Wed, 11 Mar 2020 22:17:46 +1100 (AEDT) Received: from localhost ([::1]:49754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBzMu-0002SW-9P for incoming@patchwork.ozlabs.org; Wed, 11 Mar 2020 07:17:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55581) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBzM3-0001rw-PC for qemu-devel@nongnu.org; Wed, 11 Mar 2020 07:16:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBzM2-0000IW-Fz for qemu-devel@nongnu.org; Wed, 11 Mar 2020 07:16:51 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:50317 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBzM2-0000I8-CY for qemu-devel@nongnu.org; Wed, 11 Mar 2020 07:16:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583925410; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zeB6cFMegs4WqfD1Cvq2byvQge1aNrou1NeftyjBdtw=; b=Qmk/zYSeiHdYu3c2PAdw6TE8XjrpYZVNyHo2qvch+PkoVyIscEEPCcXc7+nr4mbBp5CdMO MTSPsEmUpQz8YYt/XHqNcc92Kxdo9aY9VKAQ+ueq+j7tdOQZ9ZV7j8X7JBJGtx5UYkf/E7 fjNQhuVQYbTlwLjx1Aciy3uzbAJwgYA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-432-iSNzgdEDMjK8x2hj_1mXag-1; Wed, 11 Mar 2020 07:16:47 -0400 X-MC-Unique: iSNzgdEDMjK8x2hj_1mXag-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8EB48DB61; Wed, 11 Mar 2020 11:16:46 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.36.118.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFBFE91D9B; Wed, 11 Mar 2020 11:16:43 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org Subject: [PATCH v4 3/6] hw/arm/virt: Introduce finalize_gic_version() Date: Wed, 11 Mar 2020 12:16:23 +0100 Message-Id: <20200311111626.5705-4-eric.auger@redhat.com> In-Reply-To: <20200311111626.5705-1-eric.auger@redhat.com> References: <20200311111626.5705-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.61 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: maz@kernel.org, drjones@redhat.com, richard.henderson@linaro.org, philmd@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Let's move the code which freezes which gic-version to be applied in a dedicated function. We also now set by default the VIRT_GIC_VERSION_NO_SET. This eventually turns into the legacy v2 choice in the finalize() function. Signed-off-by: Eric Auger Reviewed-by: Richard Henderson Reviewed-by: Andrew Jones --- v2 -> v3: - add NOTSEL value at the end of the new enum type --- include/hw/arm/virt.h | 1 + hw/arm/virt.c | 54 ++++++++++++++++++++++++++----------------- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index c0827cacdf..893796d3b0 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -100,6 +100,7 @@ typedef enum VirtGICType { VIRT_GIC_VERSION_HOST, VIRT_GIC_VERSION_2, VIRT_GIC_VERSION_3, + VIRT_GIC_VERSION_NOSEL, } VirtGICType; typedef struct MemMapEntry { diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 4ed1f0cb2e..22da0a7ad7 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1535,6 +1535,37 @@ static void virt_set_memmap(VirtMachineState *vms) } } +/* + * finalize_gic_version - Determines the final gic_version + * according to the gic-version property + * + * Default GIC type is v2 + */ +static void finalize_gic_version(VirtMachineState *vms) +{ + if (vms->gic_version == VIRT_GIC_VERSION_HOST || + vms->gic_version == VIRT_GIC_VERSION_MAX) { + if (!kvm_enabled()) { + if (vms->gic_version == VIRT_GIC_VERSION_HOST) { + error_report("gic-version=host requires KVM"); + exit(1); + } else { + /* "max": currently means 3 for TCG */ + vms->gic_version = VIRT_GIC_VERSION_3; + } + } else { + vms->gic_version = kvm_arm_vgic_probe(); + if (!vms->gic_version) { + error_report( + "Unable to determine GIC version supported by host"); + exit(1); + } + } + } else if (vms->gic_version == VIRT_GIC_VERSION_NOSEL) { + vms->gic_version = VIRT_GIC_VERSION_2; + } +} + static void machvirt_init(MachineState *machine) { VirtMachineState *vms = VIRT_MACHINE(machine); @@ -1561,25 +1592,7 @@ static void machvirt_init(MachineState *machine) /* We can probe only here because during property set * KVM is not available yet */ - if (vms->gic_version == VIRT_GIC_VERSION_HOST || - vms->gic_version == VIRT_GIC_VERSION_MAX) { - if (!kvm_enabled()) { - if (vms->gic_version == VIRT_GIC_VERSION_HOST) { - error_report("gic-version=host requires KVM"); - exit(1); - } else { - /* "max": currently means 3 for TCG */ - vms->gic_version = VIRT_GIC_VERSION_3; - } - } else { - vms->gic_version = kvm_arm_vgic_probe(); - if (!vms->gic_version) { - error_report( - "Unable to determine GIC version supported by host"); - exit(1); - } - } - } + finalize_gic_version(vms); if (!cpu_type_valid(machine->cpu_type)) { error_report("mach-virt: CPU type %s not supported", machine->cpu_type); @@ -2140,8 +2153,7 @@ static void virt_instance_init(Object *obj) "Set on/off to enable/disable using " "physical address space above 32 bits", NULL); - /* Default GIC type is v2 */ - vms->gic_version = VIRT_GIC_VERSION_2; + vms->gic_version = VIRT_GIC_VERSION_NOSEL; object_property_add_str(obj, "gic-version", virt_get_gic_version, virt_set_gic_version, NULL); object_property_set_description(obj, "gic-version", From patchwork Wed Mar 11 11:16:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 1252798 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=DqetTEqC; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48cqHQ1qKjz9sPk for ; Wed, 11 Mar 2020 22:19:46 +1100 (AEDT) Received: from localhost ([::1]:49770 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBzOq-0005aO-03 for incoming@patchwork.ozlabs.org; Wed, 11 Mar 2020 07:19:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55621) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBzMB-00020n-7b for qemu-devel@nongnu.org; Wed, 11 Mar 2020 07:17:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBzM9-0000WB-Cx for qemu-devel@nongnu.org; Wed, 11 Mar 2020 07:16:59 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:42551 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBzM7-0000NI-I1 for qemu-devel@nongnu.org; Wed, 11 Mar 2020 07:16:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583925415; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WuwgRG3MZDIV9O2VREpGbG5a/gfDBmq2SMU+8pGvWZE=; b=DqetTEqC2zqU0gNsqsvxu83ke2bXfM0lnvW9U9RiIsk3Ysq3mMhlMjQsFBa4qvw2roeItP 2uYhetOhiEGKSmGZH2QxfOCPPtzWeeL4sMe6qLjQmHawZjzqMcOHhS1OTCXYYxF84x3CUl +jH/9hMn1cWQ8hNrAOwSrVIutxBUYyU= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-217-atKVSywuPniJFvfDuARPDQ-1; Wed, 11 Mar 2020 07:16:51 -0400 X-MC-Unique: atKVSywuPniJFvfDuARPDQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4FC2F107ACC7; Wed, 11 Mar 2020 11:16:50 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.36.118.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 247F491D91; Wed, 11 Mar 2020 11:16:46 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org Subject: [PATCH v4 4/6] target/arm/kvm: Let kvm_arm_vgic_probe() return a bitmap Date: Wed, 11 Mar 2020 12:16:24 +0100 Message-Id: <20200311111626.5705-5-eric.auger@redhat.com> In-Reply-To: <20200311111626.5705-1-eric.auger@redhat.com> References: <20200311111626.5705-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: maz@kernel.org, drjones@redhat.com, richard.henderson@linaro.org, philmd@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Convert kvm_arm_vgic_probe() so that it returns a bitmap of supported in-kernel emulation VGIC versions instead of the max version: at the moment values can be v2 and v3. This allows to expose the case where the host GICv3 also supports GICv2 emulation. This will be useful to choose the default version in KVM accelerated mode. Signed-off-by: Eric Auger Reviewed-by: Andrew Jones Reviewed-by: Richard Henderson --- target/arm/kvm_arm.h | 3 +++ hw/arm/virt.c | 11 +++++++++-- target/arm/kvm.c | 14 ++++++++------ 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index ae9e075d75..48bf5e16d5 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -15,6 +15,9 @@ #include "exec/memory.h" #include "qemu/error-report.h" +#define KVM_ARM_VGIC_V2 (1 << 0) +#define KVM_ARM_VGIC_V3 (1 << 1) + /** * kvm_arm_vcpu_init: * @cs: CPUState diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 22da0a7ad7..f798b6ec10 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1554,11 +1554,18 @@ static void finalize_gic_version(VirtMachineState *vms) vms->gic_version = VIRT_GIC_VERSION_3; } } else { - vms->gic_version = kvm_arm_vgic_probe(); - if (!vms->gic_version) { + int probe_bitmap = kvm_arm_vgic_probe(); + + if (!probe_bitmap) { error_report( "Unable to determine GIC version supported by host"); exit(1); + } else { + if (probe_bitmap & KVM_ARM_VGIC_V3) { + vms->gic_version = VIRT_GIC_VERSION_3; + } else { + vms->gic_version = VIRT_GIC_VERSION_2; + } } } } else if (vms->gic_version == VIRT_GIC_VERSION_NOSEL) { diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 85860e6f95..390077c518 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -874,15 +874,17 @@ int kvm_arch_irqchip_create(KVMState *s) int kvm_arm_vgic_probe(void) { + int val = 0; + if (kvm_create_device(kvm_state, KVM_DEV_TYPE_ARM_VGIC_V3, true) == 0) { - return 3; - } else if (kvm_create_device(kvm_state, - KVM_DEV_TYPE_ARM_VGIC_V2, true) == 0) { - return 2; - } else { - return 0; + val |= KVM_ARM_VGIC_V3; } + if (kvm_create_device(kvm_state, + KVM_DEV_TYPE_ARM_VGIC_V2, true) == 0) { + val |= KVM_ARM_VGIC_V2; + } + return val; } int kvm_arm_set_irq(int cpu, int irqtype, int irq, int level) From patchwork Wed Mar 11 11:16:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 1252799 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=fNmKk0Pt; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48cqHQ3tNfz9sQt for ; Wed, 11 Mar 2020 22:19:46 +1100 (AEDT) Received: from localhost ([::1]:49772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBzOq-0005b0-8C for incoming@patchwork.ozlabs.org; Wed, 11 Mar 2020 07:19:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55664) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBzMF-00022G-NW for qemu-devel@nongnu.org; Wed, 11 Mar 2020 07:17:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBzME-0000gS-FT for qemu-devel@nongnu.org; Wed, 11 Mar 2020 07:17:03 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:34456 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBzME-0000fi-CN for qemu-devel@nongnu.org; Wed, 11 Mar 2020 07:17:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583925421; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hWITm29o9F+/2vUiv5hnDt4BR+WmlReK+cyGVcscanc=; b=fNmKk0PtEgtmPbDIT9Sb5ocDhFcVV/vJM2qEV1TZBJIhjh6xDgfUSZUiJqsUfiqj8O8B80 dh+9Q1JFjhlZBokmj3unMWV4mI0FT3Ss/Z3qNUYJZbIQWSHyplz7pla5I0YIJWvELr0gyv CsDDb8jaKsoSmCD5INIYOU/MTbOmGUY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-347-L9V3O0n4N0CWWujT1-0JuA-1; Wed, 11 Mar 2020 07:16:58 -0400 X-MC-Unique: L9V3O0n4N0CWWujT1-0JuA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 03C2A107ACC4; Wed, 11 Mar 2020 11:16:57 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.36.118.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id D6BA191D91; Wed, 11 Mar 2020 11:16:50 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org Subject: [PATCH v4 5/6] hw/arm/virt: kvm: Restructure finalize_gic_version() Date: Wed, 11 Mar 2020 12:16:25 +0100 Message-Id: <20200311111626.5705-6-eric.auger@redhat.com> In-Reply-To: <20200311111626.5705-1-eric.auger@redhat.com> References: <20200311111626.5705-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.81 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: maz@kernel.org, drjones@redhat.com, richard.henderson@linaro.org, philmd@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Restructure the finalize_gic_version with switch cases and clearly separate the following cases: - KVM mode / in-kernel irqchip - KVM mode / userspace irqchip - TCG mode In KVM mode / in-kernel irqchip , we explictly check whether the chosen version is supported by the host. If the end-user explicitly sets v2/v3 and this is not supported by the host, then the user gets an explicit error message. Note that for old kernels where the CREATE_DEVICE ioctl doesn't exist then we will now fail if the user specifically asked for gicv2, where previously we (probably) would have succeeded. In KVM mode / userspace irqchip we immediatly output an error in case the end-user explicitly selected v3. Also we warn the end-user about the unexpected usage of gic-version=host in that case as only userspace GICv2 is supported. Signed-off-by: Eric Auger Reviewed-by: Andrew Jones --- v3 -> v4: - introduce a separate switch case for KVM mode / userspace irqchip - don't probe the host GIC version in case of userspace GIC - add error/warning messages in v3/host mode in userspace mode - mention old kernel case with explicit v2/v3 regression v2 -> v3: - explictly list V2 and V3 in the switch/case - fix indent --- hw/arm/virt.c | 89 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 68 insertions(+), 21 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index f798b6ec10..f5ff2d9006 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1543,33 +1543,80 @@ static void virt_set_memmap(VirtMachineState *vms) */ static void finalize_gic_version(VirtMachineState *vms) { - if (vms->gic_version == VIRT_GIC_VERSION_HOST || - vms->gic_version == VIRT_GIC_VERSION_MAX) { - if (!kvm_enabled()) { - if (vms->gic_version == VIRT_GIC_VERSION_HOST) { - error_report("gic-version=host requires KVM"); - exit(1); - } else { - /* "max": currently means 3 for TCG */ - vms->gic_version = VIRT_GIC_VERSION_3; - } - } else { - int probe_bitmap = kvm_arm_vgic_probe(); + if (kvm_enabled()) { + int probe_bitmap; - if (!probe_bitmap) { + if (!kvm_irqchip_in_kernel()) { + switch (vms->gic_version) { + case VIRT_GIC_VERSION_HOST: + warn_report( + "gic-version=host not relevant with kernel-irqchip=off " + "as only userspace GICv2 is supported. Using v2 ..."); + return; + case VIRT_GIC_VERSION_MAX: + case VIRT_GIC_VERSION_NOSEL: + vms->gic_version = VIRT_GIC_VERSION_2; + return; + case VIRT_GIC_VERSION_2: + return; + case VIRT_GIC_VERSION_3: error_report( - "Unable to determine GIC version supported by host"); + "gic-version=3 is not supported with kernel-irqchip=off"); exit(1); - } else { - if (probe_bitmap & KVM_ARM_VGIC_V3) { - vms->gic_version = VIRT_GIC_VERSION_3; - } else { - vms->gic_version = VIRT_GIC_VERSION_2; - } } } - } else if (vms->gic_version == VIRT_GIC_VERSION_NOSEL) { + + probe_bitmap = kvm_arm_vgic_probe(); + if (!probe_bitmap) { + error_report( + "Unable to determine GIC version supported by host"); + exit(1); + } + + switch (vms->gic_version) { + case VIRT_GIC_VERSION_HOST: + case VIRT_GIC_VERSION_MAX: + if (probe_bitmap & KVM_ARM_VGIC_V3) { + vms->gic_version = VIRT_GIC_VERSION_3; + } else { + vms->gic_version = VIRT_GIC_VERSION_2; + } + return; + case VIRT_GIC_VERSION_NOSEL: + vms->gic_version = VIRT_GIC_VERSION_2; + break; + case VIRT_GIC_VERSION_2: + case VIRT_GIC_VERSION_3: + break; + } + + /* Check chosen version is effectively supported by the host */ + if (vms->gic_version == VIRT_GIC_VERSION_2 && + !(probe_bitmap & KVM_ARM_VGIC_V2)) { + error_report("host does not support in-kernel GICv2 emulation"); + exit(1); + } else if (vms->gic_version == VIRT_GIC_VERSION_3 && + !(probe_bitmap & KVM_ARM_VGIC_V3)) { + error_report("host does not support in-kernel GICv3 emulation"); + exit(1); + } + return; + } + + /* TCG mode */ + switch (vms->gic_version) { + case VIRT_GIC_VERSION_NOSEL: vms->gic_version = VIRT_GIC_VERSION_2; + break; + case VIRT_GIC_VERSION_MAX: + vms->gic_version = VIRT_GIC_VERSION_3; + break; + case VIRT_GIC_VERSION_HOST: + error_report("gic-version=host requires KVM"); + exit(1); + case VIRT_GIC_VERSION_2: + case VIRT_GIC_VERSION_3: + break; } } From patchwork Wed Mar 11 11:16:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Auger X-Patchwork-Id: 1252800 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=KRA5/ySy; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48cqJq6f4dz9sPg for ; Wed, 11 Mar 2020 22:20:59 +1100 (AEDT) Received: from localhost ([::1]:49816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBzQ1-0008Jg-Sn for incoming@patchwork.ozlabs.org; Wed, 11 Mar 2020 07:20:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55688) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBzMH-000230-0T for qemu-devel@nongnu.org; Wed, 11 Mar 2020 07:17:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBzMF-0000iI-Q9 for qemu-devel@nongnu.org; Wed, 11 Mar 2020 07:17:04 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:25383 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBzMF-0000hg-MQ for qemu-devel@nongnu.org; Wed, 11 Mar 2020 07:17:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583925423; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wzbTyy338OK9x1tC0UjkMEAOnkQjAtfB2xgpd8yYspE=; b=KRA5/ySyjgeCvjnAENiv/QlCvhTviH+3neC8oza8gTlDixCY8kBhQ/x2KW+3HZJpYao7gE P3Ojf1utDoPZPkO35QaFL5SUHa2wEdSs+KjqLG6ApofLyuDZN66UMlIe/3QxNz/2xf3cLf I01rgVgFUPv1kk9HJpNrYKub7PUfhB0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-436-tPb6PKEVPIaaCF9Ku1jpsw-1; Wed, 11 Mar 2020 07:17:01 -0400 X-MC-Unique: tPb6PKEVPIaaCF9Ku1jpsw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 88EAC107ACC4; Wed, 11 Mar 2020 11:17:00 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.36.118.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A86A91D91; Wed, 11 Mar 2020 11:16:57 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, peter.maydell@linaro.org Subject: [PATCH v4 6/6] hw/arm/virt: kvm: allow gicv3 by default if v2 cannot work Date: Wed, 11 Mar 2020 12:16:26 +0100 Message-Id: <20200311111626.5705-7-eric.auger@redhat.com> In-Reply-To: <20200311111626.5705-1-eric.auger@redhat.com> References: <20200311111626.5705-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 205.139.110.120 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: maz@kernel.org, drjones@redhat.com, richard.henderson@linaro.org, philmd@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" At the moment if the end-user does not specify the gic-version along with KVM acceleration, v2 is set by default. However most of the systems now have GICv3 and sometimes they do not support GICv2 compatibility. This patch keeps the default v2 selection in all cases except in the KVM accelerated mode when either - the host does not support GICv2 in-kernel emulation or - number of VCPUS exceeds 8. Those cases did not work anyway so we do not break any compatibility. Now we get v3 selected in such a case. Signed-off-by: Eric Auger Reported-by: Dr. David Alan Gilbert Reviewed-by: Andrew Jones --- v3 -> v4: - Deal with the case where v3 is not supported by the host and the number of vcpus exceeds 8 v2 -> v3: - add () --- hw/arm/virt.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index f5ff2d9006..6becf9aaae 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1543,6 +1543,8 @@ static void virt_set_memmap(VirtMachineState *vms) */ static void finalize_gic_version(VirtMachineState *vms) { + unsigned int max_cpus = MACHINE(vms)->smp.max_cpus; + if (kvm_enabled()) { int probe_bitmap; @@ -1583,7 +1585,20 @@ static void finalize_gic_version(VirtMachineState *vms) } return; case VIRT_GIC_VERSION_NOSEL: - vms->gic_version = VIRT_GIC_VERSION_2; + if ((probe_bitmap & KVM_ARM_VGIC_V2) && max_cpus <= GIC_NCPU) { + vms->gic_version = VIRT_GIC_VERSION_2; + } else if (probe_bitmap & KVM_ARM_VGIC_V3) { + /* + * in case the host does not support v2 in-kernel emulation or + * the end-user requested more than 8 VCPUs we now default + * to v3. In any case defaulting to v2 would be broken. + */ + vms->gic_version = VIRT_GIC_VERSION_3; + } else { + error_report("host only supports in-kernel GICv2 emulation " + "but more than 8 vcpus are requested"); + exit(1); + } break; case VIRT_GIC_VERSION_2: case VIRT_GIC_VERSION_3: