Re: [PATCH v8 06/10] iommufd: Add iommufd fault object

From: Nicolin Chen
Date: Tue Jul 09 2024 - 13:34:27 EST


On Tue, Jul 09, 2024 at 02:00:38PM -0300, Jason Gunthorpe wrote:
> On Mon, Jul 08, 2024 at 11:36:57AM -0700, Nicolin Chen wrote:
> > Maybe something like this?
> >
> > struct iommu_viommu_event_arm_smmuv3 {
> > u64 evt[4];
> > };
> >
> > struct iommu_viommu_event_tegra241_cmdqv {
> > u64 vcmdq_err_map[2];
> > };
> >
> > enum iommu_event_type {
> > IOMMM_HWPT_EVENT_TYPE_IOPF,
> > IOMMU_VIOMMU_EVENT_TYPE_SMMUv3,
> > IOMMU_VIOMMU_EVENT_TYPE_TEGRA241_CMDQV,
> > };
> >
> > struct iommu_event_alloc {
> > __u32 size;
> > __u32 flags;
> > __u32 out_event_id;
> > __u32 out_event_fd;
> > __u32 type;
> > __u32 _reserved;
> > };
> >
> > It can be "report" if you prefer.
>
> Yeah, something like that makes sense to me. The other question is if
> you want to multiplex the SMMUv3 and CMDQV on the same FD?

I think at least SMMUv3 and CMDQV could be the same FD. IMHO,
a TEGRA241_CMDQV type VIOMMU should include all the features
of SMMUv3 type... otherwise, we would have two VIOMMU objects
per pSMMU on Grace, which doesn't seem to make sense either.

> Or multiplex physical smmus on the same FD.
>
> We are potentially talking about 5-10 physical smmus and 2-3 FDs per
> physical? Does that scare anyone?

I think we can share the same FD by adding a viommu_id somewhere
to indicate what the data/event belongs to. Yet, it seemed that
you had a counter-argument that a shared FD (queue) might have a
security concern as well?
https://lore.kernel.org/linux-iommu/20240522232833.GH20229@xxxxxxxxxx/

Thanks
Nicolin