Re: [RFC PATCH v4 00/13] iommu/smmuv3: Implement hardware dirty log tracking

2021-05-17 Thread Keqian Zhu
Hi all, The VFIO part is at here: https://lore.kernel.org/kvm/20210507103608.39440-1-zhukeqi...@huawei.com/ Thanks, Keqian On 2021/5/7 18:21, Keqian Zhu wrote: > Hi Robin, Will and everyone, > > I think this series is relative mature now, please give your valuable > suggestio

Re: [RFC PATCH v4 01/13] iommu: Introduce dirty log tracking framework

2021-05-13 Thread Keqian Zhu
On 2021/5/13 20:02, Lu Baolu wrote: > On 5/13/21 6:58 PM, Keqian Zhu wrote: >> >> >> On 2021/5/12 19:36, Lu Baolu wrote: >>> Hi keqian, >>> >>> On 5/12/21 4:44 PM, Keqian Zhu wrote: >>>> >>>> >>>> On 2021/5/12

Re: [RFC PATCH v4 01/13] iommu: Introduce dirty log tracking framework

2021-05-13 Thread Keqian Zhu
On 2021/5/12 19:36, Lu Baolu wrote: > Hi keqian, > > On 5/12/21 4:44 PM, Keqian Zhu wrote: >> >> >> On 2021/5/12 11:20, Lu Baolu wrote: >>> On 5/11/21 3:40 PM, Keqian Zhu wrote: >>>>> For upper layers, before starting page tracking, they chec

Re: [RFC PATCH v4 01/13] iommu: Introduce dirty log tracking framework

2021-05-12 Thread Keqian Zhu
On 2021/5/12 11:20, Lu Baolu wrote: > On 5/11/21 3:40 PM, Keqian Zhu wrote: >>> For upper layers, before starting page tracking, they check the >>> dirty_page_trackable attribution of the domain and start it only it's >>> capable. Once the page tracking is

Re: [RFC PATCH v4 01/13] iommu: Introduce dirty log tracking framework

2021-05-11 Thread Keqian Zhu
Hi Baolu, On 2021/5/11 11:12, Lu Baolu wrote: > Hi Keqian, > > On 5/10/21 7:07 PM, Keqian Zhu wrote: >>>>> I suppose this interface is to ask the vendor IOMMU driver to check >>>>> whether each device/iommu in the domain supports dirty bit tracking. >>

Re: [RFC PATCH v4 01/13] iommu: Introduce dirty log tracking framework

2021-05-10 Thread Keqian Zhu
Hi Baolu, On 2021/5/10 9:08, Lu Baolu wrote: > Hi Keqian, > > On 5/8/21 3:35 PM, Keqian Zhu wrote: >> Hi Baolu, >> >> On 2021/5/8 11:46, Lu Baolu wrote: >>> Hi Keqian, >>> >>> On 5/7/21 6:21 PM, Keqian Zhu wrote: >>>> Some type

Re: [RFC PATCH v4 01/13] iommu: Introduce dirty log tracking framework

2021-05-08 Thread Keqian Zhu
Hi Baolu, On 2021/5/8 11:46, Lu Baolu wrote: > Hi Keqian, > > On 5/7/21 6:21 PM, Keqian Zhu wrote: >> Some types of IOMMU are capable of tracking DMA dirty log, such as >> ARM SMMU with HTTU or Intel IOMMU with SLADE. This introduces the >> dirty log tracking framew

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

2021-05-07 Thread Keqian Zhu
From: Kunkun Jiang This detects BBML feature and if SMMU supports it, transfer BBMLx quirk to io-pgtable. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 19 +++ drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 6

[RFC PATCH v4 11/13] iommu/arm-smmu-v3: Realize sync_dirty_log iommu ops

2021-05-07 Thread Keqian Zhu
From: Kunkun Jiang This realizes sync_dirty_log iommu ops based on sync_dirty_log io-pgtable ops. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 30 + 1 file changed, 30 insertions(+) diff --git a/drivers/iommu

[RFC PATCH v4 13/13] iommu/arm-smmu-v3: Realize support_dirty_log iommu ops

2021-05-07 Thread Keqian Zhu
From: Kunkun Jiang We have implemented these interfaces required to support iommu dirty log tracking. The last step is reporting this feature to upper user, then the user can perform higher policy base on it. For arm smmuv3, it is equal to ARM_SMMU_FEAT_HD. Co-developed-by: Keqian Zhu Signed

[RFC PATCH v4 10/13] iommu/arm-smmu-v3: Realize switch_dirty_log iommu ops

2021-05-07 Thread Keqian Zhu
From: Kunkun Jiang This realizes switch_dirty_log. In order to get finer dirty granule, it invokes arm_smmu_split_block when start dirty log, and invokes arm_smmu_merge_page() to recover block mapping when stop dirty log. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers

[RFC PATCH v4 07/13] iommu/arm-smmu-v3: Add support for Hardware Translation Table Update

2021-05-07 Thread Keqian Zhu
From: Jean-Philippe Brucker If the SMMU supports it and the kernel was built with HTTU support, enable hardware update of access and dirty flags. This is essential for shared page tables, to reduce the number of access faults on the fault queue. Normal DMA with io-pgtables doesn't currently use t

[RFC PATCH v4 08/13] iommu/arm-smmu-v3: Enable HTTU for stage1 with io-pgtable mapping

2021-05-07 Thread Keqian Zhu
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 io-pgtable. Co-developed-by: Keqian Zhu

[RFC PATCH v4 06/13] iommu/io-pgtable-arm: Add and realize clear_dirty_log ops

2021-05-07 Thread Keqian Zhu
bitmap. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/io-pgtable-arm.c | 93 ++ include/linux/io-pgtable.h | 4 ++ 2 files changed, 97 insertions(+) diff --git a/drivers/iommu/io-pgtable-arm.c b/drivers/iommu/io-pgtable-arm.c index

[RFC PATCH v4 12/13] iommu/arm-smmu-v3: Realize clear_dirty_log iommu ops

2021-05-07 Thread Keqian Zhu
From: Kunkun Jiang This realizes clear_dirty_log iommu ops based on clear_dirty_log io-pgtable ops. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 25 + 1 file changed, 25 insertions(+) diff --git a/drivers/iommu

[RFC PATCH v4 04/13] iommu/io-pgtable-arm: Add and realize merge_page ops

2021-05-07 Thread Keqian Zhu
only used by dirty log tracking, which does not concurrently work with other pgtable ops that access underlying page table, so race condition does not exist. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/io-pgtable-arm.c | 78 ++ include

[RFC PATCH v4 05/13] iommu/io-pgtable-arm: Add and realize sync_dirty_log ops

2021-05-07 Thread Keqian Zhu
From: Kunkun Jiang During dirty log tracking, user will try to retrieve dirty log from iommu if it supports hardware dirty log. Scan leaf TTD and treat it is dirty if it's writable. As we just set DBM bit for stage1 mapping, so check whether AP[2] is not set. Co-developed-by: Keqian Zhu S

[RFC PATCH v4 01/13] iommu: Introduce dirty log tracking framework

2021-05-07 Thread Keqian Zhu
: Don't concurrently call these interfaces with other ops that access underlying page table. Signed-off-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/iommu.c| 201 +++ include/linux/iommu.h| 63 +++ include/trace/events/io

[RFC PATCH v4 00/13] iommu/smmuv3: Implement hardware dirty log tracking

2021-05-07 Thread Keqian Zhu
-Philippe Brucker (1): iommu/arm-smmu-v3: Add support for Hardware Translation Table Update Keqian Zhu (1): iommu: Introduce dirty log tracking framework Kunkun Jiang (11): iommu/io-pgtable-arm: Add quirk ARM_HD and ARM_BBMLx iommu/io-pgtable-arm: Add and realize split_block ops iommu/io

[RFC PATCH v4 02/13] iommu/io-pgtable-arm: Add quirk ARM_HD and ARM_BBMLx

2021-05-07 Thread Keqian Zhu
writable and AP[2]/ S2AP[1] means dirty. When has ARM_HD, we set DBM bit for S1 mapping. As SMMU nested mode is not upstreamed for now, we just aim to support dirty log tracking for stage1 with io-pgtable mapping (means not support SVA). Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang

[RFC PATCH v4 03/13] iommu/io-pgtable-arm: Add and realize split_block ops

2021-05-07 Thread Keqian Zhu
descriptors. BBML1 or BBML2 feature is required. Spliting block is designed to be only used by dirty log tracking, which does not concurrently work with other pgtable ops that access underlying page table, so race condition does not exist. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang

Re: [PATCH v3 02/12] iommu: Add iommu_split_block interface

2021-04-20 Thread Keqian Zhu
Hi Baolu, Cheers for the your quick reply. On 2021/4/20 10:09, Lu Baolu wrote: > Hi Keqian, > > On 4/20/21 9:25 AM, Keqian Zhu wrote: >> Hi Baolu, >> >> On 2021/4/19 21:33, Lu Baolu wrote: >>> Hi Keqian, >>> >>> On 2021/4/19 17:32, Keqian

Re: [PATCH v3 02/12] iommu: Add iommu_split_block interface

2021-04-19 Thread Keqian Zhu
Hi Baolu, On 2021/4/19 21:33, Lu Baolu wrote: > Hi Keqian, > > On 2021/4/19 17:32, Keqian Zhu wrote: >>>> +EXPORT_SYMBOL_GPL(iommu_split_block); >>> Do you really have any consumers of this interface other than the dirty >>> bit tracking? If not, I don&#x

Re: [PATCH v3 02/12] iommu: Add iommu_split_block interface

2021-04-19 Thread Keqian Zhu
Hi Baolu, On 2021/4/14 15:14, Lu Baolu wrote: > On 4/13/21 4:54 PM, Keqian Zhu wrote: >> Block(largepage) mapping is not a proper granule for dirty log tracking. >> Take an extreme example, if DMA writes one byte, under 1G mapping, the >> dirty amount reported is 1G, but

Re: [PATCH v3 01/12] iommu: Introduce dirty log tracking framework

2021-04-16 Thread Keqian Zhu
Hi Baolu, On 2021/4/15 18:21, Lu Baolu wrote: > Hi, > > On 2021/4/15 15:43, Keqian Zhu wrote: >>>> design it as not switchable. I will modify the commit message of patch#12, >>>> thanks! >>> I am not sure that I fully get your point. But I can&#x

Re: [PATCH v3 01/12] iommu: Introduce dirty log tracking framework

2021-04-15 Thread Keqian Zhu
On 2021/4/15 15:03, Lu Baolu wrote: > On 4/15/21 2:18 PM, Keqian Zhu wrote: >> Hi Baolu, >> >> Thanks for the review! >> >> On 2021/4/14 15:00, Lu Baolu wrote: >>> Hi Keqian, >>> >>> On 4/13/21 4:54 PM, Keqian Zhu wrote: >>>

Re: [PATCH v3 01/12] iommu: Introduce dirty log tracking framework

2021-04-14 Thread Keqian Zhu
Hi Baolu, Thanks for the review! On 2021/4/14 15:00, Lu Baolu wrote: > Hi Keqian, > > On 4/13/21 4:54 PM, Keqian Zhu wrote: >> Some types of IOMMU are capable of tracking DMA dirty log, such as >> ARM SMMU with HTTU or Intel IOMMU with SLADE. This introduces the >> d

[PATCH v3 10/12] iommu/arm-smmu-v3: Realize sync_dirty_log iommu ops

2021-04-13 Thread Keqian Zhu
From: Kunkun Jiang During dirty log tracking, user will try to retrieve dirty log from iommu if it supports hardware dirty log. Scan leaf TTD and treat it is dirty if it's writable. As we just enable HTTU for stage1, so check whether AP[2] is not set. Co-developed-by: Keqian Zhu Signed-o

[PATCH v3 12/12] iommu/arm-smmu-v3: Add HWDBM device feature reporting

2021-04-13 Thread Keqian Zhu
, it is equal to ARM_SMMU_FEAT_HD and it is enabled by default if supported. Other types of IOMMU can enable it by default or when user invokes enable_feature. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 6 ++ 1 file changed, 6

[PATCH v3 11/12] iommu/arm-smmu-v3: Realize clear_dirty_log iommu ops

2021-04-13 Thread Keqian Zhu
-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 25 ++ drivers/iommu/io-pgtable-arm.c | 95 + include/linux/io-pgtable.h | 4 + 3 files changed, 124 insertions(+) diff --git a/drivers/iommu

[PATCH v3 09/12] iommu/arm-smmu-v3: Realize switch_dirty_log iommu ops

2021-04-13 Thread Keqian Zhu
From: Kunkun Jiang This realizes switch_dirty_log by invoking iommu_split_block() and iommu_merge_page(). HTTU HD feature is required. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 38 + 1 file changed, 38

[PATCH v3 08/12] iommu/arm-smmu-v3: Realize merge_page iommu ops

2021-04-13 Thread Keqian Zhu
pgtable ops. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 28 drivers/iommu/io-pgtable-arm.c | 78 + include/linux/io-pgtable.h | 2 + 3 files changed, 108 insertions(+) diff

[PATCH v3 03/12] iommu: Add iommu_merge_page interface

2021-04-13 Thread Keqian Zhu
need to realize the merge_page iommu ops. We flush all iotlbs after the whole procedure is completed to ease the pressure of iommu, as we will hanle a huge range of mapping in general. Signed-off-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/iommu.c | 75

[PATCH v3 02/12] iommu: Add iommu_split_block interface

2021-04-13 Thread Keqian Zhu
specific IOMMU driver can invoke it during start dirty log. If so, the driver also need to realize the split_block iommu ops. We flush all iotlbs after the whole procedure is completed to ease the pressure of IOMMU, as we will hanle a huge range of mapping in general. Signed-off-by: Keqian Zhu

[PATCH v3 07/12] iommu/arm-smmu-v3: Realize split_block iommu ops

2021-04-13 Thread Keqian Zhu
ops. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 27 + drivers/iommu/io-pgtable-arm.c | 122 include/linux/io-pgtable.h | 2 + 3 files changed, 151 insertions(+) diff --git a

[PATCH v3 04/12] iommu/arm-smmu-v3: Add support for Hardware Translation Table Update

2021-04-13 Thread Keqian Zhu
From: Jean-Philippe Brucker If the SMMU supports it and the kernel was built with HTTU support, enable hardware update of access and dirty flags. This is essential for shared page tables, to reduce the number of access faults on the fault queue. Normal DMA with io-pgtables doesn't currently use t

[PATCH v3 06/12] iommu/arm-smmu-v3: Add feature detection for BBML

2021-04-13 Thread Keqian Zhu
change the block size without using break-before-make sequence. This adds feature detection for BBML, none functional change expected. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 19 +++ drivers/iommu/arm/arm-smmu-v3/arm

[PATCH v3 05/12] iommu/arm-smmu-v3: Enable HTTU for stage1 with io-pgtable mapping

2021-04-13 Thread Keqian Zhu
encoded using the access permission bits AP[2] (stage 1) or S2AP[1] (stage 2) in conjunction with the DBM (Dirty Bit Modifier) bit, where DBM means writable and AP[2]/ S2AP[1] means dirty. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 3

[PATCH v3 01/12] iommu: Introduce dirty log tracking framework

2021-04-13 Thread Keqian Zhu
supports and its driver realizes them. Signed-off-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/iommu.c | 150 ++ include/linux/iommu.h | 53 +++ 2 files changed, 203 insertions(+) diff --git a/drivers/iommu/iommu.c b/drivers

[PATCH v3 00/12] iommu/smmuv3: Implement hardware dirty log tracking

