[PATCH v2 0/2] iommu/vt-d: Some misc tweaks in SVA

2021-01-26 Thread Lu Baolu
ice outstanding PRQ number patch. Need more test and will repost later. Best regards, baolu Lu Baolu (2): iommu/vt-d: Clear PRQ overflow only when PRQ is empty iommu/vt-d: Use INVALID response code instead of FAILURE drivers/iommu/intel/svm.c | 18 -- 1 file changed, 12 inserti

Re: [PATCH 1/3] iommu/vt-d: Add rate limited information when PRQ overflows

2021-01-25 Thread Lu Baolu
Hi Kevin, On 2021/1/25 16:16, Tian, Kevin wrote: From: Lu Baolu Sent: Monday, January 25, 2021 2:29 PM Hi Kevin, On 2021/1/22 14:38, Tian, Kevin wrote: From: Lu Baolu Sent: Thursday, January 21, 2021 9:45 AM So that the uses could get chances to know what happened. Suggested-by: Ashok

Re: [PATCH 1/3] iommu/vt-d: Add rate limited information when PRQ overflows

2021-01-24 Thread Lu Baolu
Hi Kevin, On 2021/1/22 14:38, Tian, Kevin wrote: From: Lu Baolu Sent: Thursday, January 21, 2021 9:45 AM So that the uses could get chances to know what happened. Suggested-by: Ashok Raj Signed-off-by: Lu Baolu --- drivers/iommu/intel/svm.c | 10 -- 1 file changed, 8 insertions

[PATCH 3/3] iommu/vt-d: Use INVALID response code instead of FAILURE

2021-01-20 Thread Lu Baolu
. Let's use RESPONSE_INVALID instead for now, so that the device state machine doesn't enter HALT state. Suggested-by: Ashok Raj Signed-off-by: Lu Baolu --- drivers/iommu/intel/svm.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel

[PATCH 0/3] iommu/vt-d: Some misc tweaks in SVA

2021-01-20 Thread Lu Baolu
This includes some misc tweaks in the VT-d SVA implementation. I will plan them for v5.12 if no objections. Best regards, baolu Lu Baolu (3): iommu/vt-d: Add rate limited information when PRQ overflows iommu/vt-d: Allow devices to have more than 32 outstanding PRQ iommu/vt-d: Use INVALID

[PATCH 1/3] iommu/vt-d: Add rate limited information when PRQ overflows

2021-01-20 Thread Lu Baolu
So that the uses could get chances to know what happened. Suggested-by: Ashok Raj Signed-off-by: Lu Baolu --- drivers/iommu/intel/svm.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index 033b25886e57

[PATCH 2/3] iommu/vt-d: Allow devices to have more than 32 outstanding PRQ

2021-01-20 Thread Lu Baolu
IOMMU PRQ queue, but far from optimal for customized use cases. Signed-off-by: Jacob Pan Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 3 ++- drivers/iommu/intel/svm.c | 4 include/linux/intel-svm.h | 5 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git

Re: [PATCH 0/2 v2] iommu: fix the failure of deferred attach for iommu attach device

2021-01-19 Thread Lu Baolu
+++-- drivers/iommu/iommu.c | 12 include/linux/iommu.h | 2 ++ 3 files changed, 25 insertions(+), 18 deletions(-) Good fix and improvement. For the patches in this series: Reviewed-by: Lu Baolu Best regards, baolu

[PATCH 1/1] iommu/vt-d: Correctly check addr alignment in qi_flush_dev_iotlb_pasid()

2021-01-18 Thread Lu Baolu
iommu/vt-d: Handle non-page aligned address") Reported-and-tested-by: Guo Kaijie Signed-off-by: Lu Baolu Cc: Liu Yi L --- drivers/iommu/intel/dmar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c index 00

Re: [PATCH v4 1/3] iommu/vt-d: Audit IOMMU Capabilities and add helper functions

2021-01-18 Thread Lu Baolu
+/* + * cap_audit.c - audit iommu capabilities for boot time and hot plug + * + * Copyright (C) 2020 Intel Corporation Update to 2021. The same to other places. + * + * Author: Kyung Min Park + * Lu Baolu + */ + +#define pr_fmt(fmt)"DMAR: " fmt + +#include +#include "cap_audit.h

Re: [RFC PATCH v3 1/2] iommu: Add capability IOMMU_CAP_VIOMMU

2021-01-16 Thread Lu Baolu
Hi Leon, On 2021/1/16 16:39, Leon Romanovsky wrote: On Sat, Jan 16, 2021 at 09:20:16AM +0800, Lu Baolu wrote: Hi, On 2021/1/15 14:31, Leon Romanovsky wrote: On Fri, Jan 15, 2021 at 07:49:47AM +0800, Lu Baolu wrote: Hi Leon, On 1/14/21 9:26 PM, Leon Romanovsky wrote: On Thu, Jan 14, 2021

Re: [RFC PATCH v3 1/2] iommu: Add capability IOMMU_CAP_VIOMMU

2021-01-15 Thread Lu Baolu
Hi, On 2021/1/15 14:31, Leon Romanovsky wrote: On Fri, Jan 15, 2021 at 07:49:47AM +0800, Lu Baolu wrote: Hi Leon, On 1/14/21 9:26 PM, Leon Romanovsky wrote: On Thu, Jan 14, 2021 at 09:30:02AM +0800, Lu Baolu wrote: Some vendor IOMMU drivers are able to declare that it is running in a VM

[PATCH 1/1] iommu/vt-d: Preset Access/Dirty bits for IOVA over FL

2021-01-14 Thread Lu Baolu
to update the certain bits, it's better to set them up at the beginning. Suggested-by: Ashok Raj Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 14 -- include/linux/intel-iommu.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b

Re: [RFC PATCH v3 1/2] iommu: Add capability IOMMU_CAP_VIOMMU

2021-01-14 Thread Lu Baolu
Hi Leon, On 1/14/21 9:26 PM, Leon Romanovsky wrote: On Thu, Jan 14, 2021 at 09:30:02AM +0800, Lu Baolu wrote: Some vendor IOMMU drivers are able to declare that it is running in a VM context. This is very valuable for the features that only want to be supported on bare metal. Add a capability

[PATCH 1/1] iommu/vt-d: Add qi_submit trace event

2021-01-14 Thread Lu Baolu
: 0x13 0x7001 0x0 0x0 | qi_submit: iotlb_inv dmar2: 0x800f2 0xf9a5 0x0 0x0 This will be helpful for queued invalidation related debugging. Signed-off-by: Lu Baolu --- drivers/iommu/intel/dmar.c | 3 +++ include/trace/events/intel_iommu.h | 37

[PATCH 1/1] iommu/vt-d: Consolidate duplicate cache invaliation code

2021-01-14 Thread Lu Baolu
The pasid based IOTLB and devTLB invalidation code is duplicate in several places. Consolidate them by using the common helpers. Signed-off-by: Lu Baolu --- drivers/iommu/intel/pasid.c | 18 ++-- drivers/iommu/intel/svm.c | 55 ++--- 2 files changed, 11

[RFC PATCH v3 2/2] platform-msi: Add platform check for subdevice irq domain

2021-01-13 Thread Lu Baolu
@nanos.tec.linutronix.de/ Link: https://lore.kernel.org/linux-pci/877dqrnzr3@nanos.tec.linutronix.de/ Link: https://lore.kernel.org/linux-pci/877dqqmc2h@nanos.tec.linutronix.de/ Signed-off-by: Lu Baolu --- arch/x86/pci/common.c | 71 + drivers/base/platform-msi.c | 8

[RFC PATCH v3 0/2] Add platform check for subdevice irq domain

2021-01-13 Thread Lu Baolu
false in on_bare_metal(). This won't introduce any regression. The only impact is that the coming new platform msi feature won't be supported until the vendor specific code is provided. Best regards, baolu Lu Baolu (2): iommu: Add capability IOMMU_CAP_VIOMMU platform-msi: Add platform

[RFC PATCH v3 1/2] iommu: Add capability IOMMU_CAP_VIOMMU

2021-01-13 Thread Lu Baolu
Some vendor IOMMU drivers are able to declare that it is running in a VM context. This is very valuable for the features that only want to be supported on bare metal. Add a capability bit so that it could be used. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 20

Re: [RFC PATCH v2 1/1] platform-msi: Add platform check for subdevice irq domain

2021-01-11 Thread Lu Baolu
Hi, On 1/7/21 3:16 PM, Leon Romanovsky wrote: On Thu, Jan 07, 2021 at 06:55:16AM +, Tian, Kevin wrote: From: Leon Romanovsky Sent: Thursday, January 7, 2021 2:09 PM On Thu, Jan 07, 2021 at 02:04:29AM +, Tian, Kevin wrote: From: Leon Romanovsky Sent: Thursday, January 7, 2021 12:02

Re: [PATCH 2/5] iommu/vt-d: Fix unaligned addresses for intel_flush_svm_range_dev()

2021-01-08 Thread Lu Baolu
Hi Will, On 2021/1/8 22:09, Will Deacon wrote: Hi Lu, On Fri, Jan 08, 2021 at 07:52:47AM +0800, Lu Baolu wrote: On 2021/1/6 9:09, Lu Baolu wrote: On 2021/1/6 3:03, Will Deacon wrote: On Thu, Dec 31, 2020 at 08:53:20AM +0800, Lu Baolu wrote: @@ -170,6 +172,22 @@ static void

Re: [PATCH 3/5] iommu/vt-d: Remove unused dma map/unmap trace events

2021-01-07 Thread Lu Baolu
Hi Will, On 2021/1/7 22:40, Will Deacon wrote: On Wed, Jan 06, 2021 at 09:14:22AM +0800, Lu Baolu wrote: On 2021/1/6 3:04, Will Deacon wrote: On Thu, Dec 31, 2020 at 08:53:21AM +0800, Lu Baolu wrote: With commit c588072bba6b5 ("iommu/vt-d: Convert intel iommu driver to the iomm

Re: [PATCH 2/5] iommu/vt-d: Fix unaligned addresses for intel_flush_svm_range_dev()

2021-01-07 Thread Lu Baolu
Hi Will, On 2021/1/6 9:09, Lu Baolu wrote: Hi Will, Happy New Year! On 2021/1/6 3:03, Will Deacon wrote: On Thu, Dec 31, 2020 at 08:53:20AM +0800, Lu Baolu wrote: The VT-d hardware will ignore those Addr bits which have been masked by the AM field in the PASID-based-IOTLB invalidation

Re: [PATCH v4 2/3] iommu/vt-d: Track device aux-attach with subdevice_domain_info

2021-01-07 Thread Lu Baolu
Hi Will, On 2021/1/7 21:49, Will Deacon wrote: On Thu, Jan 07, 2021 at 12:03:56AM +0800, Liu Yi L wrote: In the existing code, loop all devices attached to a domain does not include sub-devices attached via iommu_aux_attach_device(). This was found by when I'm working on the below patch,

Re: [RFC PATCH v2 1/1] platform-msi: Add platform check for subdevice irq domain

2021-01-06 Thread Lu Baolu
On 1/7/21 12:01 AM, Leon Romanovsky wrote: On Wed, Jan 06, 2021 at 11:23:39AM -0400, Jason Gunthorpe wrote: On Wed, Jan 06, 2021 at 12:40:17PM +0200, Leon Romanovsky wrote: I asked what will you do when QEMU will gain needed functionality? Will you remove QEMU from this list? If yes, how such

Re: [PATCH v2 6/6] iommu: Delete iommu_dev_has_feature()

2021-01-06 Thread Lu Baolu
On 1/6/21 9:35 PM, John Garry wrote: Function iommu_dev_has_feature() has never been referenced in the tree, and there does not appear to be anything coming soon to use it, so delete it. It will be used by the device driver which want to support the aux- domain capability, for example, below

Re: [RFC PATCH v2 1/1] platform-msi: Add platform check for subdevice irq domain

2021-01-06 Thread Lu Baolu
Hi Leon, On 2021/1/6 14:06, Leon Romanovsky wrote: On Wed, Jan 06, 2021 at 10:27:49AM +0800, Lu Baolu wrote: The pci_subdevice_msi_create_irq_domain() should fail if the underlying platform is not able to support IMS (Interrupt Message Storage). Otherwise, the isolation of interrupt

[RFC PATCH v2 1/1] platform-msi: Add platform check for subdevice irq domain

2021-01-05 Thread Lu Baolu
@nanos.tec.linutronix.de/ Link: https://lore.kernel.org/linux-pci/877dqqmc2h@nanos.tec.linutronix.de/ Signed-off-by: Lu Baolu --- arch/x86/pci/common.c | 47 + drivers/base/platform-msi.c | 8 +++ include/linux/msi.h | 1 + 3 files

Re: [PATCH 3/5] iommu/vt-d: Remove unused dma map/unmap trace events

2021-01-05 Thread Lu Baolu
Hi Will, On 2021/1/6 3:04, Will Deacon wrote: On Thu, Dec 31, 2020 at 08:53:21AM +0800, Lu Baolu wrote: With commit c588072bba6b5 ("iommu/vt-d: Convert intel iommu driver to the iommu ops"), the trace events for dma map/unmap have no users any more. Remove them so that they don't sho

Re: [PATCH 2/5] iommu/vt-d: Fix unaligned addresses for intel_flush_svm_range_dev()

2021-01-05 Thread Lu Baolu
Hi Will, Happy New Year! On 2021/1/6 3:03, Will Deacon wrote: On Thu, Dec 31, 2020 at 08:53:20AM +0800, Lu Baolu wrote: The VT-d hardware will ignore those Addr bits which have been masked by the AM field in the PASID-based-IOTLB invalidation descriptor. As the result, if the starting address

Re: [PATCH] [v2] iommu/intel: Fix memleak in intel_irq_remapping_alloc

2021-01-05 Thread Lu Baolu
mains") Signed-off-by: Dinghao Liu Acked-by: Lu Baolu Best regards, baolu --- Changelog: v2: - Add a check against i instead of setting data to NULL. --- drivers/iommu/intel/irq_remapping.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iommu/intel/irq_remapping.c b/dri

Re: [PATCH] iommu/intel: Fix memleak in intel_irq_remapping_alloc

2021-01-04 Thread Lu Baolu
On 1/3/21 2:22 PM, dinghao@zju.edu.cn wrote: On 2021/1/3 12:08, dinghao@zju.edu.cn wrote: Hi, On 2021/1/2 17:50, Dinghao Liu wrote: When irq_domain_get_irq_data() or irqd_cfg() fails meanwhile i == 0, data allocated by kzalloc() has not been freed before returning, which leads to

Re: [PATCH] iommu/intel: Fix memleak in intel_irq_remapping_alloc

2021-01-02 Thread Lu Baolu
On 2021/1/3 12:08, dinghao@zju.edu.cn wrote: Hi, On 2021/1/2 17:50, Dinghao Liu wrote: When irq_domain_get_irq_data() or irqd_cfg() fails meanwhile i == 0, data allocated by kzalloc() has not been freed before returning, which leads to memleak. Fixes: b106ee63abccb ("irq_remapping/vt-d:

Re: [PATCH] iommu/intel: Fix memleak in intel_irq_remapping_alloc

2021-01-02 Thread Lu Baolu
Hi, On 2021/1/2 17:50, Dinghao Liu wrote: When irq_domain_get_irq_data() or irqd_cfg() fails meanwhile i == 0, data allocated by kzalloc() has not been freed before returning, which leads to memleak. Fixes: b106ee63abccb ("irq_remapping/vt-d: Enhance Intel IR driver to support hierarchical

[PATCH 4/5] Revert "iommu: Add quirk for Intel graphic devices in map_sg"

2020-12-30 Thread Lu Baolu
temporary workaround. Cc: Tvrtko Ursulin Cc: Tom Murphy Cc: Logan Gunthorpe Signed-off-by: Lu Baolu --- drivers/iommu/dma-iommu.c | 27 --- 1 file changed, 27 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index f0305e6aac1b.

[PATCH 5/5] iommu/vt-d: Fix lockdep splat in sva bind()/unbind()

2020-12-30 Thread Lu Baolu
lock(device_domain_lock); *** DEADLOCK *** Signed-off-by: Lu Baolu --- drivers/iommu/intel/svm.c | 14 -- 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index b16a4791acfb..18a9f05df407 100644 --- a/drivers/iommu

[PATCH 2/5] iommu/vt-d: Fix unaligned addresses for intel_flush_svm_range_dev()

2020-12-30 Thread Lu Baolu
is clear Fix this by using aligned address for PASID-based-IOTLB invalidation. Fixes: 1c4f88b7f1f92 ("iommu/vt-d: Shared virtual address in scalable mode") Reported-and-tested-by: Guo Kaijie Signed-off-by: Lu Baolu --- drivers/iommu/intel/svm.c | 22 -- 1 file c

[PATCH 1/5] iommu/vt-d: Fix misuse of ALIGN in qi_flush_piotlb()

2020-12-30 Thread Lu Baolu
Use IS_ALIGNED() instead. Otherwise, an unaligned address will be ignored. Fixes: 33cd6e642d6a7 ("iommu/vt-d: Flush PASID-based iotlb for iova over first level") Signed-off-by: Lu Baolu --- drivers/iommu/intel/dmar.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)

[PATCH 3/5] iommu/vt-d: Remove unused dma map/unmap trace events

2020-12-30 Thread Lu Baolu
es defined in the iommu core from now on. Fixes: c588072bba6b5 ("iommu/vt-d: Convert intel iommu driver to the iommu ops") Signed-off-by: Lu Baolu --- include/trace/events/intel_iommu.h | 119 - 1 file changed, 119 deletions(-) diff --git a/include/trace/events/inte

Re: [PATCH v3 3/3] iommu/vt-d: Fix ineffective devTLB invalidation for subdevices

2020-12-29 Thread Lu Baolu
;pdev), + addr, mask); } Nit: list_for_each_entry(sinfo, >subdevices, link_domain) { info = get_domain_info(sinfo->pdev); __iommu_flush_dev_iotlb(info, addr, mask); } Others look good to me. Acked-by: Lu Baolu Best regards, baolu spin_unlock_irqrestore(_domain_lock, flags); }

Re: [PATCH v3 2/3] iommu/vt-d: Track device aux-attach with subdevice_domain_info

2020-12-29 Thread Lu Baolu
ook good to me. Fixes: 67b8e02b5e761 ("iommu/vt-d: Aux-domain specific domain attach/detach") Acked-by: Lu Baolu Best regards, baolu --- drivers/iommu/intel/iommu.c | 95 +++-- include/linux/intel-iommu.h | 16 +-- 2 files changed, 82 inse

Re: [PATCH v3 1/3] iommu/vt-d: Move intel_iommu info from struct intel_svm to struct intel_svm_dev

2020-12-29 Thread Lu Baolu
of intel_svm_dev struct. Fixes: 1c4f88b7f1f92 ("iommu/vt-d: Shared virtual address in scalable mode") Cc: Lu Baolu Cc: Jacob Pan Cc: Raj Ashok Cc: David Woodhouse Reported-by: Guo Kaijie Reported-by: Xin Zeng Signed-off-by: Guo Kaijie Signed-off-by: Xin Zeng Signed-off-by: Liu Yi L This

Re: [PATCH v2 3/3] iommu/vt-d: Fix ineffective devTLB invalidation for subdevices

2020-12-23 Thread Lu Baolu
Hi Yi, On 2020/12/23 14:27, Liu Yi L wrote: iommu_flush_dev_iotlb() is called to invalidate caches on device. It only loops the devices which are full-attached to the domain. For sub-devices, this is ineffective. This results in invalid caching entries left on the device. Fix it by adding loop

Re: [RFC PATCH 1/1] platform-msi: Add platform check for subdevice irq domain

2020-12-15 Thread Lu Baolu
Hi Bjorn, On 12/11/20 2:57 AM, Bjorn Helgaas wrote: On Thu, Dec 10, 2020 at 08:46:24AM +0800, Lu Baolu wrote: The pci_subdevice_msi_create_irq_domain() should fail if the underlying platform is not able to support IMS (Interrupt Message Storage). Otherwise, the isolation of interrupt

Re: [RFC PATCH 1/1] platform-msi: Add platform check for subdevice irq domain

2020-12-15 Thread Lu Baolu
Hi David, On 12/10/20 4:22 PM, David Woodhouse wrote: On Thu, 2020-12-10 at 08:46 +0800, Lu Baolu wrote: +/* + * We want to figure out which context we are running in. But the hardware + * does not introduce a reliable way (instruction, CPUID leaf, MSR, whatever) + * which can be manipulated

[RFC PATCH 1/1] platform-msi: Add platform check for subdevice irq domain

2020-12-09 Thread Lu Baolu
@nanos.tec.linutronix.de/ Link: https://lore.kernel.org/linux-pci/877dqqmc2h@nanos.tec.linutronix.de/ Signed-off-by: Lu Baolu --- arch/x86/pci/common.c | 43 + drivers/base/platform-msi.c | 8 +++ include/linux/msi.h | 1 + 3 files

[PATCH v4 1/1] vfio/type1: Add vfio_group_iommu_domain()

2020-12-08 Thread Lu Baolu
-EFAULT; } pasid = iommu_aux_get_pasid(iommu_domain, iommu_device); if (pasid < 0) { vfio_group_put_external_user(vfio_group); return -EFAULT; } /* Program device context with pasid value. */ ... Signed-off-by: Lu Ba

Re: Question about domain_init (v5.3-v5.7)

2020-11-30 Thread Lu Baolu
Hi Jerry, On 12/1/20 1:50 AM, Jerry Snitselaar wrote: Lu Baolu @ 2020-11-26 19:12 MST: Hi Jerry, On 11/27/20 5:35 AM, Jerry Snitselaar wrote: Lu Baolu @ 2020-11-26 04:01 MST: Hi Jerry, On 2020/11/26 4:27, Jerry Snitselaar wrote: Is there a reason we check the requested guest address

[PATCH v3 1/1] vfio/type1: Add vfio_group_domain()

2020-11-30 Thread Lu Baolu
; } pasid = iommu_aux_get_pasid(iommu_domain, iommu_device); if (pasid < 0) { vfio_group_put_external_user(vfio_group); return -EFAULT; } /* Program device context with pasid value. */ ... Signed-off-by: Lu Ba

Re: [PATCH v2 1/1] vfio/type1: Add vfio_group_domain()

2020-11-30 Thread Lu Baolu
Hi Alex, Thanks a lot for your review comments. On 12/1/20 4:57 AM, Alex Williamson wrote: On Thu, 26 Nov 2020 09:27:26 +0800 Lu Baolu wrote: Add the API for getting the domain from a vfio group. This could be used by the physical device drivers which rely on the vfio/mdev framework

Re: Question about domain_init (v5.3-v5.7)

2020-11-26 Thread Lu Baolu
Hi Jerry, On 11/27/20 5:35 AM, Jerry Snitselaar wrote: Lu Baolu @ 2020-11-26 04:01 MST: Hi Jerry, On 2020/11/26 4:27, Jerry Snitselaar wrote: Is there a reason we check the requested guest address width against the iommu's mgaw, instead of the agaw that we already know for the iommu? I've

[PATCH 1/1] iommu/vt-d: Remove set but not used variable

2020-11-26 Thread Lu Baolu
: 2a2b8eaa5b256 ("iommu: Handle freelists when using deferred flushing in iommu drivers") Reported-by: kernel test robot Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/i

Re: Question about domain_init (v5.3-v5.7)

2020-11-26 Thread Lu Baolu
Hi Jerry, On 2020/11/26 4:27, Jerry Snitselaar wrote: Is there a reason we check the requested guest address width against the iommu's mgaw, instead of the agaw that we already know for the iommu? I've run into a case with a new system where the mgaw reported is 57, but if they set PAE to 46

[PATCH 1/1] iommu: Fix htmldocs warnings in sysfs-kernel-iommu_groups

2020-11-26 Thread Lu Baolu
: 63a816749d86 ("iommu: Document usage of "/sys/kernel/iommu_groups//type" file") Reported-by: Stephen Rothwell Link: https://lore.kernel.org/linux-next/20201126174851.200e0...@canb.auug.org.au/ Signed-off-by: Lu Baolu --- .../ABI/testing/sysfs-kernel-iommu_groups | 33 ++

Re: [PATCH v2 1/1] vfio/type1: Add vfio_group_domain()

2020-11-26 Thread Lu Baolu
Hi Yi, On 2020/11/26 15:21, Liu, Yi L wrote: On Thurs, Nov 26, 2020, at 9:27 AM, Lu Baolu wrote: Add the API for getting the domain from a vfio group. This could be used by the physical device drivers which rely on the vfio/mdev framework for mediated device user level access. The typical use

Re: linux-next: build warnings after merge of the arm64 tree

2020-11-26 Thread Lu Baolu
Hi Stephen, On 2020/11/26 14:48, Stephen Rothwell wrote: Hi all, After merging the arm64 tree, today's linux-next build (htmldocs) produced these warnings: Documentation/ABI/testing/sysfs-kernel-iommu_groups:38: WARNING: Unexpected indentation.

[PATCH v2 1/1] vfio/type1: Add vfio_group_domain()

2020-11-25 Thread Lu Baolu
-EFAULT; } pasid = iommu_aux_get_pasid(iommu_domain, iommu_device); if (pasid < 0) { vfio_group_put_external_user(vfio_group); return -EFAULT; } /* Program device context with pasid value. */ ... Signed-off-by: Lu Ba

[PATCH 1/1] x86/tboot: Don't disable swiotlb when iommu is forced on

2020-11-24 Thread Lu Baolu
won't work if "iommu=pt" kernel parameter is used. Fixes: 327d5b2fee91c ("iommu/vt-d: Allow 32bit devices to uses DMA domain") Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=210237 Reported-and-tested-by: Adrian Huang Signed-off-by: Lu Baolu --- arch/x86/kernel/tboot.

[PATCH v10 2/4] iommu: Add support to change default domain of an iommu group

2020-11-24 Thread Lu Baolu
for more information. Cc: Christoph Hellwig Cc: Joerg Roedel Cc: Ashok Raj Cc: Will Deacon Cc: Sohil Mehta Cc: Robin Murphy Cc: Jacob Pan Signed-off-by: Sai Praneeth Prakhya Signed-off-by: Lu Baolu --- drivers/iommu/iommu.c | 230 +- 1 file changed,

[PATCH v10 3/4] iommu: Take lock before reading iommu group default domain type

2020-11-24 Thread Lu Baolu
n't see stale values or iommu_group_show_type() doesn't try to derefernce stale pointers. Cc: Christoph Hellwig Cc: Joerg Roedel Cc: Ashok Raj Cc: Will Deacon Cc: Sohil Mehta Cc: Robin Murphy Cc: Jacob Pan Signed-off-by: Sai Praneeth Prakhya Signed-off-by: Lu Baolu --- drivers/iommu/iommu.c | 2 ++ 1 file c

[PATCH v10 4/4] iommu: Document usage of "/sys/kernel/iommu_groups//type" file

2020-11-24 Thread Lu Baolu
Cc: Sohil Mehta Cc: Robin Murphy Cc: Jacob Pan Signed-off-by: Sai Praneeth Prakhya Signed-off-by: Lu Baolu --- .../ABI/testing/sysfs-kernel-iommu_groups | 29 +++ 1 file changed, 29 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-kernel-iommu_groups b/Documen

[PATCH v10 1/4] iommu: Move def_domain type check for untrusted device into core

2020-11-24 Thread Lu Baolu
So that the vendor iommu drivers are no more required to provide the def_domain_type callback to always isolate the untrusted devices. Link: https://lore.kernel.org/linux-iommu/243ce89c33fe4b9da4c56ba35aceb...@huawei.com/ Cc: Shameerali Kolothum Thodi Signed-off-by: Lu Baolu --- drivers/iommu

[PATCH v10 0/4] iommu: Add support to change default domain of an iommu group

2020-11-24 Thread Lu Baolu
iommu_get_mandatory_def_domain_type() Best regards, baolu Lu Baolu (1): iommu: Move def_domain type check for untrusted device into core Sai Praneeth Prakhya (3): iommu: Add support to change default domain of an iommu group iommu: Take lock before reading iommu group default domain type

[PATCH v6 5/7] iommu/vt-d: Update domain geometry in iommu_ops.at(de)tach_dev

2020-11-24 Thread Lu Baolu
The iommu-dma constrains IOVA allocation based on the domain geometry that the driver reports. Update domain geometry everytime a domain is attached to or detached from a device. Signed-off-by: Lu Baolu Tested-by: Logan Gunthorpe --- drivers/iommu/intel/iommu.c | 16 ++-- 1 file

[PATCH v6 7/7] iommu/vt-d: Cleanup after converting to dma-iommu ops

2020-11-24 Thread Lu Baolu
Some cleanups after converting the driver to use dma-iommu ops. - Remove nobounce option; - Cleanup and simplify the path in domain mapping. Signed-off-by: Lu Baolu Tested-by: Logan Gunthorpe --- .../admin-guide/kernel-parameters.txt | 5 -- drivers/iommu/intel/iommu.c

[PATCH v6 6/7] iommu/vt-d: Convert intel iommu driver to the iommu ops

2020-11-24 Thread Lu Baolu
From: Tom Murphy Convert the intel iommu driver to the dma-iommu api. Remove the iova handling and reserve region code from the intel iommu driver. Signed-off-by: Tom Murphy Signed-off-by: Lu Baolu Tested-by: Logan Gunthorpe --- drivers/iommu/intel/Kconfig | 1 + drivers/iommu/intel

[PATCH v6 4/7] iommu: Add quirk for Intel graphic devices in map_sg

2020-11-24 Thread Lu Baolu
depends on the previous behaviour of the Intel iommu driver which would return the same number of elements in the output list as in the input list. Signed-off-by: Tom Murphy Signed-off-by: Lu Baolu Tested-by: Logan Gunthorpe --- drivers/iommu/dma-iommu.c | 27 +++ 1 file

[PATCH v6 1/7] iommu: Handle freelists when using deferred flushing in iommu drivers

2020-11-24 Thread Lu Baolu
table pages can be freed. This way we can still batch ioTLB free operations and handle the freelists. Signed-off-by: Tom Murphy Signed-off-by: Lu Baolu Tested-by: Logan Gunthorpe --- drivers/iommu/dma-iommu.c | 29 +-- drivers/iommu/intel/iommu.c | 55

[PATCH v6 2/7] iommu: Add iommu_dma_free_cpu_cached_iovas()

2020-11-24 Thread Lu Baolu
From: Tom Murphy Add a iommu_dma_free_cpu_cached_iovas function to allow drivers which use the dma-iommu ops to free cached cpu iovas. Signed-off-by: Tom Murphy Signed-off-by: Lu Baolu Tested-by: Logan Gunthorpe --- drivers/iommu/dma-iommu.c | 9 + include/linux/dma-iommu.h | 8

[PATCH v6 3/7] iommu: Allow the dma-iommu api to use bounce buffers

2020-11-24 Thread Lu Baolu
From: Tom Murphy Allow the dma-iommu api to use bounce buffers for untrusted devices. This is a copy of the intel bounce buffer code. Signed-off-by: Tom Murphy Co-developed-by: Lu Baolu Signed-off-by: Lu Baolu Tested-by: Logan Gunthorpe --- drivers/iommu/dma-iommu.c | 162

[PATCH v6 0/7] Convert the intel iommu driver to the dma-iommu api

2020-11-24 Thread Lu Baolu
/ Please review and consider it for iommu/next. Best regards, baolu Lu Baolu (3): iommu: Add quirk for Intel graphic devices in map_sg iommu/vt-d: Update domain geometry in iommu_ops.at(de)tach_dev iommu/vt-d: Cleanup after converting to dma-iommu ops Tom Murphy (4): iommu: Handle

Re: [PATCH v9 1/4] iommu: Move def_domain type check for untrusted device into core

2020-11-23 Thread Lu Baolu
Hi Will, On 2020/11/23 21:03, Will Deacon wrote: Hi Baolu, On Mon, Nov 23, 2020 at 08:55:17PM +0800, Lu Baolu wrote: On 2020/11/23 20:04, Will Deacon wrote: On Sat, Nov 21, 2020 at 09:56:17PM +0800, Lu Baolu wrote: @@ -1645,13 +1655,10 @@ struct __group_domain_type { static int

Re: [PATCH v9 1/4] iommu: Move def_domain type check for untrusted device into core

2020-11-23 Thread Lu Baolu
Hi Will, On 2020/11/23 20:04, Will Deacon wrote: On Sat, Nov 21, 2020 at 09:56:17PM +0800, Lu Baolu wrote: So that the vendor iommu drivers are no more required to provide the def_domain_type callback to always isolate the untrusted devices. Link: https://lore.kernel.org/linux-iommu

Re: [PATCH v5 3/7] iommu: Allow the dma-iommu api to use bounce buffers

2020-11-23 Thread Lu Baolu
Hi Will, On 2020/11/23 19:47, Will Deacon wrote: On Mon, Nov 23, 2020 at 07:40:57PM +0800, Lu Baolu wrote: On 2020/11/23 18:08, Christoph Hellwig wrote: + /* +* If both the physical buffer start address and size are +* page aligned, we don't need to use a bounce page

Re: [PATCH v5 3/7] iommu: Allow the dma-iommu api to use bounce buffers

2020-11-23 Thread Lu Baolu
Hi Christoph, On 2020/11/23 18:08, Christoph Hellwig wrote: + /* +* If both the physical buffer start address and size are +* page aligned, we don't need to use a bounce page. +*/ + if (IS_ENABLED(CONFIG_SWIOTLB) && dev_is_untrusted(dev) && +

[PATCH v9 1/4] iommu: Move def_domain type check for untrusted device into core

2020-11-21 Thread Lu Baolu
So that the vendor iommu drivers are no more required to provide the def_domain_type callback to always isolate the untrusted devices. Link: https://lore.kernel.org/linux-iommu/243ce89c33fe4b9da4c56ba35aceb...@huawei.com/ Cc: Shameerali Kolothum Thodi Signed-off-by: Lu Baolu --- drivers/iommu

[PATCH v9 4/4] iommu: Document usage of "/sys/kernel/iommu_groups//type" file

2020-11-21 Thread Lu Baolu
Cc: Sohil Mehta Cc: Robin Murphy Cc: Jacob Pan Signed-off-by: Sai Praneeth Prakhya Signed-off-by: Lu Baolu --- .../ABI/testing/sysfs-kernel-iommu_groups | 29 +++ 1 file changed, 29 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-kernel-iommu_groups b/Documen

[PATCH v9 2/4] iommu: Add support to change default domain of an iommu group

2020-11-21 Thread Lu Baolu
for more information. Cc: Christoph Hellwig Cc: Joerg Roedel Cc: Ashok Raj Cc: Will Deacon Cc: Sohil Mehta Cc: Robin Murphy Cc: Jacob Pan Signed-off-by: Sai Praneeth Prakhya Signed-off-by: Lu Baolu --- drivers/iommu/iommu.c | 232 +- 1 file changed,

[PATCH v9 0/4] iommu: Add support to change default domain of

2020-11-21 Thread Lu Baolu
Lu Baolu (1): iommu: Move def_domain type check for untrusted device into core Sai Praneeth Prakhya (3): iommu: Add support to change default domain of an iommu group iommu: Take lock before reading iommu group default domain type iommu: Document usage of "/sys/kernel/iommu_groups/

[PATCH v9 3/4] iommu: Take lock before reading iommu group default domain type

2020-11-21 Thread Lu Baolu
n't see stale values or iommu_group_show_type() doesn't try to derefernce stale pointers. Cc: Christoph Hellwig Cc: Joerg Roedel Cc: Ashok Raj Cc: Will Deacon Cc: Sohil Mehta Cc: Robin Murphy Cc: Jacob Pan Signed-off-by: Sai Praneeth Prakhya Signed-off-by: Lu Baolu --- drivers/iommu/iommu.c | 2 ++ 1 file c

Re: [PATCH v5 0/7] Convert the intel iommu driver to the dma-iommu api

2020-11-20 Thread Lu Baolu
Hi Chris, On 2020/11/20 20:24, Chris Wilson wrote: Quoting Lu Baolu (2020-11-20 10:17:12) Lu Baolu (3): iommu: Add quirk for Intel graphic devices in map_sg iommu/vt-d: Update domain geometry in iommu_ops.at(de)tach_dev iommu/vt-d: Cleanup after converting to dma-iommu ops Tom Murphy

[PATCH v5 7/7] iommu/vt-d: Cleanup after converting to dma-iommu ops

2020-11-20 Thread Lu Baolu
Some cleanups after converting the driver to use dma-iommu ops. - Remove nobounce option; - Cleanup and simplify the path in domain mapping. Signed-off-by: Lu Baolu Tested-by: Logan Gunthorpe --- .../admin-guide/kernel-parameters.txt | 5 -- drivers/iommu/intel/iommu.c

[PATCH v5 6/7] iommu/vt-d: Convert intel iommu driver to the iommu ops

2020-11-20 Thread Lu Baolu
From: Tom Murphy Convert the intel iommu driver to the dma-iommu api. Remove the iova handling and reserve region code from the intel iommu driver. Signed-off-by: Tom Murphy Signed-off-by: Lu Baolu Tested-by: Logan Gunthorpe --- drivers/iommu/intel/Kconfig | 1 + drivers/iommu/intel

[PATCH v5 3/7] iommu: Allow the dma-iommu api to use bounce buffers

2020-11-20 Thread Lu Baolu
From: Tom Murphy Allow the dma-iommu api to use bounce buffers for untrusted devices. This is a copy of the intel bounce buffer code. Signed-off-by: Tom Murphy Co-developed-by: Lu Baolu Signed-off-by: Lu Baolu Tested-by: Logan Gunthorpe --- drivers/iommu/dma-iommu.c | 163

[PATCH v5 5/7] iommu/vt-d: Update domain geometry in iommu_ops.at(de)tach_dev

2020-11-20 Thread Lu Baolu
The iommu-dma constrains IOVA allocation based on the domain geometry that the driver reports. Update domain geometry everytime a domain is attached to or detached from a device. Signed-off-by: Lu Baolu Tested-by: Logan Gunthorpe --- drivers/iommu/intel/iommu.c | 16 ++-- 1 file

[PATCH v5 4/7] iommu: Add quirk for Intel graphic devices in map_sg

2020-11-20 Thread Lu Baolu
depends on the previous behaviour of the Intel iommu driver which would return the same number of elements in the output list as in the input list. Signed-off-by: Tom Murphy Signed-off-by: Lu Baolu Tested-by: Logan Gunthorpe --- drivers/iommu/dma-iommu.c | 27 +++ 1 file

[PATCH v5 2/7] iommu: Add iommu_dma_free_cpu_cached_iovas()

2020-11-20 Thread Lu Baolu
From: Tom Murphy Add a iommu_dma_free_cpu_cached_iovas function to allow drivers which use the dma-iommu ops to free cached cpu iovas. Signed-off-by: Tom Murphy Signed-off-by: Lu Baolu Tested-by: Logan Gunthorpe --- drivers/iommu/dma-iommu.c | 9 + include/linux/dma-iommu.h | 8

[PATCH v5 0/7] Convert the intel iommu driver to the dma-iommu api

2020-11-20 Thread Lu Baolu
, baolu Lu Baolu (3): iommu: Add quirk for Intel graphic devices in map_sg iommu/vt-d: Update domain geometry in iommu_ops.at(de)tach_dev iommu/vt-d: Cleanup after converting to dma-iommu ops Tom Murphy (4): iommu: Handle freelists when using deferred flushing in iommu drivers iommu: Add

[PATCH v5 1/7] iommu: Handle freelists when using deferred flushing in iommu drivers

2020-11-20 Thread Lu Baolu
table pages can be freed. This way we can still batch ioTLB free operations and handle the freelists. Signed-off-by: Tom Murphy Signed-off-by: Lu Baolu Tested-by: Logan Gunthorpe --- drivers/iommu/dma-iommu.c | 29 +-- drivers/iommu/intel/iommu.c | 55

Re: [PATCH v4 0/7] Convert the intel iommu driver to the dma-iommu api

2020-11-20 Thread Lu Baolu
On 2020/11/3 18:54, Joerg Roedel wrote: Hi, On Tue, Nov 03, 2020 at 11:58:26AM +0200, Joonas Lahtinen wrote: Would that work for you? We intend to send the feature pull requests to DRM for 5.11 in the upcoming weeks. For the IOMMU side it is best to include the workaround for now. When the

[PATCH 1/1] iommu/vt-d: Fix compile error with CONFIG_PCI_ATS not set

2020-11-18 Thread Lu Baolu
"iommu/vt-d: Cure VF irqdomain hickup") Cc: Thomas Gleixner Reported-by: Geert Uytterhoeven Signed-off-by: Lu Baolu --- drivers/iommu/intel/dmar.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c index b2e8044

Re: [PATCH v2] iommu/vt-d: avoid unnecessory panic if iommu init fail in tboot system

2020-11-17 Thread Lu Baolu
+Will Please consider this patch for v5.10. Best regards, baolu On 2020/11/10 15:19, Zhenzhong Duan wrote: "intel_iommu=off" command line is used to disable iommu but iommu is force enabled in a tboot system for security reason. However for better performance on high speed network device, a

Re: [PATCH 1/1] vfio/type1: Add subdev_ioasid callback to vfio_iommu_driver_ops

2020-11-17 Thread Lu Baolu
Hi Alex, On 2020/11/17 3:56, Alex Williamson wrote: On Thu, 12 Nov 2020 10:24:07 +0800 Lu Baolu wrote: Add API for getting the ioasid of a subdevice (vfio/mdev). This calls into the backend IOMMU module to get the actual value or error number if ioasid for subdevice is not supported

Re: [PATCH] iommu: fix return error code in iommu_probe_device()

2020-11-17 Thread Lu Baolu
Hi Yingliang, On 2020/11/17 10:52, Yang Yingliang wrote: If iommu_group_get() failed, it need return error code in iommu_probe_device(). Fixes: cf193888bfbd ("iommu: Move new probe_device path...") Reported-by: Hulk Robot Signed-off-by: Yang Yingliang --- drivers/iommu/iommu.c | 4 +++- 1

Re: iommu/vt-d: Cure VF irqdomain hickup

2020-11-16 Thread Lu Baolu
On 2020/11/16 17:47, Geert Uytterhoeven wrote: Hi Thomas, On Thu, Nov 12, 2020 at 8:16 PM Thomas Gleixner wrote: The recent changes to store the MSI irqdomain pointer in struct device missed that Intel DMAR does not register virtual function devices. Due to that a VF device gets the plain

Re: [PATCH] iommu/vt-d: include conditionally on CONFIG_INTEL_IOMMU_SVM

2020-11-15 Thread Lu Baolu
unction") Acked-by: Lu Baolu Best regards, baolu --- applies cleanly on current master and next-20201113 Liu Yi L, Jakob Pan, Lu Baolu, please ack. Joerg, please pick this minor non-urgent clean-up patch. drivers/iommu/intel/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 del

Re: iommu/vt-d: Cure VF irqdomain hickup

2020-11-12 Thread Lu Baolu
f_inherit_msi_domain(pdev); return NOTIFY_DONE; + } + if (action != BUS_NOTIFY_ADD_DEVICE && action != BUS_NOTIFY_REMOVED_DEVICE) return NOTIFY_DONE; We also encountered this problem in internal testing. This patch can solve the problem.

