From: Jason Gunthorpe <jgg@ziepe.ca>
To: Teddy Astie <teddy.astie@vates.tech>
Cc: xen-devel@lists.xenproject.org, iommu@lists.linux.dev,
"Juergen Gross" <jgross@suse.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Oleksandr Tyshchenko" <oleksandr_tyshchenko@epam.com>,
"Joerg Roedel" <joro@8bytes.org>, "Will Deacon" <will@kernel.org>,
"Robin Murphy" <robin.murphy@arm.com>,
"Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
Subject: Re: [RFC PATCH] iommu/xen: Add Xen PV-IOMMU driver
Date: Wed, 19 Jun 2024 13:30:00 -0300 [thread overview]
Message-ID: <20240619163000.GK791043@ziepe.ca> (raw)
In-Reply-To: <fe36b8d36ed3bc01c78901bdf7b87a71cb1adaad.1718286176.git.teddy.astie@vates.tech>
On Thu, Jun 13, 2024 at 01:50:22PM +0000, Teddy Astie wrote:
> +struct iommu_domain *xen_iommu_domain_alloc(unsigned type)
> +{
> + struct xen_iommu_domain *domain;
> + u16 ctx_no;
> + int ret;
> +
> + if (type & IOMMU_DOMAIN_IDENTITY) {
> + /* use default domain */
> + ctx_no = 0;
Please use the new ops, domain_alloc_paging and the static identity domain.
> +static struct iommu_group *xen_iommu_device_group(struct device *dev)
> +{
> + if (!dev_is_pci(dev))
> + return ERR_PTR(-ENODEV);
> +
device_group is only called after probe_device, since you already
exclude !pci during probe there is no need for this wrapper, just set
the op directly to pci_device_group.
> +static void xen_iommu_release_device(struct device *dev)
> +{
> + int ret;
> + struct pci_dev *pdev;
> + struct pv_iommu_op op = {
> + .subop_id = IOMMUOP_reattach_device,
> + .flags = 0,
> + .ctx_no = 0 /* reattach device back to default context */
> + };
Consider if you can use release_domain for this, I think this is
probably a BLOCKED domain behavior.
> + if (!dev_is_pci(dev))
> + return;
No op is ever called on a non-probed device, remove all these checks.
> +static int xen_iommu_map_pages(struct iommu_domain *domain, unsigned long iova,
> + phys_addr_t paddr, size_t pgsize, size_t pgcount,
> + int prot, gfp_t gfp, size_t *mapped)
> +{
> + size_t xen_pg_count = (pgsize / XEN_PAGE_SIZE) * pgcount;
> + struct xen_iommu_domain *dom = to_xen_iommu_domain(domain);
> + struct pv_iommu_op op = {
> + .subop_id = IOMMUOP_map_pages,
> + .flags = 0,
> + .ctx_no = dom->ctx_no
> + };
> + /* NOTE: paddr is actually bound to pfn, not gfn */
> + uint64_t pfn = addr_to_pfn(paddr);
> + uint64_t dfn = addr_to_pfn(iova);
> + int ret = 0;
> +
> + if (WARN(!dom->ctx_no, "Tried to map page to default context"))
> + return -EINVAL;
A paging domain should be the only domain ops that have a populated
map so this should be made impossible by construction.
Jason
next prev parent reply other threads:[~2024-06-19 16:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-13 13:50 [RFC PATCH] iommu/xen: Add Xen PV-IOMMU driver Teddy Astie
2024-06-13 14:32 ` Jan Beulich
2024-06-17 13:36 ` Teddy Astie
2024-06-17 13:36 ` Teddy Astie
2024-06-17 13:43 ` Jan Beulich
2024-06-19 16:30 ` Jason Gunthorpe [this message]
2024-06-21 15:09 ` Teddy Astie
2024-06-23 3:21 ` Baolu Lu
2024-06-24 11:09 ` Robin Murphy
2024-06-25 1:18 ` Baolu Lu
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=20240619163000.GK791043@ziepe.ca \
--to=jgg@ziepe.ca \
--cc=iommu@lists.linux.dev \
--cc=jgross@suse.com \
--cc=joro@8bytes.org \
--cc=marmarek@invisiblethingslab.com \
--cc=oleksandr_tyshchenko@epam.com \
--cc=robin.murphy@arm.com \
--cc=sstabellini@kernel.org \
--cc=teddy.astie@vates.tech \
--cc=will@kernel.org \
--cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.