From: Xu Yilun <yilun.xu@linux.intel.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: "Tian, Kevin" <kevin.tian@intel.com>,
"Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>
Subject: Re: [RFC PATCH] iommufd: Destroy vdevice on device unbind
Date: Mon, 16 Jun 2025 11:56:07 +0800 [thread overview]
Message-ID: <aE+V18uALqocLsoI@yilunxu-OptiPlex-7050> (raw)
In-Reply-To: <20250613124202.GD1130869@ziepe.ca>
On Fri, Jun 13, 2025 at 09:42:02AM -0300, Jason Gunthorpe wrote:
> On Fri, Jun 13, 2025 at 07:31:48AM +0000, Tian, Kevin wrote:
> > yeah that seems to be the option if the said life-cycle dependency
> > cannot be removed...
> >
> > conceptually it's still a bit unclean as the user needs to know that
> > the vdevice object is special after idevice is unbound i.e. it can only
> > be destroyed instead of supporting any other kind of operations.
>
> I would say userspace is somewhat malfunctioning if it destroys vfio
> before the vdevice. So the main aim here should be to contain the
> resulting mess, but still expect userspace to destroy the vdevice
> without a failure.
>
> > hmm if the user needs to build certain knowledge anyway can we
> > go one step further to state that the vdevice will be destroyed
> > automatically once its idevice is unbound so the user shouldn't
> > attempt to explicitly destroy it again after unbind?
I think this statement is complex to user. I'd rather from user POV the
vdev_id's lifecycle is mostly the same as other iommufd objects. The
only difference should be, after idev unbind, vdev_id would be
disfunctional, IOCTLs against the vdev_id would fail except IOMMU_DESTROY.
My understanding of the tombstone idea is:
- Before idev unbind, IOCTL(IOMMU_DESTROY, vdev_id) could free the vdev
as normal.
- On idev unbind, destroy the associate vdev (if exists), but still
reserve the ictx->objects xa entry.
- After idev unbind & on IOCTL(IOMMU_DESTROY, vdev_id), just free the
xa entry if it's a tombstone.
- On fops_release, free the tombstones if exist.
Thanks,
Yilun
>
> I would assume a malfunctioning userspace is probably going to destroy
> the vdevice explicitly. If it had proper knowledge it wouldn't have
> done this in the first place :)
>
> Jason
>
next prev parent reply other threads:[~2025-06-16 4:03 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-10 6:51 Aneesh Kumar K.V (Arm)
2025-06-12 8:05 ` Tian, Kevin
2025-06-12 17:26 ` Jason Gunthorpe
2025-06-13 7:31 ` Tian, Kevin
2025-06-13 12:42 ` Jason Gunthorpe
2025-06-16 3:56 ` Xu Yilun [this message]
2025-06-16 4:28 ` Aneesh Kumar K.V
2025-06-16 5:37 ` Tian, Kevin
2025-06-16 16:49 ` Jason Gunthorpe
2025-06-17 8:07 ` Aneesh Kumar K.V
2025-06-17 18:34 ` Jason Gunthorpe
2025-06-18 5:29 ` Aneesh Kumar K.V
2025-06-18 13:35 ` Jason Gunthorpe
2025-06-18 14:52 ` Aneesh Kumar K.V
2025-06-18 15:00 ` Jason Gunthorpe
2025-06-19 5:37 ` Tian, Kevin
2025-06-24 10:33 ` Aneesh Kumar K.V
2025-06-24 12:24 ` Tian, Kevin
2025-06-16 5:19 ` Tian, Kevin
2025-06-16 4:15 ` Aneesh Kumar K.V
2025-06-16 5:21 ` Tian, Kevin
2025-06-16 4:46 ` Aneesh Kumar K.V
2025-06-16 5:48 ` Tian, Kevin
2025-06-16 5:58 ` Xu Yilun
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=aE+V18uALqocLsoI@yilunxu-OptiPlex-7050 \
--to=yilun.xu@linux.intel.com \
--cc=aneesh.kumar@kernel.org \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--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
all inboxes | Powered by JetHome®