[RFC PATCH v3 7/8] vfio/type1: Add selective DMA faulting support

2021-04-08 Thread Shenming Lu
directly return with an invalid response. Suggested-by: Kevin Tian Signed-off-by: Shenming Lu --- drivers/vfio/vfio.c | 4 +- drivers/vfio/vfio_iommu_type1.c | 357 +++- include/linux/vfio.h| 1 + 3 files changed, 358 insertions(+), 4

[RFC PATCH v3 6/8] vfio/type1: No need to statically pin and map if IOPF enabled

2021-04-08 Thread Shenming Lu
dirty tracking support in the future. Signed-off-by: Shenming Lu --- drivers/vfio/vfio_iommu_type1.c | 38 +++-- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 7df5711e743a

[RFC PATCH v3 8/8] vfio: Add nested IOPF support

2021-04-08 Thread Shenming Lu
handler (a consolidated one) via flags (set FAULT_REPORT_NESTED_L1), and further deliver the received stage 1 faults in the handler to the guest through a newly added vfio_device_ops callback. Signed-off-by: Shenming Lu --- drivers/vfio/vfio.c | 81

[RFC PATCH v3 3/8] vfio/type1: Add an MMU notifier to avoid pinning

2021-04-08 Thread Shenming Lu
To avoid pinning pages when they are mapped in IOMMU page tables, we add an MMU notifier to tell the addresses which are no longer valid and try to unmap them. Signed-off-by: Shenming Lu --- drivers/vfio/vfio_iommu_type1.c | 112 +++- 1 file changed, 109 insertions

[RFC PATCH v3 5/8] vfio/type1: VFIO_IOMMU_ENABLE_IOPF

2021-04-08 Thread Shenming Lu
is not supported since there may be inflight page faults when disabling. Signed-off-by: Shenming Lu --- drivers/vfio/vfio_iommu_type1.c | 223 +++- include/uapi/linux/vfio.h | 6 + 2 files changed, 226 insertions(+), 3 deletions(-) diff --git a/drivers/vfio

[RFC PATCH v3 4/8] vfio/type1: Pre-map more pages than requested in the IOPF handling

2021-04-08 Thread Shenming Lu
To optimize for fewer page fault handlings, we can pre-map more pages than requested at once. Note that IOPF_PREMAP_LEN is just an arbitrary value for now, which we could try further tuning. Signed-off-by: Shenming Lu --- drivers/vfio/vfio_iommu_type1.c | 131

[RFC PATCH v3 2/8] vfio/type1: Add a page fault handler

2021-04-08 Thread Shenming Lu
VFIO manages the DMA mapping itself. To support IOPF (on-demand paging) for VFIO (IOMMU capable) devices, we add a VFIO page fault handler to serve the reported page faults from the IOMMU driver. Signed-off-by: Shenming Lu --- drivers/vfio/vfio_iommu_type1.c | 114

[RFC PATCH v3 0/8] Add IOPF support for VFIO passthrough

2021-04-08 Thread Shenming Lu
ve DMA Buffer Tracking for Efficient Memory Management in Direct I/O. In USENIX ATC, 2020. [3] https://patchwork.kernel.org/project/linux-arm-kernel/cover/20210401154718.307519-1-jean-phili...@linaro.org/ [4] https://github.com/Linaro/uadk Thanks, Shenming Shenming Lu (8): iommu: Evolve the

[RFC PATCH v3 1/8] iommu: Evolve the device fault reporting framework

2021-04-08 Thread Shenming Lu
not a clean way. In addition, still take VFIO as an example, in nested mode, the 1st level and 2nd level fault reporting may be configured separately and currently each device can only register one iommu dev fault handler, so we add a handler update interface for this. Signed-off-by: Shenming Lu

[PATCH v1] vfio/type1: Remove the almost unused check in vfio_iommu_type1_unpin_pages

2021-04-06 Thread Shenming Lu
ith break. Signed-off-by: Shenming Lu --- drivers/vfio/vfio_iommu_type1.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 45cbfd4879a5..fd4213c41743 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/dri

Re: [PATCH v5 0/6] KVM: arm64: Add VLPI migration support on GICv4.1

2021-03-24 Thread Shenming Lu
On 2021/3/25 2:19, Marc Zyngier wrote: > On Mon, 22 Mar 2021 14:01:52 +0800, Shenming Lu wrote: >> In GICv4.1, migration has been supported except for (directly-injected) >> VLPI. And GICv4.1 Spec explicitly gives a way to get the VLPI's pending >> state (which was crucial

[PATCH v5 6/6] KVM: arm64: GICv4.1: Give a chance to save VLPI state

2021-03-22 Thread Shenming Lu
-off-by: Shenming Lu --- Documentation/virt/kvm/devices/arm-vgic-its.rst | 2 +- arch/arm64/kvm/vgic/vgic-its.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/virt/kvm/devices/arm-vgic-its.rst b/Documentation/virt/kvm/devices/arm-vgic

[PATCH v5 2/6] irqchip/gic-v3-its: Drop the setting of PTZ altogether

2021-03-22 Thread Shenming Lu
efficient to parse the empty VPT. Let's drop the setting of PTZ altogether. Signed-off-by: Shenming Lu --- drivers/irqchip/irq-gic-v3-its.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index

[PATCH v5 4/6] KVM: arm64: GICv4.1: Try to save VLPI state in save_pending_tables

2021-03-22 Thread Shenming Lu
off-by: Shenming Lu --- arch/arm64/kvm/vgic/vgic-v3.c | 66 +++ 1 file changed, 60 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kvm/vgic/vgic-v3.c b/arch/arm64/kvm/vgic/vgic-v3.c index 6f530925a231..41ecf219c333 100644 --- a/arch/arm64/kvm/vgic/vgic-v3.c +++ b/arch/ar

