> From: Jason Gunthorpe <[email protected]>
> Sent: Saturday, November 8, 2025 12:50 AM
> 
> 
> @@ -2031,7 +2155,10 @@ int iopt_pages_rw_access(struct iopt_pages
> *pages, unsigned long start_byte,
>       if ((flags & IOMMUFD_ACCESS_RW_WRITE) && !pages->writable)
>               return -EPERM;
> 
> -     if (pages->type == IOPT_ADDRESS_FILE)
> +     if (iopt_is_dmabuf(pages))
> +             return -EINVAL;
> +

probably also add helpers for other types, e.g.:

  iopt_is_user()
  iopt_is_memfd()

> +     if (pages->type != IOPT_ADDRESS_USER)
>               return iopt_pages_rw_slow(pages, start_index, last_index,
>                                         start_byte % PAGE_SIZE, data,
> length,
>                                         flags);
> --

then the following WARN_ON() becomes useless:

        if (IS_ENABLED(CONFIG_IOMMUFD_TEST) &&
            WARN_ON(pages->type != IOPT_ADDRESS_USER))
                return -EINVAL;

Reviewed-by: Kevin Tian <[email protected]>

Reply via email to