2021-04-13 Thread Keqian Zhu
implement these interfaces for arm smmuv3. Thanks, Keqian Jean-Philippe Brucker (1): iommu/arm-smmu-v3: Add support for Hardware Translation Table Update Keqian Zhu (3): iommu: Introduce dirty log tracking framework iommu: Add iommu_split_block interface iommu: Add iommu_merge_page interface

Re: [PATCH v14 05/13] iommu/smmuv3: Implement attach/detach_pasid_table

2021-03-21 Thread Keqian Zhu
Hi Eric, On 2021/3/19 21:15, Auger Eric wrote: > Hi Keqian, > > On 3/2/21 9:35 AM, Keqian Zhu wrote: >> Hi Eric, >> >> On 2021/2/24 4:56, Eric Auger wrote: >>> On attach_pasid_table() we program STE S1 related info set >>> by the guest into the ac

Re: [PATCH v2 06/11] iommu/arm-smmu-v3: Scan leaf TTD to sync hardware dirty log

2021-03-17 Thread Keqian Zhu
On 2021/3/17 18:44, Yi Sun wrote: > On 21-03-10 17:06:09, Keqian Zhu wrote: >> From: jiangkunkun >> >> During dirty log tracking, user will try to retrieve dirty log from >> iommu if it supports hardware dirty log. >> >> This adds a new interface named s

Re: [PATCH v2 04/11] iommu/arm-smmu-v3: Split block descriptor when start dirty log

2021-03-16 Thread Keqian Zhu
Hi Yi, On 2021/3/16 17:17, Yi Sun wrote: > On 21-03-10 17:06:07, Keqian Zhu wrote: >> From: jiangkunkun >> >> Block descriptor is not a proper granule for dirty log tracking. >> Take an extreme example, if DMA writes one byte, under 1G mapping, >> the dirty a

Re: [PATCH] vfio/type1: fix vaddr_get_pfns() return in vfio_pin_page_external()

2021-03-14 Thread Keqian Zhu
Hi Daniel, [+Cc iommu mail list] This patch looks good to me. (but I don't test it too.) Thanks, Keqian On 2021/3/9 1:24, Daniel Jordan wrote: > vaddr_get_pfns() now returns the positive number of pfns successfully > gotten instead of zero. vfio_pin_page_external() might return 1 to > vfio_i

[PATCH v2 01/11] iommu/arm-smmu-v3: Add support for Hardware Translation Table Update

2021-03-10 Thread Keqian Zhu
From: Jean-Philippe Brucker If the SMMU supports it and the kernel was built with HTTU support, enable hardware update of access and dirty flags. This is essential for shared page tables, to reduce the number of access faults on the fault queue. Normal DMA with io-pgtables doesn't currently use t

[PATCH v2 11/11] vfio/iommu_type1: Add support for manual dirty log clear

2021-03-10 Thread Keqian Zhu
even if they are generated before userspace handles the same dirty page. That's to say, we should minimize the time gap of dirty log clearing and dirty log handling. We can give userspace the interface to clear dirty log. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- changelog

[PATCH v2 06/11] iommu/arm-smmu-v3: Scan leaf TTD to sync hardware dirty log

2021-03-10 Thread Keqian Zhu
As we just enable HTTU for stage1, so check whether AP[2] is not set). Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- changelog: v2: - Add new sanity check in arm_smmu_sync_dirty_log(). (smmu_domain->stage != ARM_SMMU_DOMAIN_S1) - Document the purpose of flush_iotlb in arm_smmu_s

[PATCH v2 04/11] iommu/arm-smmu-v3: Split block descriptor when start dirty log

2021-03-10 Thread Keqian Zhu
. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- changelog: v2: - Change the return type of split_block(). size_t -> int. - Change commit message to properly describe race condition. (Robin) - Change commit message to properly describe the need of split block. - Add a

[PATCH v2 08/11] iommu/arm-smmu-v3: Add HWDBM device feature reporting

2021-03-10 Thread Keqian Zhu
, it is equal to ARM_SMMU_FEAT_HD and it is enabled by default if supported. Other types of IOMMU can enable it by default or when dev_enable_feature() is called. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- changelog: v2: - As dev_has_feature() has been removed from iommu layer

[PATCH v2 02/11] iommu/arm-smmu-v3: Enable HTTU for stage1 with io-pgtable mapping

2021-03-10 Thread Keqian Zhu
, where DBM means writable and AP[2]/ S2AP[1] means dirty. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- changelog: v2: - Use a new quirk flag named IO_PGTABLE_QUIRK_ARM_HD to transfer SMMU HD feature to io-pgtable. (Robin) - Rebase on Jean's HTTU patch(#1). --- drivers/

[PATCH v2 00/11] vfio/iommu_type1: Implement dirty log tracking based on smmuv3 HTTU

2021-03-10 Thread Keqian Zhu
Hi all, This patch series implement vfio dma dirty log tracking based on smmuv3 HTTU. changelog: v2: - Address all comments of RFC version, thanks for all of you ;-) - Add a bugfix that start dirty log for newly added dma ranges and domain. Intention: As we know, vfio live migration is an im

[PATCH v2 09/11] vfio/iommu_type1: Add HWDBM status maintanance