[PATCH v5 3/6] KVM: arm64: GICv4.1: Add function to get VLPI state

2021-03-22 Thread Shenming Lu
With GICv4.1 and the vPE unmapped, which indicates the invalidation of any VPT caches associated with the vPE, we can get the VLPI state by peeking at the VPT. So we add a function for this. Signed-off-by: Shenming Lu --- arch/arm64/kvm/vgic/vgic-v4.c | 19 +++ arch/arm64/kvm

[PATCH v5 1/6] irqchip/gic-v3-its: Add a cache invalidation right after vPE unmapping

2021-03-22 Thread Shenming Lu
From: Marc Zyngier Since there may be a direct read from the CPU side to the VPT after unmapping the vPE, we add a cache coherency maintenance at the end of its_vpe_irq_domain_deactivate() to ensure the validity of the VPT read later. Signed-off-by: Marc Zyngier Signed-off-by: Shenming Lu

[PATCH v5 5/6] KVM: arm64: GICv4.1: Restore VLPI pending state to physical side

2021-03-22 Thread Shenming Lu
t; to trigger a VLPI to pending. Signed-off-by: Zenghui Yu Signed-off-by: Shenming Lu --- arch/arm64/kvm/vgic/vgic-v4.c | 19 +++ 1 file changed, 19 insertions(+) diff --git a/arch/arm64/kvm/vgic/vgic-v4.c b/arch/arm64/kvm/vgic/vgic-v4.c index ac029ba3d337..c1845d8f5f7e 100644 --- a/a

[PATCH v5 0/6] KVM: arm64: Add VLPI migration support on GICv4.1

2021-03-22 Thread Shenming Lu
- Check all get_vlpi_state related conditions in save_pending_tables in one place. - Nit fixes. v1 -> v2: - Get the VLPI state from the KVM side. - Nit fixes. Thanks, Shenming Marc Zyngier (1): irqchip/gic-v3-its: Add a cache invalidation right after vPE unmapping Shenming Lu (4):

Re: [RFC PATCH v1 0/4] vfio: Add IOPF support for VFIO passthrough

2021-03-18 Thread Shenming Lu
On 2021/3/18 20:32, Tian, Kevin wrote: >> From: Shenming Lu >> Sent: Thursday, March 18, 2021 7:54 PM >> >> On 2021/3/18 17:07, Tian, Kevin wrote: >>>> From: Shenming Lu >>>> Sent: Thursday, March 18, 2021 3:53 PM >>>> &g

Re: [RFC PATCH v1 0/4] vfio: Add IOPF support for VFIO passthrough

2021-03-18 Thread Shenming Lu
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 only in selective contexts. However, there >&

Re: [RFC PATCH v1 0/4] vfio: Add IOPF support for VFIO passthrough

2021-03-18 Thread Shenming Lu
On 2021/2/4 14:52, Tian, Kevin wrote:>>> In reality, many >>> devices allow I/O faulting only in selective contexts. However, there >>> is no standard way (e.g. PCISIG) for the device to report whether >>> arbitrary I/O fault is allowed. Then we may have to maintain device >>> specific knowledge

Re: [PATCH v4 5/6] KVM: arm64: GICv4.1: Restore VLPI pending state to physical side

2021-03-15 Thread Shenming Lu
On 2021/3/15 17:20, Marc Zyngier wrote: > On 2021-03-15 09:11, Shenming Lu wrote: >> On 2021/3/15 16:30, Marc Zyngier wrote: >>> On 2021-03-13 08:38, Shenming Lu wrote: >>>> From: Zenghui Yu >>>> >>>> When setting the forwarding path of a V

Re: [PATCH v4 5/6] KVM: arm64: GICv4.1: Restore VLPI pending state to physical side

