Linux IOMMU Development
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Steve Sistare <steven.sistare@oracle.com>
Cc: iommu@lists.linux.dev, Kevin Tian <kevin.tian@intel.com>,
	Alex Williamson <alex.williamson@redhat.com>,
	Cornelia Huck <cohuck@redhat.com>
Subject: Re: [RFC V1 4/4] iommufd: update VA
Date: Mon, 22 Jul 2024 12:51:39 -0300	[thread overview]
Message-ID: <20240722155139.GH3371438@nvidia.com> (raw)
In-Reply-To: <1721501805-86928-6-git-send-email-steven.sistare@oracle.com>

On Sat, Jul 20, 2024 at 11:56:45AM -0700, Steve Sistare wrote:
> @@ -458,6 +459,76 @@ static void change_mm(struct iopt_pages *pages)
>  	free_uid(old_user);
>  }
>  
> +#define MAX_UMAP_ENTRIES 1024

Only 170 of these fit in a 4k page :\

Are you worried about the high order allocation this could trigger?

I guess the alternative is to load it into a maple tree or similar,
but that is alot of memory allocations.

> +static int iommufd_get_umap(struct iommu_ioas_change_process *cmd,
> +			    struct iommu_ioas_userspace_map **p_umap)
> +{
> +	int i;
> +	int len = cmd->n_umap * sizeof(**p_umap);
> +	struct iommu_ioas_userspace_map *umap = kzalloc(len, GFP_KERNEL);
> +
> +	if (!umap)
> +		return -ENOMEM;
> +
> +	if (len > MAX_UMAP_ENTRIES * sizeof(*umap))
> +		return -E2BIG;
> +
> +	if (copy_from_user(umap, u64_to_user_ptr(cmd->umap), len)) {
> +		kfree(umap);
> +		return -EFAULT;
> +	}

This is memdup_user ?

> +struct iommu_ioas_userspace_map {
> +	__u64 addr_old;		/* old userspace virtual address */
> +	__u64 addr_new;		/* new userspace virtual address */
> +	__u64 size;		/* size of the mapping in bytes */
> +};

Use __aligned_u64 here as well

>  struct iommu_ioas_change_process {
>  	__u32 size;
> +	__u32 flags;
> +	__u32 n_umap;
> +	__u32 __reserved;
> +	__aligned_u64 umap;
>  };
> -
>  #define IOMMU_IOAS_CHANGE_PROCESS \
>  	_IO(IOMMUFD_TYPE, IOMMUFD_CMD_IOAS_CHANGE_PROCESS)
> -

These - lines should go in the prior patch

Jason

  reply	other threads:[~2024-07-22 15:51 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-20 18:56 [RFC V1 0/4] iommufd live update Steve Sistare
2024-07-20 18:56 ` [RFC V1 1/4] iommufd: Export do_update_pinned Steve Sistare
2024-07-20 18:56 ` [RFC V1] iommufd debug print Steve Sistare
2024-07-20 19:01   ` Steven Sistare
2024-07-20 18:56 ` [RFC V1 2/4] iommufd: Lock all objects Steve Sistare
2024-07-22 15:37   ` Jason Gunthorpe
2024-08-05 19:01     ` Steven Sistare
2024-09-26 14:00       ` Steven Sistare
2024-07-20 18:56 ` [RFC V1 3/4] iommufd: Add IOMMU_IOAS_CHANGE_PROCESS Steve Sistare
2024-07-20 18:56 ` [RFC V1 4/4] iommufd: update VA Steve Sistare
2024-07-22 15:51   ` Jason Gunthorpe [this message]
2024-08-05 19:02     ` Steven Sistare
2024-08-06 12:54       ` Jason Gunthorpe
2024-07-20 19:21 ` [RFC V1 0/4] iommufd live update Steven Sistare
2024-07-22 15:55 ` Jason Gunthorpe
2024-08-05 19:03   ` Steven Sistare
2024-08-06 12:56     ` Jason Gunthorpe
2024-08-08 19:15       ` Steven Sistare
2024-08-08 19:52         ` Jason Gunthorpe
2024-08-12 17:41           ` Steven Sistare
2024-08-19 14:59             ` Jason Gunthorpe
2024-08-21 17:54               ` Steven Sistare
2024-08-21 18:04                 ` Jason Gunthorpe
2024-08-22 21:05                   ` Steven Sistare
2024-08-22 21:10                     ` Jason Gunthorpe
2024-07-23 12:48 ` Jason Gunthorpe
2024-08-05 19:02   ` Steven Sistare

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=20240722155139.GH3371438@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=alex.williamson@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=iommu@lists.linux.dev \
    --cc=kevin.tian@intel.com \
    --cc=steven.sistare@oracle.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