2021-03-10 Thread Keqian Zhu
From: jiangkunkun We are going to optimize dirty log tracking based on iommu HWDBM feature, but the dirty log from iommu is useful only when all iommu backed groups are connected to iommu with HWDBM feature. This maintains a counter for this feature. Co-developed-by: Keqian Zhu Signed-off-by

[PATCH v2 05/11] iommu/arm-smmu-v3: Merge a span of page when stop dirty log

2021-03-10 Thread Keqian Zhu
general. Merging page does not simultaneously work with other pgtable ops, as the only designed user is vfio, which always hold a lock, so race condition is not considered in the pgtable ops. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- changelog: v2: - Change the return type of

[PATCH v2 10/11] vfio/iommu_type1: Optimize dirty bitmap population based on iommu HWDBM

2021-03-10 Thread Keqian Zhu
: Keqian Zhu Signed-off-by: Kunkun Jiang --- changelog: v2: - Use new interface to start|stop dirty log. As split_block|merge_page are related to ARM SMMU. (Sun Yi) - Bugfix: Start dirty log for newly added dma range and domain. --- drivers/vfio/vfio_iommu_type1.c | 136

[PATCH v2 07/11] iommu/arm-smmu-v3: Clear dirty log according to bitmap

2021-03-10 Thread Keqian Zhu
set the AP[2] bit) of these TTDs that are specified by the user provided bitmap. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- changelog: v2: - Add new sanity check in arm_smmu_sync_dirty_log(). (smmu_domain->stage != ARM_SMMU_DOMAIN_S1) - Remove extra flush_iotlb

[PATCH v2 03/11] iommu/arm-smmu-v3: Add feature detection for BBML

2021-03-10 Thread Keqian Zhu
change the block size without using break-before-make sequence. This adds feature detection for BBML, none functional change expected. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- changelog: v2: - Use two new quirk flags named IO_PGTABLE_QUIRK_ARM_BBML1/2 to transfer SMMU BBML

Re: [PATCH v13 07/10] iommu/arm-smmu-v3: Maintain a SID->device structure

2021-03-02 Thread Keqian Zhu
Hi Jean, Reviewed-by: Keqian Zhu On 2021/3/2 17:26, Jean-Philippe Brucker wrote: > When handling faults from the event or PRI queue, we need to find the > struct device associated with a SID. Add a rb_tree to keep track of > SIDs. > > Acked-by: Jonathan Cameron > Revie

Re: [PATCH v14 05/13] iommu/smmuv3: Implement attach/detach_pasid_table

2021-03-02 Thread Keqian Zhu
Hi Eric, On 2021/2/24 4:56, Eric Auger wrote: > On attach_pasid_table() we program STE S1 related info set > by the guest into the actual physical STEs. At minimum > we need to program the context descriptor GPA and compute > whether the stage1 is translated/bypassed or aborted. > > On detach, th

Re: [RFC PATCH 01/11] iommu/arm-smmu-v3: Add feature detection for HTTU

2021-03-01 Thread Keqian Zhu
Hi Robin, I am going to send v2 at next week, to addresses these issues reported by you. Many thanks! And do you have any further comments on patch #4 #5 and #6? Thanks, Keqian On 2021/2/5 3:50, Robin Murphy wrote: > On 2021-01-28 15:17, Keqian Zhu wrote: >> From: jiangkunkun >&

Re: [PATCH v11 01/13] vfio: VFIO_IOMMU_SET_PASID_TABLE

2021-02-22 Thread Keqian Zhu
Hi Eric, On 2021/2/22 18:53, Auger Eric wrote: > Hi Keqian, > > On 2/2/21 1:34 PM, Keqian Zhu wrote: >> Hi Eric, >> >> On 2020/11/16 19:00, Eric Auger wrote: >>> From: "Liu, Yi L" >>> >>> This patch adds an VFIO_IOMMU_SET_

Re: [PATCH v13 02/15] iommu: Introduce bind/unbind_guest_msi

2021-02-18 Thread Keqian Zhu
Hi Eric, On 2021/2/12 16:55, Auger Eric wrote: > Hi Keqian, > > On 2/1/21 12:52 PM, Keqian Zhu wrote: >> Hi Eric, >> >> On 2020/11/18 19:21, Eric Auger wrote: >>> On ARM, MSI are translated by the SMMU. An IOVA is allocated >>> for each MSI doorbel

Re: [RFC PATCH 10/11] vfio/iommu_type1: Optimize dirty bitmap population based on iommu HWDBM

2021-02-17 Thread Keqian Zhu
Hi Yi, On 2021/2/9 19:57, Yi Sun wrote: > On 21-02-07 18:40:36, Keqian Zhu wrote: >> Hi Yi, >> >> On 2021/2/7 17:56, Yi Sun wrote: >>> Hi, >>> >>> On 21-01-28 23:17:41, Keqian Zhu wrote: >>> >>> [...] >&

Re: [RFC PATCH 06/11] iommu/arm-smmu-v3: Scan leaf TTD to sync hardware dirty log

2021-02-07 Thread Keqian Zhu
On 2021/2/5 3:52, Robin Murphy wrote: > On 2021-01-28 15:17, Keqian Zhu wrote: >> From: jiangkunkun >> >> During dirty log tracking, user will try to retrieve dirty log from >> iommu if it supports hardware dirty log. This adds a new interface [...] >> stat

