From nobody Sun May 12 18:40:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709819421; cv=none; d=zohomail.com; s=zohoarc; b=CEnz3QDbkNW2dM36e0MjgaZ/bmQeZeZszIzSFYbIofZYem8fyljpcdgutcy6+tFXvkOWcXh6v6cpAV3860CeDTEi7SyoO+bnw85zUYO7ymcACKOQUuzmYlUHe6MWwCy2QrOvORQm8kiDS/Thf6PwenXwQYw0fZIl+mIsbIq+KDc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709819421; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CQdBQ55XBD1zKpk7OKKORm1TNObn+aTFGDtbgCuAoGo=; b=XQhT8iIB8DtkVUP6WryjJRJgE6YEZmmBETnPTibX79ssmmbMa5clsOsNswsvHRH9+c74p9AThGFbXBL5PpDXZDjFJCwHvqtkRZ+t7/VFVl6zf4czitZP5O/OWXCTSF9nqnfm5b0bG+cOUEdIq/l+OGJdf15j+UaGgjexupNvnAY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709819421076302.81014488507617; Thu, 7 Mar 2024 05:50:21 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riE7A-0006gc-6n; Thu, 07 Mar 2024 08:48:52 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riE3f-0004qw-Ea for qemu-devel@nongnu.org; Thu, 07 Mar 2024 08:45:16 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riE3W-0007AD-1Q for qemu-devel@nongnu.org; Thu, 07 Mar 2024 08:45:09 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661-p0y4NFzPMrq6hC-PHUGS-w-1; Thu, 07 Mar 2024 08:44:56 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F0A4A187570E; Thu, 7 Mar 2024 13:44:55 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 911EB17AA7; Thu, 7 Mar 2024 13:44:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709819097; 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=CQdBQ55XBD1zKpk7OKKORm1TNObn+aTFGDtbgCuAoGo=; b=XkvbIMYK8LcIRGEMVOMSWrmLomquOLQgUyxXxuyqFqRrtEOmgi5WzSDAtXmpvIVzT9G+EY sH4gaeqvDjkjVn5gJRBJ5Cz5bmOkPIAOpqMjqzUgFLC7nCZcpEkIn9nGT8srXzUmV1J6wc q/5VRG0EVfc4QoJIby301K6Xyc37pR8= X-MC-Unique: p0y4NFzPMrq6hC-PHUGS-w-1 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, mst@redhat.com, jean-philippe@linaro.org, imammedo@redhat.com, peter.maydell@linaro.org, clg@redhat.com, yanghliu@redhat.com, zhenzhong.duan@intel.com Cc: alex.williamson@redhat.com, jasowang@redhat.com, pbonzini@redhat.com, berrange@redhat.com Subject: [PATCH v8 1/9] qdev: Add a granule_mode property Date: Thu, 7 Mar 2024 14:43:02 +0100 Message-ID: <20240307134445.92296-2-eric.auger@redhat.com> In-Reply-To: <20240307134445.92296-1-eric.auger@redhat.com> References: <20240307134445.92296-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.583, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709819422695100003 Introduce a new enum type property allowing to set an IOMMU granule. Values are 4k, 8k, 16k, 64k and host. This latter indicates the vIOMMU granule will match the host page size. A subsequent patch will add such a property to the virtio-iommu device. Signed-off-by: Eric Auger Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Zhenzhong Duan --- v5 -> v6 - remove #include "hw/virtio/virtio-iommu.h" (Zhenzhong) v4 -> v5 - remove code that can be automatically generated and add the new enum in qapi/virtio.json (Philippe). Added Phild's SOB. low case needs to be used due to the Jason generation. v3 -> v4: - Add 8K --- qapi/virtio.json | 18 ++++++++++++++++++ include/hw/qdev-properties-system.h | 3 +++ hw/core/qdev-properties-system.c | 14 ++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/qapi/virtio.json b/qapi/virtio.json index a79013fe89..95745fdfd7 100644 --- a/qapi/virtio.json +++ b/qapi/virtio.json @@ -957,3 +957,21 @@ =20 { 'struct': 'DummyVirtioForceArrays', 'data': { 'unused-iothread-vq-mapping': ['IOThreadVirtQueueMapping'] } } + +## +# @GranuleMode: +# +# @4k: granule page size of 4KiB +# +# @8k: granule page size of 8KiB +# +# @16k: granule page size of 16KiB +# +# @64k: granule page size of 64KiB +# +# @host: granule matches the host page size +# +# Since: 9.0 +## +{ 'enum': 'GranuleMode', + 'data': [ '4k', '8k', '16k', '64k', 'host' ] } diff --git a/include/hw/qdev-properties-system.h b/include/hw/qdev-properti= es-system.h index 06c359c190..626be87dd3 100644 --- a/include/hw/qdev-properties-system.h +++ b/include/hw/qdev-properties-system.h @@ -8,6 +8,7 @@ extern const PropertyInfo qdev_prop_macaddr; extern const PropertyInfo qdev_prop_reserved_region; extern const PropertyInfo qdev_prop_multifd_compression; extern const PropertyInfo qdev_prop_mig_mode; +extern const PropertyInfo qdev_prop_granule_mode; extern const PropertyInfo qdev_prop_losttickpolicy; extern const PropertyInfo qdev_prop_blockdev_on_error; extern const PropertyInfo qdev_prop_bios_chs_trans; @@ -47,6 +48,8 @@ extern const PropertyInfo qdev_prop_iothread_vq_mapping_l= ist; #define DEFINE_PROP_MIG_MODE(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_mig_mode, \ MigMode) +#define DEFINE_PROP_GRANULE_MODE(_n, _s, _f, _d) \ + DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_granule_mode, GranuleMode) #define DEFINE_PROP_LOSTTICKPOLICY(_n, _s, _f, _d) \ DEFINE_PROP_SIGNED(_n, _s, _f, _d, qdev_prop_losttickpolicy, \ LostTickPolicy) diff --git a/hw/core/qdev-properties-system.c b/hw/core/qdev-properties-sys= tem.c index 1a396521d5..b45e90edb2 100644 --- a/hw/core/qdev-properties-system.c +++ b/hw/core/qdev-properties-system.c @@ -679,6 +679,20 @@ const PropertyInfo qdev_prop_mig_mode =3D { .set_default_value =3D qdev_propinfo_set_default_value_enum, }; =20 +/* --- GranuleMode --- */ + +QEMU_BUILD_BUG_ON(sizeof(GranuleMode) !=3D sizeof(int)); + +const PropertyInfo qdev_prop_granule_mode =3D { + .name =3D "GranuleMode", + .description =3D "granule_mode values, " + "4k, 8k, 16k, 64k, host", + .enum_table =3D &GranuleMode_lookup, + .get =3D qdev_propinfo_get_enum, + .set =3D qdev_propinfo_set_enum, + .set_default_value =3D qdev_propinfo_set_default_value_enum, +}; + /* --- Reserved Region --- */ =20 /* --=20 2.41.0 From nobody Sun May 12 18:40:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709819384; cv=none; d=zohomail.com; s=zohoarc; b=f73pMPp7xsY8Gzj7jMqnTvHF7G5OWCD3mf7z7VBS2lRAM8zigpbGQe1OdJP0AGZbZpm/5NbyzTSCtdobW35raZg7ULtMO/R2tYoIC10BWcnnV6N1JwaYzhU6CDVy5CfQh/FO8VWX/7B5mu+lBX72/OiD1IxXckQ2mVy+Rdf5a8Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709819384; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WCNHJBHzbGHJQEsUZ3hntYV04NWRORdIJ35ThpnGdQk=; b=MXgImbHebxCCKTauFS9OCQLKikVXoQXq0GVj1O5IwVdqwX0VAr9vJsQJFalyljKgEpq7uwKP2wfH8PB9uxHJiGUhnPdD2R7wvaB3d/rRDoMPu8OYrAG/FeMc6A8brz6i6a2uewCMqgf8vA3lqxsKkdGUM4nAZmVwYkwrG49q0j8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709819384946777.862763497534; Thu, 7 Mar 2024 05:49:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riE7F-0006mC-WB; Thu, 07 Mar 2024 08:48:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riE3y-0004z8-BS for qemu-devel@nongnu.org; Thu, 07 Mar 2024 08:45:36 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riE3Z-0007CL-LU for qemu-devel@nongnu.org; Thu, 07 Mar 2024 08:45:29 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-538-_caR6L-1Mfe0X5af4TX3gg-1; Thu, 07 Mar 2024 08:45:00 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A2A351C00D0D; Thu, 7 Mar 2024 13:44:59 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3FE6E17AA9; Thu, 7 Mar 2024 13:44:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709819104; 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=WCNHJBHzbGHJQEsUZ3hntYV04NWRORdIJ35ThpnGdQk=; b=G1T0+c51VP7KelqjuGKIGMPZrM2waJTSpZNpZ9rkHbskMMN5lKd9JVdNjfJLG6OG6wRu4Y i7iJHzZg/ZU0f9rrv/3lcRjPqaL3HhG5/B/dwq3t/b759LiC8zPDh2me76eOgfVJ3U4zQP 1CVGc8ALU9sMtbenKT1E/+E1RyqSR/k= X-MC-Unique: _caR6L-1Mfe0X5af4TX3gg-1 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, mst@redhat.com, jean-philippe@linaro.org, imammedo@redhat.com, peter.maydell@linaro.org, clg@redhat.com, yanghliu@redhat.com, zhenzhong.duan@intel.com Cc: alex.williamson@redhat.com, jasowang@redhat.com, pbonzini@redhat.com, berrange@redhat.com Subject: [PATCH v8 2/9] virtio-iommu: Add a granule property Date: Thu, 7 Mar 2024 14:43:03 +0100 Message-ID: <20240307134445.92296-3-eric.auger@redhat.com> In-Reply-To: <20240307134445.92296-1-eric.auger@redhat.com> References: <20240307134445.92296-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.583, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709819386560100003 This allows to choose which granule will be used by default by the virtio-iommu. Current page size mask default is qemu_target_page_mask so this translates into a 4k granule on ARM and x86_64 where virtio-iommu is supported. Signed-off-by: Eric Auger Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Zhenzhong Duan --- v4 -> v5: - use -(n * KiB) (Phild) v3 -> v4: - granule_mode introduction moved to that patch --- include/hw/virtio/virtio-iommu.h | 2 ++ hw/virtio/virtio-iommu.c | 28 +++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/include/hw/virtio/virtio-iommu.h b/include/hw/virtio/virtio-io= mmu.h index 781ebaea8f..67ea5022af 100644 --- a/include/hw/virtio/virtio-iommu.h +++ b/include/hw/virtio/virtio-iommu.h @@ -24,6 +24,7 @@ #include "hw/virtio/virtio.h" #include "hw/pci/pci.h" #include "qom/object.h" +#include "qapi/qapi-types-virtio.h" =20 #define TYPE_VIRTIO_IOMMU "virtio-iommu-device" #define TYPE_VIRTIO_IOMMU_PCI "virtio-iommu-pci" @@ -66,6 +67,7 @@ struct VirtIOIOMMU { bool boot_bypass; Notifier machine_done; bool granule_frozen; + GranuleMode granule_mode; }; =20 #endif diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 86623d55a5..84d6819d3b 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -29,6 +29,7 @@ #include "sysemu/reset.h" #include "sysemu/sysemu.h" #include "qemu/reserved-region.h" +#include "qemu/units.h" #include "qapi/error.h" #include "qemu/error-report.h" #include "trace.h" @@ -1115,8 +1116,8 @@ static int virtio_iommu_notify_flag_changed(IOMMUMemo= ryRegion *iommu_mr, } =20 /* - * The default mask (TARGET_PAGE_MASK) is the smallest supported guest gra= nule, - * for example 0xfffffffffffff000. When an assigned device has page size + * The default mask depends on the "granule" property. For example, with + * 4k granule, it is -(4 * KiB). When an assigned device has page size * restrictions due to the hardware IOMMU configuration, apply this restri= ction * to the mask. */ @@ -1313,8 +1314,27 @@ static void virtio_iommu_device_realize(DeviceState = *dev, Error **errp) * in vfio realize */ s->config.bypass =3D s->boot_bypass; - s->config.page_size_mask =3D qemu_target_page_mask(); s->config.input_range.end =3D UINT64_MAX; + + switch (s->granule_mode) { + case GRANULE_MODE_4K: + s->config.page_size_mask =3D -(4 * KiB); + break; + case GRANULE_MODE_8K: + s->config.page_size_mask =3D -(8 * KiB); + break; + case GRANULE_MODE_16K: + s->config.page_size_mask =3D -(16 * KiB); + break; + case GRANULE_MODE_64K: + s->config.page_size_mask =3D -(64 * KiB); + break; + case GRANULE_MODE_HOST: + s->config.page_size_mask =3D qemu_real_host_page_mask(); + break; + default: + error_setg(errp, "Unsupported granule mode"); + } s->config.domain_range.end =3D UINT32_MAX; s->config.probe_size =3D VIOMMU_PROBE_SIZE; =20 @@ -1522,6 +1542,8 @@ static Property virtio_iommu_properties[] =3D { DEFINE_PROP_LINK("primary-bus", VirtIOIOMMU, primary_bus, TYPE_PCI_BUS, PCIBus *), DEFINE_PROP_BOOL("boot-bypass", VirtIOIOMMU, boot_bypass, true), + DEFINE_PROP_GRANULE_MODE("granule", VirtIOIOMMU, granule_mode, + GRANULE_MODE_4K), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.41.0 From nobody Sun May 12 18:40:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709819504; cv=none; d=zohomail.com; s=zohoarc; b=SifK9dhFvrAJNjDZ4DoFJX1R7D0yYifGHNyx/CWPzZbCSTBNV+ywy72NEJdfaoDTSofIr9rMhfVIhFtvEKPp/9PKmTZPboqYgW7/X09v5ToDfZuMBL7eKP6zu+61NjtzgIgZ+bsllNf/ESuQkU1BNF0IoVIb7rgn6fV96haXGLs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709819504; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=G8pf/ay85w+iMb0sdshULxgyxYsK+YqD3nZSpGMyglg=; b=EEGP85Szi46eIsU+NweX5/74U8Rfld3GzJkLpBC3J1BbaiaXk8fLZAwqjh0s2PAKQrvGCMQOQvg0u0BReoi28aXZBZjPM7bgkUyG37u45X56AjAzwMBwBs3ts+aRK9Yz+TL4t7shdf4Tv0Eliei26IVkcpd/R7AcT2T01eA6iC8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709819504077967.8167338510389; Thu, 7 Mar 2024 05:51:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riE7E-0006k6-LR; Thu, 07 Mar 2024 08:48:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riE4H-00057b-Rl for qemu-devel@nongnu.org; Thu, 07 Mar 2024 08:46:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riE3i-0007DD-79 for qemu-devel@nongnu.org; Thu, 07 Mar 2024 08:45:42 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-222-So0lJumZPF6mc655CgQ3zA-1; Thu, 07 Mar 2024 08:45:03 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 584DB8F4768; Thu, 7 Mar 2024 13:45:03 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id E67D017AA7; Thu, 7 Mar 2024 13:44:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709819105; 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=G8pf/ay85w+iMb0sdshULxgyxYsK+YqD3nZSpGMyglg=; b=ChWfaFu61TB81R6OHWar6sTkiQRuji7K+PwnvadQHY22jn4KR5lWHn/ms7LQJSS5xtVI2q QepqiOKG4pPw8ge2Lb1YvLVlXZeGQQXh8RzuwvOR0gFEZ+8UQCyTMJAAcsDfOUbUnlTNgf 3wuZ61mc61TOlOIiS1XsD/8bBv3D/T8= X-MC-Unique: So0lJumZPF6mc655CgQ3zA-1 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, mst@redhat.com, jean-philippe@linaro.org, imammedo@redhat.com, peter.maydell@linaro.org, clg@redhat.com, yanghliu@redhat.com, zhenzhong.duan@intel.com Cc: alex.williamson@redhat.com, jasowang@redhat.com, pbonzini@redhat.com, berrange@redhat.com Subject: [PATCH v8 3/9] virtio-iommu: Change the default granule to the host page size Date: Thu, 7 Mar 2024 14:43:04 +0100 Message-ID: <20240307134445.92296-4-eric.auger@redhat.com> In-Reply-To: <20240307134445.92296-1-eric.auger@redhat.com> References: <20240307134445.92296-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.583, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709819505014100005 We used to set the default granule to 4KB but with VFIO assignment it makes more sense to use the actual host page size. Indeed when hotplugging a VFIO device protected by a virtio-iommu on a 64kB/64kB host/guest config, we current get a qemu crash: "vfio: DMA mapping failed, unable to continue" This is due to the hot-attached VFIO device calling memory_region_iommu_set_page_size_mask() with 64kB granule whereas the virtio-iommu granule was already frozen to 4KB on machine init done. Set the granule property to "host" and introduce a new compat. The page size mask used before 9.0 was qemu_target_page_mask(). Since the virtio-iommu currently only supports x86_64 and aarch64, this matched a 4KB granule. Note that the new default will prevent 4kB guest on 64kB host because the granule will be set to 64kB which would be larger than the guest page size. In that situation, the virtio-iommu driver fails on viommu_domain_finalise() with "granule 0x10000 larger than system page size 0x1000". In that case the workaround is to request 4K granule. The current limitation of global granule in the virtio-iommu should be removed and turned into per domain granule. But until we get this upgraded, this new default is probably better because I don't think anyone is currently interested in running a 4KB page size guest with virtio-iommu on a 64KB host. However supporting 64kB guest on 64kB host with virtio-iommu and VFIO looks a more important feature. Signed-off-by: Eric Auger Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Zhenzhong Duan --- v4 -> v5 - use low case, mandated by the jason qapi --- hw/core/machine.c | 5 ++++- hw/virtio/virtio-iommu.c | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 9ac5d5389a..6bd09d4592 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -30,9 +30,12 @@ #include "exec/confidential-guest-support.h" #include "hw/virtio/virtio-pci.h" #include "hw/virtio/virtio-net.h" +#include "hw/virtio/virtio-iommu.h" #include "audio/audio.h" =20 -GlobalProperty hw_compat_8_2[] =3D {}; +GlobalProperty hw_compat_8_2[] =3D { + { TYPE_VIRTIO_IOMMU_PCI, "granule", "4k" }, +}; const size_t hw_compat_8_2_len =3D G_N_ELEMENTS(hw_compat_8_2); =20 GlobalProperty hw_compat_8_1[] =3D { diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 84d6819d3b..aab97e1527 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -1543,7 +1543,7 @@ static Property virtio_iommu_properties[] =3D { TYPE_PCI_BUS, PCIBus *), DEFINE_PROP_BOOL("boot-bypass", VirtIOIOMMU, boot_bypass, true), DEFINE_PROP_GRANULE_MODE("granule", VirtIOIOMMU, granule_mode, - GRANULE_MODE_4K), + GRANULE_MODE_HOST), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.41.0 From nobody Sun May 12 18:40:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709819506; cv=none; d=zohomail.com; s=zohoarc; b=g2CNiVJrGRjVTUht0XJFhKgQ0o86Sel7hL4dwxdVSdgpphIC1AiuSPvywEr/dMXj13MJ1KfsM0NOm09k1g1HYxaUhZR5GGCzUwptYOz5bB0FpuWDH8a+/AfEQRZW4Ud0w93JRH/nnmREgBiatOhzvgm9rWPQkNFAqM9j1trhyVU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709819506; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=LuqhxuaXHnZuXhFECH4rZglZe6XiMM07102AtConlIs=; b=gwhta7yEcq8urtlOWT3vQu7eFkPG3Y1IpRNp1+H2vqsV7AXZuve2dC9HSnxRgntcYVZqDr96jboZQGEQhJAvjraBHHGk/VhOEWvibtm3AWZCVlfa03fviv5JbhPfCFrxLFHZPBMHxOjAarVmvhJxtMRjMjJeOLSFeSt3jLG71gM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709819506097876.9298265429028; Thu, 7 Mar 2024 05:51:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riE7I-0006nW-Oy; Thu, 07 Mar 2024 08:49:00 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riE4h-0005CY-Vb for qemu-devel@nongnu.org; Thu, 07 Mar 2024 08:46:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riE4G-0007FG-QC for qemu-devel@nongnu.org; Thu, 07 Mar 2024 08:46:18 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-163-RnpKO7mYM_aTOKBwda9c8g-1; Thu, 07 Mar 2024 08:45:07 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0909E101CC70; Thu, 7 Mar 2024 13:45:07 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9C22B17AA8; Thu, 7 Mar 2024 13:45:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709819110; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LuqhxuaXHnZuXhFECH4rZglZe6XiMM07102AtConlIs=; b=OmzbtbaJu50uxMiOgzPKANnNyEOV/aN/sZn9L+GEB4rXIyOFkDyTGizkozILC9we0Y1EM9 2vE3QrSdLywnwm6bisunXQ+NgZaNG4YLcoAaVnNTqcR8K+0hfS2s9eqGbHWiBzlDU4p8q8 QaHmy8MgcoT2sAozwr1MTiMyrJnfvE8= X-MC-Unique: RnpKO7mYM_aTOKBwda9c8g-1 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, mst@redhat.com, jean-philippe@linaro.org, imammedo@redhat.com, peter.maydell@linaro.org, clg@redhat.com, yanghliu@redhat.com, zhenzhong.duan@intel.com Cc: alex.williamson@redhat.com, jasowang@redhat.com, pbonzini@redhat.com, berrange@redhat.com Subject: [PATCH v8 4/9] qemu-options.hx: Document the virtio-iommu-pci granule option Date: Thu, 7 Mar 2024 14:43:05 +0100 Message-ID: <20240307134445.92296-5-eric.auger@redhat.com> In-Reply-To: <20240307134445.92296-1-eric.auger@redhat.com> References: <20240307134445.92296-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.583, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709819507044100013 Content-Type: text/plain; charset="utf-8" We are missing an entry for the virtio-iommu-pci device. Add the information on which machine it is currently supported and document the new granule option. Signed-off-by: Eric Auger Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- v7 -> v8 - precise x86_64 and ARM --- qemu-options.hx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qemu-options.hx b/qemu-options.hx index 9a47385c15..379792a215 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1172,6 +1172,14 @@ SRST Please also refer to the wiki page for general scenarios of VT-d emulation in QEMU: https://wiki.qemu.org/Features/VT-d. =20 +``-device virtio-iommu-pci[,option=3D...]`` + This is only supported by ``-machine q35`` (x86_64) and ``-machine vir= t`` (ARM). + It supports below options: + + ``granule=3Dval`` (possible values are 4k, 8k, 16k, 64k and host; defa= ult: host) + This decides the default granule to be be exposed by the + virtio-iommu. If host, the granule matches the host page size. + ERST =20 DEF("name", HAS_ARG, QEMU_OPTION_name, --=20 2.41.0 From nobody Sun May 12 18:40:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709819795; cv=none; d=zohomail.com; s=zohoarc; b=adc/uvXXko+nl/TdEO253upFkx3XRnOGezJ5tFOqmb5XKpa8HwIf/EX2KA7jDvaMAdn9ClQN9h17mCPBe/chPBLHuAd7LyPT53pSFsfbk6YZcB6VoUVOnJX6GhcTc9XY1QN2Cwc9taYHIN+XJxHjwywDrx2Nf3IzsdRODzUlKCM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709819795; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cyZooDCSfcEkdv9/7vg+GOMr/LkugjJbT4YX/tuXRXs=; b=TEEr4tOSOq0OZLg68npK84Xz8LyNYWyGJUZgpKplCcNXpgZLNKD7t0f7fG2UMtuSwMliIU8Wo873xx2rYDJs3UQiF9DJbHgMZjEfBc0H5EuyD2Rv5nZLweA1svuJwB8bQXEHaD8xmFYpoF2rk2hg1rHPmwXbo0iCH/XatPGQXfI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170981979593253.61671529188163; Thu, 7 Mar 2024 05:56:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riE7V-0006u2-9b; Thu, 07 Mar 2024 08:49:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riE4h-0005Bf-Ry for qemu-devel@nongnu.org; Thu, 07 Mar 2024 08:46:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riE3q-0007G3-Em for qemu-devel@nongnu.org; Thu, 07 Mar 2024 08:46:05 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-587-59MbehsMP5GZ5I9H-EObkw-1; Thu, 07 Mar 2024 08:45:11 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C6D2A3C0EAA3; Thu, 7 Mar 2024 13:45:10 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4BC1E17AA5; Thu, 7 Mar 2024 13:45:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709819114; 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=cyZooDCSfcEkdv9/7vg+GOMr/LkugjJbT4YX/tuXRXs=; b=ZTENNedP0cxdrZtqzyVp21ocE8cxGsz0G0qnZUPlLgZf7uWjn6uHRrGMYMJ7N7oZLghcNS +zhSZNHSlZ11DWp/GVvBbpcpcqYDXFGKlDKdKoRQznMNd4pW9+MQ4zW5mYuskJ4QZxVcvr X/6jlm6Sh2jJCpT/ICIdtp4Y8UT7xqI= X-MC-Unique: 59MbehsMP5GZ5I9H-EObkw-1 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, mst@redhat.com, jean-philippe@linaro.org, imammedo@redhat.com, peter.maydell@linaro.org, clg@redhat.com, yanghliu@redhat.com, zhenzhong.duan@intel.com Cc: alex.williamson@redhat.com, jasowang@redhat.com, pbonzini@redhat.com, berrange@redhat.com Subject: [PATCH v8 5/9] virtio-iommu: Trace domain range limits as unsigned int Date: Thu, 7 Mar 2024 14:43:06 +0100 Message-ID: <20240307134445.92296-6-eric.auger@redhat.com> In-Reply-To: <20240307134445.92296-1-eric.auger@redhat.com> References: <20240307134445.92296-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709819796452100005 Use %u format to trace domain_range limits. Signed-off-by: Eric Auger Reviewed-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- hw/virtio/trace-events | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/trace-events b/hw/virtio/trace-events index 77905d1994..2350849fbd 100644 --- a/hw/virtio/trace-events +++ b/hw/virtio/trace-events @@ -111,7 +111,7 @@ virtio_iommu_device_reset(void) "reset!" virtio_iommu_system_reset(void) "system reset!" virtio_iommu_get_features(uint64_t features) "device supports features=3D0= x%"PRIx64 virtio_iommu_device_status(uint8_t status) "driver status =3D %d" -virtio_iommu_get_config(uint64_t page_size_mask, uint64_t start, uint64_t = end, uint32_t domain_start, uint32_t domain_end, uint32_t probe_size, uint8= _t bypass) "page_size_mask=3D0x%"PRIx64" input range start=3D0x%"PRIx64" in= put range end=3D0x%"PRIx64" domain range start=3D%d domain range end=3D%d p= robe_size=3D0x%x bypass=3D0x%x" +virtio_iommu_get_config(uint64_t page_size_mask, uint64_t start, uint64_t = end, uint32_t domain_start, uint32_t domain_end, uint32_t probe_size, uint8= _t bypass) "page_size_mask=3D0x%"PRIx64" input range start=3D0x%"PRIx64" in= put range end=3D0x%"PRIx64" domain range start=3D%u domain range end=3D%u p= robe_size=3D0x%x bypass=3D0x%x" virtio_iommu_set_config(uint8_t bypass) "bypass=3D0x%x" virtio_iommu_attach(uint32_t domain_id, uint32_t ep_id) "domain=3D%d endpo= int=3D%d" virtio_iommu_detach(uint32_t domain_id, uint32_t ep_id) "domain=3D%d endpo= int=3D%d" --=20 2.41.0 From nobody Sun May 12 18:40:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709819384; cv=none; d=zohomail.com; s=zohoarc; b=UiMxK/dbOE5YqPi+j2JKV1VWhyTU/Ju3k+NF1OM68A+ERtlb68xG3hyGWd3OBbw7tjqeOdWKtoZVK/ZRbKNlTefOX+8VUpW0yntEhDIX0Psy20ZyS3BvgGCs6py5eD8IZZ7CC6EbdNO052+3YPph6MShKJtBWSFTr8jwFO+6Wh0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709819384; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=1FgQp0WRWuM7fbneXl+zhQwiRO3lZEEXkMeE6HtVWUQ=; b=IQZUMTZbM/HMPpNOA6Bkc4rwqvWgdfbvp26S0KLuMpXucqNk+AN67HMxedsdB2BiioGKgocMMDanDGDx260MDpWGHGXoUXmnld9qaQpVc7nCyY0hrj8dauYsxWN4leTqYyiglWdY/chHY6wMN1+bY+ODnk+UlV0gguqZUcceRoc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709819384893175.79289904798463; Thu, 7 Mar 2024 05:49:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riE7G-0006mb-Tf; Thu, 07 Mar 2024 08:48:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riE4g-0005Bd-G5 for qemu-devel@nongnu.org; Thu, 07 Mar 2024 08:46:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riE4C-0007I2-VS for qemu-devel@nongnu.org; Thu, 07 Mar 2024 08:46:04 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-156-ornFrTirMP6MRB-FrbipNA-1; Thu, 07 Mar 2024 08:45:14 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 76BEF1C00D19; Thu, 7 Mar 2024 13:45:14 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 16D4F17AA6; Thu, 7 Mar 2024 13:45:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709819120; 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=1FgQp0WRWuM7fbneXl+zhQwiRO3lZEEXkMeE6HtVWUQ=; b=iLYjijIA4y31gUUO9/b4v15aZIBwS6EajAQ7/17BnH6gLgkGn0eigcvNeoOaoPUmdxKT1x /wigqJ8H1oitG0BHuKwLtKwDHMC8kDO275WDNWy55HColjy5CnWTisbeQ3sklVavZkaKWN Ysu2E8JvmpOtBFXeNoDQ3BhvFLmVfDg= X-MC-Unique: ornFrTirMP6MRB-FrbipNA-1 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, mst@redhat.com, jean-philippe@linaro.org, imammedo@redhat.com, peter.maydell@linaro.org, clg@redhat.com, yanghliu@redhat.com, zhenzhong.duan@intel.com Cc: alex.williamson@redhat.com, jasowang@redhat.com, pbonzini@redhat.com, berrange@redhat.com Subject: [PATCH v8 6/9] virtio-iommu: Add an option to define the input range width Date: Thu, 7 Mar 2024 14:43:07 +0100 Message-ID: <20240307134445.92296-7-eric.auger@redhat.com> In-Reply-To: <20240307134445.92296-1-eric.auger@redhat.com> References: <20240307134445.92296-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.583, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709819386589100006 aw-bits is a new option that allows to set the bit width of the input address range. This value will be used as a default for the device config input_range.end. By default it is set to 64 bits which is the current value. Signed-off-by: Eric Auger Reviewed-by: Zhenzhong Duan Reviewed-by: C=C3=A9dric Le Goater --- v7 -> v8: - add return when error [Phil] v1 -> v2: - Check the aw-bits value is within [32,64] --- include/hw/virtio/virtio-iommu.h | 1 + hw/virtio/virtio-iommu.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/include/hw/virtio/virtio-iommu.h b/include/hw/virtio/virtio-io= mmu.h index 67ea5022af..83a52cc446 100644 --- a/include/hw/virtio/virtio-iommu.h +++ b/include/hw/virtio/virtio-iommu.h @@ -68,6 +68,7 @@ struct VirtIOIOMMU { Notifier machine_done; bool granule_frozen; GranuleMode granule_mode; + uint8_t aw_bits; }; =20 #endif diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index aab97e1527..1326c6ec41 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -1314,7 +1314,12 @@ static void virtio_iommu_device_realize(DeviceState = *dev, Error **errp) * in vfio realize */ s->config.bypass =3D s->boot_bypass; - s->config.input_range.end =3D UINT64_MAX; + if (s->aw_bits < 32 || s->aw_bits > 64) { + error_setg(errp, "aw-bits must be within [32,64]"); + return; + } + s->config.input_range.end =3D + s->aw_bits =3D=3D 64 ? UINT64_MAX : BIT_ULL(s->aw_bits) - 1; =20 switch (s->granule_mode) { case GRANULE_MODE_4K: @@ -1544,6 +1549,7 @@ static Property virtio_iommu_properties[] =3D { DEFINE_PROP_BOOL("boot-bypass", VirtIOIOMMU, boot_bypass, true), DEFINE_PROP_GRANULE_MODE("granule", VirtIOIOMMU, granule_mode, GRANULE_MODE_HOST), + DEFINE_PROP_UINT8("aw-bits", VirtIOIOMMU, aw_bits, 64), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.41.0 From nobody Sun May 12 18:40:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709819504; cv=none; d=zohomail.com; s=zohoarc; b=BuBJahXBh+n26px/3TEZ74912JW/DnNbvsGiop/g5UNwkklmcoxzcH3tkrOUA5ioUlDKQDGLeY2OW0x9rbg0OeGntdRaGNQLzkABUCROCNYALLs+Mgg8VJOJbvVXhDiyzwN4//1vH3+tmbBMz80o4vYeP7HY76DJD9lKKT8PQQ8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709819504; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=czEcqsIErIQNXIn00F0Uho7fUouArtsC4cjIi74+OlU=; b=adWfLcv3HnkBq6RJwhoSKO8UeyNch6Gzx2equjdypo/o58uD3wTuOxNymH22VFh9i1hq1pVgcAcJMqb5mpSyUY/zDYmWwYAxJtVgtfb2fkRJqPGMDR9GOFiaMdL/U7HQe3Tzu0q6Mn3CY1yY+S3J4Oe1gYKwOteiVlzkNM7cAws= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709819504614303.1527873962266; Thu, 7 Mar 2024 05:51:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riE7z-0007TI-3w; Thu, 07 Mar 2024 08:49:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riE4g-0005Bt-T2 for qemu-devel@nongnu.org; Thu, 07 Mar 2024 08:46:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riE4C-0007Ie-Vc for qemu-devel@nongnu.org; Thu, 07 Mar 2024 08:46:04 -0500 Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-456-QiUoSJkzNPO-XPXDh28xbQ-1; Thu, 07 Mar 2024 08:45:18 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 26DE01C00D27; Thu, 7 Mar 2024 13:45:18 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC5B417AA8; Thu, 7 Mar 2024 13:45:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709819122; 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=czEcqsIErIQNXIn00F0Uho7fUouArtsC4cjIi74+OlU=; b=fk8hYDo5GP2YvVDqkCRlUZP+QNULJPvhEWUBgiGGvbpvxmLIT05MoprA5fWK3aFPbACVDz Ge8tEKd3YXVgVL6RccMWEyWI2lLIFfgNL7U3DA6zwbIFTSTpfNZ7kf4t4JkvP5Xd3jPoyj rB0QoNCiq68EzoKJBqQMPgIzFG7ITnI= X-MC-Unique: QiUoSJkzNPO-XPXDh28xbQ-1 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, mst@redhat.com, jean-philippe@linaro.org, imammedo@redhat.com, peter.maydell@linaro.org, clg@redhat.com, yanghliu@redhat.com, zhenzhong.duan@intel.com Cc: alex.williamson@redhat.com, jasowang@redhat.com, pbonzini@redhat.com, berrange@redhat.com Subject: [PATCH v8 7/9] hw/i386/q35: Set virtio-iommu aw-bits default value to 39 Date: Thu, 7 Mar 2024 14:43:08 +0100 Message-ID: <20240307134445.92296-8-eric.auger@redhat.com> In-Reply-To: <20240307134445.92296-1-eric.auger@redhat.com> References: <20240307134445.92296-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.583, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709819505015100006 Currently the default input range can extend to 64 bits. On x86, when the virtio-iommu protects vfio devices, the physical iommu may support only 39 bits. Let's set the default to 39, as done for the intel-iommu. We use hw_compat_8_2 to handle the compatibility for machines before 9.0 which used to have a virtio-iommu default input range of 64 bits. Of course if aw-bits is set from the command line, the default is overriden. Signed-off-by: Eric Auger --- v6 -> v7: - use static pc_q35_compat_defaults - remove spurious header addition - s/32/UINT32_MAX in the qtest v5 -> v6: - split pc/arm settings v3 -> v4: - update the qos test to relax the check on the max input IOVA v2 -> v3: - collected Zhenzhong's R-b - use &error_abort instead of NULL error handle on object_property_get_uint() call (C=C3=A9dric) - use VTD_HOST_AW_39BIT (C=C3=A9dric) v1 -> v2: - set aw-bits to 48b on ARM - use hw_compat_8_2 to handle the compat for older machines which used 64b as a default --- hw/core/machine.c | 1 + hw/i386/pc_q35.c | 9 +++++++++ tests/qtest/virtio-iommu-test.c | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 6bd09d4592..4b89172d1c 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -35,6 +35,7 @@ =20 GlobalProperty hw_compat_8_2[] =3D { { TYPE_VIRTIO_IOMMU_PCI, "granule", "4k" }, + { TYPE_VIRTIO_IOMMU_PCI, "aw-bits", "64" }, }; const size_t hw_compat_8_2_len =3D G_N_ELEMENTS(hw_compat_8_2); =20 diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 45a4102e75..1e7464d39a 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -45,6 +45,7 @@ #include "hw/i386/pc.h" #include "hw/i386/amd_iommu.h" #include "hw/i386/intel_iommu.h" +#include "hw/virtio/virtio-iommu.h" #include "hw/display/ramfb.h" #include "hw/ide/pci.h" #include "hw/ide/ahci-pci.h" @@ -63,6 +64,12 @@ /* ICH9 AHCI has 6 ports */ #define MAX_SATA_PORTS 6 =20 +static GlobalProperty pc_q35_compat_defaults[] =3D { + { TYPE_VIRTIO_IOMMU_PCI, "aw-bits", "39" }, +}; +static const size_t pc_q35_compat_defaults_len =3D + G_N_ELEMENTS(pc_q35_compat_defaults); + struct ehci_companions { const char *name; int func; @@ -356,6 +363,8 @@ static void pc_q35_machine_options(MachineClass *m) machine_class_allow_dynamic_sysbus_dev(m, TYPE_INTEL_IOMMU_DEVICE); machine_class_allow_dynamic_sysbus_dev(m, TYPE_RAMFB_DEVICE); machine_class_allow_dynamic_sysbus_dev(m, TYPE_VMBUS_BRIDGE); + compat_props_add(m->compat_props, + pc_q35_compat_defaults, pc_q35_compat_defaults_len); } =20 static void pc_q35_9_0_machine_options(MachineClass *m) diff --git a/tests/qtest/virtio-iommu-test.c b/tests/qtest/virtio-iommu-tes= t.c index 068e7a9e6c..afb225971d 100644 --- a/tests/qtest/virtio-iommu-test.c +++ b/tests/qtest/virtio-iommu-test.c @@ -34,7 +34,7 @@ static void pci_config(void *obj, void *data, QGuestAlloc= ator *t_alloc) uint8_t bypass =3D qvirtio_config_readb(dev, 36); =20 g_assert_cmpint(input_range_start, =3D=3D, 0); - g_assert_cmphex(input_range_end, =3D=3D, UINT64_MAX); + g_assert_cmphex(input_range_end, >=3D, UINT32_MAX); g_assert_cmpint(domain_range_start, =3D=3D, 0); g_assert_cmpint(domain_range_end, =3D=3D, UINT32_MAX); g_assert_cmpint(bypass, =3D=3D, 1); --=20 2.41.0 From nobody Sun May 12 18:40:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709819505; cv=none; d=zohomail.com; s=zohoarc; b=Nhpm1tAI8Z2eIohnBabeF9+rU9Tap38LZIID+VPqjNIePSo0wECVjSyg9dOhS27cn2KxLwwXVhsJJpyxo8STXwNtXOCSZGRvOZCl+8F81G3j01gTDYstYCrEq9vXFWP8I6/QMElZZy26oyaXER6fFX0INa+EgrOhMRVH6Appfo4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709819505; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=chKv2cBabJOJEUIJJ5A4r+Q2wAgq0Jq23Cv/UF3W8pk=; b=oBPX6ma4g7DPUcWpBVxYaWnKbFsj6wOdH9s5Sc1jGMJJ0e+BQ+nL/eGbMlp5Hy+OsuMqdU9uffsaaAmV+3RV1Kmz3q3tdhu0r+dxDu/Pm6U7IJqgFEYLpg31vKj4rGu0+ts4WxCdkeHRtsmkz1opB0fR1Bt/3oqiq2G75SfZ6ac= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17098195059161016.249089071277; Thu, 7 Mar 2024 05:51:45 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riE7H-0006n4-T9; Thu, 07 Mar 2024 08:48:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riE4g-0005Bu-TA for qemu-devel@nongnu.org; Thu, 07 Mar 2024 08:46:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riE4C-0007M8-VS for qemu-devel@nongnu.org; Thu, 07 Mar 2024 08:46:05 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-628-AwK_PLSFO-adyOL0ev9Hzw-1; Thu, 07 Mar 2024 08:45:23 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 13FA28F4781; Thu, 7 Mar 2024 13:45:22 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A3C417AA5; Thu, 7 Mar 2024 13:45:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709819130; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=chKv2cBabJOJEUIJJ5A4r+Q2wAgq0Jq23Cv/UF3W8pk=; b=cKxsxfNKJONRMMwVQCIB5Pqd7MCZSEy/tCM8aylOR2Gkzws/nfoCYwCEw2bBRC2Kw6EBR0 8H6f9pfcbILxRxgwAMb2BIy/S8dgWTiu13eTkaxgy7ZWm/20hM1jaPQBW7R8QVPj0yQo7v 24AO6sNXuCf8Wl0MlqVz6NBaPZDeJ10= X-MC-Unique: AwK_PLSFO-adyOL0ev9Hzw-1 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, mst@redhat.com, jean-philippe@linaro.org, imammedo@redhat.com, peter.maydell@linaro.org, clg@redhat.com, yanghliu@redhat.com, zhenzhong.duan@intel.com Cc: alex.williamson@redhat.com, jasowang@redhat.com, pbonzini@redhat.com, berrange@redhat.com Subject: [PATCH v8 8/9] hw/arm/virt: Set virtio-iommu aw-bits default value to 48 Date: Thu, 7 Mar 2024 14:43:09 +0100 Message-ID: <20240307134445.92296-9-eric.auger@redhat.com> In-Reply-To: <20240307134445.92296-1-eric.auger@redhat.com> References: <20240307134445.92296-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.583, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709819507046100014 Content-Type: text/plain; charset="utf-8" On ARM we set 48b as a default (matching SMMUv3 SMMU_IDR5.VAX =3D=3D 0). hw_compat_8_2 is used to handle the compatibility for machine types before 9.0 (default was 64 bits). Signed-off-by: Eric Auger Reviewed-by: Zhenzhong Duan --- v6 -> v7 turn arm_virt_compat and arm_virt_compat_len static --- hw/arm/virt.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 0af1943697..e5cd935232 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -85,11 +85,28 @@ #include "hw/char/pl011.h" #include "qemu/guest-random.h" =20 +static GlobalProperty arm_virt_compat[] =3D { + { TYPE_VIRTIO_IOMMU_PCI, "aw-bits", "48" }, +}; +static const size_t arm_virt_compat_len =3D G_N_ELEMENTS(arm_virt_compat); + +/* + * This cannot be called from the virt_machine_class_init() because + * TYPE_VIRT_MACHINE is abstract and mc->compat_props g_ptr_array_new() + * only is called on virt non abstract class init. + */ +static void arm_virt_compat_set(MachineClass *mc) +{ + compat_props_add(mc->compat_props, arm_virt_compat, + arm_virt_compat_len); +} + #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ void *data) \ { \ MachineClass *mc =3D MACHINE_CLASS(oc); \ + arm_virt_compat_set(mc); \ virt_machine_##major##_##minor##_options(mc); \ mc->desc =3D "QEMU " # major "." # minor " ARM Virtual Machine"; \ if (latest) { \ --=20 2.41.0 From nobody Sun May 12 18:40:17 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1709819391; cv=none; d=zohomail.com; s=zohoarc; b=c2qLKI68+zgW+6ozZ2O7o6yHKiCYH9IKzt/J8Py4iJwJ9GOYWbak6bUVfSuWRLW4Lqb1IDsaBIz9TyUNdsQAsnn+9wk63U4SFaUsex+AXrgfNGDQhyFz8vvRDwmohxs+HViANqGji1lrLEiwv7UA31DXLlTDFqORARBQHc3xKII= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709819391; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mEN4q9jJ+qzM8VxqRYFb6XiPswpU0UkMhMmZLMHWIEU=; b=fC/BSo1txi7XbHq9JZxGu+ziOXMNbSjSXUD0mBtuL2rNGekTDap/I/nr2lhGDuCm6LsERgY0fTamsrXPqMUBdE5J9FdLdSkzzFnqzZ3HMjEuj/40hl7/Aimi+JwYqb9eLlZT08DopwkaA9eDeXGB2/lTpKdttd6uqtUO1mokmeU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709819391464717.9278647185146; Thu, 7 Mar 2024 05:49:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1riE7H-0006mw-M0; Thu, 07 Mar 2024 08:48:59 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riE4h-0005CJ-TT for qemu-devel@nongnu.org; Thu, 07 Mar 2024 08:46:22 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1riE4G-0007NJ-Pw for qemu-devel@nongnu.org; Thu, 07 Mar 2024 08:46:18 -0500 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-638-cpNTy1V1OpSHpW5y8PXs0g-1; Thu, 07 Mar 2024 08:45:32 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7E352181B20F; Thu, 7 Mar 2024 13:45:27 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 56D2517AAC; Thu, 7 Mar 2024 13:45:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709819135; 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=mEN4q9jJ+qzM8VxqRYFb6XiPswpU0UkMhMmZLMHWIEU=; b=PX53UqSTwlV4Qd0v3GFv0Xg4F+GBpcMl7WS979d0eBrybsT3Z4A/WQGNbwH8cqfRfyDA68 bVivWwajwg8l1YtqJ83w1ZY9spvQP5ay0ljevJD3SrwV+OCbeVgk33qOAbeEwFLlT6Ke+z UPCIqgjLwAKph7LGr304W713cDCrKIA= X-MC-Unique: cpNTy1V1OpSHpW5y8PXs0g-1 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, mst@redhat.com, jean-philippe@linaro.org, imammedo@redhat.com, peter.maydell@linaro.org, clg@redhat.com, yanghliu@redhat.com, zhenzhong.duan@intel.com Cc: alex.williamson@redhat.com, jasowang@redhat.com, pbonzini@redhat.com, berrange@redhat.com Subject: [PATCH v8 9/9] qemu-options.hx: Document the virtio-iommu-pci aw-bits option Date: Thu, 7 Mar 2024 14:43:10 +0100 Message-ID: <20240307134445.92296-10-eric.auger@redhat.com> In-Reply-To: <20240307134445.92296-1-eric.auger@redhat.com> References: <20240307134445.92296-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.583, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1709819392522100003 Document the new aw-bits option. Signed-off-by: Eric Auger --- v7 -> v8: - remove "it defaults" - removed Cedric's R-b v4 -> v5 - tweek the aw-bits option description according to C=C3=A9dric's suggestion --- qemu-options.hx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qemu-options.hx b/qemu-options.hx index 379792a215..9d49ce9460 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -1180,6 +1180,9 @@ SRST This decides the default granule to be be exposed by the virtio-iommu. If host, the granule matches the host page size. =20 + ``aw-bits=3Dval`` (val between 32 and 64, default depends on machine) + This decides the address width of the IOVA address space. + ERST =20 DEF("name", HAS_ARG, QEMU_OPTION_name, --=20 2.41.0