Additional vIOMMU fixes related to UNMAP notifiers
cover Additional vIOMMU fixes related to UNMAP notifiers
958ec334bca3 ("vhost: Unbreak SMMU and virtio-iommu on dev-iotlb support") fixed part of the UNMAP related regressions introduced by b68ba1ca5767 ("memory: Add IOMMU_NOTIFIER_DEVIOTLB_UNMAP IOMMUTLBNotificationType").
However the case of the spapr_iommu was not addressed. It should be identical to the others. Also 958ec334bca3 introduced a regresion on the VIRTIO-IOMMU/VFIO integration.
spapr_iommu is not tested.
Best Regards
Eric
Eric Auger (2):
vfio: Do not register any IOMMU_NOTIFIER_DEVIOTLB_UNMAP notifier
spapr_iommu: Fix vhost integration regression
hw/ppc/spapr_iommu.c | 5 +++++ hw/vfio/common.c | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-)
Signature · 1 line
2.26.2
PATCH 1/2 vfio: Do not register any IOMMU_NOTIFIER_DEVIOTLB_UNMAP notifier
In an attempt to fix smmu/virtio-iommu - vhost regression, commit 958ec334bca3 ("vhost: Unbreak SMMU and virtio-iommu on dev-iotlb support") broke virtio-iommu integration. This is due to the fact VFIO registers IOMMU_NOTIFIER_ALL notifiers, which includes IOMMU_NOTIFIER_DEVIOTLB_UNMAP and this latter now is rejected by the virtio-iommu. As a consequence, the registration fails. VHOST behaves like a device with an ATC cache. The VFIO device does not support this scheme yet.
Let's register only legacy MAP and UNMAP notifiers.
--- hw/vfio/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/vfio/common.c +1 -1
@@ -787,7 +787,7 @@ static void vfio_listener_region_add(MemoryListener *listener, iommu_idx =memory_region_iommu_attrs_to_index (iommu_mr,MEMTXATTRS_UNSPECIFIED );iommu_notifier_init (&giommu->n, vfio_iommu_map_notify, -IOMMU_NOTIFIER_ALL , +IOMMU_NOTIFIER_IOTLB_EVENTS , section->offset_within_region,int128_get64 (llend), iommu_idx);
Signature · 1 line
2.26.2
Re: [PATCH 1/2] vfio: Do not register any IOMMU_NOTIFIER_DEVIOTLB_UNMAP notifier
Quoted 21 lines · Eric Auger
In an attempt to fix smmu/virtio-iommu - vhost regression, commit
958ec334bca3("vhost: Unbreak SMMU and virtio-iommu on dev-iotlb support") broke virtio-iommu integration. This is due to the fact VFIO registersIOMMU_NOTIFIER_ALLnotifiers, which includesIOMMU_NOTIFIER_DEVIOTLB_UNMAPand this latter now is rejected by the virtio-iommu. As a consequence, the registration fails. VHOST behaves like a device with an ATC cache. The VFIO device does not support this scheme yet.Let's register only legacy MAP and UNMAP notifiers.
Fixes 958ec334bca3 ("vhost: Unbreak SMMU and virtio-iommu on dev-iotlb support")Signed-off-by Eric Auger <[email protected]>--- hw/vfio/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/vfio/common.c +0
-0
hw/vfio/common.c static void vfio_listener_region_add(MemoryListener *listener, · line 793
Quoted 8 lines
hw/vfio/common.c +1
-1@@ -787,7 +787,7 @@ static void vfio_listener_region_add(MemoryListener *listener, iommu_idx =memory_region_iommu_attrs_to_index (iommu_mr,MEMTXATTRS_UNSPECIFIED );iommu_notifier_init (&giommu->n, vfio_iommu_map_notify, -IOMMU_NOTIFIER_ALL , +IOMMU_NOTIFIER_IOTLB_EVENTS , section->offset_within_region,int128_get64 (llend), iommu_idx);
Re: [PATCH 1/2] vfio: Do not register any IOMMU_NOTIFIER_DEVIOTLB_UNMAP notifier
In reply to Eric AugerQuoted 21 lines · On Tue, 9 Feb 2021 22:32:32 +0100 Eric Auger <[email protected]> wrote:
In an attempt to fix smmu/virtio-iommu - vhost regression, commit
958ec334bca3("vhost: Unbreak SMMU and virtio-iommu on dev-iotlb support") broke virtio-iommu integration. This is due to the fact VFIO registersIOMMU_NOTIFIER_ALLnotifiers, which includesIOMMU_NOTIFIER_DEVIOTLB_UNMAPand this latter now is rejected by the virtio-iommu. As a consequence, the registration fails. VHOST behaves like a device with an ATC cache. The VFIO device does not support this scheme yet.Let's register only legacy MAP and UNMAP notifiers.
Fixes 958ec334bca3 ("vhost: Unbreak SMMU and virtio-iommu on dev-iotlb support")Signed-off-by Eric Auger <[email protected]>--- hw/vfio/common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/vfio/common.c +0
-0
hw/vfio/common.c static void vfio_listener_region_add(MemoryListener *listener, · line 793
Quoted 8 lines
hw/vfio/common.c +1
-1@@ -787,7 +787,7 @@ static void vfio_listener_region_add(MemoryListener *listener, iommu_idx =memory_region_iommu_attrs_to_index (iommu_mr,MEMTXATTRS_UNSPECIFIED );iommu_notifier_init (&giommu->n, vfio_iommu_map_notify, -IOMMU_NOTIFIER_ALL , +IOMMU_NOTIFIER_IOTLB_EVENTS , section->offset_within_region,int128_get64 (llend), iommu_idx);
PATCH 2/2 spapr_iommu: Fix vhost integration regression
In reply to Eric AugerPrevious work on dev-iotlb message broke spapr_iommu/vhost integration as it did for SMMU and virtio-iommu. The spapr_iommu currently only sends IOMMU_NOTIFIER_UNMAP notifications. Since commit 958ec334bca3 ("vhost: Unbreak SMMU and virtio-iommu on dev-iotlb support"), VHOST first tries to register IOMMU_NOTIFIER_DEVIOTLB_UNMAP notifier and if it fails, falls back to legacy IOMMU_NOTIFIER_UNMAP. So spapr_iommu must fail on the IOMMU_NOTIFIER_DEVIOTLB_UNMAP registration.
--- hw/ppc/spapr_iommu.c | 5 +++++ 1 file changed, 5 insertions(+)
hw/ppc/spapr_iommu.c +5 -0
@@ -212,6 +212,11 @@ static int spapr_tce_notify_flag_changed(IOMMUMemoryRegion *iommu, {struct SpaprTceTable *tbl =container_of (iommu, SpaprTceTable, iommu); +if (new &IOMMU_NOTIFIER_DEVIOTLB_UNMAP ) { +error_setg (errp,"spart_tce does not support dev-iotlb yet" ); +return -EINVAL ; + } +if (old ==IOMMU_NOTIFIER_NONE && new !=IOMMU_NOTIFIER_NONE ) {spapr_tce_set_need_vfio (tbl, true); }else if (old !=IOMMU_NOTIFIER_NONE && new ==IOMMU_NOTIFIER_NONE ) {
Signature · 1 line
2.26.2
Re: [PATCH 2/2] spapr_iommu: Fix vhost integration regression
Quoted 9 lines · Eric Auger
Previous work on dev-iotlb message broke spapr_iommu/vhost integration as it did for SMMU and virtio-iommu. The
spapr_iommucurrently only sendsIOMMU_NOTIFIER_UNMAPnotifications. Since commit958ec334bca3("vhost: Unbreak SMMU and virtio-iommu on dev-iotlb support"), VHOST first tries to registerIOMMU_NOTIFIER_DEVIOTLB_UNMAPnotifier and if it fails, falls back to legacyIOMMU_NOTIFIER_UNMAP. Sospapr_iommumust fail on theIOMMU_NOTIFIER_DEVIOTLB_UNMAPregistration.
Quoted 3 lines
Reported-by Peter Xu <[email protected]>Fixes b68ba1ca57677acf870d5ab10579e6105c1f5338Signed-off-by Eric Auger <[email protected]>
Quoted 20 lines
--- hw/ppc/spapr_iommu.c | 5 +++++ 1 file changed, 5 insertions(+)hw/ppc/spapr_iommu.c +5
-0@@ -212,6 +212,11 @@ static int spapr_tce_notify_flag_changed(IOMMUMemoryRegion *iommu, {struct SpaprTceTable *tbl =container_of (iommu, SpaprTceTable, iommu); +if (new &IOMMU_NOTIFIER_DEVIOTLB_UNMAP ) { +error_setg (errp,"spart_tce does not support dev-iotlb yet" ); +return -EINVAL ; + } +if (old ==IOMMU_NOTIFIER_NONE && new !=IOMMU_NOTIFIER_NONE ) {spapr_tce_set_need_vfio (tbl, true); }else if (old !=IOMMU_NOTIFIER_NONE && new ==IOMMU_NOTIFIER_NONE ) {
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson
Re: [PATCH 2/2] spapr_iommu: Fix vhost integration regression
In reply to Eric AugerQuoted 9 lines · Eric Auger
Previous work on dev-iotlb message broke spapr_iommu/vhost integration as it did for SMMU and virtio-iommu. The
spapr_iommucurrently only sendsIOMMU_NOTIFIER_UNMAPnotifications. Since commit958ec334bca3("vhost: Unbreak SMMU and virtio-iommu on dev-iotlb support"), VHOST first tries to registerIOMMU_NOTIFIER_DEVIOTLB_UNMAPnotifier and if it fails, falls back to legacyIOMMU_NOTIFIER_UNMAP. Sospapr_iommumust fail on theIOMMU_NOTIFIER_DEVIOTLB_UNMAPregistration.
Quoted 3 lines
Reported-by Peter Xu <[email protected]>Fixes b68ba1ca57677acf870d5ab10579e6105c1f5338Signed-off-by Eric Auger <[email protected]>
Quoted 22 lines
--- hw/ppc/spapr_iommu.c | 5 +++++ 1 file changed, 5 insertions(+)hw/ppc/spapr_iommu.c +5
-0@@ -212,6 +212,11 @@ static int spapr_tce_notify_flag_changed(IOMMUMemoryRegion *iommu, {struct SpaprTceTable *tbl =container_of (iommu, SpaprTceTable, iommu); +if (new &IOMMU_NOTIFIER_DEVIOTLB_UNMAP ) { +error_setg (errp,"spart_tce does not support dev-iotlb yet" ); +return -EINVAL ; + } +if (old ==IOMMU_NOTIFIER_NONE && new !=IOMMU_NOTIFIER_NONE ) {spapr_tce_set_need_vfio (tbl, true); }else if (old !=IOMMU_NOTIFIER_NONE && new ==IOMMU_NOTIFIER_NONE ) {Signature · 1 line
2.26.2
Re: [PATCH 2/2] spapr_iommu: Fix vhost integration regression
In reply to Eric AugerQuoted 9 lines · Eric Auger
Previous work on dev-iotlb message broke spapr_iommu/vhost integration as it did for SMMU and virtio-iommu. The
spapr_iommucurrently only sendsIOMMU_NOTIFIER_UNMAPnotifications. Since commit958ec334bca3("vhost: Unbreak SMMU and virtio-iommu on dev-iotlb support"), VHOST first tries to registerIOMMU_NOTIFIER_DEVIOTLB_UNMAPnotifier and if it fails, falls back to legacyIOMMU_NOTIFIER_UNMAP. Sospapr_iommumust fail on theIOMMU_NOTIFIER_DEVIOTLB_UNMAPregistration.
Quoted 4 lines
Reported-by Peter Xu <[email protected]>Fixes b68ba1ca57677acf870d5ab10579e6105c1f5338Signed-off-by Eric Auger <[email protected]>---
Quoted 19 lines
hw/ppc/spapr_iommu.c | 5 +++++ 1 file changed, 5 insertions(+)hw/ppc/spapr_iommu.c +5
-0@@ -212,6 +212,11 @@ static int spapr_tce_notify_flag_changed(IOMMUMemoryRegion *iommu, {struct SpaprTceTable *tbl =container_of (iommu, SpaprTceTable, iommu); +if (new &IOMMU_NOTIFIER_DEVIOTLB_UNMAP ) { +error_setg (errp,"spart_tce does not support dev-iotlb yet" ); +return -EINVAL ; + } +if (old ==IOMMU_NOTIFIER_NONE && new !=IOMMU_NOTIFIER_NONE ) {spapr_tce_set_need_vfio (tbl, true); }else if (old !=IOMMU_NOTIFIER_NONE && new ==IOMMU_NOTIFIER_NONE ) {
Re: [PATCH 2/2] spapr_iommu: Fix vhost integration regression
In reply to Eric AugerQuoted 9 lines · On Tue, 9 Feb 2021 22:32:33 +0100 Eric Auger <[email protected]> wrote:
Previous work on dev-iotlb message broke spapr_iommu/vhost integration as it did for SMMU and virtio-iommu. The
spapr_iommucurrently only sendsIOMMU_NOTIFIER_UNMAPnotifications. Since commit958ec334bca3("vhost: Unbreak SMMU and virtio-iommu on dev-iotlb support"), VHOST first tries to registerIOMMU_NOTIFIER_DEVIOTLB_UNMAPnotifier and if it fails, falls back to legacyIOMMU_NOTIFIER_UNMAP. Sospapr_iommumust fail on theIOMMU_NOTIFIER_DEVIOTLB_UNMAPregistration.
Quoted 4 lines
Reported-by Peter Xu <[email protected]>Fixes b68ba1ca57677acf870d5ab10579e6105c1f5338Signed-off-by Eric Auger <[email protected]>---
Quoted 19 lines
hw/ppc/spapr_iommu.c | 5 +++++ 1 file changed, 5 insertions(+)hw/ppc/spapr_iommu.c +5
-0@@ -212,6 +212,11 @@ static int spapr_tce_notify_flag_changed(IOMMUMemoryRegion *iommu, {struct SpaprTceTable *tbl =container_of (iommu, SpaprTceTable, iommu); +if (new &IOMMU_NOTIFIER_DEVIOTLB_UNMAP ) { +error_setg (errp,"spart_tce does not support dev-iotlb yet" ); +return -EINVAL ; + } +if (old ==IOMMU_NOTIFIER_NONE && new !=IOMMU_NOTIFIER_NONE ) {spapr_tce_set_need_vfio (tbl, true); }else if (old !=IOMMU_NOTIFIER_NONE && new ==IOMMU_NOTIFIER_NONE ) {
Quoted 10 lines · Eric Auger
958ec334bca3("vhost: Unbreak SMMU and virtio-iommu on dev-iotlb support") fixed part of the UNMAP related regressions introduced byb68ba1ca5767("memory: AddIOMMU_NOTIFIER_DEVIOTLB_UNMAPIOMMUTLBNotificationType").However the case of the
spapr_iommuwas not addressed. It should be identical to the others. Also958ec334bca3introduced a regresion on the VIRTIO-IOMMU/VFIO integration.
spapr_iommuis not tested.
Thanks!
Signature · 1 line
Peter Xu