From: Robin Murphy <robin.murphy@arm.com>
To: Jason Gunthorpe <jgg@nvidia.com>,
iommu@lists.linux.dev,
Jean-Philippe Brucker <jean-philippe@linaro.org>,
Joerg Roedel <joro@8bytes.org>,
virtualization@lists.linux.dev, Will Deacon <will@kernel.org>
Cc: Eric Auger <eric.auger@redhat.com>,
patches@lists.linux.dev, Alyssa Rosenzweig <alyssa@rosenzweig.io>,
Sven Peter <sven@svenpeter.dev>, Janne Grunau <j@jannau.net>
Subject: Re: [PATCH 2/5] iommu: Add domain_alloc_identity()
Date: Wed, 12 Feb 2025 13:56:55 +0000 [thread overview]
Message-ID: <f0164c18-9ded-4c41-a8c5-c225a978973d@arm.com> (raw)
In-Reply-To: <2-v1-91eed9c8014a+53a37-iommu_virtio_domains_jgg@nvidia.com>
On 2025-02-07 2:46 pm, Jason Gunthorpe wrote:
> virtio-iommu has a mode where the IDENTITY domain is actually a paging
> domain with an identity mapping covering some of the system address
> space manually created.
>
> To support this add a new domain_alloc_identity() op that accepts
> the struct device so that virtio can allocate and fully finalize a
> paging domain to return.
Oh, I'd already managed to forget this idea - this could be convenient
for DART to implement per-instance identity domain support as well.
Robin.
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
> drivers/iommu/iommu.c | 20 ++++++++++++--------
> include/linux/iommu.h | 4 ++++
> 2 files changed, 16 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 870c3cdbd0f622..ee33d26dfcd40d 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -1595,15 +1595,19 @@ static struct iommu_domain *__iommu_alloc_identity_domain(struct device *dev)
> if (ops->identity_domain)
> return ops->identity_domain;
>
> - /* Older drivers create the identity domain via ops->domain_alloc() */
> - if (!ops->domain_alloc)
> + if (ops->domain_alloc_identity) {
> + domain = ops->domain_alloc_identity(dev);
> + if (IS_ERR(domain))
> + return domain;
> + } else if (ops->domain_alloc) {
> + domain = ops->domain_alloc(IOMMU_DOMAIN_IDENTITY);
> + if (!domain)
> + return ERR_PTR(-ENOMEM);
> + if (IS_ERR(domain))
> + return domain;
> + } else {
> return ERR_PTR(-EOPNOTSUPP);
> -
> - domain = ops->domain_alloc(IOMMU_DOMAIN_IDENTITY);
> - if (IS_ERR(domain))
> - return domain;
> - if (!domain)
> - return ERR_PTR(-ENOMEM);
> + }
>
> iommu_domain_init(domain, IOMMU_DOMAIN_IDENTITY, ops);
> return domain;
> diff --git a/include/linux/iommu.h b/include/linux/iommu.h
> index 38c65e92ecd091..6389d59178ba3f 100644
> --- a/include/linux/iommu.h
> +++ b/include/linux/iommu.h
> @@ -557,6 +557,9 @@ iommu_copy_struct_from_full_user_array(void *kdst, size_t kdst_entry_size,
> * @domain_alloc: allocate and return an iommu domain if success. Otherwise
> * NULL is returned. The domain is not fully initialized until
> * the caller iommu_domain_alloc() returns.
> + * @domain_alloc_identity: allocate an IDENTITY domain. Drivers should prefer to
> + * use identity_domain instead. This should only be used
> + * if dynamic logic is necessary.
> * @domain_alloc_paging_flags: Allocate an iommu domain corresponding to the
> * input parameters as defined in
> * include/uapi/linux/iommufd.h. The @user_data can be
> @@ -615,6 +618,7 @@ struct iommu_ops {
>
> /* Domain allocation and freeing by the iommu driver */
> struct iommu_domain *(*domain_alloc)(unsigned iommu_domain_type);
> + struct iommu_domain *(*domain_alloc_identity)(struct device *dev);
> struct iommu_domain *(*domain_alloc_paging_flags)(
> struct device *dev, u32 flags,
> const struct iommu_user_data *user_data);
next prev parent reply other threads:[~2025-02-12 13:57 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-07 14:46 [PATCH 0/5] Convert virtio-iommu to domain_alloc_paging() Jason Gunthorpe
2025-02-07 14:46 ` [PATCH 1/5] iommu/virtio: Break out bypass identity support into a global static Jason Gunthorpe
2025-02-12 0:43 ` Jacob Pan
2025-02-18 18:21 ` Jason Gunthorpe
2025-02-21 11:35 ` Jean-Philippe Brucker
2025-02-24 19:37 ` Jason Gunthorpe
2025-02-07 14:46 ` [PATCH 2/5] iommu: Add domain_alloc_identity() Jason Gunthorpe
2025-02-12 13:56 ` Robin Murphy [this message]
2025-02-12 14:03 ` Jason Gunthorpe
2025-02-12 14:16 ` Robin Murphy
2025-02-12 14:45 ` Jason Gunthorpe
2025-02-07 14:46 ` [PATCH 3/5] iommu/virtio: Move to domain_alloc_paging() Jason Gunthorpe
2025-02-12 19:22 ` Jacob Pan
2025-02-12 23:30 ` Jason Gunthorpe
2025-02-13 5:47 ` Jacob Pan
2025-02-18 20:01 ` Jason Gunthorpe
[not found] ` <67ad876d.170a0220.3c21dc.85ceSMTPIN_ADDED_BROKEN@mx.google.com>
2025-02-13 9:46 ` Jean-Philippe Brucker
2025-02-13 17:03 ` Yu Zhang
2025-02-13 18:09 ` Jean-Philippe Brucker
2025-02-19 9:39 ` Yu Zhang
2025-02-19 10:35 ` Jean-Philippe Brucker
2025-02-19 11:11 ` Yu Zhang
2025-02-19 11:57 ` Jean-Philippe Brucker
2025-02-19 13:10 ` Yi Liu
2025-02-20 2:58 ` Baolu Lu
2025-02-20 3:44 ` Yu Zhang
2025-02-07 14:46 ` [PATCH 4/5] iommu: Do not call domain_alloc() in iommu_sva_domain_alloc() Jason Gunthorpe
2025-02-07 14:46 ` [PATCH 5/5] iommu: Hide ops.domain_alloc behind CONFIG_FSL_PAMU Jason Gunthorpe
2025-02-12 0:41 ` [PATCH 0/5] Convert virtio-iommu to domain_alloc_paging() Jacob Pan
2025-02-12 12:50 ` Jason Gunthorpe
2025-02-12 18:50 ` Jacob Pan
2025-02-12 20:10 ` Robin Murphy
2025-02-21 11:42 ` Jean-Philippe Brucker
2025-02-24 19:39 ` Jason Gunthorpe
[not found] ` <67abee53.170a0220.154671.ae28SMTPIN_ADDED_BROKEN@mx.google.com>
2025-02-12 11:58 ` Jean-Philippe Brucker
2025-02-12 17:05 ` Jacob Pan
[not found] ` <67acd4e2.630a0220.365aab.e098SMTPIN_ADDED_BROKEN@mx.google.com>
2025-02-12 19:16 ` Jean-Philippe Brucker
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=f0164c18-9ded-4c41-a8c5-c225a978973d@arm.com \
--to=robin.murphy@arm.com \
--cc=alyssa@rosenzweig.io \
--cc=eric.auger@redhat.com \
--cc=iommu@lists.linux.dev \
--cc=j@jannau.net \
--cc=jean-philippe@linaro.org \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=patches@lists.linux.dev \
--cc=sven@svenpeter.dev \
--cc=virtualization@lists.linux.dev \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox