Re: [PATCH RFC 04/19] iommu: Add an unmap API that returns dirtied IOPTEs

2022-04-29 Thread Baolu Lu
On 2022/4/29 05:09, Joao Martins wrote: Today, the dirty state is lost and the page wouldn't be migrated to destination potentially leading the guest into error. Add an unmap API that reads the dirty bit and sets it in the user passed bitmap. This unmap iommu API tackles a potentially racy

Re: [PATCH RFC 03/19] iommufd: Dirty tracking data support

2022-04-29 Thread Baolu Lu
On 2022/4/29 05:09, Joao Martins wrote: Add an IO pagetable API iopt_read_and_clear_dirty_data() that performs the reading of dirty IOPTEs for a given IOVA range and then copying back to userspace from each area-internal bitmap. Underneath it uses the IOMMU equivalent API which will read the

Re: [PATCH RFC 02/19] iommufd: Dirty tracking for io_pagetable

2022-04-29 Thread Baolu Lu
On 2022/4/29 05:09, Joao Martins wrote: +int iopt_set_dirty_tracking(struct io_pagetable *iopt, + struct iommu_domain *domain, bool enable) +{ + struct iommu_domain *dom; + unsigned long index; + int ret = -EOPNOTSUPP; + +

Re: [PATCH] swiotlb-xen: fix DMA_ATTR_NO_KERNEL_MAPPING on arm

2022-04-29 Thread Stefano Stabellini
On Fri, 29 Apr 2022, Boris Ostrovsky wrote: > On 4/28/22 6:49 PM, Stefano Stabellini wrote: > > On Thu, 28 Apr 2022, Boris Ostrovsky wrote: > > > On 4/28/22 5:49 PM, Stefano Stabellini wrote: > > > > On Thu, 28 Apr 2022, Christoph Hellwig wrote: > > > > > On Tue, Apr 26, 2022 at 04:07:45PM -0700,

Re: [PATCH] swiotlb-xen: fix DMA_ATTR_NO_KERNEL_MAPPING on arm

2022-04-29 Thread Boris Ostrovsky
On 4/28/22 6:49 PM, Stefano Stabellini wrote: On Thu, 28 Apr 2022, Boris Ostrovsky wrote: On 4/28/22 5:49 PM, Stefano Stabellini wrote: On Thu, 28 Apr 2022, Christoph Hellwig wrote: On Tue, Apr 26, 2022 at 04:07:45PM -0700, Stefano Stabellini wrote: Reported-by: Rahul Singh Signed-off-by:

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-29 Thread Fenghua Yu
Hi, Jean and Baolu, On Fri, Apr 29, 2022 at 03:34:36PM +0100, Jean-Philippe Brucker wrote: > On Fri, Apr 29, 2022 at 06:51:17AM -0700, Fenghua Yu wrote: > > Hi, Baolu, > > > > On Fri, Apr 29, 2022 at 03:53:57PM +0800, Baolu Lu wrote: > > > On 2022/4/28 16:39, Jean-Philippe Brucker wrote: > > > >

[PATCH v1] driver core: Extend deferred probe timeout on driver registration

2022-04-29 Thread Saravana Kannan via iommu
The deferred probe timer that's used for this currently starts at late_initcall and runs for driver_deferred_probe_timeout seconds. The assumption being that all available drivers would be loaded and registered before the timer expires. This means, the driver_deferred_probe_timeout has to be

Re: [PATCH RFC 15/19] iommu/arm-smmu-v3: Add set_dirty_tracking_range() support

2022-04-29 Thread Robin Murphy
On 2022-04-29 17:40, Joao Martins wrote: On 4/29/22 17:11, Jason Gunthorpe wrote: On Fri, Apr 29, 2022 at 03:45:23PM +0100, Joao Martins wrote: On 4/29/22 13:23, Jason Gunthorpe wrote: On Fri, Apr 29, 2022 at 01:06:06PM +0100, Joao Martins wrote: TBH I'd be inclined to just enable DBM

Re: [PATCH v2 03/14] iommu: Move bus setup to IOMMU device registration

2022-04-29 Thread Robin Murphy
On 29/04/2022 9:50 am, Robin Murphy wrote: On 2022-04-29 07:57, Baolu Lu wrote: Hi Robin, On 2022/4/28 21:18, Robin Murphy wrote: Move the bus setup to iommu_device_register(). This should allow bus_iommu_probe() to be correctly replayed for multiple IOMMU instances, and leaves

[GIT PULL] Please pull VFIO changes

2022-04-29 Thread Jason Gunthorpe via iommu
Hi Alex, Here is the PR for Joerg's shared topic branch for VFIO. It was merged to iommu here: https://lore.kernel.org/all/ympffa1iiqygb...@8bytes.org/ The cover letter for making the merge commit is here: https://lore.kernel.org/all/20220418005000.897664-1-baolu...@linux.intel.com/ It is

Re: [PATCH RFC 15/19] iommu/arm-smmu-v3: Add set_dirty_tracking_range() support

2022-04-29 Thread Jason Gunthorpe via iommu
On Fri, Apr 29, 2022 at 05:40:56PM +0100, Joao Martins wrote: > > A common use model might be to just destroy the iommu_domain without > > doing stop so prefering the clearing io page table at stop might be a > > better overall design. > > If we want to ensure that the IOPTE dirty state is

Re: [PATCH RFC 15/19] iommu/arm-smmu-v3: Add set_dirty_tracking_range() support

2022-04-29 Thread Joao Martins
On 4/29/22 17:11, Jason Gunthorpe wrote: > On Fri, Apr 29, 2022 at 03:45:23PM +0100, Joao Martins wrote: >> On 4/29/22 13:23, Jason Gunthorpe wrote: >>> On Fri, Apr 29, 2022 at 01:06:06PM +0100, Joao Martins wrote: >>> > TBH I'd be inclined to just enable DBM unconditionally in >

Re: [PATCH RFC 15/19] iommu/arm-smmu-v3: Add set_dirty_tracking_range() support

2022-04-29 Thread Jason Gunthorpe via iommu
On Fri, Apr 29, 2022 at 03:45:23PM +0100, Joao Martins wrote: > On 4/29/22 13:23, Jason Gunthorpe wrote: > > On Fri, Apr 29, 2022 at 01:06:06PM +0100, Joao Martins wrote: > > > >>> TBH I'd be inclined to just enable DBM unconditionally in > >>> arm_smmu_domain_finalise() if the SMMU supports it.

Re: [PATCH v7 2/7] hwtracing: Add trace function support for HiSilicon PCIe Tune and Trace device

2022-04-29 Thread Leo Yan
On Thu, Apr 07, 2022 at 08:58:36PM +0800, Yicong Yang via iommu wrote: > HiSilicon PCIe tune and trace device(PTT) is a PCIe Root Complex integrated > Endpoint(RCiEP) device, providing the capability to dynamically monitor and > tune the PCIe traffic, and trace the TLP headers. > > Add the driver

Re: [PATCH RFC 01/19] iommu: Add iommu_domain ops for dirty tracking

2022-04-29 Thread Joao Martins
On 4/29/22 14:40, Baolu Lu wrote: > Hi Joao, > > Thanks for doing this. > > On 2022/4/29 05:09, Joao Martins wrote: >> Add to iommu domain operations a set of callbacks to >> perform dirty tracking, particulary to start and stop >> tracking and finally to test and clear the dirty data. >> >>

Re: [PATCH RFC 00/19] IOMMUFD Dirty Tracking

2022-04-29 Thread Joao Martins
On 4/29/22 13:38, Jason Gunthorpe wrote: > On Fri, Apr 29, 2022 at 11:27:58AM +0100, Joao Martins wrote: 3) Unmapping an IOVA range while returning its dirty bit prior to unmap. This case is specific for non-nested vIOMMU case where an erronous guest (or device) DMAing to an

