Re: [RFC PATCH v2 2/2] KVM: x86: Not wr-protect huge page with init_all_set dirty log

2021-04-20 Thread Keqian Zhu
Hi Ben, On 2021/4/20 3:20, Ben Gardon wrote: > On Fri, Apr 16, 2021 at 1:25 AM Keqian Zhu wrote: >> >> Currently during start dirty logging, if we're with init-all-set, >> we write protect huge pages and leave normal pages untouched, for >> that we can enable dirt

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 v4 2/2] kvm/arm64: Try stage2 block mapping for host device MMIO

2021-04-16 Thread Keqian Zhu
Hi Marc, On 2021/4/16 22:44, Marc Zyngier wrote: > On Thu, 15 Apr 2021 15:08:09 +0100, > Keqian Zhu wrote: >> >> Hi Marc, >> >> On 2021/4/15 22:03, Keqian Zhu wrote: >>> The MMIO region of a device maybe huge (GB level), try to use >>> block

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 3/3] vfio/iommu_type1: Add support for manual dirty log clear

2021-04-16 Thread Keqian Zhu
Hi Alex, On 2021/4/16 4:43, Alex Williamson wrote: > On Tue, 13 Apr 2021 17:14:45 +0800 > Keqian Zhu wrote: > >> From: Kunkun Jiang >> >> In the past, we clear dirty log immediately after sync dirty >> log to userspace. This may cause redundant dirty handling

[RFC PATCH v2 1/2] KVM: x86: Support write protect gfn with min_level

2021-04-16 Thread Keqian Zhu
Under some circumstances, we just need to write protect large page gfn. This gets prepared for write protecting large page lazily during dirty log tracking. None function and performance change expected. Signed-off-by: Keqian Zhu --- arch/x86/kvm/mmu/mmu.c | 9 + arch/x86/kvm

[RFC PATCH v2 0/2] KVM: x86: Enable dirty logging lazily for huge pages

2021-04-16 Thread Keqian Zhu
me of start dirty logging, also greatly reduces side-effect on guest when there is high dirty rate. Thanks, Keqian Keqian Zhu (2): KVM: x86: Support write protect gfn with min_level KVM: x86: Not wr-protect huge page with init_all_set dirty log arch/x86/kvm/mmu/mmu.c

[RFC PATCH v2 2/2] KVM: x86: Not wr-protect huge page with init_all_set dirty log

