> From: Jason Gunthorpe > Sent: Tuesday, April 6, 2021 7:43 AM > > On Fri, Apr 02, 2021 at 08:22:28AM +0000, Tian, Kevin wrote: > > > From: Jason Gunthorpe <jgg@xxxxxxxxxx> > > > Sent: Tuesday, March 30, 2021 9:29 PM > > > > > > > > > > > First, userspace may use ioasid in a non-SVA scenario where ioasid is > > > > bound to specific security context (e.g. a control vq in vDPA) instead of > > > > tying to mm. In this case there is no pgtable binding initiated from user > > > > space. Instead, ioasid is allocated from /dev/ioasid and then > programmed > > > > to the intended security context through specific passthrough > framework > > > > which manages that context. > > > > > > This sounds like the exact opposite of what I'd like to see. > > > > > > I do not want to see every subsystem gaining APIs to program a > > > PASID. All of that should be consolidated in *one place*. > > > > > > I do not want to see VDPA and VFIO have two nearly identical sets of > > > APIs to control the PASID. > > > > > > Drivers consuming a PASID, like VDPA, should consume the PASID and do > > > nothing more than authorize the HW to use it. > > > > > > quemu should have general code under the viommu driver that drives > > > /dev/ioasid to create PASID's and manage the IO mapping according to > > > the guest's needs. > > > > > > Drivers like VDPA and VFIO should simply accept that PASID and > > > configure/authorize their HW to do DMA's with its tag. > > > > > > > I agree with you on consolidating things in one place (especially for the > > general SVA support). But here I was referring to an usage without > > pgtable binding (Possibly Jason. W can say more here), where the > > userspace just wants to allocate PASIDs, program/accept PASIDs to > > various workqueues (device specific), and then use MAP/UNMAP > > interface to manage address spaces associated with each PASID. > > I just wanted to point out that the latter two steps are through > > VFIO/VDPA specific interfaces. > > No, don't do that. > > VFIO and VDPA has no buisness having map/unmap interfaces once we have > /dev/ioasid. That all belongs in the iosaid side. > > I know they have those interfaces today, but that doesn't mean we have > to keep using them for PASID use cases, they should be replaced with a > 'do dma from this pasid on /dev/ioasid' interface certainly not a > 'here is a pasid from /dev/ioasid, go ahead and configure it youself' > interface > > This is because PASID is *complicated* in the general case! For > instance all the two level stuff you are talking about must not leak > into every user! > Hi, Jason, I didn't get your last comment how the two level stuff is leaked into every user. Could you elaborate it a bit? and here is one example why using existing VFIO/VDPA interface makes sense. say dev1 (w/ sva) and dev2 (w/o sva) are placed in a single VFIO container. The container is associated to an iommu domain which contains a single 2nd-level page table, shared by both devices (when attached to the domain). The VFIO MAP operation is applied to the 2nd-level page table thus naturally applied to both devices. Then userspace could use /dev/ioasid to further allocate IOASIDs and bind multiple 1st-level page tables for dev1, nested on the shared 2nd-level page table. If following your suggestion then VFIO must deny VFIO MAP operations on sva1 (assume userspace should not mix sva1 and sva2 in the same container and instead use /dev/ioasid to map for sva1)? and even for a sva-capable device there is a window before the guest actually enables sva on that device then VFIO should still accept MAP in that window and then deny it after sva is enabled by the guest? This all sounds unnecessary complex while there is already a clean way to achieve it... Thanks Kevin