From nobody Tue Nov 26 05:33:51 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=1709757295; cv=none; d=zohomail.com; s=zohoarc; b=aIJbfi9/dWPVLxLELIlYVUG1C79+sDOpxEGgaO5RmmJb81caDUI243D174lKep3qJYxsx3sM5WNj1SbAwVRrLj8zTezimTQjcjrx8AsKdQx0s3WblIIyrlQhElVIX98SGLDQ6jPWUbJWBbN/xuJqhycSVbg70vvnDFPPpfWhVnI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709757295; 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=Cnqpauqw/aVL+r/RtHO6cJCqgYyFFJ7LK4xyZi4aNiyrUqmeQ1suAnBxlxVNIuDl8Ut6kQaRvJCYdp9piw6D1Jy8sA9vmFrBkNUhpQohvgUCkkC9bZi0SMXE1nksGVbOEH1dwNVh24BW9mbMdXBMoVr0tuL4/eD+CTyRsiVOFBI= 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 1709757295415149.71226059417825; Wed, 6 Mar 2024 12:34:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhxxt-0004Fh-Hz; Wed, 06 Mar 2024 15:34:15 -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 1rhxxl-0004Ep-PF for qemu-devel@nongnu.org; Wed, 06 Mar 2024 15:34:06 -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 1rhxxk-0001nQ-B1 for qemu-devel@nongnu.org; Wed, 06 Mar 2024 15:34: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-613-Rvi4R51iM1SVnqVhVlIKNQ-1; Wed, 06 Mar 2024 15:33:59 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 B07C389C663; Wed, 6 Mar 2024 20:33:58 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 49BB147CB; Wed, 6 Mar 2024 20:33:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709757243; 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=awPCQQs9RxwXWs6enxN1bxU4V6wLHwDyjTWmyxyUVuBeVTrcIcqGZkc3snS3rX4SY2zaVU SIlbvjlpq8tZUfCeZDbzNUYwQ52o9QZFU864pUpVOdHeu+ThgdaFQsiLfBKnpPgtH8eXHv CC0Y8gzBXSR8cMvM+WVj3fS/yHWejcQ= X-MC-Unique: Rvi4R51iM1SVnqVhVlIKNQ-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 v7 1/9] qdev: Add a granule_mode property Date: Wed, 6 Mar 2024 21:32:40 +0100 Message-ID: <20240306203348.65776-2-eric.auger@redhat.com> In-Reply-To: <20240306203348.65776-1-eric.auger@redhat.com> References: <20240306203348.65776-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.1 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.365, 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=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: 1709757296949100002 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 Tue Nov 26 05:33:51 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=1709757324; cv=none; d=zohomail.com; s=zohoarc; b=czUeruoD3rRzD1VNg+DujlZLc/0x4fBeTiKHK8LQRGua+HzEZD5P91j6d2/wBx2f5LVKOGJCKYiejShvsX/7ihLgI+6sEEAhgXDAaaIkst8kJDyroltH8Qp13zV+C8nxGAlG7ssHp2n7n3SXBBfQDSrfIK69kLBGC2o2nbKZR9k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709757324; 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=Zz467+J9al61ZoJBLvVtKaWosobBLpr9CSArctBOvxfkHuy9JmRavb1xapPnanncl32i+79DVxtQTok68DzZN9dzzqI3eAKpYqiW0Q+EDK+Valn1Hk965NH4TNreRTAxoExc79d5qbN2L4Jz/YGSCcNSCXC6uVsFkqLCg2/9Y4E= 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 1709757324523604.5079570031178; Wed, 6 Mar 2024 12:35:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhxy6-0004MM-FG; Wed, 06 Mar 2024 15:34:27 -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 1rhxxo-0004F6-Ly for qemu-devel@nongnu.org; Wed, 06 Mar 2024 15:34:09 -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 1rhxxn-0001nw-2e for qemu-devel@nongnu.org; Wed, 06 Mar 2024 15:34:08 -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-618-A6wJnyQIPU6QrmJcGpTOaw-1; Wed, 06 Mar 2024 15:34:03 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 714FE800262; Wed, 6 Mar 2024 20:34:02 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 07CB136FF; Wed, 6 Mar 2024 20:33:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709757246; 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=F8FaGotl3lG4DzV2g55DhrCqfaVO7WRvZA/T/FxqIJ47rhnVgsMNrJkzD/FZT17DEsU60g 4KfmDmcdwf/jWXSHc4vLmexT1Eif3vXVHWZ3HnoODcWKzOdpK7aHH1hSFW0ZLOlPxjGBy6 ECPjk8ikkBhZrey/NsMU3jg5vC86t0c= X-MC-Unique: A6wJnyQIPU6QrmJcGpTOaw-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 v7 2/9] virtio-iommu: Add a granule property Date: Wed, 6 Mar 2024 21:32:41 +0100 Message-ID: <20240306203348.65776-3-eric.auger@redhat.com> In-Reply-To: <20240306203348.65776-1-eric.auger@redhat.com> References: <20240306203348.65776-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.1 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.365, 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: 1709757325004100001 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 Tue Nov 26 05:33:51 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=1709757372; cv=none; d=zohomail.com; s=zohoarc; b=Uu7F4EWC/2Wk31vJmd5RKDjlqj9JpE7zcCdstsuBkg7Uet+Pf1oXAJ+WeHHtyx1ObliHnpOUiIx6FHKvs9+wqwUsceHcgrJq0R4lYzt5CndTkju+QFO/VlVATzc2qOUtshFF7X277XnphoCtSU5NEHA5FccME4knqe43ZBgs9R8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709757372; 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=G1MUDGDwNJcNYxMYPI5rg4qYCqzifxN03qFToe2xyyPr2yehW+HmOrmH8VUdtTBA+3mjrS4oOL1lZlhJ0bZE+mhCAaUTeRVLAnNey6wKxjw4HGU9VGBcAcyjz0I2H7tjAGI8KkKY2ck5CR5tRqW9FpiSX9+eNEkLNRaVRzO1NGg= 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 1709757372127415.94048046852924; Wed, 6 Mar 2024 12:36:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhxyE-0004Sr-5z; Wed, 06 Mar 2024 15:34:34 -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 1rhxxt-0004G3-U1 for qemu-devel@nongnu.org; Wed, 06 Mar 2024 15:34:15 -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 1rhxxs-0001oL-FA for qemu-devel@nongnu.org; Wed, 06 Mar 2024 15:34:13 -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-549-6MQ-kGa6OpyHH_UswJVa4Q-1; Wed, 06 Mar 2024 15:34:06 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 3252A800264; Wed, 6 Mar 2024 20:34:06 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4D9047CB; Wed, 6 Mar 2024 20:34:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709757250; 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=VDp76QcJig4srDf8g00XEsHIWC5XPe9kFGgb3o8YE/OiI3/X0o/V0TcVedG4dB/DpyCd4n NP6NTv8wrEX54oWwE5530PKWvhDr2N3vc7oI4TMpb90Lf//rVXBGiYUsB8WjUYwYeL0JDY oaEjcBsDweFYM9C7uZhz2dht8jbjiuU= X-MC-Unique: 6MQ-kGa6OpyHH_UswJVa4Q-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 v7 3/9] virtio-iommu: Change the default granule to the host page size Date: Wed, 6 Mar 2024 21:32:42 +0100 Message-ID: <20240306203348.65776-4-eric.auger@redhat.com> In-Reply-To: <20240306203348.65776-1-eric.auger@redhat.com> References: <20240306203348.65776-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.1 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.365, 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=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: 1709757373204100001 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 Tue Nov 26 05:33:51 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=1709757355; cv=none; d=zohomail.com; s=zohoarc; b=S5OSf2SIPB/909I7yR3FQ3BHK8wt6c+eOHZExGuLOmaeG1A9i5iRKUp9+bgCCCfBRFpn6RqE34Jlxvh+oBpEtvBPQE26+Ao3684fNWWiLvtY0vhznCWbjhCYEgC4FW0varexuqzwV+HGQxNVrrjZfim0BgybUvt9EmDP+ftaJmE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709757355; 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=Ds+IJz/k3bgm4Wib0Mb+o00Gd/ddoUQz4Q1KqkWK7dA=; b=PApvvXktedv1OHEipy32Bs78BBNKlWhuo4JMBVWw00wV+PQJoSoiMC8P99wkjUYN3H9R7vS9TH5eO6G5cVt9urKzvRt8X8Znq9KOvTe7AyM6uWMvzayDsW72MQP7iORKy2+XPQcssta1T3yzilNLsHBFeddm75Ut+xHypOdmlro= 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 1709757355576398.68207688122254; Wed, 6 Mar 2024 12:35:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhxyB-0004Og-F8; Wed, 06 Mar 2024 15:34:31 -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 1rhxxx-0004H8-4C for qemu-devel@nongnu.org; Wed, 06 Mar 2024 15:34:18 -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 1rhxxu-0001ol-FJ for qemu-devel@nongnu.org; Wed, 06 Mar 2024 15:34:15 -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-589-BD0XHLjNPcCv3nuZ8iA90g-1; Wed, 06 Mar 2024 15:34:10 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 E0E942804809; Wed, 6 Mar 2024 20:34:09 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 802EA36FF; Wed, 6 Mar 2024 20:34:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709757253; 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=Ds+IJz/k3bgm4Wib0Mb+o00Gd/ddoUQz4Q1KqkWK7dA=; b=Tb2Ahd8QjpYWdbGTv91GiSdvSCJW3Em2YAYA37/Y8tOOMA+NOtHzwui09o0XvhXR1FMclq zKXHvItDMPF2hQrHsB5n0l6nUSmit2rDVk1UxL+MJrrP6Fn/96Uh8RJeClEslBNg/tKzbj GUvIk86JNPvgaw8IXbGQP4JXDErhGMI= X-MC-Unique: BD0XHLjNPcCv3nuZ8iA90g-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 v7 4/9] qemu-options.hx: Document the virtio-iommu-pci granule option Date: Wed, 6 Mar 2024 21:32:43 +0100 Message-ID: <20240306203348.65776-5-eric.auger@redhat.com> In-Reply-To: <20240306203348.65776-1-eric.auger@redhat.com> References: <20240306203348.65776-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.1 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.365, 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=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: 1709757357068100005 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 --- qemu-options.hx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/qemu-options.hx b/qemu-options.hx index 9a47385c15..757df3eac0 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`` and ``-machine virt``. + 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 Tue Nov 26 05:33:51 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=1709757308; cv=none; d=zohomail.com; s=zohoarc; b=T8WF5gXN4+6WHdA6JHFXWIxB3N/RII/fv/GiXYIq0m9dUbyryHVhWQD5x3D3cal+4l+HZtLbmu4c+OVjeErsize58C8hx+SJ6PcInBwZjWx+wwNsk6J++YxvhfgBqB94hbt2s1KHk60o0R7hCAEnrPdsd08Z0ooTW7QV7CoS5S0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709757308; 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=hZ9WvbOAqi8InAmWBQR6TtDi85kq8kEC5rYV9VWt+s9zD3nh6CGkCKb6FzumF5ca2dXb3mqXmXnLcw0etVE5ZrZKsCAmpgCO7mn/JxKZ2QNPKnPn9kJfREj/VIDFObemZomDa9u+OBqGeLm/Z16NtQwCO1ps7Cjtl99Y/k/CNQI= 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 1709757308203486.0751078607949; Wed, 6 Mar 2024 12:35:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhxyD-0004Qj-AY; Wed, 06 Mar 2024 15:34:33 -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 1rhxxy-0004HE-Cp for qemu-devel@nongnu.org; Wed, 06 Mar 2024 15:34: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 1rhxxw-0001pA-Tp for qemu-devel@nongnu.org; Wed, 06 Mar 2024 15:34:18 -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-57-JxZUE-8rOqOyEXfX2VcA_A-1; Wed, 06 Mar 2024 15:34:14 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 98D692804800; Wed, 6 Mar 2024 20:34:13 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 30B2C3701; Wed, 6 Mar 2024 20:34:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709757255; 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=OwPcdCa51pFu4tjjlMsbWD7B2TM3wbHNJJNSAOixvxxeZ5gdA2YKUyOn/QESfi0IAdEByB NwtYKohN+wc39RlBwJi2wc9+2AzLk+0GKMNiQ24cDfnNyI3mIm5J+7GV6Lrvdw1l7rWvGq cKxFOsisT7sXD+KWkoYu6cWxefZu6+I= X-MC-Unique: JxZUE-8rOqOyEXfX2VcA_A-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 v7 5/9] virtio-iommu: Trace domain range limits as unsigned int Date: Wed, 6 Mar 2024 21:32:44 +0100 Message-ID: <20240306203348.65776-6-eric.auger@redhat.com> In-Reply-To: <20240306203348.65776-1-eric.auger@redhat.com> References: <20240306203348.65776-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.1 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.365, 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=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: 1709757308893100001 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 Tue Nov 26 05:33:51 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=1709757295; cv=none; d=zohomail.com; s=zohoarc; b=Tr8L1UlLVnGoRTlfOdNr/y0rNYTCgZn+EC+ighHKFY099r8pcuB8s0QpkIar5qGgsXwqxd/T6uPbFpgksYJoLez4+XhdH+6jFdy7Fd2guDSvRdnPP5sPjq24lfPMr444MRI3MwMlqP7KMP3SqhW7qSeVLjxeVTnAZJGutUykfD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709757295; 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=mtAnTSStkOKpy0/Q14u1Ipt8HVO4uL1e5P+fAKhJM+A=; b=GysOUnb4CInj1RlsN9+0R74KmBQ/kQOhOB7Don6nYD06LgD/rr4vsH0DkzL1+4havQ6eoRYo9nwJLS7D0jsJRSxgXbkz0wn2CpNHheusdZPPy3l84xaAPtMLCGQa4VD/g9oWZBOEXZhXqWIAGy+zKNFKoT5o/KFJGBxRqt5LcFU= 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 1709757295268753.5150681346031; Wed, 6 Mar 2024 12:34:55 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhxyI-0004UJ-9N; Wed, 06 Mar 2024 15:34:38 -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 1rhxy2-0004Ke-9c for qemu-devel@nongnu.org; Wed, 06 Mar 2024 15:34:24 -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 1rhxy0-0001q2-SN for qemu-devel@nongnu.org; Wed, 06 Mar 2024 15:34:22 -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-175-rgH-kNiNO7yzoVsBvg7fUA-1; Wed, 06 Mar 2024 15:34:17 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 6033A2804800; Wed, 6 Mar 2024 20:34:17 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC9D336FF; Wed, 6 Mar 2024 20:34:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709757259; 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=mtAnTSStkOKpy0/Q14u1Ipt8HVO4uL1e5P+fAKhJM+A=; b=AeLiZPuoOWYXyytSBQRn+BwH470K02+rSsfRXzr7O3umFl7t1Fe/YKm2SFWaojz15yletS ue7X06ImQ38IM2oWwwsJ5KE6HZfZ/fXZgyyKsju3aonD/cfMCglWIMRSBg8JIk9Ua8XgmP euxGXh2l6mRIojQLnGae/S4dpopTdw0= X-MC-Unique: rgH-kNiNO7yzoVsBvg7fUA-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 v7 6/9] virtio-iommu: Add an option to define the input range width Date: Wed, 6 Mar 2024 21:32:45 +0100 Message-ID: <20240306203348.65776-7-eric.auger@redhat.com> In-Reply-To: <20240306203348.65776-1-eric.auger@redhat.com> References: <20240306203348.65776-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.1 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.365, 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=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: 1709757296939100001 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 --- v1 -> v2: - Check the aw-bits value is within [32,64] --- include/hw/virtio/virtio-iommu.h | 1 + hw/virtio/virtio-iommu.c | 7 ++++++- 2 files changed, 7 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..9b2813188b 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -1314,7 +1314,11 @@ 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]"); + } + 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 +1548,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 Tue Nov 26 05:33:51 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=1709757377; cv=none; d=zohomail.com; s=zohoarc; b=c/CKOdD7yaRUhuvwdYTqPk18AMMwXUVrjxtXyfAagDy+Cp1X0Vpc3wiE5U4blnyv5/vrqVI7zOWmXY1ugrZI+mK+3rEB3Nf29iw5AqPo/M5tYGgSYIXdDnYJzxY/zwkYeN0SRR4pvW7ahMS1CFX3qTDHXy1aRndQYO3BcIlQrNE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709757377; 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=gmVKf/P5incIhdFrXifBbemuPN+TxRflgxZaw3pYVqvRfD3MtOJrAlU8zJBTaxT0uIefiQ98sIxg4OqVMiWxye5sRWnb7zN17HFCe5dzEec12piDfo0kG9W4EuT1d2njxIOvL7E+WoRYKK3rfAN8li7febCurishTA9ZMBwml88= 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 170975737775054.8435762588158; Wed, 6 Mar 2024 12:36:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhxyW-0004aO-BK; Wed, 06 Mar 2024 15:34: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 1rhxy8-0004Ni-EA for qemu-devel@nongnu.org; Wed, 06 Mar 2024 15:34:29 -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 1rhxy5-0001qa-GH for qemu-devel@nongnu.org; Wed, 06 Mar 2024 15:34:28 -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-441-aF8o0b6YPnG6APvJEwt9qw-1; Wed, 06 Mar 2024 15:34:21 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 115AA185A783; Wed, 6 Mar 2024 20:34:21 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id A4B043701; Wed, 6 Mar 2024 20:34:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709757264; 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=SaoYVvvU4tsNxIeZYP/M3JJBwppvROHwZh6izDYMKfZ7gh2TLWX99MOhvdnAJ79E2EG1zZ 2FsiZnwyDA3Rxn2I2nhisrRx5GXymLSvIJ/Mtlpb3iTqC0lMUEcqB9LKTeyqHih4tTuNnR QJ1HYaCnOVQB1IsScvWjfdpmPT0RDjg= X-MC-Unique: aF8o0b6YPnG6APvJEwt9qw-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 v7 7/9] hw/i386/q35: Set virtio-iommu aw-bits default value to 39 Date: Wed, 6 Mar 2024 21:32:46 +0100 Message-ID: <20240306203348.65776-8-eric.auger@redhat.com> In-Reply-To: <20240306203348.65776-1-eric.auger@redhat.com> References: <20240306203348.65776-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.1 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.365, 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=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: 1709757379296100001 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 Tue Nov 26 05:33:51 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=1709757352; cv=none; d=zohomail.com; s=zohoarc; b=dSr6CINZNOQiRuRrA4riRxPnmPNw5RqEn4fubSyEcQYKpHAIYjBLm2FGqFATaT8y78Ne4b30m7jB74YOts6o5UdsGLhzowl3qUh9CdR5cK2v65rG7W/Tc1BMJV0V1HLJ+JqE+dT55kR0/EOW1OrRmSTFCz0r4y4IbWn4sRYwI3U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709757352; 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=T8fD0r4SlH+yjhZAGRFIybDqF22TlS4Rg4TuygBnAsKEl2WCWX7lOrNHmuQQLNIjJ81BagGtZcWM2lmenJ2ZAG0Omd1e6IUQ+l1mwdRuAT0GGsUjk2wG5rpPQyOAHuhn1q3lHIlh/DWRVm+TvkN43lcy4ivlSTDFvkCiYscTEE0= 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 1709757352976569.6314883742353; Wed, 6 Mar 2024 12:35:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhxyK-0004Ud-Js; Wed, 06 Mar 2024 15:34:41 -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 1rhxyB-0004PZ-J5 for qemu-devel@nongnu.org; Wed, 06 Mar 2024 15:34:31 -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 1rhxyA-0001rG-1q for qemu-devel@nongnu.org; Wed, 06 Mar 2024 15:34:31 -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-457-ouZLYDpaMCyNnVR3ywvG_w-1; Wed, 06 Mar 2024 15:34:25 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 B69E78007A1; Wed, 6 Mar 2024 20:34:24 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5556736FF; Wed, 6 Mar 2024 20:34:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709757269; 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=KKsnoLbvZVf8QvaLU2iQdWXNKQH0LEeqipX3Sgxmw/UP1ntk/aN+U527foQg5rEW04moMF 3tUOe/X0vvSoNaaNnfY4MnQWl//bahNg16GlnhjgSmpJDQ43Vim7Xc9mtZgZC29wXZ6DmT PXHP6tKkC6StNV3xHWRG/g2wngP85Qk= X-MC-Unique: ouZLYDpaMCyNnVR3ywvG_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 v7 8/9] hw/arm/virt: Set virtio-iommu aw-bits default value to 48 Date: Wed, 6 Mar 2024 21:32:47 +0100 Message-ID: <20240306203348.65776-9-eric.auger@redhat.com> In-Reply-To: <20240306203348.65776-1-eric.auger@redhat.com> References: <20240306203348.65776-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.1 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.365, 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: 1709757355091100003 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 Tue Nov 26 05:33:51 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=1709757343; cv=none; d=zohomail.com; s=zohoarc; b=DRXWpcY23LggWjHIioCZg56cxl7V5Psz2+fRdhVfz0d7HKN2Muq9sbSl89PqOsRiG0+ppAVZfyAubZ1DHCqF46vrYbwJclV6oQk4IJvoyuCgxSv7Cu0tkMn05yMv+BC0TW0kQ3dn4EVQYJpCmhZRsT1qTlihJ+ZXgsvKp1x5cpk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1709757343; 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=qNjqP63Eeycrewa8Jj4wem7P+RbfIAVckxR+16X/ZBA=; b=d4SlfT0Y8DQI38/agkae7wA1qAIfvhoxPCL7bcXCCGA3ZwDxEDEOcwQ5sl4Zg4qJxEUhGbhnjG7kyi56YhGNC6YiqZ+Ndfz+nwwrOKzjSaV0X4qsPsCKD1eCh9Q2Ibf9gkGrzJKCYBOPXu0Z1D8X+Z5K/BmEhwsTEKLowIhmEOU= 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 170975734368861.97742524178602; Wed, 6 Mar 2024 12:35:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rhxyX-0004fB-7S; Wed, 06 Mar 2024 15:34:53 -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 1rhxyD-0004Ru-KG for qemu-devel@nongnu.org; Wed, 06 Mar 2024 15:34:33 -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 1rhxyB-0001rl-Am for qemu-devel@nongnu.org; Wed, 06 Mar 2024 15:34:33 -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-126-XYM0yGA2Pz-HuEishwvWgw-1; Wed, 06 Mar 2024 15:34:29 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 7144B85A58C; Wed, 6 Mar 2024 20:34:28 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0AEF637F6; Wed, 6 Mar 2024 20:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709757270; 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=qNjqP63Eeycrewa8Jj4wem7P+RbfIAVckxR+16X/ZBA=; b=F+j1icV96U2IAQ26hHyWMcMDjR0izQFcNTAcz/Lkj+zRxp9PxGZ52ZgCl2ywr56qLgzTUL /Zbv3QJMc3wkSY9OjvUsHEn4ynsyzT4lISFYLnz2WDPsBMqHIhEwdIyRgEz5Ku44M0TLF/ ignUzm0tWL/NWhZAn899/bGnotB6Hj0= X-MC-Unique: XYM0yGA2Pz-HuEishwvWgw-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 v7 9/9] qemu-options.hx: Document the virtio-iommu-pci aw-bits option Date: Wed, 6 Mar 2024 21:32:48 +0100 Message-ID: <20240306203348.65776-10-eric.auger@redhat.com> In-Reply-To: <20240306203348.65776-1-eric.auger@redhat.com> References: <20240306203348.65776-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.1 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: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.365, 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: 1709757345036100001 Document the new aw-bits option. Signed-off-by: Eric Auger Reviewed-by: C=C3=A9dric Le Goater --- 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 757df3eac0..87959ede08 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 IOVA address space. It defaults + ERST =20 DEF("name", HAS_ARG, QEMU_OPTION_name, --=20 2.41.0