2021-03-15 Thread Shenming Lu
On 2021/3/15 16:30, Marc Zyngier wrote: > On 2021-03-13 08:38, Shenming Lu wrote: >> From: Zenghui Yu >> >> When setting the forwarding path of a VLPI (switch to the HW mode), >> we can also transfer the pending state from irq->pending_latch to >> VPT (especia

[PATCH v4 4/6] KVM: arm64: GICv4.1: Try to save VLPI state in save_pending_tables

2021-03-13 Thread Shenming Lu
off-by: Shenming Lu --- arch/arm64/kvm/vgic/vgic-v3.c | 66 +++ 1 file changed, 60 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kvm/vgic/vgic-v3.c b/arch/arm64/kvm/vgic/vgic-v3.c index 52915b342351..359d4dc35264 100644 --- a/arch/arm64/kvm/vgic/vgic-v3.c +++ b/arch/ar

[PATCH v4 6/6] KVM: arm64: GICv4.1: Give a chance to save VLPI state

2021-03-13 Thread Shenming Lu
-off-by: Shenming Lu --- Documentation/virt/kvm/devices/arm-vgic-its.rst | 2 +- arch/arm64/kvm/vgic/vgic-its.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/virt/kvm/devices/arm-vgic-its.rst b/Documentation/virt/kvm/devices/arm-vgic

[PATCH v4 3/6] KVM: arm64: GICv4.1: Add function to get VLPI state

2021-03-13 Thread Shenming Lu
With GICv4.1 and the vPE unmapped, which indicates the invalidation of any VPT caches associated with the vPE, we can get the VLPI state by peeking at the VPT. So we add a function for this. Signed-off-by: Shenming Lu --- arch/arm64/kvm/vgic/vgic-v4.c | 19 +++ arch/arm64/kvm

[PATCH v4 2/6] irqchip/gic-v3-its: Drop the setting of PTZ altogether

2021-03-13 Thread Shenming Lu
efficient to parse the empty VPT. Let's drop the setting of PTZ altogether. Signed-off-by: Shenming Lu --- drivers/irqchip/irq-gic-v3-its.c | 12 ++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index

[PATCH v4 5/6] KVM: arm64: GICv4.1: Restore VLPI pending state to physical side

2021-03-13 Thread Shenming Lu
t; to trigger a VLPI to pending. Signed-off-by: Zenghui Yu Signed-off-by: Shenming Lu --- arch/arm64/kvm/vgic/vgic-v4.c | 18 ++ 1 file changed, 18 insertions(+) diff --git a/arch/arm64/kvm/vgic/vgic-v4.c b/arch/arm64/kvm/vgic/vgic-v4.c index ac029ba3d337..3b82ab80c2f3 100644 --- a/a

[PATCH v4 0/6] KVM: arm64: Add VLPI migration support on GICv4.1

2021-03-13 Thread Shenming Lu
- Nit fixes. v1 -> v2: - Get the VLPI state from the KVM side. - Nit fixes. Thanks, Shenming Marc Zyngier (1): irqchip/gic-v3-its: Add a cache invalidation right after vPE unmapping Shenming Lu (4): irqchip/gic-v3-its: Drop the setting of PTZ altogether KVM: arm64: GICv4.1: Add functi

[PATCH v4 1/6] irqchip/gic-v3-its: Add a cache invalidation right after vPE unmapping

2021-03-13 Thread Shenming Lu
From: Marc Zyngier Since there may be a direct read from the CPU side to the VPT after unmapping the vPE, we add a cache coherency maintenance at the end of its_vpe_irq_domain_deactivate() to ensure the validity of the VPT read later. Signed-off-by: Marc Zyngier Signed-off-by: Shenming Lu

Re: [PATCH v3 3/4] KVM: arm64: GICv4.1: Restore VLPI's pending state to physical side

2021-03-12 Thread Shenming Lu
On 2021/3/12 20:02, Marc Zyngier wrote: > On Fri, 12 Mar 2021 11:34:07 +, > Shenming Lu wrote: >> >> On 2021/3/12 19:10, Marc Zyngier wrote: >>> On Fri, 12 Mar 2021 10:48:29 +, >>> Shenming Lu wrote: >>>> >>>> On 2021/3/12 1

Re: [PATCH v3 3/4] KVM: arm64: GICv4.1: Restore VLPI's pending state to physical side

2021-03-12 Thread Shenming Lu
On 2021/3/12 19:10, Marc Zyngier wrote: > On Fri, 12 Mar 2021 10:48:29 +, > Shenming Lu wrote: >> >> On 2021/3/12 17:05, Marc Zyngier wrote: >>> On Thu, 11 Mar 2021 12:32:07 +, >>> Shenming Lu wrote: >>>> >>>> On 2021/3/11 1

Re: [PATCH v3 3/4] KVM: arm64: GICv4.1: Restore VLPI's pending state to physical side

2021-03-12 Thread Shenming Lu
On 2021/3/12 17:05, Marc Zyngier wrote: > On Thu, 11 Mar 2021 12:32:07 +, > Shenming Lu wrote: >> >> On 2021/3/11 17:14, Marc Zyngier wrote: >>> On Wed, 27 Jan 2021 12:13:36 +, >>> Shenming Lu wrote: >>>> >>>> From: Zenghui Yu

Re: [PATCH v3 2/4] KVM: arm64: GICv4.1: Try to save hw pending state in save_pending_tables

2021-03-12 Thread Shenming Lu
On 2021/3/12 17:02, Marc Zyngier wrote: > On Thu, 11 Mar 2021 12:31:48 +, > Shenming Lu wrote: >> >> On 2021/3/11 17:09, Marc Zyngier wrote: > >>> I have asked that question in the past: is it actually safe to remap >>> the vPEs and expect them to be

Re: [PATCH v3 3/4] KVM: arm64: GICv4.1: Restore VLPI's pending state to physical side

2021-03-11 Thread Shenming Lu
On 2021/3/11 17:14, Marc Zyngier wrote: > On Wed, 27 Jan 2021 12:13:36 +, > Shenming Lu wrote: >> >> From: Zenghui Yu >> >> When setting the forwarding path of a VLPI (switch to the HW mode), >> we could also transfer the pending state from irq-

Re: [PATCH v3 2/4] KVM: arm64: GICv4.1: Try to save hw pending state in save_pending_tables

2021-03-11 Thread Shenming Lu
On 2021/3/11 17:09, Marc Zyngier wrote: > On Wed, 27 Jan 2021 12:13:35 +, > Shenming Lu wrote: >> >> After pausing all vCPUs and devices capable of interrupting, in order >> to save the information of all interrupts, besides flushing the pending >> states in kv

Re: [PATCH v3 1/4] KVM: arm64: GICv4.1: Add function to get VLPI state

2021-03-11 Thread Shenming Lu
On 2021/3/11 16:57, Marc Zyngier wrote: > On Wed, 27 Jan 2021 12:13:34 +, > Shenming Lu wrote: >> >> With GICv4.1 and the vPE unmapped, which indicates the invalidation >> of any VPT caches associated with the vPE, we can get the VLPI state >> by peeking at

Re: [PATCH v3 0/4] KVM: arm64: Add VLPI migration support on GICv4.1

2021-03-10 Thread Shenming Lu
Hi, Sorry to bother again, I am really hoping a response for this series. :-) Thanks, Shenming On 2021/2/26 16:58, Shenming Lu wrote: > Hi Marc, > > Gentle ping. Does this series need any further modification? Wish you can > pick it up. :-) > > Thanks, > Shenming &g

Re: [RFC PATCH v2 1/6] iommu: Evolve to support more scenarios of using IOPF

2021-03-09 Thread Shenming Lu
Hi Baolu, On 2021/3/10 10:09, Lu Baolu wrote: > Hi Shenming, > > On 3/9/21 2:22 PM, Shenming Lu wrote: >> This patch follows the discussion here: >> >> https://lore.kernel.org/linux-acpi/YAaxjmJW+ZMvrhac@myrica/ >> >> In order to support more s