Re: [RFC PATCH 06/11] iommu/arm-smmu-v3: Scan leaf TTD to sync hardware dirty log

2021-02-07 Thread Keqian Zhu
Hi Robin, On 2021/2/5 3:52, Robin Murphy wrote: > On 2021-01-28 15:17, Keqian Zhu wrote: >> From: jiangkunkun >> >> During dirty log tracking, user will try to retrieve dirty log from >> iommu if it supports hardware dirty log. This adds a new interface >> named

Re: [RFC PATCH 05/11] iommu/arm-smmu-v3: Merge a span of page to block descriptor

2021-02-07 Thread Keqian Zhu
Hi Robin, On 2021/2/5 3:52, Robin Murphy wrote: > On 2021-01-28 15:17, Keqian Zhu wrote: >> From: jiangkunkun >> >> When stop dirty log tracking, we need to recover all block descriptors >> which are splited when start dirty log tracking. This adds a new >> in

Re: [RFC PATCH 10/11] vfio/iommu_type1: Optimize dirty bitmap population based on iommu HWDBM

2021-02-07 Thread Keqian Zhu
Hi Yi, On 2021/2/7 17:56, Yi Sun wrote: > Hi, > > On 21-01-28 23:17:41, Keqian Zhu wrote: > > [...] > >> +static void vfio_dma_dirty_log_start(struct vfio_iommu *iommu, >> + struct vfio_dma *dma) >&

Re: [RFC PATCH 04/11] iommu/arm-smmu-v3: Split block descriptor to a span of page

2021-02-07 Thread Keqian Zhu
Hi Robin, On 2021/2/5 3:51, Robin Murphy wrote: > On 2021-01-28 15:17, Keqian Zhu wrote: >> From: jiangkunkun >> >> Block descriptor is not a proper granule for dirty log tracking. This >> adds a new interface named split_block in iommu layer and arm smmuv3 >>

Re: [RFC PATCH 01/11] iommu/arm-smmu-v3: Add feature detection for HTTU

2021-02-06 Thread Keqian Zhu
Hi Robin, On 2021/2/5 19:48, Robin Murphy wrote: > On 2021-02-05 09:13, Keqian Zhu wrote: >> Hi Robin and Jean, >> >> On 2021/2/5 3:50, Robin Murphy wrote: >>> On 2021-01-28 15:17, Keqian Zhu wrote: >>>> From: jiangkunkun >>>> >>>&g

Re: [RFC PATCH 01/11] iommu/arm-smmu-v3: Add feature detection for HTTU

2021-02-06 Thread Keqian Zhu
Hi Robin, On 2021/2/6 0:11, Robin Murphy wrote: > On 2021-02-05 11:48, Robin Murphy wrote: >> On 2021-02-05 09:13, Keqian Zhu wrote: >>> Hi Robin and Jean, >>> >>> On 2021/2/5 3:50, Robin Murphy wrote: >>>> On 2021-01-28 15:17, Keqian Zhu wrote: >

Re: [RFC PATCH 01/11] iommu/arm-smmu-v3: Add feature detection for HTTU

2021-02-06 Thread Keqian Zhu
Hi Jean, On 2021/2/5 17:51, Jean-Philippe Brucker wrote: > Hi Keqian, > > On Fri, Feb 05, 2021 at 05:13:50PM +0800, Keqian Zhu wrote: >>> We need to accommodate the firmware override as well if we need this to be >>> meaningful. Jean-Philippe is already carrying

Re: [RFC PATCH 01/11] iommu/arm-smmu-v3: Add feature detection for HTTU

2021-02-05 Thread Keqian Zhu
Hi Robin and Jean, On 2021/2/5 3:50, Robin Murphy wrote: > On 2021-01-28 15:17, Keqian Zhu wrote: >> From: jiangkunkun >> >> The SMMU which supports HTTU (Hardware Translation Table Update) can >> update the access flag and the dirty state of TTD by hardware. It is

Re: [RFC] Use SMMU HTTU for DMA dirty page tracking

2021-02-04 Thread Keqian Zhu
Hi Jean and Kevin, FYI, I have send out the SMMUv3 HTTU support for DMA dirty tracking[1] a week ago. Thanks, Keqian [1] https://lore.kernel.org/linux-iommu/20210128151742.18840-1-zhukeqi...@huawei.com/ On 2020/5/27 17:14, Jean-Philippe Brucker wrote: > On Wed, May 27, 2020 at 08:40:47AM +000

Re: [PATCH] iommu: Update the document of IOMMU_DOMAIN_UNMANAGED

2021-02-02 Thread Keqian Zhu
On 2021/2/2 20:58, Robin Murphy wrote: > On 2021-02-02 08:53, Keqian Zhu wrote: >> Signed-off-by: Keqian Zhu >> --- >> include/linux/iommu.h | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/include/linux/iommu.h b/incl

Re: [PATCH v11 01/13] vfio: VFIO_IOMMU_SET_PASID_TABLE

2021-02-02 Thread Keqian Zhu
Hi Eric, On 2020/11/16 19:00, Eric Auger wrote: > From: "Liu, Yi L" > > This patch adds an VFIO_IOMMU_SET_PASID_TABLE ioctl > which aims to pass the virtual iommu guest configuration > to the host. This latter takes the form of the so-called > PASID table. > > Signed-off-by: Jacob Pan > Signed

