From: "Cédric Le Goater" <clg@redhat.com>
To: Joao Martins <joao.m.martins@oracle.com>, qemu-devel@nongnu.org
Cc: Alex Williamson <alex.williamson@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>, Peter Xu <peterx@redhat.com>,
David Hildenbrand <david@redhat.com>,
Philippe Mathieu-Daude <philmd@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
Jason Wang <jasowang@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
Eduardo Habkost <eduardo@habkost.net>,
Avihai Horon <avihaih@nvidia.com>,
Jason Gunthorpe <jgg@nvidia.com>, Yi Liu <yi.l.liu@intel.com>
Subject: Re: [PATCH v4 00/15] vfio: VFIO migration support with vIOMMU
Date: Mon, 10 Jun 2024 18:53:46 +0200 [thread overview]
Message-ID: <d6ef8a37-9337-433e-a0bf-ce50af20a734@redhat.com> (raw)
In-Reply-To: <8ca65f18-5a0d-4176-9bc1-f318d4ba4db5@oracle.com>
On 6/7/24 5:10 PM, Joao Martins wrote:
> On 06/06/2024 16:43, Cédric Le Goater wrote:
>> Hello Joao,
>>
>> On 6/22/23 23:48, Joao Martins wrote:
>>> Hey,
>>>
>>> This series introduces support for vIOMMU with VFIO device migration,
>>> particurlarly related to how we do the dirty page tracking.
>>>
>>> Today vIOMMUs serve two purposes: 1) enable interrupt remaping 2)
>>> provide dma translation services for guests to provide some form of
>>> guest kernel managed DMA e.g. for nested virt based usage; (1) is specially
>>> required for big VMs with VFs with more than 255 vcpus. We tackle both
>>> and remove the migration blocker when vIOMMU is present provided the
>>> conditions are met. I have both use-cases here in one series, but I am happy
>>> to tackle them in separate series.
>>>
>>> As I found out we don't necessarily need to expose the whole vIOMMU
>>> functionality in order to just support interrupt remapping. x86 IOMMUs
>>> on Windows Server 2018[2] and Linux >=5.10, with qemu 7.1+ (or really
>>> Linux guests with commit c40aaaac10 and since qemu commit 8646d9c773d8)
>>> can instantiate a IOMMU just for interrupt remapping without needing to
>>> be advertised/support DMA translation. AMD IOMMU in theory can provide
>>> the same, but Linux doesn't quite support the IR-only part there yet,
>>> only intel-iommu.
>>>
>>> The series is organized as following:
>>>
>>> Patches 1-5: Today we can't gather vIOMMU details before the guest
>>> establishes their first DMA mapping via the vIOMMU. So these first four
>>> patches add a way for vIOMMUs to be asked of their properties at start
>>> of day. I choose the least churn possible way for now (as opposed to a
>>> treewide conversion) and allow easy conversion a posteriori. As
>>> suggested by Peter Xu[7], I have ressurected Yi's patches[5][6] which
>>> allows us to fetch PCI backing vIOMMU attributes, without necessarily
>>> tieing the caller (VFIO or anyone else) to an IOMMU MR like I
>>> was doing in v3.
>>>
>>> Patches 6-8: Handle configs with vIOMMU interrupt remapping but without
>>> DMA translation allowed. Today the 'dma-translation' attribute is
>>> x86-iommu only, but the way this series is structured nothing stops from
>>> other vIOMMUs supporting it too as long as they use
>>> pci_setup_iommu_ops() and the necessary IOMMU MR get_attr attributes
>>> are handled. The blocker is thus relaxed when vIOMMUs are able to toggle
>>> the toggle/report DMA_TRANSLATION attribute. With the patches up to this set,
>>> we've then tackled item (1) of the second paragraph.
>>>
>>> Patches 9-15: Simplified a lot from v2 (patch 9) to only track the complete
>>> IOVA address space, leveraging the logic we use to compose the dirty ranges.
>>> The blocker is once again relaxed for vIOMMUs that advertise their IOVA
>>> addressing limits. This tackles item (2). So far I mainly use it with
>>> intel-iommu, although I have a small set of patches for virtio-iommu per
>>> Alex's suggestion in v2.
>>>
>>> Comments, suggestions welcome. Thanks for the review!
>>
>>
>> I spent sometime refreshing your series on upstream QEMU (See [1]) and
>> gave migration a try with CX-7 VF. LGTM. It doesn't seem we are far
>> from acceptance in QEMU 9.1. Are we ?
>>
> Yeah.
>
> There was a comment from Zhenzhong on the vfio_viommu_preset() here[0]. But I
> was looking at that to remind myself what was it that we had to change, but even
> with re-reading the thread I can't spot any flaw that needs change.
>
> [0]
> https://lore.kernel.org/qemu-devel/de2b72d2-f56b-9350-ce0f-70edfb58eff5@intel.com/#r
I introduced a vfio_devices_all_viommu_preset() routine to check all devices
in a container and a simplified version of vfio_viommu_get_max_iova()
returning the space max_iova.
>> First, I will resend these with the changes I made :
>>
>> vfio/common: Extract vIOMMU code from vfio_sync_dirty_bitmap()
>> vfio/common: Move dirty tracking ranges update to helper()
>>
>> I guess the PCIIOMMUOps::get_iommu_attr needs a close review. Is
>> IOMMU_ATTR_DMA_TRANSLATION a must have ?
>>
> It's sort of the 'correct way' of relaxing vIOMMU checks, because you are 100%
> guaranteed that the guest won't do DMA. The other outstanding thing related to
> that is for older kernels which is to use the directmap for dirty page tracking,
> but the moment a mapping is attempted the migration doesn't start or if it's in
> progress it gets aborted[*]:
>
> https://lore.kernel.org/qemu-devel/20230908120521.50903-1-joao.m.martins@oracle.com/
>
> The above link and DMA_TRANSLATION is mostly for the usecase we use that only
> cares about vIOMMU for interrupt remapping only and no DMA translation services.
> But we can't just disable dma-translation in qemu because it may crash older
> kernels, so it supports both old and new this way.
>
> [*] Recently I noticed you improved error reporting, so
> vfio_set_migration_error(-EOPNOTSUPP) probably has a better way of getting there.
Yes. So, I did a little more change to improve vfio_dirty_tracking_init().
>> The rest is mostly VFIO internals for dirty tracking.
>>
> Right.
>
> I derailed with other work and also stuff required for iommu dirty tracking that
> I forgot about these patches, sorry.
That's fine.
I am trying to sort out which patches could be merged in advance for QEMU 9.1
and your series has shrunk a lot since it was last sent. I might resend the
whole to cherry pick the simple changes and get some R-b tags.
For the record, here is my watch list:
QEMU series under review:
* [v7] Add a host IOMMU device abstraction to check with vIOMMU
https://lore.kernel.org/all/20240605083043.317831-1-zhenzhong.duan@intel.com
Needs feedback on the PCI IOMMU ops. vIOMMU "iommufd" property ?
Pushed on vfio-9.1 branch.
* [RFC v2] VIRTIO-IOMMU/VFIO: Fix host iommu geometry
https://lore.kernel.org/all/20240607143905.765133-1-eric.auger@redhat.com
Pushed on vfio-9.1 branch.
Need a resend :
* [v4] vfio: VFIO migration support with vIOMMU
https://lore.kernel.org/qemu-devel/20230622214845.3980-1-joao.m.martins@oracle.com/
Refreshed the patchset on upstream and pushed on vfio-9.1 branch.
* [RFCv2] vfio/iommufd: IOMMUFD Dirty Tracking
https://lore.kernel.org/qemu-devel/20240212135643.5858-1-joao.m.martins@oracle.com/
* [v1] vfio: container: Fix missing allocation of VFIOSpaprContainer
https://lore.kernel.org/qemu-devel/171528203026.8420.10620440513237875837.stgit@ltcd48-lp2.aus.stglabs.ibm.com/
Other interesting series (IOMMU related):
* [rfcv2] intel_iommu: Enable stage-1 translation for emulated device
https://lore.kernel.org/all/20240522062313.453317-1-zhenzhong.duan@intel.com/
* [PATCH ats_vtd v2 00/25] ATS support for VT-d
https://lore.kernel.org/all/20240515071057.33990-1-clement.mathieu--drif@eviden.com/
* [RFC v3] SMMUv3 nested translation support
https://lore.kernel.org/qemu-devel/20240429032403.74910-1-smostafa@google.com/
* [PATCH RFCv1 00/14] Add Tegra241 (Grace) CMDQV Support (part 2/2)
https://lore.kernel.org/all/cover.1712978212.git.nicolinc@nvidia.com/
Yet to be sent,
https://github.com/nicolinc/qemu/commits/wip/iommufd_vcmdq/
* [RFC] Multifd device state transfer support with VFIO consumer
https://lore.kernel.org/all/cover.1713269378.git.maciej.szmigiero@oracle.com/
Thanks,
C.
next prev parent reply other threads:[~2024-06-10 16:54 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-22 21:48 [PATCH v4 00/15] vfio: VFIO migration support with vIOMMU Joao Martins
2023-06-22 21:48 ` [PATCH v4 01/15] hw/pci: Add a pci_setup_iommu_ops() helper Joao Martins
2023-10-02 15:12 ` Cédric Le Goater
2023-10-06 8:38 ` Joao Martins
2023-10-06 8:50 ` Cédric Le Goater
2023-10-06 11:06 ` Joao Martins
2023-10-06 17:09 ` Cédric Le Goater
2023-10-06 17:59 ` Joao Martins
2023-10-09 13:01 ` Cédric Le Goater
2023-10-06 8:45 ` Eric Auger
2023-10-06 11:03 ` Joao Martins
2023-06-22 21:48 ` [PATCH v4 02/15] hw/pci: Refactor pci_device_iommu_address_space() Joao Martins
2023-10-02 15:22 ` Cédric Le Goater
2023-10-06 8:39 ` Joao Martins
2023-10-06 8:40 ` Joao Martins
2023-10-06 8:52 ` Eric Auger
2023-10-06 11:07 ` Joao Martins
2023-10-06 9:11 ` Eric Auger
2023-06-22 21:48 ` [PATCH v4 03/15] hw/pci: Introduce pci_device_iommu_get_attr() Joao Martins
2023-06-22 21:48 ` [PATCH v4 04/15] intel-iommu: Switch to pci_setup_iommu_ops() Joao Martins
2023-06-22 21:48 ` [PATCH v4 05/15] memory/iommu: Add IOMMU_ATTR_DMA_TRANSLATION attribute Joao Martins
2023-10-06 13:08 ` Eric Auger
2023-06-22 21:48 ` [PATCH v4 06/15] intel-iommu: Implement get_attr() method Joao Martins
2023-09-08 6:23 ` Duan, Zhenzhong
2023-09-08 10:11 ` Joao Martins
2023-10-02 15:23 ` Cédric Le Goater
2023-10-06 8:42 ` Joao Martins
2023-06-22 21:48 ` [PATCH v4 07/15] vfio/common: Track whether DMA Translation is enabled on the vIOMMU Joao Martins
2023-07-09 15:10 ` Avihai Horon
2023-07-10 13:44 ` Joao Martins
2023-10-06 13:09 ` Eric Auger
2023-06-22 21:48 ` [PATCH v4 08/15] vfio/common: Relax vIOMMU detection when DMA translation is off Joao Martins
2023-06-22 21:48 ` [PATCH v4 09/15] memory/iommu: Add IOMMU_ATTR_MAX_IOVA attribute Joao Martins
2023-06-22 21:48 ` [PATCH v4 10/15] intel-iommu: Implement IOMMU_ATTR_MAX_IOVA get_attr() attribute Joao Martins
2023-07-09 15:17 ` Avihai Horon
2023-07-10 13:44 ` Joao Martins
2023-10-02 15:42 ` Cédric Le Goater
2023-10-06 8:43 ` Joao Martins
2023-06-22 21:48 ` [PATCH v4 11/15] vfio/common: Move dirty tracking ranges update to helper Joao Martins
2023-06-22 21:48 ` [PATCH v4 12/15] vfio/common: Support device dirty page tracking with vIOMMU Joao Martins
2023-07-09 15:24 ` Avihai Horon
2023-07-10 13:49 ` Joao Martins
2023-09-08 6:11 ` Duan, Zhenzhong
2023-09-08 10:11 ` Joao Martins
2023-09-08 11:52 ` Duan, Zhenzhong
2023-09-08 11:54 ` Joao Martins
2023-06-22 21:48 ` [PATCH v4 13/15] vfio/common: Extract vIOMMU code from vfio_sync_dirty_bitmap() Joao Martins
2023-06-22 21:48 ` [PATCH v4 14/15] vfio/common: Optimize device dirty page tracking with vIOMMU Joao Martins
2023-06-22 21:48 ` [PATCH v4 15/15] vfio/common: Block migration with vIOMMUs without address width limits Joao Martins
2023-09-08 6:28 ` Duan, Zhenzhong
2023-09-08 10:11 ` Joao Martins
2023-06-22 22:18 ` [PATCH v4 00/15] vfio: VFIO migration support with vIOMMU Joao Martins
2023-09-07 11:11 ` Joao Martins
2023-09-07 12:40 ` Cédric Le Goater
2023-09-07 15:20 ` Joao Martins
2024-06-06 15:43 ` Cédric Le Goater
2024-06-07 15:10 ` Joao Martins
2024-06-10 16:53 ` Cédric Le Goater [this message]
2024-06-18 11:26 ` Joao Martins
2024-06-20 12:31 ` Cédric Le Goater
2024-11-28 3:19 ` Zhangfei Gao
2024-11-28 18:29 ` Joao Martins
2025-01-21 16:42 ` Joao Martins
2025-01-07 6:55 ` Zhangfei Gao
2025-01-21 16:42 ` Joao Martins
2025-02-08 2:07 ` Zhangfei Gao
2025-03-05 11:59 ` Joao Martins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d6ef8a37-9337-433e-a0bf-ce50af20a734@redhat.com \
--to=clg@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=avihaih@nvidia.com \
--cc=david@redhat.com \
--cc=eduardo@habkost.net \
--cc=jasowang@redhat.com \
--cc=jgg@nvidia.com \
--cc=joao.m.martins@oracle.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=yi.l.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.