Received: by 2002:a17:906:3953:b0:a3d:1c09:7d3d with SMTP id g19csp311820eje; Tue, 13 Feb 2024 10:30:40 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCX2V24c3uRtSrPUfoWqmQn9nzbhRdq2AgDUHLy3KlvxXBe5MpuWEH7mEDFHaUkZcSaBQu2Gc5XlJqLJ5uQOncQEVGNcaYSl X-Google-Smtp-Source: AGHT+IHgErVgXi1hDCdIPyP9MfdKyf05ix2iQLCXYyTeMKC7QdtfJoB+CywvfwQgouf5kUo4+xXz X-Received: by 2002:a0c:f34d:0:b0:68d:1500:66a7 with SMTP id e13-20020a0cf34d000000b0068d150066a7mr329345qvm.50.1707849040635; Tue, 13 Feb 2024 10:30:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707849040; cv=none; d=google.com; s=arc-20160816; b=OrVzL2DPfXmraqh1rcW2OGuii9kZStivXAeOsFQ1H3aJ2dDw6heWZCsmWzPjORj/3j E5uL3ixuCxZKi+Vm5kCU4o/GyaaIw7LaaZrpA5Rw2yT1i6eDsIbsdZi/okIZsoOGPL/y tEYCjOATdTpOD2N0QXZf46XbsmEYzMM5zEDcB+Jt5H6W+YTT3G7Qm0Ybtv5oDZLM78bz 11ZQgiSSOGin74TCadQxgOKsCW2T5bIKsJBDpn08zZQNoMmQ8AAql72bxTrjCfjitmLd 3hGx01UsmJ3v1WPTz7LfJpwkz3RsDUnDlqvDDb0u9fMPChO159vPPA3prow4L3qzUgnr Bcyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=mTAQs9dMz92UFHNPid8w50AvKN0MwDzNhUcDn3Zc3tI=; fh=rqUKX6aeOlFlXx3z0H6aa+I5d9GYVjZXJjhRdQbiZg4=; b=WXa/V4L91XzOvJftYKNBlrsrzR360hoLc3hrTMKlk/OFEm4N+Bm/6sBldMlF1i0ENa JhYxryK4GMYJqtJgwHvNQyVgcMNVrPXNpO0Fo+dQACUf6vIhxOxuHnLxlm1wAweeAC8v bbrT3zeAidYXE2TTK+NU7vCIwXAm1wVTxvGlwLbbfoFAo7rcCxEQpfjBvKuq6rUoYBMl psDToW4wcBNlnlS8XWtOY14UKNmtHWzN0DJ7noye2FQt8xwulvgE/ebeWT2+7rbqeUel AieFqWA7yQCMF1Ij1QNQo3zM2zC2Ah3xwK8aJvYTZCMYPSvt4UnvnP6A59P1sfb2yJfz icUg==; darn=linaro.org ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NDFtPvBr; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com X-Forwarded-Encrypted: i=1; AJvYcCXs7iasleUJl2DpCDNEjPW8jhRklBlj7BmKmgn7ah5f0TFoqzBKMskXkcfhBYgXYmk4lE+RoyeunYYPpxiG8/z1Uf7WBcDL Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r4-20020a056214212400b0068562009ae9si3838004qvc.3.2024.02.13.10.30.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 13 Feb 2024 10:30:40 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NDFtPvBr; spf=pass (google.com: domain of qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZxXR-0006eS-Tg; Tue, 13 Feb 2024 13:29:49 -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 1rZxXQ-0006c4-Ce for qemu-devel@nongnu.org; Tue, 13 Feb 2024 13:29:48 -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 1rZxXO-0001qw-OI for qemu-devel@nongnu.org; Tue, 13 Feb 2024 13:29:48 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1707848985; 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; bh=mTAQs9dMz92UFHNPid8w50AvKN0MwDzNhUcDn3Zc3tI=; b=NDFtPvBrW4KtdWqyLdOqA6qOmQ4vRLcvx/x5UX8D+dqcHPOqJVQiEjw6TmSA6MJaBI3QPt FBPpf6Lu0N1DrcjM/lgCwcqifp1bAumiLi0mNEmsZ3lZqxHWHkHBWE7Z+30ze/8gFd36C1 VeM+l9lvVSBJSjL5Qur/i0evN4QIJ7Q= 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-516-VgB7ARJlOXWjC4sOjk0NeA-1; Tue, 13 Feb 2024 13:29:42 -0500 X-MC-Unique: VgB7ARJlOXWjC4sOjk0NeA-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 1780D106D0C5; Tue, 13 Feb 2024 18:29:42 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.193.101]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CE2140CD14A; Tue, 13 Feb 2024 18:29:38 +0000 (UTC) From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, qemu-devel@nongnu.org, qemu-arm@nongnu.org, jean-philippe@linaro.org, mst@redhat.com, peter.maydell@linaro.org, clg@redhat.com, zhenzhong.duan@intel.com, yanghliu@redhat.com Cc: alex.williamson@redhat.com, jasowang@redhat.com Subject: [PATCH v4 0/4] VIRTIO-IOMMU: Introduce an aw-bits option Date: Tue, 13 Feb 2024 19:28:27 +0100 Message-ID: <20240213182933.825268-1-eric.auger@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 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: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.504, 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+alex.bennee=linaro.org@nongnu.org Sender: qemu-devel-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: j2fBU6yu1U1V In [1] and [2] we attempted to fix a case where a VFIO-PCI device protected with a virtio-iommu is assigned to an x86 guest. On x86 the physical IOMMU may have an address width (gaw) of 39 or 48 bits whereas the virtio-iommu exposes a 64b input address space by default. Hence the guest may try to use the full 64b space and DMA MAP failures may be encountered. To work around this issue we endeavoured to pass usable host IOVA regions (excluding the out of range space) from VFIO to the virtio-iommu device so that the virtio-iommu driver can query those latter during the probe request and let the guest iommu kernel subsystem carve them out. However if there are several devices in the same iommu group, only the reserved regions of the first one are taken into account by the iommu subsystem of the guest. This generally works on baremetal because devices are not going to expose different reserved regions. However in our case, this may prevent from taking into account the host iommu geometry. So the simplest solution to this problem looks to introduce an input address width option, aw-bits, which matches what is done on the intel-iommu. By default, from now on it is set to 39 bits with pc_q35 and 48 with arm virt. This replaces the previous default value of 64b. So we need to introduce a compat for machines older than 9.0 to behave similarly. We use hw_compat_8_2 to acheive that goal. Outstanding series [2] remains useful to let resv regions beeing communicated on time before the probe request. [1] [PATCH v4 00/12] VIRTIO-IOMMU/VFIO: Don't assume 64b IOVA space https://lore.kernel.org/all/20231019134651.842175-1-eric.auger@redhat.com/ - This is merged - [2] [RFC 0/7] VIRTIO-IOMMU/VFIO: Fix host iommu geometry handling for hotplugged devices https://lore.kernel.org/all/20240117080414.316890-1-eric.auger@redhat.com/ - This is pending for review on the ML - This series can be found at: https://github.com/eauger/qemu/tree/virtio-iommu-aw-bits-v4 previous https://github.com/eauger/qemu/tree/virtio-iommu-aw-bits-v3 History: v3 -> v4: - remove dependency on [PATCH v2] virtio-iommu: Use qemu_real_host_page_mask as default page_size_mask - Fix qtest error [Michael] - add doc entry in qemu-options.hx v2 -> v3: - Collected Zhenzhong and Cédric's R-b + Yanghang's T-b - use &error_abort instead of NULL error handle on object_property_get_uint() call (Cédric) - use VTD_HOST_AW_39BIT (Cédric) v1 -> v2 - Limit aw to 48b on ARM - Check aw is within [32,64] - Use hw_compat_8_2 Eric Auger (4): virtio-iommu: Add an option to define the input range width virtio-iommu: Trace domain range limits as unsigned int hw: Set virtio-iommu aw-bits default value on pc_q35 and arm virt qemu-options.hx: Add an entry for virtio-iommu-pci and document aw-bits include/hw/virtio/virtio-iommu.h | 1 + hw/arm/virt.c | 6 ++++++ hw/core/machine.c | 5 ++++- hw/i386/pc.c | 6 ++++++ hw/virtio/virtio-iommu.c | 7 ++++++- tests/qtest/virtio-iommu-test.c | 2 +- hw/virtio/trace-events | 2 +- qemu-options.hx | 8 ++++++++ 8 files changed, 33 insertions(+), 4 deletions(-) -- 2.41.0