[PATCH V2 0/5] Fix UNMAP notifier for intel-iommu

Jason Wang posted 5 patches 1 year, 2 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230223065924.42503-1-jasowang@redhat.com
Maintainers: Eric Auger <eric.auger@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, "Michael S. Tsirkin" <mst@redhat.com>, Peter Xu <peterx@redhat.com>, Jason Wang <jasowang@redhat.com>, Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <richard.henderson@linaro.org>, Eduardo Habkost <eduardo@habkost.net>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, David Hildenbrand <david@redhat.com>, "Philippe Mathieu-Daudé" <philmd@linaro.org>
hw/arm/smmu-common.c  | 16 +---------------
hw/i386/intel_iommu.c | 29 ++++++++++++++++++++++++-----
include/exec/memory.h | 10 ++++++++++
softmmu/memory.c      | 13 +++++++++++++
4 files changed, 48 insertions(+), 20 deletions(-)
[PATCH V2 0/5] Fix UNMAP notifier for intel-iommu
Posted by Jason Wang 1 year, 2 months ago
Hi All:

According to ATS, device should work if ATS is disabled. This is not
correctly implemented in the current intel-iommu since it doesn't
handle the UNMAP notifier correctly. This breaks the vhost-net +
vIOMMU without dt.

The root casue is that the when there's a device IOTLB miss (note that
it's not specific to PCI so it can work without ATS), Qemu doesn't
build the IOVA tree, so when guest start an IOTLB invalidation, Qemu
won't trigger the UNMAP notifier.

Fixing this by triggering UNMAP notifier in those cases.

Thanks

Changes since V1:

- Do not depend on the iova tree for such kind of invalidation but
  simply tries to do UNMAP for all attached IOMMU notifiers

Jason Wang (4):
  intel-iommu: fail MAP notifier without caching mode
  intel-iommu: fail DEVIOTLB_UNMAP without dt mode
  memory: introduce memory_region_unmap_iommu_notifier_range()
  smmu: switch to use memory_region_unmap_iommu_notifier_range()

Peter Xu (1):
  intel-iommu: send UNMAP notifications for domain or global inv desc

 hw/arm/smmu-common.c  | 16 +---------------
 hw/i386/intel_iommu.c | 29 ++++++++++++++++++++++++-----
 include/exec/memory.h | 10 ++++++++++
 softmmu/memory.c      | 13 +++++++++++++
 4 files changed, 48 insertions(+), 20 deletions(-)

-- 
2.25.1
Re: [PATCH V2 0/5] Fix UNMAP notifier for intel-iommu
Posted by Peter Xu 1 year, 2 months ago
On Thu, Feb 23, 2023 at 02:59:19PM +0800, Jason Wang wrote:
> Hi All:
> 
> According to ATS, device should work if ATS is disabled. This is not
> correctly implemented in the current intel-iommu since it doesn't
> handle the UNMAP notifier correctly. This breaks the vhost-net +
> vIOMMU without dt.
> 
> The root casue is that the when there's a device IOTLB miss (note that
> it's not specific to PCI so it can work without ATS), Qemu doesn't
> build the IOVA tree, so when guest start an IOTLB invalidation, Qemu
> won't trigger the UNMAP notifier.
> 
> Fixing this by triggering UNMAP notifier in those cases.

Maybe someday we should start merging different places where we used the
same IOMMU_NOTIFIER_UNMAP event and also taking care of truncation of
notifier ranges within memory.c, but that can definitely be done later.

Reviewed-by: Peter Xu <peterx@redhat.com>

Thanks, Jason!

-- 
Peter Xu
Re: [PATCH V2 0/5] Fix UNMAP notifier for intel-iommu
Posted by Jason Wang 1 year, 2 months ago
On Thu, Feb 23, 2023 at 11:47 PM Peter Xu <peterx@redhat.com> wrote:
>
> On Thu, Feb 23, 2023 at 02:59:19PM +0800, Jason Wang wrote:
> > Hi All:
> >
> > According to ATS, device should work if ATS is disabled. This is not
> > correctly implemented in the current intel-iommu since it doesn't
> > handle the UNMAP notifier correctly. This breaks the vhost-net +
> > vIOMMU without dt.
> >
> > The root casue is that the when there's a device IOTLB miss (note that
> > it's not specific to PCI so it can work without ATS), Qemu doesn't
> > build the IOVA tree, so when guest start an IOTLB invalidation, Qemu
> > won't trigger the UNMAP notifier.
> >
> > Fixing this by triggering UNMAP notifier in those cases.
>
> Maybe someday we should start merging different places where we used the
> same IOMMU_NOTIFIER_UNMAP event and also taking care of truncation of
> notifier ranges within memory.c, but that can definitely be done later.

Yes, probably.

>
> Reviewed-by: Peter Xu <peterx@redhat.com>
>
> Thanks, Jason!

You're welcome :)

Thanks

>
> --
> Peter Xu
>