2021-04-16 Thread Keqian Zhu
me of start dirty logging, also greatly reduces side-effect on guest when there is high dirty rate. Signed-off-by: Keqian Zhu --- arch/x86/kvm/mmu/mmu.c | 48 ++ arch/x86/kvm/x86.c | 37 +--- 2 files changed, 54 insertions(+

Re: [PATCH v4 2/2] kvm/arm64: Try stage2 block mapping for host device MMIO

2021-04-15 Thread Keqian Zhu
Hi Marc, On 2021/4/15 22:03, Keqian Zhu wrote: > The MMIO region of a device maybe huge (GB level), try to use > block mapping in stage2 to speedup both map and unmap. > > Compared to normal memory mapping, we should consider two more > points when try block mapping for MMIO regi

[PATCH v4 1/2] kvm/arm64: Remove the creation time's mapping of MMIO regions

2021-04-15 Thread Keqian Zhu
The MMIO regions may be unmapped for many reasons and can be remapped by stage2 fault path. Map MMIO regions at creation time becomes a minor optimization and makes these two mapping path hard to sync. Remove the mapping code while keep the useful sanity check. Signed-off-by: Keqian Zhu

[PATCH v4 2/2] kvm/arm64: Try stage2 block mapping for host device MMIO

2021-04-15 Thread Keqian Zhu
ting block mapping size for MMIO region. Signed-off-by: Keqian Zhu --- arch/arm64/kvm/mmu.c | 61 1 file changed, 51 insertions(+), 10 deletions(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index c59af5ca01b0..5a1cc7751e6d 100644 --- a/arch

[PATCH v4 0/2] kvm/arm64: Try stage2 block mapping for host device MMIO

2021-04-15 Thread Keqian Zhu
handle all cases. (Marc) - get rid of force_pte for device mapping. (Marc) v3: - Do not need to check memslot boundary in device_rough_page_shift(). (Marc) Thanks, Keqian Keqian Zhu (2): kvm/arm64: Remove the creation time's mapping of MMIO regions kvm/arm64: Try stage2 block mapping

Re: [PATCH 1/5] KVM: arm64: Divorce the perf code from oprofile helpers

2021-04-15 Thread Keqian Zhu
Hi Marc, On 2021/4/15 18:42, Marc Zyngier wrote: > On Thu, 15 Apr 2021 07:59:26 +0100, > Keqian Zhu wrote: >> >> Hi Marc, >> >> On 2021/4/14 21:44, Marc Zyngier wrote: >>> KVM/arm64 is the sole user of perf_num_counters(), and really >>> cou

Re: [PATCH v3 2/2] kvm/arm64: Try stage2 block mapping for host device MMIO

2021-04-15 Thread Keqian Zhu
Hi Marc, On 2021/4/15 18:23, Marc Zyngier wrote: > On Thu, 15 Apr 2021 03:20:52 +0100, > Keqian Zhu wrote: >> >> Hi Marc, >> >> On 2021/4/14 17:05, Marc Zyngier wrote: >>> + Santosh, who found some interesting bugs in that area before. >>> >&g

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 1/5] KVM: arm64: Divorce the perf code from oprofile helpers

2021-04-14 Thread Keqian Zhu
Hi Marc, On 2021/4/14 21:44, Marc Zyngier wrote: > KVM/arm64 is the sole user of perf_num_counters(), and really > could do without it. Stop using the obsolete API by relying on > the existing probing code. > > Signed-off-by: Marc Zyngier > --- > arch/arm64/kvm/perf.c | 7 +-- > arch/ar

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

Re: [PATCH v3 2/2] kvm/arm64: Try stage2 block mapping for host device MMIO

2021-04-14 Thread Keqian Zhu
Hi Marc, On 2021/4/14 17:05, Marc Zyngier wrote: > + Santosh, who found some interesting bugs in that area before. > > On Wed, 14 Apr 2021 07:51:09 +0100, > Keqian Zhu wrote: >> >> The MMIO region of a device maybe huge (GB level), try to use >> block mapping in

Re: [RFC PATCH] KVM: x86: Support write protect huge pages lazily

2021-04-14 Thread Keqian Zhu
Hi Ben, On 2021/4/14 0:43, Ben Gardon wrote: > On Tue, Apr 13, 2021 at 2:39 AM Keqian Zhu wrote: >> >> >> >> On 2021/4/13 1:19, Ben Gardon wrote: >>> On Tue, Apr 6, 2021 at 4:42 PM Sean Christopherson >>> wrote: >>>> >>>>

Re: [RFC PATCH v2 2/2] kvm/arm64: Try stage2 block mapping for host device MMIO

2021-04-13 Thread Keqian Zhu
Hi Marc, On 2021/4/8 15:28, Keqian Zhu wrote: > Hi Marc, > > On 2021/4/7 21:18, Marc Zyngier wrote: >> On Tue, 16 Mar 2021 13:43:38 +0000, >> Keqian Zhu wrote: >>> [...] >>> >>> +/* >>> + * Find a mapping size that properly insides th

[PATCH v3 0/2] kvm/arm64: Try stage2 block mapping for host device MMIO

2021-04-13 Thread Keqian Zhu
t boundary in device_rough_page_shift(). (Marc) Thanks, Keqian Keqian Zhu (2): kvm/arm64: Remove the creation time's mapping of MMIO regions kvm/arm64: Try stage2 block mapping for host device MMIO arch/arm64/kvm/mmu.c | 75 +--- 1 file changed

[PATCH v3 2/2] kvm/arm64: Try stage2 block mapping for host device MMIO

2021-04-13 Thread Keqian Zhu
perly fit into vma, so we don't check whether the mapping size exceeds the boundary of vma. But for device memory mapping, we should pay attention to this. This adds device_rough_page_shift() to check these two points when selecting block mapping size. Signed-off-by: Keqian Zhu --- arch

[PATCH v3 1/2] kvm/arm64: Remove the creation time's mapping of MMIO regions

2021-04-13 Thread Keqian Zhu
The MMIO regions may be unmapped for many reasons and can be remapped by stage2 fault path. Map MMIO regions at creation time becomes a minor optimization and makes these two mapping path hard to sync. Remove the mapping code while keep the useful sanity check. Signed-off-by: Keqian Zhu

Re: [RFC PATCH v2 2/2] kvm/arm64: Try stage2 block mapping for host device MMIO

2021-04-13 Thread Keqian Zhu
: > On Tue, 16 Mar 2021 13:43:38 +, > Keqian Zhu wrote: >> >> The MMIO region of a device maybe huge (GB level), try to use >> block mapping in stage2 to speedup both map and unmap. >> >> Compared to normal memory mapping, we should consider two more >&

Re: [RFC PATCH] KVM: x86: Support write protect huge pages lazily

2021-04-13 Thread Keqian Zhu
On 2021/4/13 1:19, Ben Gardon wrote: > On Tue, Apr 6, 2021 at 4:42 PM Sean Christopherson wrote: >> >> +Ben >> >> On Tue, Apr 06, 2021, Keqian Zhu wrote: >>> Hi Paolo, >>> >>> I plan to rework this patch and do full test. What do you th

[PATCH 2/3] vfio/iommu_type1: Optimize dirty bitmap population based on iommu HWDBM

2021-04-13 Thread Keqian Zhu
tplug some groups (attach a group without HWDBM or detach all groups without HWDBM). So our policy is that switch dirty log for domains dynamically. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/vfio/vfio_iommu_type1.c | 166 ++-- 1 file changed

[PATCH 1/3] vfio/iommu_type1: Add HWDBM status maintanance

2021-04-13 Thread Keqian Zhu
patch. This also maintains a counter in vfio_domain, which is used in the policy of switch dirty log in next patch. Co-developed-by: Keqian Zhu Signed-off-by: Kunkun Jiang --- drivers/vfio/vfio_iommu_type1.c | 44 + 1 file changed, 44 insertions(+) diff --git a

[PATCH 0/3] vfio/iommu_type1: Implement dirty log tracking based on IOMMU HWDBM

2021-04-13 Thread Keqian Zhu
Hi everyone, This patch series implement vfio dma dirty log tracking based on IOMMU HWDBM (hardware dirty bit management, such as SMMU with HTTU or intel IOMMU with SLADE). This patch series is split from the series[1] that containes both IOMMU part and VFIO part. Please refer the new IOMMU part

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

2021-04-13 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

[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 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 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 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 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 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 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 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 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 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 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 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] KVM: arm/arm64: Fix KVM_VGIC_V3_ADDR_TYPE_REDIST read

2021-04-12 Thread Keqian Zhu
On 2021/4/12 23:00, Eric Auger wrote: > When reading the base address of the a REDIST region > through KVM_VGIC_V3_ADDR_TYPE_REDIST we expect the > redistributor region list to be populated with a single > element. > > However list_first_entry() expects the list to be non empty. Indeed, list_fir

[PATCH] vfio/iommu_type1: Remove unused pinned_page_dirty_scope in vfio_iommu

2021-04-11 Thread Keqian Zhu
pinned_page_dirty_scope is optimized out by commit 010321565a7d ("vfio/iommu_type1: Mantain a counter for non_pinned_groups"), but appears again due to some issues during merging branches. We can safely remove it here. Signed-off-by: Keqian Zhu --- However, I'm not clear about t

Re: [RFC PATCH] KVM: x86: Support write protect huge pages lazily

2021-04-08 Thread Keqian Zhu
Hi Sean, On 2021/4/8 23:52, Sean Christopherson wrote: > On Thu, Apr 08, 2021, Keqian Zhu wrote: >> Hi Ben, >> >> Do you have any similar idea that can share with us? > > Doh, Ben is out this week, he'll be back Monday. Sorry for gumming up the > works :-/

Re: [RFC PATCH] KVM: x86: Support write protect huge pages lazily

2021-04-08 Thread Keqian Zhu
Hi Ben, Do you have any similar idea that can share with us? Thanks Keqian On 2021/4/7 7:42, Sean Christopherson wrote: > +Ben > > On Tue, Apr 06, 2021, Keqian Zhu wrote: >> Hi Paolo, >> >> I plan to rework this patch and do full test. What do you think about thi

Re: [RFC PATCH v2 2/2] kvm/arm64: Try stage2 block mapping for host device MMIO

2021-04-08 Thread Keqian Zhu
Hi Marc, On 2021/4/7 21:18, Marc Zyngier wrote: > On Tue, 16 Mar 2021 13:43:38 +, > Keqian Zhu wrote: >> >> The MMIO region of a device maybe huge (GB level), try to use >> block mapping in stage2 to speedup both map and unmap. >> >> Compared to normal me

Re: [PATCH] KVM: MMU: protect TDP MMU pages only down to required level

2021-04-06 Thread Keqian Zhu
On 2021/4/7 7:38, Sean Christopherson wrote: > On Tue, Apr 06, 2021, Keqian Zhu wrote: >> Hi Paolo, >> >> I'm just going to fix this issue, and found that you have done this ;-) > > Ha, and meanwhile I'm having a serious case of deja vu[1]. It even rece

Re: [RFC PATCH] KVM: x86: Support write protect huge pages lazily

2021-04-06 Thread Keqian Zhu
Hi Paolo, I plan to rework this patch and do full test. What do you think about this idea (enable dirty logging for huge pages lazily)? Best Regards, Keqian PS: As dirty log of TDP MMU has been supported, I should add more code. On 2020/8/28 16:11, Keqian Zhu wrote: > Currently during ena

[PATCH] KVM: x86: Remove unused function declaration

2021-04-05 Thread Keqian Zhu
kvm_mmu_slot_largepage_remove_write_access() is decared but not used, just remove it. Signed-off-by: Keqian Zhu --- arch/x86/include/asm/kvm_host.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 3768819693e5

Re: [PATCH] KVM: MMU: protect TDP MMU pages only down to required level

2021-04-05 Thread Keqian Zhu
Hi Paolo, I'm just going to fix this issue, and found that you have done this ;-) Please feel free to add: Reviewed-by: Keqian Zhu Thanks, Keqian On 2021/4/2 20:17, Paolo Bonzini wrote: > When using manual protection of dirty pages, it is not necessary > to protect nested page tab

Re: [RFC PATCH v2 0/2] kvm/arm64: Try stage2 block mapping for host device MMIO

2021-03-31 Thread Keqian Zhu
Kind ping... On 2021/3/16 21:43, Keqian Zhu wrote: > Hi all, > > We have two pathes to build stage2 mapping for MMIO regions. > > Create time's path and stage2 fault path. > > Patch#1 removes the creation time's mapping of MMIO regions > Patch#2 tries stage2

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: [RFC PATCH v1 0/4] vfio: Add IOPF support for VFIO passthrough

2021-03-18 Thread Keqian Zhu
Hi Baolu, On 2021/3/19 8:33, Lu Baolu wrote: > On 3/18/21 7:53 PM, Shenming Lu wrote: >> On 2021/3/18 17:07, Tian, Kevin wrote: From: Shenming Lu Sent: Thursday, March 18, 2021 3:53 PM On 2021/2/4 14:52, Tian, Kevin wrote:>>> In reality, many >>> devices allow I/O faulting

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

[RFC PATCH v2 2/2] kvm/arm64: Try stage2 block mapping for host device MMIO

2021-03-16 Thread Keqian Zhu
perly fit into vma, so we don't check whether the mapping size exceeds the boundary of vma. But for device memory mapping, we should pay attention to this. This adds device_rough_page_shift() to check these two points when selecting block mapping size. Signed-off-by: Keqian Zhu --- Main

[RFC PATCH v2 1/2] kvm/arm64: Remove the creation time's mapping of MMIO regions

2021-03-16 Thread Keqian Zhu
The MMIO regions may be unmapped for many reasons and can be remapped by stage2 fault path. Map MMIO regions at creation time becomes a minor optimization and makes these two mapping path hard to sync. Remove the mapping code while keep the useful sanity check. Signed-off-by: Keqian Zhu

[RFC PATCH v2 0/2] kvm/arm64: Try stage2 block mapping for host device MMIO

2021-03-16 Thread Keqian Zhu
Hi all, We have two pathes to build stage2 mapping for MMIO regions. Create time's path and stage2 fault path. Patch#1 removes the creation time's mapping of MMIO regions Patch#2 tries stage2 block mapping for host device MMIO at fault path Thanks, Keqian Keqian Zhu (2): kvm/arm

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 2/4] KVM: arm64: Use find_vma_intersection()

2021-03-15 Thread Keqian Zhu
Hi Gavin, On 2021/3/16 11:52, Gavin Shan wrote: > Hi Keqian, > > On 3/15/21 8:42 PM, Gavin Shan wrote: >> On 3/15/21 7:04 PM, Keqian Zhu wrote: >>> On 2021/3/15 12:18, Gavin Shan wrote: >>>> find_vma_intersection() has been existing to search the intersec

Re: [PATCH 4/4] KVM: arm64: Don't retrieve memory slot again in page fault handler

2021-03-15 Thread Keqian Zhu
Hi Gavin, On 2021/3/15 17:56, Gavin Shan wrote: > Hi Keqian, > > On 3/15/21 7:25 PM, Keqian Zhu wrote: >> On 2021/3/15 12:18, Gavin Shan wrote: >>> We needn't retrieve the memory slot again in user_mem_abort() because >>> the corresponding memory slot has

Re: [PATCH 4/4] KVM: arm64: Don't retrieve memory slot again in page fault handler

2021-03-15 Thread Keqian Zhu
Hi Gavin, On 2021/3/15 12:18, Gavin Shan wrote: > We needn't retrieve the memory slot again in user_mem_abort() because > the corresponding memory slot has been passed from the caller. This I think you are right, though fault_ipa will be adjusted when we try to use block mapping, the fault_suppor

Re: [PATCH 2/4] KVM: arm64: Use find_vma_intersection()

2021-03-15 Thread Keqian Zhu
Hi Gavin, On 2021/3/15 12:18, Gavin Shan wrote: > find_vma_intersection() has been existing to search the intersected > vma. This uses the function where it's applicable, to simplify the > code. > > Signed-off-by: Gavin Shan > --- > arch/arm64/kvm/mmu.c | 10 ++ > 1 file changed, 6 inse

Re: [PATCH 1/4] KVM: arm64: Hide kvm_mmu_wp_memory_region()

2021-03-15 Thread Keqian Zhu
Hi Gavin, This function is only used by mmu.c in the first commit c64735554c0a, so please feel free to add: Reviewed-by: Keqian Zhu Thanks, Keqian On 2021/3/15 12:18, Gavin Shan wrote: > We needn't expose the function as it's only used by mmu.c. > > Signed-off-by: Gavin

Re: [PATCH 3/4] KVM: arm64: Fix address check for memory slot

2021-03-15 Thread Keqian Zhu
Hi Gavin, FYI, this has been fixed by Marc in commit 262b003d059c. Thanks, Keqian On 2021/3/15 12:18, Gavin Shan wrote: > The last (IPA) page can't be specified when a new memory slot is > added. The error -EFAULT is returned when the memory slot is added > with the following parameters for the

Re: [PATCH] KVM: clean up the unused argument

2021-03-14 Thread Keqian Zhu
This looks OK. The use of vcpu argument is removed in commit d383b3146d80 (KVM: x86: Fix NULL dereference at kvm_msr_ignored_check()) Reviewed-by: Keqian Zhu On 2021/3/13 13:10, lihaiwei.ker...@gmail.com wrote: > From: Haiwei Li > > kvm_msr_ignored_check function never uses vcpu

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

Re: [RFC PATCH] kvm: arm64: Try stage2 block mapping for host device MMIO

2021-03-12 Thread Keqian Zhu
Hi Marc, On 2021/3/12 16:52, Marc Zyngier wrote: > On Thu, 11 Mar 2021 14:28:17 +, > Keqian Zhu wrote: >> >> Hi Marc, >> >> On 2021/3/11 16:43, Marc Zyngier wrote: >>> Digging this patch back from my Inbox... >> Yeah, thanks ;-) >> >>

Re: [RFC PATCH] kvm: arm64: Try stage2 block mapping for host device MMIO

2021-03-11 Thread Keqian Zhu
Hi Marc, On 2021/3/11 16:43, Marc Zyngier wrote: > Digging this patch back from my Inbox... Yeah, thanks ;-) > > On Fri, 22 Jan 2021 08:36:50 +, > Keqian Zhu wrote: >> >> The MMIO region of a device maybe huge (GB level), try to use block >> mapping in stage2

[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 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 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

[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 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 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 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 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 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 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

Re: [RFC PATCH] kvm: arm64: Try stage2 block mapping for host device MMIO

2021-03-02 Thread Keqian Zhu
Hi Marc, Do you have further suggestion on this? Block mapping do bring obvious benefit. Thanks, Keqian On 2021/1/25 19:25, Keqian Zhu wrote: > Hi Marc, > > On 2021/1/22 17:45, Marc Zyngier wrote: >> On 2021-01-22 08:36, Keqian Zhu wrote: >>> The MMIO region of a dev

Re: [RFC PATCH 0/7] kvm: arm64: Implement SW/HW combined dirty log

2021-03-02 Thread Keqian Zhu
Hi everyone, Any comments are welcome :). Thanks, Keqian On 2021/1/26 20:44, Keqian Zhu wrote: > The intention: > > On arm64 platform, we tracking dirty log of vCPU through guest memory abort. > KVM occupys some vCPU time of guest to change stage2 mapping and mark dirty. > This

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-02 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: [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

  1   2   3   >