[RFC PATCH v2 6/6] vfio: Add nested IOPF support

2021-03-08 Thread Shenming Lu
handler (a combined one) via flags (set IOPF_REPORT_NESTED_L1_CONCERNED), and further deliver the received stage 1 faults in the handler to the guest through a newly added vfio_device_ops callback. Signed-off-by: Shenming Lu --- drivers/vfio/vfio.c | 83

[RFC PATCH v2 4/6] vfio: VFIO_IOMMU_ENABLE_IOPF

2021-03-08 Thread Shenming Lu
is not supported since there may be inflight page faults when disabling. Signed-off-by: Shenming Lu --- drivers/vfio/vfio_iommu_type1.c | 139 +++- include/uapi/linux/vfio.h | 6 ++ 2 files changed, 142 insertions(+), 3 deletions(-) diff --git a/drivers/vfio

[RFC PATCH v2 2/6] vfio: Add an MMU notifier to avoid pinning

2021-03-08 Thread Shenming Lu
To avoid pinning pages when they are mapped in IOMMU page tables, we add an MMU notifier to tell the addresses which are no longer valid and try to unmap them. Signed-off-by: Shenming Lu --- drivers/vfio/vfio_iommu_type1.c | 68 + 1 file changed, 68 insertions

[RFC PATCH v2 5/6] vfio: No need to statically pin and map if IOPF enabled

2021-03-08 Thread Shenming Lu
If IOPF enabled for the VFIO container, there is no need to statically pin and map the entire DMA range, we can do it on demand. And unmap according to the IOPF mapped bitmap when removing vfio_dma. Signed-off-by: Shenming Lu --- drivers/vfio/vfio_iommu_type1.c | 35

[RFC PATCH v2 1/6] iommu: Evolve to support more scenarios of using IOPF

2021-03-08 Thread Shenming Lu
be interested in only one level. Signed-off-by: Shenming Lu --- .../iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 3 +- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 11 ++-- drivers/iommu/io-pgfault.c| 4 -- drivers/iommu/iommu.c | 56

[RFC PATCH v2 3/6] vfio: Add a page fault handler

2021-03-08 Thread Shenming Lu
VFIO manages the DMA mapping itself. To support IOPF for VFIO devices, we add a VFIO page fault handler to serve the reported page faults from the IOMMU driver. Besides, we can pre-map more pages than requested at once to optimize for fewer page fault handlings. Signed-off-by: Shenming Lu

[RFC PATCH v2 0/6] Add IOPF support for VFIO passthrough

2021-03-08 Thread Shenming Lu
nts and suggestions are very welcome. :-) Thanks, Shenming Shenming Lu (6): iommu: Evolve to support more scenarios of using IOPF vfio: Add an MMU notifier to avoid pinning vfio: Add a page fault handler vfio: VFIO_IOMMU_ENABLE_IOPF vfio: No need to statically pin and map if IOPF enab

Re: [PATCH v3 0/4] KVM: arm64: Add VLPI migration support on GICv4.1

2021-02-26 Thread Shenming Lu
Hi Marc, Gentle ping. Does this series need any further modification? Wish you can pick it up. :-) Thanks, Shenming On 2021/1/27 20:13, Shenming Lu wrote: > Hi Marc, sorry for the late commit. > > In GICv4.1, migration has been supported except for (directly-injected) > VLPI. And

Re: [PATCH v11 04/13] vfio/pci: Add VFIO_REGION_TYPE_NESTED region type

