Linux IOMMU Development
 help / color / mirror / Atom feed
From: Steven Sistare <steven.sistare@oracle.com>
To: iommu@lists.linux.dev
Cc: Jason Gunthorpe <jgg@nvidia.com>,
	Kevin Tian <kevin.tian@intel.com>,
	Nicolin Chen <nicolinc@nvidia.com>
Subject: Re: [PATCH V1 7/9] iommufd: file mappings for mdev
Date: Wed, 18 Sep 2024 10:52:41 -0400	[thread overview]
Message-ID: <5b422c77-d299-48ed-8a40-e7f584b6bb2e@oracle.com> (raw)
In-Reply-To: <1726319158-283074-8-git-send-email-steven.sistare@oracle.com>

Hi Jason, any comments or RB on this before I submit V2? - steve

On 9/14/2024 9:05 AM, Steve Sistare wrote:
> Support file mappings for mediated devices, aka mdevs.  Access is initiated
> by the vfio_pin_pages and vfio_dma_rw kernel interfaces.
> 
> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
> ---
>   drivers/iommu/iommufd/pages.c | 22 +++++++++++++++-------
>   1 file changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iommu/iommufd/pages.c b/drivers/iommu/iommufd/pages.c
> index 8c8d0ff..4cb532e 100644
> --- a/drivers/iommu/iommufd/pages.c
> +++ b/drivers/iommu/iommufd/pages.c
> @@ -1706,11 +1706,11 @@ static int iopt_pages_fill_from_domain(struct iopt_pages *pages,
>   	return 0;
>   }
>   
> -static int iopt_pages_fill_from_mm(struct iopt_pages *pages,
> -				   struct pfn_reader_user *user,
> -				   unsigned long start_index,
> -				   unsigned long last_index,
> -				   struct page **out_pages)
> +static int iopt_pages_fill(struct iopt_pages *pages,
> +			   struct pfn_reader_user *user,
> +			   unsigned long start_index,
> +			   unsigned long last_index,
> +			   struct page **out_pages)
>   {
>   	unsigned long cur_index = start_index;
>   	int rc;
> @@ -1784,8 +1784,8 @@ int iopt_pages_fill_xarray(struct iopt_pages *pages, unsigned long start_index,
>   
>   		/* hole */
>   		cur_pages = out_pages + (span.start_hole - start_index);
> -		rc = iopt_pages_fill_from_mm(pages, &user, span.start_hole,
> -					     span.last_hole, cur_pages);
> +		rc = iopt_pages_fill(pages, &user, span.start_hole,
> +				     span.last_hole, cur_pages);
>   		if (rc)
>   			goto out_clean_xa;
>   		rc = pages_to_xarray(&pages->pinned_pfns, span.start_hole,
> @@ -1865,6 +1865,9 @@ static int iopt_pages_rw_page(struct iopt_pages *pages, unsigned long index,
>   	struct page *page = NULL;
>   	int rc;
>   
> +	if (WARN_ON(pages->type != IOPT_ADDRESS_USER))
> +		return -EINVAL;
> +
>   	if (!mmget_not_zero(pages->source_mm))
>   		return iopt_pages_rw_slow(pages, index, index, offset, data,
>   					  length, flags);
> @@ -1920,6 +1923,11 @@ 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)
> +		return iopt_pages_rw_slow(pages, start_index, last_index,
> +					  start_byte % PAGE_SIZE, data, length,
> +					  flags);
> +
>   	if (!(flags & IOMMUFD_ACCESS_RW_KTHREAD) && change_mm) {
>   		if (start_index == last_index)
>   			return iopt_pages_rw_page(pages, start_index,

  reply	other threads:[~2024-09-18 14:52 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-14 13:05 [PATCH V1 0/9] iommu_ioas_map_file Steve Sistare
2024-09-14 13:05 ` [PATCH V1 1/9] mm/gup: repin_folio_unhugely Steve Sistare
2024-09-14 13:19   ` Steven Sistare
2024-09-17 12:25     ` David Hildenbrand
2024-09-18 14:51       ` Steven Sistare
2024-09-19  8:11         ` David Hildenbrand
2024-09-19 21:06           ` Steven Sistare
2024-09-26 11:38             ` David Hildenbrand
2024-09-20 13:28           ` Jason Gunthorpe
2024-09-26 11:32             ` David Hildenbrand
2024-09-26 11:40               ` Jason Gunthorpe
2024-09-26 12:57                 ` David Hildenbrand
2024-09-26 12:58                   ` David Hildenbrand
2024-09-15 20:37   ` Jason Gunthorpe
2024-09-18 14:51     ` Steven Sistare
2024-09-14 13:05 ` [PATCH V1 2/9] iommufd: remove uptr from iopt_alloc_iova Steve Sistare
2024-09-15 20:41   ` Jason Gunthorpe
2024-09-18 14:51     ` Steven Sistare
2024-09-24 19:50       ` Jason Gunthorpe
2024-09-14 13:05 ` [PATCH V1 3/9] iommufd: generalize iopt_pages address Steve Sistare
2024-09-18 14:52   ` Steven Sistare
2024-09-14 13:05 ` [PATCH V1 4/9] iommufd: pfn reader for file mappings Steve Sistare
2024-09-15 20:51   ` Jason Gunthorpe
2024-09-18 14:51     ` Steven Sistare
2024-09-14 13:05 ` [PATCH V1 5/9] iommufd: IOMMU_IOAS_MAP_FILE interface Steve Sistare
2024-09-15 20:52   ` Jason Gunthorpe
2024-09-18 14:51     ` Steven Sistare
2024-09-14 13:05 ` [PATCH V1 6/9] iommufd: IOMMU_IOAS_MAP_FILE implementation Steve Sistare
2024-09-17  1:48   ` kernel test robot
2024-09-14 13:05 ` [PATCH V1 7/9] iommufd: file mappings for mdev Steve Sistare
2024-09-18 14:52   ` Steven Sistare [this message]
2024-09-14 13:05 ` [PATCH V1 8/9] iommufd: replace upages_len Steve Sistare
2024-09-14 13:05 ` [PATCH V1 9/9] iommufd: optimize file mapping Steve Sistare
2024-09-15 20:59   ` Jason Gunthorpe
2024-09-18 14:52     ` Steven Sistare
2024-09-14 13:21 ` [PATCH V1 0/9] iommu_ioas_map_file Steven Sistare
2024-09-15 20:30 ` Jason Gunthorpe
2024-09-18 14:52   ` Steven Sistare
2024-09-23 17:33     ` Jason Gunthorpe

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=5b422c77-d299-48ed-8a40-e7f584b6bb2e@oracle.com \
    --to=steven.sistare@oracle.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@nvidia.com \
    --cc=kevin.tian@intel.com \
    --cc=nicolinc@nvidia.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox