From: Jason Gunthorpe <jgg@nvidia.com>
To: Yi Liu <yi.l.liu@intel.com>
Cc: kevin.tian@intel.com, joro@8bytes.org, baolu.lu@linux.intel.com,
iommu@lists.linux.dev, nicolinc@nvidia.com,
Lai Yi <yi1.lai@linux.intel.com>
Subject: Re: [PATCH] iommufd: Test attach before detaching pasid
Date: Fri, 28 Mar 2025 11:40:35 -0300 [thread overview]
Message-ID: <20250328144035.GB10839@nvidia.com> (raw)
In-Reply-To: <20250328133448.22052-1-yi.l.liu@intel.com>
On Fri, Mar 28, 2025 at 06:34:48AM -0700, Yi Liu wrote:
> Check if the pasid has been attached before going further in the detach
> path. This makes this path more robust. Add a selftest as well.
>
> Reported-by: Lai Yi <yi1.lai@linux.intel.com>
> Closes: https://lore.kernel.org/linux-iommu/Z+X0tzxhiaupJT7b@ly-workstation/#t
> Fixes: c0e301b2978d ("iommufd/device: Add pasid_attach array to track per-PASID attach")
> Signed-off-by: Yi Liu <yi.l.liu@intel.com>
> ---
> drivers/iommu/iommufd/device.c | 7 +++++++
> tools/testing/selftests/iommu/iommufd.c | 6 ++++++
> 2 files changed, 13 insertions(+)
>
> diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
> index 2307daad65c0..375dd262f431 100644
> --- a/drivers/iommu/iommufd/device.c
> +++ b/drivers/iommu/iommufd/device.c
> @@ -644,6 +644,11 @@ iommufd_hw_pagetable_detach(struct iommufd_device *idev, ioasid_t pasid)
>
> mutex_lock(&igroup->lock);
> attach = xa_load(&igroup->pasid_attach, pasid);
> + if (WARN_ON(!attach)) {
> + mutex_unlock(&igroup->lock);
> + return NULL;
> + }
We can't trigger a WARN_ON during the test suite!
# RUN iommufd_device_pasid.no_pasid.pasid_attach ...
[ 23.723948] iommufd_mock iommufd_mock0: Adding to iommu group 0
[ 23.724532] iommufd_mock iommufd_mock1: Adding to iommu group 1
[ 23.724722] ------------[ cut here ]------------
[ 23.725194] WARNING: CPU: 5 PID: 1169 at drivers/iommu/iommufd/device.c:647 iommufd_hw_pagetable_detach+0x1e7/0x230 [iommufd]
[ 23.725350] Modules linked in: iommufd
[ 23.725406] CPU: 5 UID: 0 PID: 1169 Comm: iommufd Not tainted 6.14.0-rc2+ #1
Just drop the WARN_ON check right?
I took it like that, please let me know
Jason
next prev parent reply other threads:[~2025-03-28 14:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-28 13:34 [PATCH] iommufd: Test attach before detaching pasid Yi Liu
2025-03-28 14:40 ` Jason Gunthorpe [this message]
2025-03-31 2:24 ` Yi Liu
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=20250328144035.GB10839@nvidia.com \
--to=jgg@nvidia.com \
--cc=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=nicolinc@nvidia.com \
--cc=yi.l.liu@intel.com \
--cc=yi1.lai@linux.intel.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 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.