2021-02-23 Thread Shenming Lu
> +static int vfio_pci_dma_fault_init(struct vfio_pci_device *vdev) > +{ > + struct vfio_region_dma_fault *header; > + struct iommu_domain *domain; > + size_t size; > + bool nested; > + int ret; > + > + domain = iommu_get_domain_for_dev(>pdev->dev); > + ret =

Re: [RFC PATCH v1 0/4] vfio: Add IOPF support for VFIO passthrough

2021-02-10 Thread Shenming Lu
On 2021/2/9 19:06, Liu, Yi L wrote: >> From: Tian, Kevin >> Sent: Thursday, February 4, 2021 2:52 PM >> >>> From: Shenming Lu >>> Sent: Tuesday, February 2, 2021 2:42 PM >>> >>> On 2021/2/1 15:56, Tian, Kevin wrote: >>>>>

Re: [RFC PATCH v1 0/4] vfio: Add IOPF support for VFIO passthrough

2021-02-07 Thread Shenming Lu
On 2021/2/7 16:20, Tian, Kevin wrote: >> From: Jean-Philippe Brucker >> Sent: Friday, February 5, 2021 6:37 PM >> >> Hi, >> >> On Thu, Feb 04, 2021 at 06:52:10AM +, Tian, Kevin wrote: >>> The static pinning and mapping problem in VFIO and possible >> solutions >>> have been discussed

Re: [RFC PATCH v1 0/4] vfio: Add IOPF support for VFIO passthrough

2021-02-01 Thread Shenming Lu
On 2021/2/1 15:56, Tian, Kevin wrote: >> From: Alex Williamson >> Sent: Saturday, January 30, 2021 6:58 AM >> >> On Mon, 25 Jan 2021 17:03:58 +0800 >> Shenming Lu wrote: >> >>> Hi, >>> >>> The static pinning and mapping problem in

Re: [RFC PATCH v1 0/4] vfio: Add IOPF support for VFIO passthrough

2021-01-30 Thread Shenming Lu
On 2021/1/30 6:57, Alex Williamson wrote: > On Mon, 25 Jan 2021 17:03:58 +0800 > Shenming Lu wrote: > >> Hi, >> >> The static pinning and mapping problem in VFIO and possible solutions >> have been discussed a lot [1, 2]. One of the solutions is to add I/O >&

Re: [RFC PATCH v1 3/4] vfio: Try to enable IOPF for VFIO devices

2021-01-30 Thread Shenming Lu
On 2021/1/30 6:42, Alex Williamson wrote: > On Mon, 25 Jan 2021 17:04:01 +0800 > Shenming Lu wrote: > >> If IOMMU_DEV_FEAT_IOPF is set for the VFIO device, which means that >> the delivering of page faults of this device from the IOMMU is enabled, >> we register

Re: [RFC PATCH v1 1/4] vfio/type1: Add a bitmap to track IOPF mapped pages

2021-01-30 Thread Shenming Lu
On 2021/1/30 6:58, Alex Williamson wrote: > On Mon, 25 Jan 2021 17:03:59 +0800 > Shenming Lu wrote: > >> When IOPF enabled, the pages are pinned and mapped on demand, we add >> a bitmap to track them. >> >> Signed-off-by: Shenming Lu >> --- &

Re: [RFC PATCH v1 2/4] vfio: Add a page fault handler

2021-01-27 Thread Shenming Lu
On 2021/1/28 1:42, Christoph Hellwig wrote: > On Mon, Jan 25, 2021 at 05:04:00PM +0800, Shenming Lu wrote: >> +EXPORT_SYMBOL_GPL(vfio_iommu_dev_fault_handler); > > This function is only used in vfio.c itself, so it should not be > exported, but rather marked static. > . >

[PATCH v3 0/4] KVM: arm64: Add VLPI migration support on GICv4.1

2021-01-27 Thread Shenming Lu
fixes. Thanks, Shenming Shenming Lu (3): KVM: arm64: GICv4.1: Add function to get VLPI state KVM: arm64: GICv4.1: Try to save hw pending state in save_pending_tables KVM: arm64: GICv4.1: Give a chance to save VLPI's pending state Zenghui Yu (1): KVM: arm64: GICv4.1: Restore VLPI's pending

[PATCH v3 1/4] KVM: arm64: GICv4.1: Add function to get VLPI state

2021-01-27 Thread Shenming Lu
With GICv4.1 and the vPE unmapped, which indicates the invalidation of any VPT caches associated with the vPE, we can get the VLPI state by peeking at the VPT. So we add a function for this. Signed-off-by: Shenming Lu --- arch/arm64/kvm/vgic/vgic-v4.c | 19 +++ arch/arm64/kvm

[PATCH v3 2/4] KVM: arm64: GICv4.1: Try to save hw pending state in save_pending_tables

2021-01-27 Thread Shenming Lu
off-by: Shenming Lu --- arch/arm64/kvm/vgic/vgic-v3.c | 61 +++ 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kvm/vgic/vgic-v3.c b/arch/arm64/kvm/vgic/vgic-v3.c index 52915b342351..06b1162b7a0a 100644 --- a/arch/arm64/kvm/vgic/vgic-v3.c ++

[PATCH v3 3/4] KVM: arm64: GICv4.1: Restore VLPI's pending state to physical side

2021-01-27 Thread Shenming Lu
t; to trigger a VLPI to pending. Signed-off-by: Zenghui Yu Signed-off-by: Shenming Lu --- arch/arm64/kvm/vgic/vgic-v4.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/arch/arm64/kvm/vgic/vgic-v4.c b/arch/arm64/kvm/vgic/vgic-v4.c index ac029ba3d337..a3542af6f04a 100644 --- a/a

[PATCH v3 4/4] KVM: arm64: GICv4.1: Give a chance to save VLPI's pending state

2021-01-27 Thread Shenming Lu
the UAPI). Signed-off-by: Shenming Lu --- Documentation/virt/kvm/devices/arm-vgic-its.rst | 2 +- arch/arm64/kvm/vgic/vgic-its.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/virt/kvm/devices/arm-vgic-its.rst b/Documentation/virt/kvm/devices

[RFC PATCH v1 0/4] vfio: Add IOPF support for VFIO passthrough

2021-01-26 Thread Shenming Lu
ver/20201116110030.32335-1-eric.au...@redhat.com/ Thanks, Shenming Shenming Lu (4): vfio/type1: Add a bitmap to track IOPF mapped pages vfio: Add a page fault handler vfio: Try to enable IOPF for VFIO devices vfio: Allow to pin and map dynamically drivers/vfio/vfio.c |

[RFC PATCH v1 1/4] vfio/type1: Add a bitmap to track IOPF mapped pages

2021-01-25 Thread Shenming Lu
When IOPF enabled, the pages are pinned and mapped on demand, we add a bitmap to track them. Signed-off-by: Shenming Lu --- drivers/vfio/vfio_iommu_type1.c | 12 1 file changed, 12 insertions(+) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index

[RFC PATCH v1 4/4] vfio: Allow to pin and map dynamically

2021-01-25 Thread Shenming Lu
If IOPF enabled for the whole VFIO container, there is no need to statically pin and map the entire DMA range, we can do it on demand. And unmap and unpin according to the IOPF mapped bitmap when removing the DMA mapping. Signed-off-by: Shenming Lu --- drivers/vfio/vfio.c | 20

[RFC PATCH v1 2/4] vfio: Add a page fault handler

2021-01-25 Thread Shenming Lu
VFIO manages the passthrough DMA mapping itself. In order to support IOPF for VFIO devices, we need to add a VFIO page fault handler to serve the reported page faults from the IOMMU driver. Signed-off-by: Shenming Lu --- drivers/vfio/vfio.c | 35 drivers/vfio

[RFC PATCH v1 3/4] vfio: Try to enable IOPF for VFIO devices

2021-01-25 Thread Shenming Lu
-off-by: Shenming Lu --- drivers/vfio/vfio.c | 20 1 file changed, 20 insertions(+) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c index ff7797260d0f..fd885d99ee0f 100644 --- a/drivers/vfio/vfio.c +++ b/drivers/vfio/vfio.c @@ -97,6 +97,7 @@ struct vfio_device