Re: [PATCH RFC 07/19] iommufd/vfio-compat: Dirty tracking IOCTLs compatibility

2022-04-29 Thread Joao Martins
On 4/29/22 15:36, Jason Gunthorpe wrote: > On Fri, Apr 29, 2022 at 03:27:00PM +0100, Joao Martins wrote: > >>> We've made a qemu patch to allow qemu to be happy if dirty tracking is >>> not supported in the vfio container for migration, which is part of >>> the v2 enablement series. That seems

Re: [PATCH v2 10/37] iommu/amd: Introduce per PCI segment last_bdf

2022-04-29 Thread Vasant Hegde via iommu
Joerg, On 4/28/2022 3:40 PM, Joerg Roedel wrote: > On Mon, Apr 25, 2022 at 05:03:48PM +0530, Vasant Hegde wrote: >> +/* Largest PCI device id we expect translation requests for */ >> +u16 last_bdf; > > How does the IVRS table look like on these systems? Do they still > enumerate the

Re: [PATCH RFC 15/19] iommu/arm-smmu-v3: Add set_dirty_tracking_range() support

2022-04-29 Thread Joao Martins
On 4/29/22 13:23, Jason Gunthorpe wrote: > On Fri, Apr 29, 2022 at 01:06:06PM +0100, Joao Martins wrote: > >>> TBH I'd be inclined to just enable DBM unconditionally in >>> arm_smmu_domain_finalise() if the SMMU supports it. Trying to toggle it >>> dynamically (especially on a live domain)

Re: [PATCH v2 02/37] iommu/amd: Introduce pci segment structure

