> From: Jason Gunthorpe <[email protected]>
> Sent: Thursday, September 4, 2025 1:47 AM
> 
> map is slightly complicated because it has to handle a number of special
> edge cases:
>  - Overmapping a previously shared table with an OA - requries validating
>    and freeing the possibly empty tables
>  - Doing the above across an entire to-be-created contiguous entry
>  - Installing a new shared table level concurrently with another thread
>  - Expanding the table by adding more top levels

what is 'shared table'? Looks this term doesn't appear in previous patches.

also it's unclear to me why overmapping a previously shared table can
succeed while overmapping leaf entries cannot (w/ -EADDRINUSE)

> +
> +     /* Calculate target page size and level for the leaves */
> +     if (pt_has_system_page(common) && pgsize == PAGE_SIZE &&
> pgcount == 1) {
> +             PT_WARN_ON(!(pgsize_bitmap & PAGE_SIZE));
> +             if (log2_mod(iova | paddr, PAGE_SHIFT))
> +                     return -ENXIO;
> +             map.leaf_pgsize_lg2 = PAGE_SHIFT;
> +             map.leaf_level = 0;
> +             single_page = true;
> +     } else {
> +             map.leaf_pgsize_lg2 = pt_compute_best_pgsize(
> +                     pgsize_bitmap, range.va, range.last_va, paddr);
> +             if (!map.leaf_pgsize_lg2)
> +                     return -ENXIO;
> +             map.leaf_level =
> +                     pt_pgsz_lg2_to_level(common, map.leaf_pgsize_lg2);

Existing driver checks alignment on pgsize, e.g. intel-iommu:

        if (!IS_ALIGNED(iova | paddr, pgsize))
                return -EINVAL;

But pt_compute_best_pgsize() doesn't use 'pgsize' and only have checks
on calculated pgsz_lg2:

        pgsz_lg2 = log2_fls(pgsz_bitmap);
        if (!pgsz_lg2)
                return 0;

        pgsz_lg2--;

        PT_WARN_ON(log2_mod(va, pgsz_lg2) != 0);
        PT_WARN_ON(oalog2_mod(oa, pgsz_lg2) != 0);

Looks not identical.

> +/**
> + * struct pt_iommu_flush_ops - HW IOTLB cache flushing operations
> + *
> + * The IOMMU driver should implement these using
> container_of(iommu_table) to
> + * get to it's iommu_domain dervied structure. All ops can be called in
> atomic
> + * contexts as they are buried under DMA API calls.

s/dervied/derived/


Reply via email to