Re: [RFC PATCH v2 2/4] KVM: arm64: GICv4.1: Try to save hw pending state in save_pending_tables

2021-01-05 Thread Shenming Lu
On 2021/1/5 21:47, Marc Zyngier wrote: > On 2021-01-05 13:02, Shenming Lu wrote: >> On 2021/1/5 17:13, Marc Zyngier wrote: >>> On 2021-01-04 08:16, Shenming Lu wrote: >>>> After pausing all vCPUs and devices capable of interrupting, in order >>>> to save

Re: [RFC PATCH v2 2/4] KVM: arm64: GICv4.1: Try to save hw pending state in save_pending_tables

2021-01-05 Thread Shenming Lu
On 2021/1/5 19:40, Marc Zyngier wrote: > On 2021-01-05 09:13, Marc Zyngier wrote: >> On 2021-01-04 08:16, Shenming Lu wrote: >>> After pausing all vCPUs and devices capable of interrupting, in order >>> to save the information of all interrupts, besides flushing the

Re: [RFC PATCH v2 3/4] KVM: arm64: GICv4.1: Restore VLPI's pending state to physical side

2021-01-05 Thread Shenming Lu
On 2021/1/5 17:25, Marc Zyngier wrote: > On 2021-01-04 08:16, Shenming Lu wrote: >> From: Zenghui Yu >> >> When setting the forwarding path of a VLPI (switch to the HW mode), >> we could also transfer the pending state from irq->pending_latch to >> VPT (especia

Re: [RFC PATCH v2 2/4] KVM: arm64: GICv4.1: Try to save hw pending state in save_pending_tables

2021-01-05 Thread Shenming Lu
On 2021/1/5 17:13, Marc Zyngier wrote: > On 2021-01-04 08:16, Shenming Lu wrote: >> After pausing all vCPUs and devices capable of interrupting, in order >> to save the information of all interrupts, besides flushing the pending >> states in kvm’s vgic, we also try to flus

[RFC PATCH v2 0/4] KVM: arm64: Add VLPI migration support on GICv4.1

2021-01-04 Thread Shenming Lu
Nit fixes. Since there seems to be no better place to transfer the pending states in patch 3, we just keep it unchanged. Thanks, Shenming Shenming Lu (3): KVM: arm64: GICv4.1: Add function to get VLPI state KVM: arm64: GICv4.1: Try to save hw pending state in save_pending_tables KVM: ar

[RFC PATCH v2 1/4] KVM: arm64: GICv4.1: Add function to get VLPI state

2021-01-04 Thread Shenming Lu
With GICv4.1 and the vPE unmapped, which indicates the invalidation of any VPT caches associated with the vPE, we can get the VLPI state by peeking at the VPT. So we add a function for this. Signed-off-by: Shenming Lu --- arch/arm64/kvm/vgic/vgic-v4.c | 24 arch/arm64

[RFC PATCH v2 2/4] KVM: arm64: GICv4.1: Try to save hw pending state in save_pending_tables

2021-01-04 Thread Shenming Lu
the vPEs first. Signed-off-by: Shenming Lu --- arch/arm64/kvm/vgic/vgic-v3.c | 58 +++ 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kvm/vgic/vgic-v3.c b/arch/arm64/kvm/vgic/vgic-v3.c index 9cdf39a94a63..a58c94127cb0 100644 --- a/arch

[RFC PATCH v2 3/4] KVM: arm64: GICv4.1: Restore VLPI's pending state to physical side

2021-01-04 Thread Shenming Lu
t; to trigger a VLPI to pending. Signed-off-by: Zenghui Yu Signed-off-by: Shenming Lu --- arch/arm64/kvm/vgic/vgic-v4.c | 12 1 file changed, 12 insertions(+) diff --git a/arch/arm64/kvm/vgic/vgic-v4.c b/arch/arm64/kvm/vgic/vgic-v4.c index f211a7c32704..7945d6d09cdd 100644 --- a/arch/a

[RFC PATCH v2 4/4] KVM: arm64: GICv4.1: Give a chance to save VLPI's pending state

2021-01-04 Thread Shenming Lu
the UAPI). Signed-off-by: Shenming Lu --- Documentation/virt/kvm/devices/arm-vgic-its.rst | 2 +- arch/arm64/kvm/vgic/vgic-its.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/virt/kvm/devices/arm-vgic-its.rst b/Documentation/virt/kvm/devices

Re: [PATCH RFC] KVM: arm64: vgic: Decouple the check of the EnableLPIs bit from the ITS LPI translation

2020-12-31 Thread Shenming Lu
On 2020/12/31 20:22, Marc Zyngier wrote: > On 2020-12-31 11:58, Shenming Lu wrote: >> On 2020/12/31 16:57, Marc Zyngier wrote: >>> Hi Shemming, >>> >>> On 2020-12-31 06:28, Shenming Lu wrote: >>>> When the EnableLPIs bit is set to 0, any ITS LPI req

Re: [PATCH RFC] KVM: arm64: vgic: Decouple the check of the EnableLPIs bit from the ITS LPI translation

2020-12-31 Thread Shenming Lu
On 2020/12/31 16:57, Marc Zyngier wrote: > Hi Shemming, > > On 2020-12-31 06:28, Shenming Lu wrote: >> When the EnableLPIs bit is set to 0, any ITS LPI requests in the >> Redistributor would be ignored. And this check is independent from >> the ITS LPI translation. So

[PATCH RFC] KVM: arm64: vgic: Decouple the check of the EnableLPIs bit from the ITS LPI translation

