All of lore.kernel.org
 help / color / mirror / Atom feed
From: Samiullah Khawaja <skhawaja@google.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: iommu@lists.linux.dev, Joerg Roedel <joro@8bytes.org>,
	 Robin Murphy <robin.murphy@arm.com>,
	Will Deacon <will@kernel.org>,
	 Alejandro Jimenez <alejandro.j.jimenez@oracle.com>,
	Lu Baolu <baolu.lu@linux.intel.com>,
	 Joerg Roedel <joerg.roedel@amd.com>,
	Josua Mayer <josua@solid-run.com>,
	 Kevin Tian <kevin.tian@intel.com>,
	Pasha Tatashin <pasha.tatashin@soleen.com>,
	 patches@lists.linux.dev, Pranjal Shrivastava <praan@google.com>,
	 Mostafa Saleh <smostafa@google.com>,
	stable@vger.kernel.org
Subject: Re: [PATCH rc 4/5] iommupt: Check for missing PAGE_SIZE in the pgsize_bitmap
Date: Wed, 13 May 2026 18:48:26 +0000	[thread overview]
Message-ID: <agS-MDCnoofhsBEe@google.com> (raw)
In-Reply-To: <20260513180607.GC787748@nvidia.com>

On Wed, May 13, 2026 at 03:06:07PM -0300, Jason Gunthorpe wrote:
>On Wed, May 13, 2026 at 05:57:13PM +0000, Samiullah Khawaja wrote:
>> On Wed, May 13, 2026 at 05:46:22PM +0000, Samiullah Khawaja wrote:
>> > On Tue, May 12, 2026 at 01:46:16PM -0300, Jason Gunthorpe wrote:
>> > > Sashiko pointed out that the driver could drop PAGE_SIZE from the
>> > > pgsize_bitmap. That is technically allowed but nothing does it, and
>> > > such an iommu_domain would not be used with the DMA API today.
>> > >
>> > > Still, it is against the design and it is trivial to fix up. Lift
>> > > the PT_WARN_ON to the if branch and just skip the fast path.
>> > >
>> > > Fixes: dcd6a011a8d5 ("iommupt: Add map_pages op")
>> > > Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
>> > > ---
>> > > drivers/iommu/generic_pt/iommu_pt.h | 4 ++--
>> > > 1 file changed, 2 insertions(+), 2 deletions(-)
>> > >
>> > > diff --git a/drivers/iommu/generic_pt/iommu_pt.h b/drivers/iommu/generic_pt/iommu_pt.h
>> > > index 19b6daf88f2ab1..4877b05291c9d4 100644
>> > > --- a/drivers/iommu/generic_pt/iommu_pt.h
>> > > +++ b/drivers/iommu/generic_pt/iommu_pt.h
>> > > @@ -920,8 +920,8 @@ static int NS(map_range)(struct pt_iommu *iommu_table, dma_addr_t iova,
>> > > 		return ret;
>> > >
>> > > 	/* Calculate target page size and level for the leaves */
>> > > -	if (pt_has_system_page_size(common) && len == PAGE_SIZE) {
>> > > -		PT_WARN_ON(!(pgsize_bitmap & PAGE_SIZE));
>> > > +	if (pt_has_system_page_size(common) && len == PAGE_SIZE &&
>> > > +		likely(pgsize_bitmap & PAGE_SIZE)) {
>> > > 		if (log2_mod(iova | paddr, PAGE_SHIFT))
>> > > 			return -ENXIO;
>>
>> After thought nit:
>>
>> I wonder if the error handling of iova and paddr alignment should also
>> be deferred to non-fast path? Basically lift the iova and paddr check
>> in the parent if?
>
>That would break support for < PAGE_SIZE tables which I've tried to

I was also thinking about support of < PAGE_SIZE tables and wondering
whether the < PAGE_SIZE tables support is already broken. For examples
consider following:

iova = 0x12341800
paddr = 0x56781800
len = PAGE_SIZE (4k)

But pt_has_system_page_size() will be false in such a system.
>keep generic support for. Similar checks already exist in the generic
>code in a more general way, probably the first is
>pt_compute_best_pgsize().

I was suggesting to rely on the already existing checks in
pt_compute_best_pgsize() to do error handling, by only entering fast
path if iova and paddr are also aligned.
>
>Thanks,
>Jason

No change needed. Putting this here again:

Reviewed-by: Samiullah Khawaja <skhawaja@google.com>

Thanks,
Sami

  reply	other threads:[~2026-05-13 18:48 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-12 16:46 [PATCH rc 0/5] Fix some iommupt mistakes from Sashiko Jason Gunthorpe
2026-05-12 16:46 ` [PATCH rc 1/5] iommu: Fix loss of errno on map failure for classic ops Jason Gunthorpe
2026-05-13 14:57   ` Mostafa Saleh
2026-05-13 16:32   ` Samiullah Khawaja
2026-05-13 17:42   ` Pranjal Shrivastava
2026-05-12 16:46 ` [PATCH rc 2/5] iommu: Fix up map/unmap debugging for iommupt domains Jason Gunthorpe
2026-05-13 15:11   ` Mostafa Saleh
2026-05-13 16:45   ` Samiullah Khawaja
2026-05-13 17:44   ` Pranjal Shrivastava
2026-05-12 16:46 ` [PATCH rc 3/5] iommu: Handle unmap error when iommu_debug is enabled Jason Gunthorpe
2026-05-13 15:13   ` Mostafa Saleh
2026-05-13 15:18     ` Jason Gunthorpe
2026-05-13 16:56   ` Samiullah Khawaja
2026-05-13 17:47   ` Pranjal Shrivastava
2026-05-12 16:46 ` [PATCH rc 4/5] iommupt: Check for missing PAGE_SIZE in the pgsize_bitmap Jason Gunthorpe
2026-05-13 17:46   ` Samiullah Khawaja
2026-05-13 17:57     ` Samiullah Khawaja
2026-05-13 18:06       ` Jason Gunthorpe
2026-05-13 18:48         ` Samiullah Khawaja [this message]
2026-05-13 21:03           ` Jason Gunthorpe
2026-05-13 17:48   ` Pranjal Shrivastava
2026-05-12 16:46 ` [PATCH rc 5/5] iommupt: Fix the end_index calculation in __map_range_leaf() Jason Gunthorpe
2026-05-13 17:58   ` Pranjal Shrivastava
2026-05-13 18:53   ` Samiullah Khawaja
2026-05-13 11:08 ` [PATCH rc 0/5] Fix some iommupt mistakes from Sashiko Josua Mayer
2026-05-15  5:29 ` Joerg Roedel

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=agS-MDCnoofhsBEe@google.com \
    --to=skhawaja@google.com \
    --cc=alejandro.j.jimenez@oracle.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=joerg.roedel@amd.com \
    --cc=joro@8bytes.org \
    --cc=josua@solid-run.com \
    --cc=kevin.tian@intel.com \
    --cc=pasha.tatashin@soleen.com \
    --cc=patches@lists.linux.dev \
    --cc=praan@google.com \
    --cc=robin.murphy@arm.com \
    --cc=smostafa@google.com \
    --cc=stable@vger.kernel.org \
    --cc=will@kernel.org \
    /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.