2022-04-29 Thread Vasant Hegde via iommu
Joerg, On 4/28/2022 3:24 PM, Joerg Roedel wrote: > Hi Vasant, > > On Mon, Apr 25, 2022 at 05:03:40PM +0530, Vasant Hegde wrote: >> +/* >> + * This structure contains information about one PCI segment in the system. >> + */ >> +struct amd_iommu_pci_seg { >> +struct list_head list; > > The

[PATCH 2/2] iommu/mediatek: Enable allocating page table in normal memory

2022-04-29 Thread yf.wang--- via iommu
From: Yunfei Wang Add the quirk IO_PGTABLE_QUIRK_ARM_MTK_TTBR_EXT support, so that level 2 page table can allocate in normal memory. Signed-off-by: Ning Li Signed-off-by: Yunfei Wang Cc: # 5.10.* --- drivers/iommu/mtk_iommu.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff

[PATCH 1/2] iommu/io-pgtable-arm-v7s: Add a quirk to support TTBR up to 35bit for MediaTek

2022-04-29 Thread yf.wang--- via iommu
From: Yunfei Wang The calling to kmem_cache_alloc for level 2 page table allocation may run in atomic context, and it fails sometimes when DMA32 zone runs out of memory. Since Mediatek IOMMU hardware support at most 35bit PA in page table, so add a quirk to allow the PA of level 2 pgtable

Re: [PATCH v2 27/37] iommu/amd: Remove global amd_iommu_dev_table

2022-04-29 Thread Vasant Hegde via iommu
On 4/28/2022 3:45 PM, Joerg Roedel wrote: > On Mon, Apr 25, 2022 at 05:04:05PM +0530, Vasant Hegde wrote: >> From: Suravee Suthikulpanit >> >> Replace global amd_iommu_dev_table with per PCI segment device table. >> Also remove "dev_table_size". >> >> Co-developed-by: Vasant Hegde >>

Re: [PATCH v2 37/37] iommu/amd: Update amd_iommu_fault structure to include PCI seg ID

2022-04-29 Thread Vasant Hegde via iommu
Joerg, On 4/28/2022 3:49 PM, Joerg Roedel wrote: > On Mon, Apr 25, 2022 at 05:04:15PM +0530, Vasant Hegde wrote: >> +seg_id = (iommu_fault->sbdf >> 16) & 0x; >> +devid = iommu_fault->sbdf & 0x; > > This deserves some macros for readability. Sure. Will add macros in next

Re: [PATCH RFC 05/19] iommufd: Add a dirty bitmap to iopt_unmap_iova()

2022-04-29 Thread Joao Martins
On 4/29/22 13:14, Jason Gunthorpe wrote: > On Thu, Apr 28, 2022 at 10:09:19PM +0100, Joao Martins wrote: > >> +static void iommu_unmap_read_dirty_nofail(struct iommu_domain *domain, >> + unsigned long iova, size_t size, >> +

Re: [PATCH RFC 07/19] iommufd/vfio-compat: Dirty tracking IOCTLs compatibility

2022-04-29 Thread Jason Gunthorpe via iommu
On Fri, Apr 29, 2022 at 03:27:00PM +0100, Joao Martins wrote: > > We've made a qemu patch to allow qemu to be happy if dirty tracking is > > not supported in the vfio container for migration, which is part of > > the v2 enablement series. That seems like the better direction. > > > So in my

Re: [PATCH v2 00/37] iommu/amd: Add multiple PCI segments support

2022-04-29 Thread Vasant Hegde via iommu
Joerg, On 4/28/2022 3:52 PM, Joerg Roedel wrote: > Hi Vasant, Hi Suravee, > > On Mon, Apr 25, 2022 at 05:03:38PM +0530, Vasant Hegde wrote: >> Newer AMD systems can support multiple PCI segments, where each segment >> contains one or more IOMMU instances. However, an IOMMU instance can only >>

Re: [PATCH RFC 13/19] iommu/arm-smmu-v3: Add feature detection for BBML

2022-04-29 Thread Joao Martins
On 4/29/22 13:26, Robin Murphy wrote: > On 2022-04-29 12:54, Joao Martins wrote: >> On 4/29/22 12:11, Robin Murphy wrote: >>> On 2022-04-28 22:09, Joao Martins wrote: From: Kunkun Jiang This detects BBML feature and if SMMU supports it, transfer BBMLx quirk to io-pgtable.

Re: [PATCH RFC 01/19] iommu: Add iommu_domain ops for dirty tracking

2022-04-29 Thread Jason Gunthorpe via iommu
On Fri, Apr 29, 2022 at 03:26:41PM +0100, Joao Martins wrote: > I had this in the iommufd_dirty_iter logic given that the iommu iteration > logic is in the parent structure that stores iommu_dirty_data. > > My thinking with this patch was just to have what the IOMMU driver needs. I would put

Re: [PATCH v2 01/37] iommu/amd: Update struct iommu_dev_data defination

2022-04-29 Thread Vasant Hegde via iommu
Joerg, On 4/28/2022 3:25 PM, Joerg Roedel wrote: > On Mon, Apr 25, 2022 at 05:03:39PM +0530, Vasant Hegde wrote: > > Subject: iommu/amd: Update struct iommu_dev_data defination > ^^ Typo > Thanks for the review. Will fix it in v3.

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-29 Thread Jean-Philippe Brucker
On Fri, Apr 29, 2022 at 06:51:17AM -0700, Fenghua Yu wrote: > Hi, Baolu, > > On Fri, Apr 29, 2022 at 03:53:57PM +0800, Baolu Lu wrote: > > On 2022/4/28 16:39, Jean-Philippe Brucker wrote: > > > > The address space is what the OOM killer is after. That gets refcounted > > > > with

Re: [PATCH RFC 03/19] iommufd: Dirty tracking data support

2022-04-29 Thread Joao Martins
On 4/29/22 13:09, Jason Gunthorpe wrote: > On Fri, Apr 29, 2022 at 11:54:16AM +0100, Joao Martins wrote: >> On 4/29/22 09:12, Tian, Kevin wrote: From: Joao Martins Sent: Friday, April 29, 2022 5:09 AM >>> [...] + +static int iommu_read_and_clear_dirty(struct iommu_domain

Re: [PATCH RFC 02/19] iommufd: Dirty tracking for io_pagetable

2022-04-29 Thread Joao Martins
On 4/29/22 12:56, Jason Gunthorpe wrote: > On Fri, Apr 29, 2022 at 08:07:14AM +, Tian, Kevin wrote: >>> From: Joao Martins >>> Sent: Friday, April 29, 2022 5:09 AM >>> >>> +static int __set_dirty_tracking_range_locked(struct iommu_domain >>> *domain, >> >> suppose anything using iommu_domain

Re: [PATCH RFC 07/19] iommufd/vfio-compat: Dirty tracking IOCTLs compatibility

2022-04-29 Thread Joao Martins
On 4/29/22 13:19, Jason Gunthorpe wrote: > On Thu, Apr 28, 2022 at 10:09:21PM +0100, Joao Martins wrote: >> Add the correspondent APIs for performing VFIO dirty tracking, >> particularly VFIO_IOMMU_DIRTY_PAGES ioctl subcmds: >> * VFIO_IOMMU_DIRTY_PAGES_FLAG_START: Start dirty tracking and

Re: [PATCH RFC 01/19] iommu: Add iommu_domain ops for dirty tracking

2022-04-29 Thread Joao Martins
On 4/29/22 13:08, Jason Gunthorpe wrote: > On Thu, Apr 28, 2022 at 10:09:15PM +0100, Joao Martins wrote: >> + >> +unsigned int iommu_dirty_bitmap_record(struct iommu_dirty_bitmap *dirty, >> + unsigned long iova, unsigned long length) >> +{ > > Lets put

Re: [RFC PATCH] swiotlb: Add Child IO TLB mem support

2022-04-29 Thread Tianyu Lan
On 4/29/2022 10:21 PM, Tianyu Lan wrote: From: Tianyu Lan Traditionally swiotlb was not performance critical because it was only used for slow devices. But in some setups, like TDX/SEV confidential guests, all IO has to go through swiotlb. Currently swiotlb only has a single lock. Under high

[RFC PATCH] swiotlb: Add Child IO TLB mem support

2022-04-29 Thread Tianyu Lan
From: Tianyu Lan Traditionally swiotlb was not performance critical because it was only used for slow devices. But in some setups, like TDX/SEV confidential guests, all IO has to go through swiotlb. Currently swiotlb only has a single lock. Under high IO load with multiple CPUs this can lead to

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-29 Thread Fenghua Yu
Hi, Baolu, On Fri, Apr 29, 2022 at 03:53:57PM +0800, Baolu Lu wrote: > On 2022/4/28 16:39, Jean-Philippe Brucker wrote: > > > The address space is what the OOM killer is after. That gets refcounted > > > with mmget()/mmput()/mm->mm_users. The OOM killer is satiated by the > > > page freeing

Re: [PATCH RFC 01/19] iommu: Add iommu_domain ops for dirty tracking

2022-04-29 Thread Baolu Lu
Hi Joao, Thanks for doing this. On 2022/4/29 05:09, Joao Martins wrote: Add to iommu domain operations a set of callbacks to perform dirty tracking, particulary to start and stop tracking and finally to test and clear the dirty data. Drivers are expected to dynamically change its hw

Re: [PATCH RFC 08/12] iommufd: IOCTLs for the io_pagetable

2022-04-29 Thread Jason Gunthorpe via iommu
On Fri, Apr 29, 2022 at 04:00:14PM +1000, David Gibson wrote: > > But I don't have a use case in mind? The simplified things I know > > about want to attach their devices then allocate valid IOVA, they > > don't really have a notion about what IOVA regions they are willing to > > accept, or

Re: [PATCH RFC 11/12] iommufd: vfio container FD ioctl compatibility

2022-04-29 Thread Jason Gunthorpe via iommu
On Fri, Apr 29, 2022 at 04:22:56PM +1000, David Gibson wrote: > On Fri, Apr 29, 2022 at 01:21:30AM +, Tian, Kevin wrote: > > > From: Jason Gunthorpe > > > Sent: Thursday, April 28, 2022 11:11 PM > > > > > > > > > > 3) "dynamic DMA windows" (DDW). The IBM IOMMU hardware allows for > > > 2

Re: [PATCH RFC 11/12] iommufd: vfio container FD ioctl compatibility

2022-04-29 Thread Jason Gunthorpe via iommu
On Fri, Apr 29, 2022 at 04:20:36PM +1000, David Gibson wrote: > > I think PPC and S390 are solving the same problem here. I think S390 > > is going to go to a SW nested model where it has an iommu_domain > > controlled by iommufd that is populated with the pinned pages, eg > > stored in an

Re: [PATCH RFC 16/19] iommu/arm-smmu-v3: Enable HTTU for stage1 with io-pgtable mapping

2022-04-29 Thread Robin Murphy
On 2022-04-29 13:10, Joao Martins wrote: On 4/29/22 12:35, Robin Murphy wrote: On 2022-04-28 22:09, Joao Martins wrote: From: Kunkun Jiang As nested mode is not upstreamed now, we just aim to support dirty log tracking for stage1 with io-pgtable mapping (means not support SVA mapping). If

Re: [PATCH RFC 00/19] IOMMUFD Dirty Tracking

2022-04-29 Thread Jason Gunthorpe via iommu
On Fri, Apr 29, 2022 at 11:27:58AM +0100, Joao Martins wrote: > >> 3) Unmapping an IOVA range while returning its dirty bit prior to > >> unmap. This case is specific for non-nested vIOMMU case where an > >> erronous guest (or device) DMAing to an address being unmapped at the > >> same time. > >

Re: [PATCH RFC 13/19] iommu/arm-smmu-v3: Add feature detection for BBML

2022-04-29 Thread Robin Murphy
On 2022-04-29 12:54, Joao Martins wrote: On 4/29/22 12:11, Robin Murphy wrote: On 2022-04-28 22:09, Joao Martins wrote: From: Kunkun Jiang This detects BBML feature and if SMMU supports it, transfer BBMLx quirk to io-pgtable. BBML1 requires still marking PTE nT prior to performing a

Re: [PATCH RFC 15/19] iommu/arm-smmu-v3: Add set_dirty_tracking_range() support

2022-04-29 Thread Jason Gunthorpe via iommu
On Fri, Apr 29, 2022 at 01:06:06PM +0100, Joao Martins wrote: > > TBH I'd be inclined to just enable DBM unconditionally in > > arm_smmu_domain_finalise() if the SMMU supports it. Trying to toggle it > > dynamically (especially on a live domain) seems more trouble that it's > > worth. > >

Re: [PATCH RFC 07/19] iommufd/vfio-compat: Dirty tracking IOCTLs compatibility

2022-04-29 Thread Jason Gunthorpe via iommu
On Thu, Apr 28, 2022 at 10:09:21PM +0100, Joao Martins wrote: > Add the correspondent APIs for performing VFIO dirty tracking, > particularly VFIO_IOMMU_DIRTY_PAGES ioctl subcmds: > * VFIO_IOMMU_DIRTY_PAGES_FLAG_START: Start dirty tracking and allocates >the

Re: [PATCH RFC 05/19] iommufd: Add a dirty bitmap to iopt_unmap_iova()

2022-04-29 Thread Jason Gunthorpe via iommu
On Thu, Apr 28, 2022 at 10:09:19PM +0100, Joao Martins wrote: > +static void iommu_unmap_read_dirty_nofail(struct iommu_domain *domain, > + unsigned long iova, size_t size, > + struct iommufd_dirty_data *bitmap, > +

Re: [PATCH RFC 16/19] iommu/arm-smmu-v3: Enable HTTU for stage1 with io-pgtable mapping

2022-04-29 Thread Joao Martins
On 4/29/22 12:35, Robin Murphy wrote: > On 2022-04-28 22:09, Joao Martins wrote: >> From: Kunkun Jiang >> >> As nested mode is not upstreamed now, we just aim to support dirty >> log tracking for stage1 with io-pgtable mapping (means not support >> SVA mapping). If HTTU is supported, we enable

Re: [PATCH RFC 03/19] iommufd: Dirty tracking data support

2022-04-29 Thread Jason Gunthorpe via iommu
On Fri, Apr 29, 2022 at 11:54:16AM +0100, Joao Martins wrote: > On 4/29/22 09:12, Tian, Kevin wrote: > >> From: Joao Martins > >> Sent: Friday, April 29, 2022 5:09 AM > > [...] > >> + > >> +static int iommu_read_and_clear_dirty(struct iommu_domain *domain, > >> +

Re: [PATCH RFC 01/19] iommu: Add iommu_domain ops for dirty tracking

2022-04-29 Thread Jason Gunthorpe via iommu
On Thu, Apr 28, 2022 at 10:09:15PM +0100, Joao Martins wrote: > + > +unsigned int iommu_dirty_bitmap_record(struct iommu_dirty_bitmap *dirty, > +unsigned long iova, unsigned long length) > +{ Lets put iommu_dirty_bitmap in its own patch, the VFIO driver side

Re: [PATCH RFC 15/19] iommu/arm-smmu-v3: Add set_dirty_tracking_range() support

2022-04-29 Thread Joao Martins
On 4/29/22 12:19, Robin Murphy wrote: > On 2022-04-29 12:05, Joao Martins wrote: >> On 4/29/22 09:28, Tian, Kevin wrote: From: Joao Martins Sent: Friday, April 29, 2022 5:09 AM Similar to .read_and_clear_dirty() use the page table walker helper functions and set

Re: [PATCH RFC 02/19] iommufd: Dirty tracking for io_pagetable

2022-04-29 Thread Jason Gunthorpe via iommu
On Fri, Apr 29, 2022 at 08:07:14AM +, Tian, Kevin wrote: > > From: Joao Martins > > Sent: Friday, April 29, 2022 5:09 AM > > > > +static int __set_dirty_tracking_range_locked(struct iommu_domain > > *domain, > > suppose anything using iommu_domain as the first argument should > be put in

Re: [PATCH RFC 13/19] iommu/arm-smmu-v3: Add feature detection for BBML

2022-04-29 Thread Joao Martins
On 4/29/22 12:11, Robin Murphy wrote: > On 2022-04-28 22:09, Joao Martins wrote: >> From: Kunkun Jiang >> >> This detects BBML feature and if SMMU supports it, transfer BBMLx >> quirk to io-pgtable. >> >> BBML1 requires still marking PTE nT prior to performing a >> translation table update, while

Re: [PATCH RFC 17/19] iommu/arm-smmu-v3: Add unmap_read_dirty() support

2022-04-29 Thread Robin Murphy
On 2022-04-28 22:09, Joao Martins wrote: Mostly reuses unmap existing code with the extra addition of marshalling into a bitmap of a page size. To tackle the race, switch away from a plain store to a cmpxchg() and check whether IOVA was dirtied or not once it succeeds. Signed-off-by: Joao

Re: [PATCH RFC 16/19] iommu/arm-smmu-v3: Enable HTTU for stage1 with io-pgtable mapping

2022-04-29 Thread Robin Murphy
On 2022-04-28 22:09, Joao Martins wrote: From: Kunkun Jiang As nested mode is not upstreamed now, we just aim to support dirty log tracking for stage1 with io-pgtable mapping (means not support SVA mapping). If HTTU is supported, we enable HA/HD bits in the SMMU CD and transfer ARM_HD quirk to

Re: [PATCH RFC 18/19] iommu/intel: Access/Dirty bit support for SL domains

2022-04-29 Thread Joao Martins
On 4/29/22 10:03, Tian, Kevin wrote: >> From: Joao Martins >> Sent: Friday, April 29, 2022 5:10 AM >> >> IOMMU advertises Access/Dirty bits if the extended capability >> DMAR register reports it (ECAP, mnemonic ECAP.SSADS). The first >> stage table, though, has not bit for advertising, unless

Re: [PATCH RFC 15/19] iommu/arm-smmu-v3: Add set_dirty_tracking_range() support

2022-04-29 Thread Robin Murphy
On 2022-04-29 12:05, Joao Martins wrote: On 4/29/22 09:28, Tian, Kevin wrote: From: Joao Martins Sent: Friday, April 29, 2022 5:09 AM Similar to .read_and_clear_dirty() use the page table walker helper functions and set DBM|RDONLY bit, thus switching the IOPTE to writeable-clean. this

Re: [PATCH RFC 13/19] iommu/arm-smmu-v3: Add feature detection for BBML

2022-04-29 Thread Robin Murphy
On 2022-04-28 22:09, Joao Martins wrote: From: Kunkun Jiang This detects BBML feature and if SMMU supports it, transfer BBMLx quirk to io-pgtable. BBML1 requires still marking PTE nT prior to performing a translation table update, while BBML2 requires neither break-before-make nor PTE nT bit

Re: [PATCH RFC 15/19] iommu/arm-smmu-v3: Add set_dirty_tracking_range() support

2022-04-29 Thread Joao Martins
On 4/29/22 09:28, Tian, Kevin wrote: >> From: Joao Martins >> Sent: Friday, April 29, 2022 5:09 AM >> >> Similar to .read_and_clear_dirty() use the page table >> walker helper functions and set DBM|RDONLY bit, thus >> switching the IOPTE to writeable-clean. > > this should not be one-off if the

Re: [PATCH RFC 03/19] iommufd: Dirty tracking data support

2022-04-29 Thread Joao Martins
On 4/29/22 09:12, Tian, Kevin wrote: >> From: Joao Martins >> Sent: Friday, April 29, 2022 5:09 AM > [...] >> + >> +static int iommu_read_and_clear_dirty(struct iommu_domain *domain, >> + struct iommufd_dirty_data *bitmap) > > In a glance this function and all

Re: [PATCH RFC 02/19] iommufd: Dirty tracking for io_pagetable

2022-04-29 Thread Joao Martins
On 4/29/22 09:07, Tian, Kevin wrote: >> From: Joao Martins >> Sent: Friday, April 29, 2022 5:09 AM >> >> +static int __set_dirty_tracking_range_locked(struct iommu_domain >> *domain, > > suppose anything using iommu_domain as the first argument should > be put in the iommu layer. Here it's more

Re: [PATCH RFC 01/19] iommu: Add iommu_domain ops for dirty tracking

2022-04-29 Thread Joao Martins
On 4/29/22 08:54, Tian, Kevin wrote: >> From: Joao Martins >> Sent: Friday, April 29, 2022 5:09 AM >> >> Add to iommu domain operations a set of callbacks to >> perform dirty tracking, particulary to start and stop >> tracking and finally to test and clear the dirty data. > > to be consistent

Re: [PATCH RFC 00/19] IOMMUFD Dirty Tracking

2022-04-29 Thread Joao Martins
On 4/29/22 06:45, Tian, Kevin wrote: >> From: Joao Martins >> Sent: Friday, April 29, 2022 5:09 AM >> >> Presented herewith is a series that extends IOMMUFD to have IOMMU >> hardware support for dirty bit in the IOPTEs. >> >> Today, AMD Milan (which been out for a year now) supports it while ARM

RE: [PATCH RFC 18/19] iommu/intel: Access/Dirty bit support for SL domains

2022-04-29 Thread Tian, Kevin
> From: Joao Martins > Sent: Friday, April 29, 2022 5:10 AM > > IOMMU advertises Access/Dirty bits if the extended capability > DMAR register reports it (ECAP, mnemonic ECAP.SSADS). The first > stage table, though, has not bit for advertising, unless referenced via first-stage is compatible to

Re: [PATCH v2 03/14] iommu: Move bus setup to IOMMU device registration

2022-04-29 Thread Robin Murphy
On 2022-04-29 07:57, Baolu Lu wrote: Hi Robin, On 2022/4/28 21:18, Robin Murphy wrote: Move the bus setup to iommu_device_register(). This should allow bus_iommu_probe() to be correctly replayed for multiple IOMMU instances, and leaves bus_set_iommu() as a glorified no-op to be cleaned up

RE: [PATCH RFC 15/19] iommu/arm-smmu-v3: Add set_dirty_tracking_range() support

2022-04-29 Thread Tian, Kevin
> From: Joao Martins > Sent: Friday, April 29, 2022 5:09 AM > > Similar to .read_and_clear_dirty() use the page table > walker helper functions and set DBM|RDONLY bit, thus > switching the IOPTE to writeable-clean. this should not be one-off if the operation needs to be applied to IOPTE. Say a

[PATCH v3 3/3] iommu/arm-smmu: Support Tegra234 SMMU

2022-04-29 Thread Thierry Reding
From: Thierry Reding Allow the NVIDIA-specific ARM SMMU implementation to bind to the SMMU instances found on Tegra234. Acked-by: Robin Murphy Acked-by: Will Deacon Signed-off-by: Thierry Reding --- drivers/iommu/arm/arm-smmu/arm-smmu-impl.c | 3 ++- 1 file changed, 2 insertions(+), 1

[PATCH v3 2/3] dt-bindings: arm-smmu: Add compatible for Tegra234 SOC

2022-04-29 Thread Thierry Reding
From: Thierry Reding The NVIDIA Tegra234 SoC comes with one single-instance ARM SMMU used by isochronous memory clients and two dual-instance ARM SMMUs used by non- isochronous memory clients. Reviewed-by: Rob Herring Acked-by: Will Deacon Signed-off-by: Thierry Reding ---

[PATCH v3 1/3] dt-bindings: arm-smmu: Document nvidia, memory-controller property

2022-04-29 Thread Thierry Reding
From: Thierry Reding On NVIDIA SoC's the ARM SMMU needs to interact with the memory controller in order to map memory clients to the corresponding stream IDs. Document how the nvidia,memory-controller property can be used to achieve this. Note that this is a backwards-incompatible change that

[PATCH v3 0/3] iommu/arm-smmu: Support Tegra234 SMMU

2022-04-29 Thread Thierry Reding
From: Thierry Reding Hi Joerg, this is essentially a resend of v2 with a Acked-by:s from Robin and Will added. These have been on the list for quite a while now, but apparently there was a misunderstanding, so neither you nor Will picked this up. Since Will acked these, I think it's probably

RE: [PATCH RFC 03/19] iommufd: Dirty tracking data support

2022-04-29 Thread Tian, Kevin
> From: Joao Martins > Sent: Friday, April 29, 2022 5:09 AM [...] > + > +static int iommu_read_and_clear_dirty(struct iommu_domain *domain, > + struct iommufd_dirty_data *bitmap) In a glance this function and all previous helpers doesn't rely on any iommufd

RE: [PATCH RFC 02/19] iommufd: Dirty tracking for io_pagetable

2022-04-29 Thread Tian, Kevin
> From: Joao Martins > Sent: Friday, April 29, 2022 5:09 AM > > +static int __set_dirty_tracking_range_locked(struct iommu_domain > *domain, suppose anything using iommu_domain as the first argument should be put in the iommu layer. Here it's more reasonable to use iopt as the first argument or

RE: [PATCH RFC 01/19] iommu: Add iommu_domain ops for dirty tracking

2022-04-29 Thread Tian, Kevin
> From: Joao Martins > Sent: Friday, April 29, 2022 5:09 AM > > Add to iommu domain operations a set of callbacks to > perform dirty tracking, particulary to start and stop > tracking and finally to test and clear the dirty data. to be consistent with other context, s/test/read/ > > Drivers

Re: [PATCH v4 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-04-29 Thread Baolu Lu
On 2022/4/28 16:39, Jean-Philippe Brucker wrote: On Tue, Apr 26, 2022 at 04:31:57PM -0700, Dave Hansen wrote: On 4/26/22 09:48, Jean-Philippe Brucker wrote: On Tue, Apr 26, 2022 at 08:27:00AM -0700, Dave Hansen wrote: On 4/25/22 09:40, Jean-Philippe Brucker wrote: The problem is that we'd

Re: [PATCH v2 03/14] iommu: Move bus setup to IOMMU device registration

2022-04-29 Thread Baolu Lu
Hi Robin, On 2022/4/28 21:18, Robin Murphy wrote: Move the bus setup to iommu_device_register(). This should allow bus_iommu_probe() to be correctly replayed for multiple IOMMU instances, and leaves bus_set_iommu() as a glorified no-op to be cleaned up next. I re-fetched the latest patches on

Re: [PATCH RFC 11/12] iommufd: vfio container FD ioctl compatibility

2022-04-29 Thread David Gibson
On Thu, Apr 28, 2022 at 12:10:37PM -0300, Jason Gunthorpe wrote: > On Fri, Apr 29, 2022 at 12:53:16AM +1000, David Gibson wrote: > > > 2) Costly GUPs. pseries (the most common ppc machine type) always > > expects a (v)IOMMU. That means that unlike the common x86 model of a > > host with IOMMU,

Re: [PATCH RFC 11/12] iommufd: vfio container FD ioctl compatibility

2022-04-29 Thread David Gibson
On Fri, Apr 29, 2022 at 01:21:30AM +, Tian, Kevin wrote: > > From: Jason Gunthorpe > > Sent: Thursday, April 28, 2022 11:11 PM > > > > > > > 3) "dynamic DMA windows" (DDW). The IBM IOMMU hardware allows for > > 2 IOVA > > > windows, which aren't contiguous with each other. The base

Re: [PATCH RFC 08/12] iommufd: IOCTLs for the io_pagetable

2022-04-29 Thread David Gibson
On Thu, Apr 28, 2022 at 11:22:58AM -0300, Jason Gunthorpe wrote: > On Thu, Apr 28, 2022 at 03:58:30PM +1000, David Gibson wrote: > > On Thu, Mar 31, 2022 at 09:58:41AM -0300, Jason Gunthorpe wrote: > > > On Thu, Mar 31, 2022 at 03:36:29PM +1100, David Gibson wrote: > > > > > > > > +/** > > > > >

Re: [PATCH v4 11/12] iommu: Per-domain I/O page fault handling

2022-04-29 Thread Baolu Lu
On 2022/4/28 22:57, Jean-Philippe Brucker wrote: On Thu, Apr 21, 2022 at 01:21:20PM +0800, Lu Baolu wrote: static void iopf_handle_group(struct work_struct *work) { struct iopf_group *group; @@ -134,12 +78,23 @@ static void iopf_handle_group(struct work_struct *work) group =

Re: [PATCH v4 03/12] iommu: Add attach/detach_dev_pasid domain ops

2022-04-29 Thread Baolu Lu
On 2022/4/28 22:53, Jean-Philippe Brucker wrote: On Thu, Apr 21, 2022 at 01:21:12PM +0800, Lu Baolu wrote: Attaching an IOMMU domain to a PASID of a device is a generic operation for modern IOMMU drivers which support PASID-granular DMA address translation. Currently visible usage scenarios

Re: [PATCH v4 10/12] iommu: Prepare IOMMU domain for IOPF

2022-04-29 Thread Baolu Lu
Hi Jean, On 2022/4/28 22:47, Jean-Philippe Brucker wrote: Hi Baolu, On Thu, Apr 21, 2022 at 01:21:19PM +0800, Lu Baolu wrote: +/* + * Get the attached domain for asynchronous usage, for example the I/O + * page fault handling framework. The caller get a reference counter + * of the domain