iommu/s390: Fixes related to attach and aperture handling
Subsystems (3)
Niklas Schnelle
maintainerv3 cover iommu/s390: Fixes related to attach and aperture handling
Hi All,
This is v3 of a follow up to Matt's recent series[0] where he tackled a race that turned out to be outside of the s390 IOMMU driver itself as well as duplicate device attachments. After an internal discussion we came up with what I believe is a cleaner fix. Instead of actively checking for duplicates we instead detach from any previous domain on attach. From my cursory reading of the code this seems to be what the Intel IOMMU driver is doing as well.
Moreover we drop the attempt to re-attach the device to its previous IOMMU domain on failure. This was fragile, unlikely to help and unexpected for calling code. Thanks Jason for the suggestion.
During development of this fix we realized that we can get rid of struct s390_domain_device entirely if we instead thread the list through the attached struct zpci_devs. This saves us from having to allocate during attach and gets rid of one level of indirection during IOMMU operations.
Additionally 3 more fixes have been added that weren't in v2 of this series. One is for a potential situation where the aperture of a domain could shrink and leave invalid translations. The next one fixes an off by one in checking validity of an IOVA and the last one fixes a wrong value for pgsize_bitmap.
*Note*:
This series is against the s390 features branch[1] which already contains the bus_next field removal that was part of v2.
Best regards,
Niklas
Changes since v2:
- The patch removing the unused bus_next field has been spun out and already made it into the s390 feature branch on git.kernel.org
- Make __s390_iommu_detach_device() return void (Jason)
- Remove the re-attach on failure dance as it is unlikely to help and complicates debug and recovery (Jason)
- Ignore attempts to detach from domain that is not the active one
- Add patch to fix potential shrinking of the aperture and use reserved ranges per device instead of the aperture to respect IOVA range restrictions (Jason)
- Add a fix for an off by one error on checking an IOVA against the aperture
- Add a fix for wrong pgsize_bitmap
Changes since v1:
- After patch 3 we don't have to search in the devices list on detach as we alreadz have hold of the zpci_dev (Jason)
- Add a WARN_ON() if somehow ended up detaching a device from a domain that isn't the device's current domain.
- Removed the iteration and list delete from s390_domain_free() instead just WARN_ON() when we're freeing without having detached
- The last two points should help catching sequencing errors much more quickly in the future.
[0] https://lore.kernel.org/linux-iommu/[email protected]/
[1] https://git.kernel.org/pub/scm/linux/kernel/git/s390/linux.git/
Niklas Schnelle (5):
iommu/s390: Fix duplicate domain attachments iommu/s390: Get rid of s390_domain_device iommu/s390: Fix potential s390_domain aperture shrinking iommu/s390: Fix incorrect aperture check iommu/s390: Fix incorrect pgsize_bitmap
arch/s390/include/asm/pci.h | 1 + drivers/iommu/s390-iommu.c | 147 ++++++++++++++++-------------------- 2 files changed, 64 insertions(+), 84 deletions(-)
Signature · 1 line
2.34.1
Niklas Schnelle
maintainerPATCH v3 1/5 iommu/s390: Fix duplicate domain attachments
Since commit fa7e9ecc5e1c ("iommu/s390: Tolerate repeat attach_dev calls") we can end up with duplicates in the list of devices attached to a domain. This is inefficient and confusing since only one domain can actually be in control of the IOMMU translations for a device. Fix this by detaching the device from the previous domain, if any, on attach. Add a WARN_ON() in case we still have attached devices on freeing the domain. While here remove the re-attach on failure dance as it was determined to be unlikely to help and may confuse debug and recovery.
---
Changes since v2:
- Make __s390_iommu_detach_device() return void (Jason)
- Remove superfluous locking when we're freeing anyway (Jason)
- Remove the re-attach on failure dance as it is unlikely to help and complicates debug and recovery (Jason)
- Ignore attempts to detach from domain that the device is no longer attached to.
drivers/iommu/s390-iommu.c | 77 +++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 43 deletions(-)
drivers/iommu/s390-iommu.c +34 -43
@@ -79,10 +79,36 @@ static void s390_domain_free(struct iommu_domain *domain) {struct s390_domain *s390_domain =to_s390_domain (domain); +WARN_ON (!list_empty (&s390_domain->devices));dma_cleanup_tables (s390_domain->dma_table);kfree (s390_domain); } +static void __s390_iommu_detach_device (struct s390_domain *s390_domain, +struct zpci_dev *zdev) +{ +struct s390_domain_device *domain_device, *tmp; +unsigned long flags; + +if (!zdev || zdev->s390_domain != s390_domain) +return ; + +spin_lock_irqsave (&s390_domain->list_lock, flags); +list_for_each_entry_safe (domain_device, tmp, &s390_domain->devices, + list) { +if (domain_device->zdev == zdev) { +list_del (&domain_device->list); +kfree (domain_device); +break ; + } + } +spin_unlock_irqrestore (&s390_domain->list_lock, flags); + +zpci_unregister_ioat (zdev,0 ); + zdev->s390_domain =NULL ; + zdev->dma_table =NULL ; +} +static int s390_iommu_attach_device (struct iommu_domain *domain,struct device *dev) {
@@ -90,7 +116,7 @@ static int s390_iommu_attach_device(struct iommu_domain *domain,struct zpci_dev *zdev =to_zpci_dev (dev);struct s390_domain_device *domain_device;unsigned long flags; -int cc, rc; +int cc, rc =0 ;if (!zdev)return -ENODEV ;
@@ -99,23 +125,17 @@ static int s390_iommu_attach_device(struct iommu_domain *domain,if (!domain_device)return -ENOMEM ; -if (zdev->dma_table && !zdev->s390_domain) { - cc =zpci_dma_exit_device (zdev); -if (cc) { - rc = -EIO ; - goto out_free; - } - } -if (zdev->s390_domain) -zpci_unregister_ioat (zdev,0 ); +__s390_iommu_detach_device (zdev->s390_domain, zdev); +else if (zdev->dma_table) +zpci_dma_exit_device (zdev); zdev->dma_table = s390_domain->dma_table; cc =zpci_register_ioat (zdev,0 , zdev->start_dma, zdev->end_dma,virt_to_phys (zdev->dma_table));if (cc) { rc = -EIO ; - goto out_restore; + goto out_free; }spin_lock_irqsave (&s390_domain->list_lock, flags);
@@ -129,7 +149,7 @@ static int s390_iommu_attach_device(struct iommu_domain *domain, domain->geometry.aperture_end != zdev->end_dma) { rc = -EINVAL ;spin_unlock_irqrestore (&s390_domain->list_lock, flags); - goto out_restore; + goto out_free; } domain_device->zdev = zdev; zdev->s390_domain = s390_domain;
@@ -138,14 +158,6 @@ static int s390_iommu_attach_device(struct iommu_domain *domain,return 0 ; -out_restore: -if (!zdev->s390_domain) { -zpci_dma_init_device (zdev); - }else { - zdev->dma_table = zdev->s390_domain->dma_table; -zpci_register_ioat (zdev,0 , zdev->start_dma, zdev->end_dma, -virt_to_phys (zdev->dma_table)); - } out_free:kfree (domain_device);
@@ -157,30 +169,9 @@ static void s390_iommu_detach_device(struct iommu_domain *domain, {struct s390_domain *s390_domain =to_s390_domain (domain);struct zpci_dev *zdev =to_zpci_dev (dev); -struct s390_domain_device *domain_device, *tmp; -unsigned long flags; -int found =0 ; - -if (!zdev) -return ; - -spin_lock_irqsave (&s390_domain->list_lock, flags); -list_for_each_entry_safe (domain_device, tmp, &s390_domain->devices, - list) { -if (domain_device->zdev == zdev) { -list_del (&domain_device->list); -kfree (domain_device); - found =1 ; -break ; - } - } -spin_unlock_irqrestore (&s390_domain->list_lock, flags); -if (found && (zdev->s390_domain == s390_domain)) { - zdev->s390_domain =NULL ; -zpci_unregister_ioat (zdev,0 ); -zpci_dma_init_device (zdev); - } +__s390_iommu_detach_device (s390_domain, zdev); +zpci_dma_init_device (zdev); }static struct iommu_device *s390_iommu_probe_device (struct device *dev)
Signature · 1 line
2.34.1
Re: [PATCH v3 1/5] iommu/s390: Fix duplicate domain attachments
Quoted 33 lines · Niklas Schnelle
Since commit
fa7e9ecc5e1c("iommu/s390: Tolerate repeatattach_devcalls") we can end up with duplicates in the list of devices attached to a domain. This is inefficient and confusing since only one domain can actually be in control of the IOMMU translations for a device. Fix this by detaching the device from the previous domain, if any, on attach. Add aWARN_ON()in case we still have attached devices on freeing the domain. While here remove the re-attach on failure dance as it was determined to be unlikely to help and may confuse debug and recovery.Fixes fa7e9ecc5e1c ("iommu/s390: Tolerate repeat attach_dev calls")Signed-off-by Niklas Schnelle <[email protected]>---
Changes since v2:
- Make__s390_iommu_detach_device()return void (Jason)
- Remove superfluous locking when we're freeing anyway (Jason)
- Remove the re-attach on failure dance as it is unlikely to help and complicates debug and recovery (Jason)
- Ignore attempts to detach from domain that the device is no longer attached to.drivers/iommu/s390-iommu.c | 77 +++++++++++++++++--------------------- 1 file changed, 34 insertions(+), 43 deletions(-)drivers/iommu/s390-iommu.c +1
-0@@ -79,10 +79,36 @@ static void s390_domain_free(struct iommu_domain *domain) {struct s390_domain *s390_domain =to_s390_domain (domain); +WARN_ON (!list_empty (&s390_domain->devices));dma_cleanup_tables (s390_domain->dma_table);
drivers/iommu/s390-iommu.c static void s390_domain_free(struct iommu_domain *domain) · line 93
Quoted 10 lines
drivers/iommu/s390-iommu.c +7
-0kfree (s390_domain); } +static void __s390_iommu_detach_device (struct s390_domain *s390_domain, +struct zpci_dev *zdev) +{ +struct s390_domain_device *domain_device, *tmp; +unsigned long flags; + +if (!zdev || zdev->s390_domain != s390_domain)
Please drop the s390_domain from this function, it is pointless..
Calling detach_device with a mismatched domain argument is a WARN_ON offense, the correct recovery is still to remove the domain.
And zdev can already never be null due to the call chain
Also, s390_iommu_release_device() should call this new function since we don't want to return back to the platform DMA when releasing.
So, like this:
drivers/iommu/s390-iommu.c +11 -20
@@ -75,12 +75,12 @@ static void s390_domain_free(struct iommu_domain *domain)kfree (s390_domain); } -static void __s390_iommu_detach_device (struct s390_domain *s390_domain, -struct zpci_dev *zdev) +static void __s390_iommu_detach_device (struct zpci_dev *zdev) { +struct s390_domain *s390_domain = zdev->s390_domain;unsigned long flags; -if (!zdev || zdev->s390_domain != s390_domain) +if (!s390_domain)return ;spin_lock_irqsave (&s390_domain->list_lock, flags);
@@ -108,7 +108,7 @@ static int s390_iommu_attach_device(struct iommu_domain *domain,return -EINVAL ;if (zdev->s390_domain) -__s390_iommu_detach_device (zdev->s390_domain, zdev); +__s390_iommu_detach_device (zdev);else if (zdev->dma_table)zpci_dma_exit_device (zdev);
@@ -130,10 +130,11 @@ static int s390_iommu_attach_device(struct iommu_domain *domain,static void s390_iommu_detach_device (struct iommu_domain *domain,struct device *dev) { -struct s390_domain *s390_domain =to_s390_domain (domain);struct zpci_dev *zdev =to_zpci_dev (dev); -__s390_iommu_detach_device (s390_domain, zdev); +WARN_ON (zdev->s390_domain !=to_s390_domain (domain)); + +__s390_iommu_detach_device (zdev);zpci_dma_init_device (zdev); }
@@ -174,21 +175,11 @@ static void s390_iommu_release_device(struct device *dev)struct iommu_domain *domain;/* -* This is a workaround for a scenario where the IOMMU API common code -* "forgets" to call the detach_dev callback: After binding a device -* to vfio-pci and completing the VFIO_SET_IOMMU ioctl (which triggers -* the attach_dev), removing the device via -* "echo 1 > /sys/bus/pci/devices/.../remove" won't trigger detach_dev, -* only release_device will be called via the BUS_NOTIFY_REMOVED_DEVICE -* notifier. -* -* So let's call detach_dev from here if it hasn't been called before. +* release_device is expected to detach any domain currently attached +* to the device, but keep it attached to other devices in the group. */ -if (zdev && zdev->s390_domain) { - domain =iommu_get_domain_for_dev (dev); -if (domain) -s390_iommu_detach_device (domain, dev); - } +if (zdev) +__s390_iommu_detach_device (zdev); } static int s390_iommu_update_trans(struct s390_domain *s390_domain,
Niklas Schnelle
maintainerPATCH v3 2/5 iommu/s390: Get rid of s390_domain_device
In reply to Niklas SchnelleThe struct s390_domain_device serves the sole purpose as list entry for the devices list of a struct s390_domain. As it contains no additional information besides a list_head and a pointer to the struct zpci_dev we can simplify things and just thread the device list through struct zpci_dev directly. This removes the need to allocate during domain attach and gets rid of one level of indirection during mapping operations.
---v2->v3:
- Remove search in devices list when we have the pointer to the list item (Jason)
arch/s390/include/asm/pci.h | 1 + drivers/iommu/s390-iommu.c | 45 ++++++++----------------------------- 2 files changed, 10 insertions(+), 36 deletions(-)
arch/s390/include/asm/pci.h +1 -0
@@ -117,6 +117,7 @@ struct zpci_bus {struct zpci_dev {struct zpci_bus *zbus;struct list_head entry;/* list of all zpci_devices, needed for hotplug, etc. */ +struct list_head iommu_list;struct kref kref;struct hotplug_slot hotplug_slot;
drivers/iommu/s390-iommu.c +9 -36
107 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH v3 2/5] iommu/s390: Get rid of s390_domain_device
Quoted 8 lines · Niklas Schnelle
The struct
s390_domain_deviceserves the sole purpose as list entry for the devices list of a structs390_domain. As it contains no additional information besides alist_headand a pointer to the structzpci_devwe can simplify things and just thread the device list through structzpci_devdirectly. This removes the need to allocate during domain attach and gets rid of one level of indirection during mapping operations.
Quoted 5 lines
Signed-off-by Niklas Schnelle <[email protected]>---
v2->v3:
- Remove search in devices list when we have the pointer to the list item (Jason)
Jason
Niklas Schnelle
maintainerPATCH v3 3/5 iommu/s390: Fix potential s390_domain aperture shrinking
In reply to Niklas SchnelleThe s390 IOMMU driver currently sets the IOMMU domain's aperture to match the device specific DMA address range of the device that is first attached. This is not ideal. For one if the domain has no device attached in the meantime the aperture could be shrunk allowing translations outside the aperture to exist in the translation tables. Also this is a bit of a misuse of the aperture which really should describe what addresses can be translated and not some device specific limitations.
Instead of misusing the aperture like this we can instead create reserved ranges for the ranges inaccessible to the attached devices allowing devices with overlapping ranges to still share an IOMMU domain. This also significantly simplifies s390_iommu_attach_device() allowing us to move the aperture check to the beginning of the function and removing the need to hold the device list's lock to check the aperture.
--- drivers/iommu/s390-iommu.c | 50 +++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 14 deletions(-)
drivers/iommu/s390-iommu.c +36 -14
@@ -62,6 +62,9 @@ static struct iommu_domain *s390_domain_alloc(unsigned domain_type)kfree (s390_domain);return NULL ; } + s390_domain->domain.geometry.force_aperture = true; + s390_domain->domain.geometry.aperture_start =0 ; + s390_domain->domain.geometry.aperture_end =ZPCI_TABLE_SIZE_RT -1 ;spin_lock_init (&s390_domain->dma_table_lock);spin_lock_init (&s390_domain->list_lock);
@@ -107,30 +110,24 @@ static int s390_iommu_attach_device(struct iommu_domain *domain,if (!zdev)return -ENODEV ; +if (domain->geometry.aperture_start > zdev->end_dma || + domain->geometry.aperture_end < zdev->start_dma) +return -EINVAL ; +if (zdev->s390_domain)__s390_iommu_detach_device (zdev->s390_domain, zdev);else if (zdev->dma_table)zpci_dma_exit_device (zdev); - zdev->dma_table = s390_domain->dma_table; cc =zpci_register_ioat (zdev,0 , zdev->start_dma, zdev->end_dma, -virt_to_phys (zdev->dma_table)); +virt_to_phys (s390_domain->dma_table));if (cc)return -EIO ; -spin_lock_irqsave (&s390_domain->list_lock, flags); -/* First device defines the DMA range limits */ -if (list_empty (&s390_domain->devices)) { - domain->geometry.aperture_start = zdev->start_dma; - domain->geometry.aperture_end = zdev->end_dma; - domain->geometry.force_aperture = true; -/* Allow only devices with identical DMA range limits */ - }else if (domain->geometry.aperture_start != zdev->start_dma || - domain->geometry.aperture_end != zdev->end_dma) { -spin_unlock_irqrestore (&s390_domain->list_lock, flags); -return -EINVAL ; - } + zdev->dma_table = s390_domain->dma_table; zdev->s390_domain = s390_domain; + +spin_lock_irqsave (&s390_domain->list_lock, flags);list_add (&zdev->iommu_list, &s390_domain->devices);spin_unlock_irqrestore (&s390_domain->list_lock, flags);
@@ -147,6 +144,30 @@ static void s390_iommu_detach_device(struct iommu_domain *domain,zpci_dma_init_device (zdev); } +static void s390_iommu_get_resv_regions (struct device *dev, +struct list_head *list) +{ +struct zpci_dev *zdev =to_zpci_dev (dev); +struct iommu_resv_region *region; + +if (zdev->start_dma) { + region =iommu_alloc_resv_region (0 , zdev->start_dma,0 , +IOMMU_RESV_RESERVED ); +if (!region) +return ; +list_add_tail (®ion->list, list); + } + +if (zdev->end_dma <ZPCI_TABLE_SIZE_RT -1 ) { + region =iommu_alloc_resv_region (zdev->end_dma +1 , +ZPCI_TABLE_SIZE_RT - zdev->end_dma -1 , +0 ,IOMMU_RESV_RESERVED ); +if (!region) +return ; +list_add_tail (®ion->list, list); + } +} +static struct iommu_device *s390_iommu_probe_device (struct device *dev) {struct zpci_dev *zdev =to_zpci_dev (dev);
@@ -340,6 +361,7 @@ static const struct iommu_ops s390_iommu_ops = { .release_device = s390_iommu_release_device, .device_group = generic_device_group, .pgsize_bitmap = S390_IOMMU_PGSIZES, + .get_resv_regions = s390_iommu_get_resv_regions, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = s390_iommu_attach_device, .detach_dev = s390_iommu_detach_device,
Signature · 1 line
2.34.1
Re: [PATCH v3 3/5] iommu/s390: Fix potential s390_domain aperture shrinking
Quoted 16 lines · Niklas Schnelle
The s390 IOMMU driver currently sets the IOMMU domain's aperture to match the device specific DMA address range of the device that is first attached. This is not ideal. For one if the domain has no device attached in the meantime the aperture could be shrunk allowing translations outside the aperture to exist in the translation tables. Also this is a bit of a misuse of the aperture which really should describe what addresses can be translated and not some device specific limitations.
Instead of misusing the aperture like this we can instead create reserved ranges for the ranges inaccessible to the attached devices allowing devices with overlapping ranges to still share an IOMMU domain. This also significantly simplifies
s390_iommu_attach_device()allowing us to move the aperture check to the beginning of the function and removing the need to hold the device list's lock to check the aperture.
Quoted 5 lines
Suggested-by Jason Gunthorpe <[email protected]>Signed-off-by Niklas Schnelle <[email protected]>--- drivers/iommu/s390-iommu.c | 50 +++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 14 deletions(-)
Jason
Niklas Schnelle
maintainerPATCH v3 4/5 iommu/s390: Fix incorrect aperture check
In reply to Niklas SchnelleThe domain->geometry.aperture_end specifies the last valid address treat it as such when checking if a DMA address is valid.
--- drivers/iommu/s390-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/s390-iommu.c +1 -1
@@ -210,7 +210,7 @@ static int s390_iommu_update_trans(struct s390_domain *s390_domain,int rc =0 ;if (dma_addr < s390_domain->domain.geometry.aperture_start || - dma_addr + size > s390_domain->domain.geometry.aperture_end) + dma_addr + size > s390_domain->domain.geometry.aperture_end +1 )return -EINVAL ; nr_pages =PAGE_ALIGN (size) >>PAGE_SHIFT ;
Signature · 1 line
2.34.1
Re: [PATCH v3 4/5] iommu/s390: Fix incorrect aperture check
Quoted 15 lines · Niklas Schnelle
The
domain->geometry.aperture_endspecifies the last valid address treat it as such when checking if a DMA address is valid.Reviewed-by Pierre Morel <[email protected]>Reviewed-by Matthew Rosato <[email protected]>Signed-off-by Niklas Schnelle <[email protected]>--- drivers/iommu/s390-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iommu/s390-iommu.c +0
-0
drivers/iommu/s390-iommu.c static int s390_iommu_update_trans(struct s390_domain *s390_domain, · line 213
Quoted 5 lines
drivers/iommu/s390-iommu.c +1
-1@@ -210,7 +210,7 @@ static int s390_iommu_update_trans(struct s390_domain *s390_domain,int rc =0 ;if (dma_addr < s390_domain->domain.geometry.aperture_start || - dma_addr + size > s390_domain->domain.geometry.aperture_end) + dma_addr + size > s390_domain->domain.geometry.aperture_end +1 )
The reason the iommu layer uses 'last' (= start + size - 1) not 'end' is to allow for the very last byte of the range to be used.
Meaning (start + size) == 0 in some cases due to the overflow.
Generally when working with lasts's I prefer people write code in a way that doesn't trigger the overflow, because there are some complicated C rules about integer promotion that can mean the desired overflow silently doesn't happen in obscure cases - especially if unsigned long != u64
So, I'd write this as:
(dma_addr + size - 1) > s390_domain->domain.geometry.aperture_end
Jason
Niklas Schnelle
maintainerRe: [PATCH v3 4/5] iommu/s390: Fix incorrect aperture check
Quoted 33 lines · Jason Gunthorpe
Quoted 15 lines · Niklas Schnelle
The
domain->geometry.aperture_endspecifies the last valid address treat it as such when checking if a DMA address is valid.Reviewed-by Pierre Morel <[email protected]>Reviewed-by Matthew Rosato <[email protected]>Signed-off-by Niklas Schnelle <[email protected]>--- drivers/iommu/s390-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iommu/s390-iommu.c +0
-0drivers/iommu/s390-iommu.c static int s390_iommu_update_trans(struct s390_domain *s390_domain, · line 213
Quoted 5 lines
drivers/iommu/s390-iommu.c +1
-1@@ -210,7 +210,7 @@ static int s390_iommu_update_trans(struct s390_domain *s390_domain,int rc =0 ;if (dma_addr < s390_domain->domain.geometry.aperture_start || - dma_addr + size > s390_domain->domain.geometry.aperture_end) + dma_addr + size > s390_domain->domain.geometry.aperture_end +1 )The reason the iommu layer uses 'last' (= start + size - 1) not 'end' is to allow for the very last byte of the range to be used.
Meaning (start + size) == 0 in some cases due to the overflow.
Generally when working with lasts's I prefer people write code in a way that doesn't trigger the overflow, because there are some complicated C rules about integer promotion that can mean the desired overflow silently doesn't happen in obscure cases - especially if unsigned long != u64
Quoted 5 lines
So, I'd write this as:
(
dma_addr+ size - 1) >s390_domain->domain.geometry.aperture_endJason
Makes sense. Thanks.
Niklas Schnelle
maintainerPATCH v3 5/5 iommu/s390: Fix incorrect pgsize_bitmap
In reply to Niklas SchnelleThe .pgsize_bitmap property of struct iommu_ops is not a page mask but rather has a bit set for each size of pages the IOMMU supports. As the comment correctly pointed out at this moment the code only support 4K pages so simply use SZ_4K here.
--- drivers/iommu/s390-iommu.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
drivers/iommu/s390-iommu.c +1 -8
@@ -12,13 +12,6 @@#include <linux/sizes.h> #include <asm/pci_dma.h> -/* -* Physically contiguous memory regions can be mapped with 4 KiB alignment, -* we allow all page sizes that are an order of 4KiB (no special large page -* support so far). -*/ -#define S390_IOMMU_PGSIZES (~0xFFFUL) -static const struct iommu_ops s390_iommu_ops;struct s390_domain {
@@ -360,7 +353,7 @@ static const struct iommu_ops s390_iommu_ops = { .probe_device = s390_iommu_probe_device, .release_device = s390_iommu_release_device, .device_group = generic_device_group, - .pgsize_bitmap = S390_IOMMU_PGSIZES, + .pgsize_bitmap = SZ_4K, .get_resv_regions = s390_iommu_get_resv_regions, .default_domain_ops = &(const struct iommu_domain_ops ) { .attach_dev = s390_iommu_attach_device,
Signature · 1 line
2.34.1
Re: [PATCH v3 5/5] iommu/s390: Fix incorrect pgsize_bitmap
Quoted 9 lines · Niklas Schnelle
The .pgsize_bitmap property of struct
iommu_opsis not a page mask but rather has a bit set for each size of pages the IOMMU supports. As the comment correctly pointed out at this moment the code only support 4K pages so simply useSZ_4Khere.Signed-off-by Niklas Schnelle <[email protected]>--- drivers/iommu/s390-iommu.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
Yep!
Jason