2020-12-30 Thread Shenming Lu
cache. Besides it seems that by this the invalidating of the translation cache caused by the LPI disabling is unnecessary. Not sure if I have missed something... Thanks. Signed-off-by: Shenming Lu --- arch/arm64/kvm/vgic/vgic-its.c | 9 + arch/arm64/kvm/vgic/vgic-mmio-v3.c | 4

Re: [RFC PATCH v1 3/4] KVM: arm64: GICv4.1: Restore VLPI's pending state to physical side

2020-12-16 Thread Shenming Lu
On 2020/12/16 18:35, Auger Eric wrote: > Hi Shenming, > > On 12/1/20 1:15 PM, Shenming Lu wrote: >> On 2020/12/1 19:50, Marc Zyngier wrote: >>> On 2020-12-01 11:40, Shenming Lu wrote: >>>> On 2020/12/1 18:55, Marc Zyngier wrote: >>>>> On

[irqchip: irq/irqchip-next] irqchip/gic-v4.1: Reduce the delay when polling GICR_VPENDBASER.Dirty

2020-12-11 Thread irqchip-bot for Shenming Lu
The following commit has been merged into the irq/irqchip-next branch of irqchip: Commit-ID: 0b39498230ae53e6af981141be99f4c7d5144de6 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/0b39498230ae53e6af981141be99f4c7d5144de6 Author:Shenming Lu

Re: [RFC PATCH v1 3/4] KVM: arm64: GICv4.1: Restore VLPI's pending state to physical side

2020-12-08 Thread Shenming Lu
On 2020/12/1 20:15, Shenming Lu wrote: > On 2020/12/1 19:50, Marc Zyngier wrote: >> On 2020-12-01 11:40, Shenming Lu wrote: >>> On 2020/12/1 18:55, Marc Zyngier wrote: >>>> On 2020-11-30 07:23, Shenming Lu wrote: >>>> >>>> Hi Shenming, &g

Re: [RFC PATCH v1 3/4] KVM: arm64: GICv4.1: Restore VLPI's pending state to physical side

2020-12-01 Thread Shenming Lu
On 2020/12/1 19:50, Marc Zyngier wrote: > On 2020-12-01 11:40, Shenming Lu wrote: >> On 2020/12/1 18:55, Marc Zyngier wrote: >>> On 2020-11-30 07:23, Shenming Lu wrote: >>> >>> Hi Shenming, >>> >>>> We are pondering over this pro

Re: [RFC PATCH v1 3/4] KVM: arm64: GICv4.1: Restore VLPI's pending state to physical side

2020-12-01 Thread Shenming Lu
On 2020/12/1 18:55, Marc Zyngier wrote: > On 2020-11-30 07:23, Shenming Lu wrote: > > Hi Shenming, > >> We are pondering over this problem these days, but still don't get a >> good solution... >> Could you give us some advice on this? >> >> Or could w

Re: [PATCH v2 2/2] KVM: arm64: Delay the execution of the polling on the GICR_VPENDBASER.Dirty bit

