Re: [PATCH v4 5/5] iommu/s390: allow larger region tables

From: Heiko Carstens
Date: Tue Apr 01 2025 - 05:12:06 EST


On Mon, Mar 31, 2025 at 04:21:59PM -0400, Matthew Rosato wrote:
> Extend the aperture calculation to consider sizes beyond the maximum
> size of a region third table. Attempt to always use the smallest
> table size possible to avoid unnecessary extra steps during translation.
> Update reserved region calculations to use the appropriate table size.
>
> Signed-off-by: Matthew Rosato <mjrosato@xxxxxxxxxxxxx>
> ---
> arch/s390/include/asm/pci_dma.h | 1 +
> drivers/iommu/s390-iommu.c | 71 ++++++++++++++++++++++++---------
> 2 files changed, 53 insertions(+), 19 deletions(-)

...

> + spin_lock_irqsave(&zdev->dom_lock, flags);
> + if (zdev->s390_domain->type == IOMMU_DOMAIN_BLOCKED ||
> + zdev->s390_domain->type == IOMMU_DOMAIN_IDENTITY)
> + goto out;
> +
> + s390_domain = to_s390_domain(zdev->s390_domain);
> + if (zdev->end_dma < max_tbl_size(s390_domain)) {
> + end_resv = max_tbl_size(s390_domain) - zdev->end_dma;
> + region = iommu_alloc_resv_region(zdev->end_dma + 1, end_resv,
> + 0, IOMMU_RESV_RESERVED,
> + GFP_KERNEL);

GFP_KERNEL allocation while holding a spinlock is not correct.