Re: [PATCH v11 03/13] vfio: VFIO_IOMMU_SET_MSI_BINDING

2021-02-02 Thread Keqian Zhu
Hi Eric, On 2020/11/16 19:00, Eric Auger wrote: > This patch adds the VFIO_IOMMU_SET_MSI_BINDING ioctl which aim > to (un)register the guest MSI binding to the host. This latter > then can use those stage 1 bindings to build a nested stage > binding targeting the physical MSIs. [...] > +static in

[PATCH] iommu: Update the document of IOMMU_DOMAIN_UNMANAGED

2021-02-02 Thread Keqian Zhu
Signed-off-by: Keqian Zhu --- include/linux/iommu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 77e561ed57fd..e8f2efae212b 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -68,7 +68,7 @@ struct

Re: [PATCH v13 06/15] iommu/smmuv3: Implement attach/detach_pasid_table

2021-02-02 Thread Keqian Zhu
Hi Eric, On 2020/11/18 19:21, Eric Auger wrote: > On attach_pasid_table() we program STE S1 related info set > by the guest into the actual physical STEs. At minimum > we need to program the context descriptor GPA and compute > whether the stage1 is translated/bypassed or aborted. > > Signed-off-

Re: [PATCH v13 03/15] iommu/arm-smmu-v3: Maintain a SID->device structure

2021-02-01 Thread Keqian Zhu
Hi Eric, On 2021/2/2 1:19, Auger Eric wrote: > Hi Keqian, > > On 2/1/21 1:26 PM, Keqian Zhu wrote: >> Hi Eric, >> >> On 2020/11/18 19:21, Eric Auger wrote: >>> From: Jean-Philippe Brucker >>> >>> When handling faults from the event or PRI q

Re: [PATCH v13 05/15] iommu/smmuv3: Get prepared for nested stage support

2021-02-01 Thread Keqian Zhu
Hi Eric, On 2020/11/18 19:21, Eric Auger wrote: > When nested stage translation is setup, both s1_cfg and > s2_cfg are set. > > We introduce a new smmu domain abort field that will be set > upon guest stage1 configuration passing. > > arm_smmu_write_strtab_ent() is modified to write both stage >

Re: [PATCH v13 03/15] iommu/arm-smmu-v3: Maintain a SID->device structure

2021-02-01 Thread Keqian Zhu
Hi Jean, On 2021/2/1 23:15, Jean-Philippe Brucker wrote: > On Mon, Feb 01, 2021 at 08:26:41PM +0800, Keqian Zhu wrote: >>> +static int arm_smmu_insert_master(struct arm_smmu_device *smmu, >>> + struct arm_smmu_master *master) >>> +{ >

Re: [PATCH v13 04/15] iommu/smmuv3: Allow s1 and s2 configs to coexist

2021-02-01 Thread Keqian Zhu
Hi Eric, On 2020/11/18 19:21, Eric Auger wrote: > In true nested mode, both s1_cfg and s2_cfg will coexist. > Let's remove the union and add a "set" field in each > config structure telling whether the config is set and needs > to be applied when writing the STE. In legacy nested mode, > only the

Re: [PATCH v13 03/15] iommu/arm-smmu-v3: Maintain a SID->device structure

2021-02-01 Thread Keqian Zhu
Hi Eric, On 2020/11/18 19:21, Eric Auger wrote: > From: Jean-Philippe Brucker > > When handling faults from the event or PRI queue, we need to find the > struct device associated to a SID. Add a rb_tree to keep track of SIDs. > > Signed-off-by: Jean-Philippe Brucker [...] > } > > +static i

Re: [PATCH v13 02/15] iommu: Introduce bind/unbind_guest_msi

2021-02-01 Thread Keqian Zhu
Hi Eric, On 2020/11/18 19:21, Eric Auger wrote: > On ARM, MSI are translated by the SMMU. An IOVA is allocated > for each MSI doorbell. If both the host and the guest are exposed > with SMMUs, we end up with 2 different IOVAs allocated by each. > guest allocates an IOVA (gIOVA) to map onto the gue

Re: [PATCH v13 01/15] iommu: Introduce attach/detach_pasid_table API

2021-02-01 Thread Keqian Zhu
Hi Eric, On 2020/11/18 19:21, Eric Auger wrote: > In virtualization use case, when a guest is assigned > a PCI host device, protected by a virtual IOMMU on the guest, > the physical IOMMU must be programmed to be consistent with > the guest mappings. If the physical IOMMU supports two > translatio

Re: [PATCH v3 2/2] vfio/iommu_type1: Fix some sanity checks in detach group

2021-01-28 Thread Keqian Zhu
On 2021/1/28 7:46, Alex Williamson wrote: > On Fri, 22 Jan 2021 17:26:35 +0800 > Keqian Zhu wrote: > >> vfio_sanity_check_pfn_list() is used to check whether pfn_list and >> notifier are empty when remove the external domain, so it makes a >> wrong assumption tha

Re: [PATCH 1/1] iommu/arm-smmu-v3: add support for BBML