[PATCH 1/1] vfio/type1: Add subdev_ioasid callback to vfio_iommu_driver_ops

2020-11-11 Thread Lu Baolu
lue. */ Signed-off-by: Lu Baolu --- drivers/vfio/vfio.c | 34 drivers/vfio/vfio_iommu_type1.c | 57 + include/linux/vfio.h| 4 +++ 3 files changed, 95 insertions(+) diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfi

Re: [PATCH v6 5/5] vfio/type1: Use mdev bus iommu_ops for IOMMU callbacks

2020-11-11 Thread Lu Baolu
Hi Alex, On 11/3/20 1:22 PM, Lu Baolu wrote: Hi Alex, On 10/31/20 5:06 AM, Alex Williamson wrote: On Fri, 30 Oct 2020 06:16:28 + "Tian, Kevin" wrote: From: Lu Baolu Sent: Friday, October 30, 2020 12:58 PM With the IOMMU driver registering iommu_ops for the mdev_bus,

Re: [PATCH v2] iommu/vt-d: avoid unnecessory panic if iommu init fail in tboot system

2020-11-10 Thread Lu Baolu
mmu code. Fixes: 7304e8f28bb2 ("iommu/vt-d: Correctly disable Intel IOMMU force on") Signed-off-by: Zhenzhong Duan Thanks for the patch. Acked-by: Lu Baolu Best regards, baolu --- v2: move ckeck of intel_iommu_tboot_noforce into iommu code per Baolu. arch/x86/kernel/tboot.c |

<    1   2   3   4   5   6   7   8   9   10   >