From: Nicolin Chen <nicolinc@nvidia.com>
To: "Tian, Kevin" <kevin.tian@intel.com>,
Baolu Lu <baolu.lu@linux.intel.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>, Joerg Roedel <joro@8bytes.org>,
"Will Deacon" <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
"Jean-Philippe Brucker" <jean-philippe@linaro.org>,
"Liu, Yi L" <yi.l.liu@intel.com>,
"Jacob Pan" <jacob.jun.pan@linux.intel.com>,
Joel Granados <j.granados@samsung.com>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
"virtualization@lists.linux-foundation.org"
<virtualization@lists.linux-foundation.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Jason Gunthorpe <jgg@nvidia.com>
Subject: Re: [PATCH v8 06/10] iommufd: Add iommufd fault object
Date: Thu, 4 Jul 2024 16:18:52 -0700 [thread overview]
Message-ID: <Zoct3LVVHhDNbPBT@Asurada-Nvidia> (raw)
In-Reply-To: <fc7f5bb1-25b7-4a5f-8d6b-1fa17b1af534@linux.intel.com>
On Thu, Jul 04, 2024 at 03:32:32PM +0800, Baolu Lu wrote:
> On 2024/7/4 14:37, Tian, Kevin wrote:
> > > From: Nicolin Chen<nicolinc@nvidia.com>
> > > Sent: Thursday, July 4, 2024 1:36 PM
> > >
> > > On Thu, Jul 04, 2024 at 10:59:45AM +0800, Baolu Lu wrote:
> > > > > On Tue, Jul 02, 2024 at 02:34:40PM +0800, Lu Baolu wrote:
> > > > >
> > > > > +enum iommu_fault_type {
> > > > > + IOMMU_FAULT_TYPE_HWPT_IOPF,
> > > > > + IOMMU_FAULT_TYPE_VIOMMU_IRQ,
> > > > > +};
> > > > >
> > > > > struct iommu_fault_alloc {
> > > > > __u32 size;
> > > > > __u32 flags;
> > > > > + __u32 type; /* enum iommu_fault_type */
> > > > > __u32 out_fault_id;
> > > > > __u32 out_fault_fd;
> > and need a new reserved field for alignment.
Hmm, what's the reason for enforcing a 64-bit alignment to an
all-u32 struct though? I thought we need a reserved field only
for padding. The struct iommu_ioas_alloc has three u32 members
for example?
> > > > > };
> > > > >
> > > > > I understand that this is already v8. So, maybe we can, for now,
> > > > > apply the small diff above with an IOMMU_FAULT_TYPE_HWPT_IOPF
> > > type
> > > > > check in the ioctl handler. And a decoupling for the iopf fops in
> > > > > the ioctl handler can come later in the viommu series:
> > > > > switch (type) {
> > > > > case IOMMU_FAULT_TYPE_HWPT_IOPF:
> > > > > filep = anon_inode_getfile("[iommufd-pgfault]",
> > > > > &iommufd_fault_fops_iopf);
> > > > > case IOMMU_FAULT_TYPE_VIOMMU_IRQ:
> > > > > filep = anon_inode_getfile("[iommufd-viommu-irq]",
> > > > > &iommufd_fault_fops_viommu);
> > > > > default:
> > > > > return -EOPNOSUPP;
> > > > > }
> > > > >
> > > > > Since you are the designer here, I think you have a better 10000
> > > > > foot view -- maybe I am missing something here implying that the
> > > > > fault object can't be really reused by viommu.
> > > > >
> > > > > Would you mind sharing some thoughts here?
> > > > I think this is a choice between "two different objects" vs. "same
> > > > object with different FD interfaces". If I understand it correctly, your
> > > > proposal of unrecoverable fault delivery is not limited to vcmdq, but
> > > > generic to all unrecoverable events that userspace should be aware of
> > > > when the passed-through device is affected.
> > > It's basically IRQ forwarding, not confined to unrecoverable
> > > faults. For example, a VCMDQ used by the guest kernel would
> > > raise an HW IRQ if the guest kernel issues an illegal command
> > > to the HW Queue assigned to it. The host kernel will receive
> > > the IRQ, so it needs a way to forward it to the VM for guest
> > > kernel to recover the HW queue.
> > >
> > > The way that we define the structure can follow what we have
> > > for hwpt_alloc/invalidate uAPIs, i.e. driver data/event. And
> > > such an event can carry unrecoverable translation faults too.
> > > SMMU at least reports DMA translation faults using an eventQ
> > > in its own native language.
> > >
> > > > From a hardware architecture perspective, the interfaces for
> > > > unrecoverable events don't always match the page faults. For example,
> > > > VT-d architecture defines a PR queue for page faults, but uses a
> > > > register set to report unrecoverable events. The 'reason', 'request id'
> > > > and 'pasid' fields of the register set indicate what happened on the
> > > > hardware. New unrecoverable events will not be reported until the
> > > > previous one has been fetched.
> > > Understood. I don't think we can share the majority pieces in
> > > the fault.c. Just the "IOMMU_FAULT_QUEUE_ALLOC" ioctl itself
> > > looks way too general to be limited to page-fault usage only.
> > > So, I feel we can share, for example:
> > > IOMMU_FAULT_QUEUE_ALLOC (type=hwpt_iopf) -> fault_id=1
> > > IOMMU_HWPT_ALLOC (fault_id=1) -> hwpt_id=2
> > > IOMMU_FAULT_QUEUE_ALLOC (type=viommu_irq) -> fault_id=3
> > > IOMMU_VIOMMU_ALLOC (fault_id=2) -> viommu_id=4
> > > The handler will direct to different fops as I drafted in my
> > > previous mail.
> > >
> > > > With the above being said, I have no strong opinions between these two
> > > > choices. Jason and Kevin should have more insights.
> > > Thanks. Jason is out of office this week, so hopefully Kevin
> > > may shed some light. I personally feel that we don't need to
> > > largely update this series until we add VIOMMU. Yet, it would
> > > be convenient if we add a "type" in the uAPI with this series.
> > >
> > This is ok to me.
>
> So
>
> Nicolin, perhaps can you please cook an additional patch on top of this
> series and post it for further review?
Thank you both for the inputs. Yea, so long as we merge them
in the same cycle, it won't be a uAPI breakage. I will draft
an incremental one. And Jason can make a final call.
Nicolin
next prev parent reply other threads:[~2024-07-04 23:19 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-02 6:34 [PATCH v8 00/10] IOMMUFD: Deliver IO page faults to user space Lu Baolu
2024-07-02 6:34 ` [PATCH v8 01/10] iommu: Introduce domain attachment handle Lu Baolu
2024-07-02 6:34 ` [PATCH v8 02/10] iommu: Remove sva handle list Lu Baolu
2024-07-02 6:34 ` [PATCH v8 03/10] iommu: Add attach handle to struct iopf_group Lu Baolu
2024-07-02 6:34 ` [PATCH v8 04/10] iommu: Extend domain attach group with handle support Lu Baolu
2024-07-02 6:34 ` [PATCH v8 05/10] iommufd: Add fault and response message definitions Lu Baolu
2024-07-02 6:34 ` [PATCH v8 06/10] iommufd: Add iommufd fault object Lu Baolu
2024-07-03 23:06 ` Nicolin Chen
2024-07-04 2:59 ` Baolu Lu
2024-07-04 5:36 ` Nicolin Chen
2024-07-04 6:37 ` Tian, Kevin
2024-07-04 7:32 ` Baolu Lu
2024-07-04 23:18 ` Nicolin Chen [this message]
2024-07-05 0:49 ` Tian, Kevin
2024-07-08 16:22 ` Jason Gunthorpe
2024-07-08 16:29 ` Jason Gunthorpe
2024-07-08 18:36 ` Nicolin Chen
2024-07-09 17:00 ` Jason Gunthorpe
2024-07-09 17:33 ` Nicolin Chen
2024-07-12 13:00 ` Jason Gunthorpe
2024-07-02 6:34 ` [PATCH v8 07/10] iommufd: Fault-capable hwpt attach/detach/replace Lu Baolu
2024-10-15 3:19 ` Zhangfei Gao
2024-10-15 12:54 ` Jason Gunthorpe
2024-10-16 1:58 ` Zhangfei Gao
2024-10-16 15:25 ` Jason Gunthorpe
2024-10-17 1:44 ` Zhangfei Gao
2024-10-17 12:05 ` Jason Gunthorpe
2024-10-17 12:35 ` Zhangfei Gao
2024-10-17 12:58 ` Shameerali Kolothum Thodi
2024-10-17 13:08 ` Jason Gunthorpe
2024-10-18 1:58 ` Baolu Lu
2024-10-18 2:45 ` Zhangfei Gao
2024-10-27 14:12 ` Zhangfei Gao
2024-10-27 14:26 ` Baolu Lu
2024-10-28 9:56 ` Zhangfei Gao
2024-10-28 11:17 ` Baolu Lu
2024-10-18 14:33 ` Jason Gunthorpe
2024-10-18 13:53 ` Jason Gunthorpe
2024-10-22 14:30 ` Zhangfei Gao
2024-10-22 14:52 ` Jason Gunthorpe
2024-10-23 10:22 ` Zhangfei Gao
2024-07-02 6:34 ` [PATCH v8 08/10] iommufd: Associate fault object with iommufd_hw_pgtable Lu Baolu
2024-07-02 6:34 ` [PATCH v8 09/10] iommufd/selftest: Add IOPF support for mock device Lu Baolu
2024-07-02 6:34 ` [PATCH v8 10/10] iommufd/selftest: Add coverage for IOPF test Lu Baolu
2024-07-04 14:18 ` [PATCH v8 00/10] IOMMUFD: Deliver IO page faults to user space Will Deacon
2024-07-09 17:23 ` Jason Gunthorpe
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=Zoct3LVVHhDNbPBT@Asurada-Nvidia \
--to=nicolinc@nvidia.com \
--cc=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=j.granados@samsung.com \
--cc=jacob.jun.pan@linux.intel.com \
--cc=jean-philippe@linaro.org \
--cc=jgg@nvidia.com \
--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=virtualization@lists.linux-foundation.org \
--cc=will@kernel.org \
--cc=yi.l.liu@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).