2021-01-28 Thread Keqian Zhu
On 2021/1/29 0:17, Robin Murphy wrote: > On 2021-01-28 15:18, Keqian Zhu wrote: >> >> >> On 2021/1/27 17:39, Robin Murphy wrote: >>> On 2021-01-27 07:36, Keqian Zhu wrote: >>>> >>>> >>>> On 2021/1/27 10:01, Leizhen (ThunderTo

[RFC PATCH 07/11] iommu/arm-smmu-v3: Clear dirty log according to bitmap

2021-01-28 Thread Keqian Zhu
) of these TTDs that are specified by the user provided bitmap. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 24 ++ drivers/iommu/io-pgtable-arm.c | 95 + drivers/iommu/iommu.c

Re: [PATCH v3 2/2] vfio/iommu_type1: Fix some sanity checks in detach group

2021-01-28 Thread Keqian Zhu
On 2021/1/28 7:46, Alex Williamson wrote: > On Fri, 22 Jan 2021 17:26:35 +0800 > Keqian Zhu wrote: > >> vfio_sanity_check_pfn_list() is used to check whether pfn_list and >> notifier are empty when remove the external domain, so it makes a >> wrong assumption tha

Re: [PATCH 1/1] iommu/arm-smmu-v3: add support for BBML

2021-01-28 Thread Keqian Zhu
On 2021/1/27 17:39, Robin Murphy wrote: > On 2021-01-27 07:36, Keqian Zhu wrote: >> >> >> On 2021/1/27 10:01, Leizhen (ThunderTown) wrote: >>> >>> >>> On 2021/1/26 18:12, Will Deacon wrote: >>>> On Mon, Jan 25, 2021 at 08:23:40PM +00

[RFC PATCH 01/11] iommu/arm-smmu-v3: Add feature detection for HTTU

2021-01-28 Thread Keqian Zhu
From: jiangkunkun The SMMU which supports HTTU (Hardware Translation Table Update) can update the access flag and the dirty state of TTD by hardware. It is essential to track dirty pages of DMA. This adds feature detection, none functional change. Co-developed-by: Keqian Zhu Signed-off-by

[RFC PATCH 10/11] vfio/iommu_type1: Optimize dirty bitmap population based on iommu HWDBM

2021-01-28 Thread Keqian Zhu
From: jiangkunkun In the past if vfio_iommu is not of pinned_page_dirty_scope and vfio_dma is iommu_mapped, we populate full dirty bitmap for this vfio_dma. Now we can try to get dirty log from iommu before make the lousy decision. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang

[RFC PATCH 11/11] vfio/iommu_type1: Add support for manual dirty log clear

2021-01-28 Thread Keqian Zhu
even if they are generated before userspace handles the same dirty page. That's to say, we should minimize the time gap of dirty log clearing and dirty log handling. We can give userspace the interface to clear dirty log. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers

[RFC PATCH 09/11] vfio/iommu_type1: Add HWDBM status maintanance

2021-01-28 Thread Keqian Zhu
From: jiangkunkun We are going to optimize dirty log tracking based on iommu HWDBM feature, but the dirty log from iommu is useful only when all iommu backed groups are connected to iommu with HWDBM feature. This maintains a counter for this feature. Co-developed-by: Keqian Zhu Signed-off-by

[RFC PATCH 06/11] iommu/arm-smmu-v3: Scan leaf TTD to sync hardware dirty log

2021-01-28 Thread Keqian Zhu
As we just enable HTTU for stage1, so check AP[2] is not set). Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 27 +++ drivers/iommu/io-pgtable-arm.c | 90 + drivers/iommu/iommu.c

[RFC PATCH 05/11] iommu/arm-smmu-v3: Merge a span of page to block descriptor

2021-01-28 Thread Keqian Zhu
e mappings in general. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 20 ++ drivers/iommu/io-pgtable-arm.c | 78 + drivers/iommu/iommu.c | 75 includ

[RFC PATCH 02/11] iommu/arm-smmu-v3: Enable HTTU for SMMU stage1 mapping

2021-01-28 Thread Keqian Zhu
, where DBM means writable and AP[2]/ S2AP[1] means dirty. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 5 + drivers/iommu/io-pgtable-arm.c | 7 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers

[RFC PATCH 04/11] iommu/arm-smmu-v3: Split block descriptor to a span of page

2021-01-28 Thread Keqian Zhu
expected to be working, so race condition does not exist. And we flush all iotlbs after the split procedure is completed to ease the pressure of iommu, as we will split a huge range of block mappings in general. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/arm/arm-smmu

[RFC PATCH 03/11] iommu/arm-smmu-v3: Add feature detection for BBML

2021-01-28 Thread Keqian Zhu
change the block size without using break-before-make. This adds feature detection for BBML, none functional change. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 24 - drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 6

[RFC PATCH 08/11] iommu/arm-smmu-v3: Add HWDBM device feature reporting

2021-01-28 Thread Keqian Zhu
, it is equal to ARM_SMMU_FEAT_HTTU_HD. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 2 ++ include/linux/iommu.h | 1 + 2 files changed, 3 insertions(+) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b

[RFC PATCH 00/11] vfio/iommu_type1: Implement dirty log tracking based on smmuv3 HTTU

2021-01-28 Thread Keqian Zhu
Hi all, This patch series implement a new dirty log tracking method for vfio dma. Intention: As we know, vfio live migration is an important and valuable feature, but there are still many hurdles to solve, including migration of interrupt, device state, DMA dirty log tracking, and etc. For now,

  1   2   >