2020-11-30 Thread Shenming Lu
On 2020/11/30 19:22, Marc Zyngier wrote: > On 2020-11-28 14:18, Shenming Lu wrote: >> In order to further reduce the impact of the wait delay of the >> VPT analysis, we can delay the execution of the polling on the >> GICR_VPENDBASER.Dirty bit (call it from k

Re: [RFC PATCH v1 3/4] KVM: arm64: GICv4.1: Restore VLPI's pending state to physical side

2020-11-29 Thread Shenming Lu
On 2020/11/24 21:12, Shenming Lu wrote: > On 2020/11/24 16:44, Marc Zyngier wrote: >> On 2020-11-24 08:10, Shenming Lu wrote: >>> On 2020/11/23 17:27, Marc Zyngier wrote: >>>> On 2020-11-23 06:54, Shenming Lu wrote: >>>>> From: Zenghui Yu >>&

[PATCH v2 2/2] KVM: arm64: Delay the execution of the polling on the GICR_VPENDBASER.Dirty bit

2020-11-28 Thread Shenming Lu
-by: Shenming Lu --- arch/arm64/kvm/vgic/vgic-v4.c | 16 arch/arm64/kvm/vgic/vgic.c | 3 +++ drivers/irqchip/irq-gic-v3-its.c | 16 drivers/irqchip/irq-gic-v4.c | 11 +++ include/kvm/arm_vgic.h | 3 +++ include/linux/irqchip

[PATCH v2 0/2] KVM: arm64: Optimize the wait for the completion of the VPT analysis

2020-11-28 Thread Shenming Lu
path. Shenming Lu (2): irqchip/gic-v4.1: Reduce the delay time of the poll on the GICR_VPENDBASER.Dirty bit KVM: arm64: Delay the execution of the polling on the GICR_VPENDBASER.Dirty bit arch/arm64/kvm/vgic/vgic-v4.c | 16 arch/arm64/kvm/vgic/vgic.c | 3

[PATCH v2 1/2] irqchip/gic-v4.1: Reduce the delay time of the poll on the GICR_VPENDBASER.Dirty bit

2020-11-28 Thread Shenming Lu
The 10 delay_us of the poll on the GICR_VPENDBASER.Dirty bit is too high, which might greatly affect the total scheduling latency of a vCPU in our measurement. So we reduce it to 1 to lessen the impact. Signed-off-by: Shenming Lu --- drivers/irqchip/irq-gic-v3-its.c | 2 +- 1 file changed, 1

Re: [PATCH] irqchip/gic-v4.1: Optimize the wait for the completion of the analysis of the VPT

2020-11-27 Thread Shenming Lu
On 2020/11/28 3:35, Marc Zyngier wrote: > Shenming, > > Somehow this patch ended up in the wrong folder. > Apologies for the delay reviewing it.> > On 2020-09-23 07:35, Shenming Lu wrote: >> Right after a vPE is made resident, the code starts polling the >> G

Re: [RFC PATCH v1 3/4] KVM: arm64: GICv4.1: Restore VLPI's pending state to physical side

2020-11-24 Thread Shenming Lu
On 2020/11/24 16:44, Marc Zyngier wrote: > On 2020-11-24 08:10, Shenming Lu wrote: >> On 2020/11/23 17:27, Marc Zyngier wrote: >>> On 2020-11-23 06:54, Shenming Lu wrote: >>>> From: Zenghui Yu >>>> >>>> When setting the forwarding path of

Re: [RFC PATCH v1 2/4] KVM: arm64: GICv4.1: Try to save hw pending state in save_pending_tables

2020-11-24 Thread Shenming Lu
On 2020/11/24 16:26, Marc Zyngier wrote: > On 2020-11-24 07:40, Shenming Lu wrote: >> On 2020/11/23 17:18, Marc Zyngier wrote: >>> On 2020-11-23 06:54, Shenming Lu wrote: >>>> After pausing all vCPUs and devices capable of interrupting, in order >>>  

Re: [RFC PATCH v1 3/4] KVM: arm64: GICv4.1: Restore VLPI's pending state to physical side

2020-11-24 Thread Shenming Lu
On 2020/11/23 17:27, Marc Zyngier wrote: > On 2020-11-23 06:54, Shenming Lu wrote: >> From: Zenghui Yu >> >> When setting the forwarding path of a VLPI, it is more consistent to > > I'm not sure it is more consistent. It is a *new* behaviour, because it only > ma

Re: [RFC PATCH v1 2/4] KVM: arm64: GICv4.1: Try to save hw pending state in save_pending_tables

2020-11-23 Thread Shenming Lu
On 2020/11/23 17:18, Marc Zyngier wrote: > On 2020-11-23 06:54, Shenming Lu wrote: >> After pausing all vCPUs and devices capable of interrupting, in order >     ^ > See my comment below about this. > >> to save the information of all interrupts, besi

Re: [RFC PATCH v1 1/4] irqchip/gic-v4.1: Plumb get_irqchip_state VLPI callback

2020-11-23 Thread Shenming Lu
On 2020/11/23 17:01, Marc Zyngier wrote: > On 2020-11-23 06:54, Shenming Lu wrote: >> From: Zenghui Yu >> >> Up to now, the irq_get_irqchip_state() callback of its_irq_chip >> leaves unimplemented since there is no architectural way to get >> the VLPI's p

[RFC PATCH v1 3/4] KVM: arm64: GICv4.1: Restore VLPI's pending state to physical side

2020-11-22 Thread Shenming Lu
rigger a VLPI to pending. Signed-off-by: Zenghui Yu Signed-off-by: Shenming Lu --- arch/arm64/kvm/vgic/vgic-v4.c | 12 1 file changed, 12 insertions(+) diff --git a/arch/arm64/kvm/vgic/vgic-v4.c b/arch/arm64/kvm/vgic/vgic-v4.c index b5fa73c9fd35..cc3ab9cea182 100644 --- a/arch/arm64/kvm

[RFC PATCH v1 0/4] KVM: arm64: Add VLPI migration support on GICv4.1

2020-11-22 Thread Shenming Lu
: Set the priority of VFIO VM state change handler explicitly: https://patchwork.ozlabs.org/patch/1401280/ Shenming Lu (2): KVM: arm64: GICv4.1: Try to save hw pending state in save_pending_tables KVM: arm64: GICv4.1: Give a chance to save VLPI's pending state Zenghui Yu (2): irqchip/gic

[RFC PATCH v1 2/4] KVM: arm64: GICv4.1: Try to save hw pending state in save_pending_tables

2020-11-22 Thread Shenming Lu
the vPEs first. Signed-off-by: Shenming Lu --- arch/arm64/kvm/vgic/vgic-v3.c | 62 +++ 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/arch/arm64/kvm/vgic/vgic-v3.c b/arch/arm64/kvm/vgic/vgic-v3.c index 9cdf39a94a63..e1b3aa4b2b12 100644 --- a/arch

[RFC PATCH v1 4/4] KVM: arm64: GICv4.1: Give a chance to save VLPI's pending state

2020-11-22 Thread Shenming Lu
the interfaces). Signed-off-by: Shenming Lu --- Documentation/virt/kvm/devices/arm-vgic-its.rst | 2 +- arch/arm64/kvm/vgic/vgic-its.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/virt/kvm/devices/arm-vgic-its.rst b/Documentation/virt/kvm

[RFC PATCH v1 1/4] irqchip/gic-v4.1: Plumb get_irqchip_state VLPI callback

2020-11-22 Thread Shenming Lu
any caching of the VPT, we can get the VLPI's pending state by peeking at the VPT. So we implement the irq_get_irqchip_state() callback of its_irq_chip to do it. Signed-off-by: Zenghui Yu Signed-off-by: Shenming Lu --- drivers/irqchip/irq-gic-v3-its.c | 38 1 file

Re: [PATCH] irqchip/gic-v4.1: Optimize the wait for the completion of the analysis of the VPT

2020-11-15 Thread Shenming Lu
, this is mainly caused by the 10 us delay in its_wait_vpt_parse_complete() (the above difference is just about 10 us)... What's your opinion about this? Thanks, Shenming On 2020/9/23 14:35, Shenming Lu wrote: > Right after a vPE is made resident, the code starts polling the > GICR_VPENDBASER

[PATCH] irqchip/gic-v4.1: Optimize the wait for the completion of the analysis of the VPT

2020-09-23 Thread Shenming Lu
niversal. Besides, we can delay the execution of its_wait_vpt_parse_complete() (call it from kvm_vgic_flush_hwstate() corresponding to vPE resident), giving the GIC a chance to work in parallel with the CPU on the entry path. Signed-off-by: Shenming Lu --- arch/arm64/kvm/vgic/vgic-v4.c

  1   2   >