Re: [PATCH v2 2/2] iommu/vt-d: Fix a bug for PDP check in prq_event_thread

2020-10-30 Thread Lu Baolu
-off-by: Liu, Yi L Signed-off-by: Yi Sun Cc: sta...@ver.kernel.org Acked-by: Lu Baolu Best regards, baolu --- drivers/iommu/intel/svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index 7584669..3242ebd 100644

Re: [PATCH v2 1/2] iommu/vt-d: Fix sid not set issue in intel_svm_bind_gpasid()

2020-10-30 Thread Lu Baolu
igned-off-by: Yi Sun Cc: sta...@ver.kernel.org Acked-by: Lu Baolu Best regards, baolu --- drivers/iommu/intel/svm.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index f1861fa..7584669 100644 --- a/drivers/iommu/intel/svm

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

2020-10-29 Thread Lu Baolu
With the IOMMU driver registering iommu_ops for the mdev_bus, the IOMMU operations on an mdev could be done in the same way as any normal device (for example, PCI/PCIe). There's no need to distinguish an mdev from others for iommu operations. Remove the unnecessary code. Signed-off-by: Lu Baolu

[PATCH v6 4/5] iommu/vt-d: Add iommu_ops support for subdevice bus

2020-10-29 Thread Lu Baolu
as an aux-domain; Otherwise, it will be attached to the parent as a primary domain. Signed-off-by: Lu Baolu --- drivers/iommu/intel/Kconfig | 13 drivers/iommu/intel/Makefile | 1 + drivers/iommu/intel/iommu.c | 5 ++ drivers/iommu/intel/siov.c | 119

[PATCH v6 1/5] vfio/mdev: Register mdev bus earlier during boot

2020-10-29 Thread Lu Baolu
Move mdev bus registration earlier than IOMMU probe processing so that the IOMMU drivers could be able to set iommu_ops for the mdev bus. This only applies when vfio-mdev module is setected to be built-in. Signed-off-by: Lu Baolu --- drivers/vfio/mdev/mdev_core.c | 4 1 file changed, 4

[PATCH v6 2/5] iommu: Use bus iommu ops for aux related callback

2020-10-29 Thread Lu Baolu
The aux-domain apis were designed for macro driver where the subdevices are created and used inside a device driver. Use the device's bus iommu ops instead of that in iommu domain for various callbacks. Signed-off-by: Lu Baolu --- drivers/iommu/iommu.c | 16 ++-- 1 file changed, 10

[PATCH v6 0/5] iommu aux-domain APIs extensions

2020-10-29 Thread Lu Baolu
regards, baolu Lu Baolu (5): vfio/mdev: Register mdev bus earlier during boot iommu: Use bus iommu ops for aux related callback iommu/vt-d: Make some static functions global iommu/vt-d: Add iommu_ops support for subdevice bus vfio/type1: Use mdev bus iommu_ops for IOMMU callbacks drivers

[PATCH v6 3/5] iommu/vt-d: Make some static functions global

2020-10-29 Thread Lu Baolu
So that they could be used in other files as well. No functional changes. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 74 +++-- include/linux/intel-iommu.h | 49 2 files changed, 62 insertions(+), 61 deletions(-) diff --git

[PATCH 1/1] iommu/vt-d: Fix kernel NULL pointer dereference in find_domain()

2020-10-28 Thread Lu Baolu
4/0xa9 [ 362.928405] RIP: 0033:0x7f84855c5e95 Filter out those devices to avoid such error. Fixes: e2726daea583d ("iommu/vt-d: debugfs: Add support to show page table internals") Cc: sta...@vger.kernel.org#v5.6+ Reported-and-tested-by: Xu Pengfei Signed-off-by: Lu Baolu --- dri

Re: [PATCH v1 3/3] iommu/vt-d: Fix a bug for PDP check in prq_event_thread

2020-10-27 Thread Lu Baolu
Hi Yi, On 10/28/20 9:36 AM, Yi Sun wrote: From: "Liu, Yi L" Can you please add some description here? How far should this patch back ported? A Fixes tag? Best regards, baolu Signed-off-by: Liu, Yi L Signed-off-by: Yi Sun --- drivers/iommu/intel/svm.c | 2 +- 1 file changed, 1

Re: [PATCH v1 1/3] iommu/vt-d: Fix prq reporting issues

2020-10-27 Thread Lu Baolu
Hi Yi, On 10/28/20 9:36 AM, Yi Sun wrote: From: Liu Yi L Should get correct sid and set it into sdev. Because we execute 'sdev->sid != req->rid' in the loop of prq_event_thread(). How about making the title more accurate, how about something like: iommu/vt-d: Fix use before set issue in

[PATCH 1/1] iommu: Fix deferred domain attachment in iommu_probe_device()

2020-10-26 Thread Lu Baolu
The IOMMU core has support for deferring the attachment of default domain to device. Fix a missed deferred attaching check in iommu_probe_device(). Fixes: cf193888bfbd3 ("iommu: Move new probe_device path to separate function") Cc: sta...@vger.kernel.org # v5.8+ Signed-off-by

Re: [PATCH next] iommu: intel: don't dereference iommu_device if IOMMU_API is not built

2020-10-14 Thread Lu Baolu
Hi Bartosz, On 10/14/20 3:18 PM, Bartosz Golaszewski wrote: On Wed, Oct 14, 2020 at 2:49 AM Lu Baolu wrote: On 10/13/20 3:30 PM, Bartosz Golaszewski wrote: From: Bartosz Golaszewski Since commit c40c1018 ("iommu/vt-d: Gracefully handle DMAR units with no supported address w

Re: [PATCH next] iommu: intel: don't dereference iommu_device if IOMMU_API is not built

2020-10-13 Thread Lu Baolu
szewski With commit title adjusted to "iommu/vt-d: Don't dereference iommu_device if IOMMU_API is not built", Acked-by: Lu Baolu Best regards, baolu --- drivers/iommu/intel/dmar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/intel/dmar.c

Re: [PATCH next] iommu: intel: make DMAR_TABLE select IOMMU_API

2020-10-12 Thread Lu Baolu
Hi, On 10/12/20 8:31 PM, Bartosz Golaszewski wrote: From: Bartosz Golaszewski Since commit c40c1018 ("iommu/vt-d: Gracefully handle DMAR units with no supported address widths") dmar.c needs struct iommu_device to be defined. We need to unconditionally select IOMMU_API when DMAR_TABLE is

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

2020-10-12 Thread Lu Baolu
Hi Tvrtko, On 10/12/20 4:44 PM, Tvrtko Ursulin wrote: On 29/09/2020 01:11, Lu Baolu wrote: Hi Tvrtko, On 9/28/20 5:44 PM, Tvrtko Ursulin wrote: On 27/09/2020 07:34, Lu Baolu wrote: Hi, The previous post of this series could be found here. https://lore.kernel.org/linux-iommu

Re: [PATCH v3 0/2] Add support for ACPI device in RMRR

2020-10-11 Thread Lu Baolu
Hi Felix, On 10/10/20 4:02 PM, FelixCuioc wrote: BIOS allocate reserved memory ranges that may be DMA targets. BIOS may report each such reserved memory region through the RMRR structures,along with the devices that requires access to the specified reserved memory region. The purpose of this

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

2020-10-02 Thread Lu Baolu
Hi Joerg, On 2020/10/1 20:17, Joerg Roedel wrote: Hi Baolu, On Tue, Sep 29, 2020 at 08:11:35AM +0800, Lu Baolu wrote: I have no preference. It depends on which patch goes first. Let the maintainers help here. No preference on my side, except that it is too late for this now to make

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

2020-09-28 Thread Lu Baolu
Hi Tvrtko, On 9/28/20 5:44 PM, Tvrtko Ursulin wrote: On 27/09/2020 07:34, Lu Baolu wrote: Hi, The previous post of this series could be found here. https://lore.kernel.org/linux-iommu/20200912032200.11489-1-baolu...@linux.intel.com/ This version introduce a new patch [4/7] to fix

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

2020-09-27 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 --- drivers/iommu/dma-iommu.c | 29 +-- drivers/iommu/intel/iommu.c | 55 - include/linux

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

2020-09-27 Thread Lu Baolu
...@linux.intel.com/ There aren't any other changes. Please help to test and review. 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

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

2020-09-27 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 --- drivers/iommu/dma-iommu.c | 9 + include/linux/dma-iommu.h | 8 2 files changed, 17

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

2020-09-27 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 --- drivers/iommu/intel/Kconfig | 1 + drivers/iommu/intel/iommu.c | 742

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

2020-09-27 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 --- .../admin-guide/kernel-parameters.txt | 5 -- drivers/iommu/intel/iommu.c | 90

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

2020-09-27 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 --- drivers/iommu/dma-iommu.c | 163 +++--- 1

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

2020-09-27 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 --- drivers/iommu/dma-iommu.c | 27 +++ 1 file changed, 27 insertions

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

2020-09-27 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 --- drivers/iommu/intel/iommu.c | 16 ++-- 1 file changed, 14 insertions(+), 2

[PATCH 1/1] iommu/vt-d: Fix lockdep splat in iommu_flush_dev_iotlb()

2020-09-27 Thread Lu Baolu
ock(>lock); [ 12.704158] [ 12.704164] lock(device_domain_lock); [ 12.704174] *** DEADLOCK *** Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/i

Re: [PATCH] iommu/vt-d: gracefully handle DMAR units with no supported address widths

2020-09-24 Thread Lu Baolu
On 9/24/20 10:08 PM, David Woodhouse wrote: From: David Woodhouse Instead of bailing out completely, such a unit can still be used for interrupt remapping. Reviewed-by: Lu Baolu Best regards, baolu Signed-off-by: David Woodhouse --- drivers/iommu/intel/dmar.c | 46

Re: [PATCH v5 0/5] iommu aux-domain APIs extensions

2020-09-24 Thread Lu Baolu
Hi Joerg, On 9/24/20 5:55 PM, Joerg Roedel wrote: On Tue, Sep 22, 2020 at 02:10:37PM +0800, Lu Baolu wrote: Hi Jorge and Alex, A description of this patch series could be found here. https://lore.kernel.org/linux-iommu/20200901033422.22249-1-baolu...@linux.intel.com/ Hmm, I am wondering

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

2020-09-23 Thread Lu Baolu
Hi Tvrtko, On 9/15/20 4:31 PM, Tvrtko Ursulin wrote: With the previous version of the series I hit a problem on Ivybridge where apparently the dma engine width is not respected. At least that is my layman interpretation of the errors. From the older thread: <3> [209.526605] DMAR:

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

2020-09-22 Thread Lu Baolu
On 9/22/20 7:05 PM, Robin Murphy wrote: With the previous version of the series I hit a problem on Ivybridge where apparently the dma engine width is not respected. At least that is my layman interpretation of the errors. From the older thread: <3> [209.526605] DMAR: intel_iommu_map: iommu

[PATCH v5 0/5] iommu aux-domain APIs extensions

2020-09-22 Thread Lu Baolu
Lu Baolu (5): iommu: Add optional subdev in aux_at(de)tach ops iommu: Add iommu_at(de)tach_subdev_group() iommu: Add iommu_aux_get_domain_for_dev() vfio/type1: Use iommu_aux_at(de)tach_group() APIs iommu/vt-d: Add is_aux_domain support drivers/iommu/intel/iommu.c | 139

[PATCH v5 3/5] iommu: Add iommu_aux_get_domain_for_dev()

2020-09-22 Thread Lu Baolu
ted-by: Alex Williamson Link: https://lore.kernel.org/linux-iommu/20200708130749.1b1e1...@x1.home/ Signed-off-by: Lu Baolu --- drivers/iommu/iommu.c | 18 ++ include/linux/iommu.h | 20 2 files changed, 38 insertions(+) diff --git a/drivers/iommu/iommu.c b/driv

[PATCH v5 5/5] iommu/vt-d: Add is_aux_domain support

2020-09-22 Thread Lu Baolu
With subdevice information opt-in through iommu_ops.aux_at(de)tach_dev() interfaces, the vendor iommu driver is able to learn the knowledge about the relationships between the subdevices and the aux-domains. Implement is_aux_domain() support based on the relationship knowledges. Signed-off-by: Lu

[PATCH v5 2/5] iommu: Add iommu_at(de)tach_subdev_group()

2020-09-22 Thread Lu Baolu
the _attach_group() interfaces while the _attach_device() interfaces are relegated to special cases. Link: https://lore.kernel.org/linux-iommu/20200730134658.44c57...@x1.home/ Link: https://lore.kernel.org/linux-iommu/20200730151703.5daf8...@x1.home/ Signed-off-by: Lu Baolu --- drivers/iommu

[PATCH v5 1/5] iommu: Add optional subdev in aux_at(de)tach ops

2020-09-22 Thread Lu Baolu
-in. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 10 ++ drivers/iommu/iommu.c | 26 +- include/linux/iommu.h | 6 -- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c

[PATCH v5 4/5] vfio/type1: Use iommu_aux_at(de)tach_group() APIs

2020-09-22 Thread Lu Baolu
Replace iommu_aux_at(de)tach_device() with iommu_at(de)tach_subdev_group(). Signed-off-by: Lu Baolu --- drivers/vfio/vfio_iommu_type1.c | 43 + 1 file changed, 6 insertions(+), 37 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio

[PATCH 1/1] iommu/vt-d: Use device numa domain if RHSA is missing

2020-09-22 Thread Lu Baolu
If there are multiple NUMA domains but the RHSA is missing in ACPI/DMAR table, we could default to the device NUMA domain as fall back. Signed-off-by: Lu Baolu Reviewed-by: Kevin Tian Cc: Jacob Pan Cc: Kevin Tian Cc: Ashok Raj Link: https://lore.kernel.org/r/20200904010303.2961-1-baolu

[PATCH 0/1] [PULL REQUEST] iommu/vt-d: patches for v5.10

2020-09-22 Thread Lu Baolu
Hi Joerg, Below patch is ready for v5.10. It includes: - Use device numa domain if RHSA is missing Can you please consider them for v5.10? Best regards, Lu Baolu Lu Baolu (1): iommu/vt-d: Use device numa domain if RHSA is missing drivers/iommu/intel/iommu.c | 37

Re: [Intel-gfx] [PATCH v3 0/6] Convert the intel iommu driver to the dma-iommu api

2020-09-21 Thread Lu Baolu
Hi Logan, On 9/21/20 11:48 PM, Logan Gunthorpe wrote: On 2020-09-20 12:36 a.m., Lu Baolu wrote: Hi Logan, On 2020/9/19 4:47, Logan Gunthorpe wrote: Hi Lu, On 2020-09-11 9:21 p.m., Lu Baolu wrote: Tom Murphy has almost done all the work. His latest patch series was posted here. https

Re: [Intel-gfx] [PATCH v3 0/6] Convert the intel iommu driver to the dma-iommu api

2020-09-20 Thread Lu Baolu
Hi Logan, On 2020/9/19 4:47, Logan Gunthorpe wrote: Hi Lu, On 2020-09-11 9:21 p.m., Lu Baolu wrote: Tom Murphy has almost done all the work. His latest patch series was posted here. https://lore.kernel.org/linux-iommu/20200903201839.7327-1-murph...@tcd.ie/ Thanks a lot! This series

Re: [PATCH v7 00/16] vfio: expose virtual Shared Virtual Addressing to VMs

2020-09-15 Thread Lu Baolu
On 9/16/20 8:22 AM, Jacob Pan (Jun) wrote: If user space wants to bind page tables, create the PASID with /dev/sva, use ioctls there to setup the page table the way it wants, then pass the now configured PASID to a driver that can use it. Are we talking about bare metal SVA? If so, I don't see

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

2020-09-14 Thread Lu Baolu
Hi Tvrtko, On 9/14/20 4:04 PM, Tvrtko Ursulin wrote: Hi, On 12/09/2020 04:21, Lu Baolu wrote: Tom Murphy has almost done all the work. His latest patch series was posted here. https://lore.kernel.org/linux-iommu/20200903201839.7327-1-murph...@tcd.ie/ Thanks a lot! This series is a follow

Re: [PATCH v4 5/5] iommu/vt-d: Add is_aux_domain support

2020-09-13 Thread Lu Baolu
Hi Alex, On 9/11/20 6:05 AM, Alex Williamson wrote: On Tue, 1 Sep 2020 11:34:22 +0800 Lu Baolu wrote: With subdevice information opt-in through iommu_ops.aux_at(de)tach_dev() interfaces, the vendor iommu driver is able to learn the knowledge about the relationships between the subdevices

Re: [PATCH v4 2/5] iommu: Add iommu_at(de)tach_subdev_group()

2020-09-13 Thread Lu Baolu
Hi Alex, On 9/11/20 6:05 AM, Alex Williamson wrote: On Tue, 1 Sep 2020 11:34:19 +0800 Lu Baolu wrote: This adds two new APIs for the use cases like vfio/mdev where subdevices derived from physical devices are created and put in an iommu_group. The new IOMMU API interfaces mimic

Re: [PATCH v4 1/5] iommu: Add optional subdev in aux_at(de)tach ops

2020-09-13 Thread Lu Baolu
Hi Alex, On 9/11/20 6:05 AM, Alex Williamson wrote: On Tue, 1 Sep 2020 11:34:18 +0800 Lu Baolu wrote: In the vfio/mdev use case of aux-domain, the subdevices are created from the physical devices with IOMMU_DEV_FEAT_AUX enabled and the aux-domains are attached to the subdevices through

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

2020-09-11 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 --- drivers/iommu/dma-iommu.c | 163 +++--- 1

[PATCH v3 0/6] Convert the intel iommu driver to the dma-iommu api

2020-09-11 Thread Lu Baolu
. Fix several bugs in patch "iommu: Allow the dma-iommu api to use bounce buffers" to make the bounce buffer work for untrusted devices. 3. Several cleanups in iommu/vt-d driver after the conversion. Please review and test. Best regards, baolu Lu Baolu (2): iommu: Add quirk for Int

[PATCH v3 4/6] iommu: Add quirk for Intel graphic devices in map_sg

2020-09-11 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 --- drivers/iommu/dma-iommu.c | 27 +++ 1 file changed, 27 insertions

[PATCH v3 6/6] iommu/vt-d: Cleanup after converting to dma-iommu ops

2020-09-11 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 --- .../admin-guide/kernel-parameters.txt | 5 -- drivers/iommu/intel/iommu.c | 90

[PATCH v3 1/6] iommu: Handle freelists when using deferred flushing in iommu drivers

2020-09-11 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 --- drivers/iommu/dma-iommu.c | 30 ++-- drivers/iommu/intel/iommu.c | 55 - include

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

2020-09-11 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 --- drivers/iommu/intel/Kconfig | 1 + drivers/iommu/intel/iommu.c | 742

[PATCH v3 2/6] iommu: Add iommu_dma_free_cpu_cached_iovas()

2020-09-11 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 --- drivers/iommu/dma-iommu.c | 9 + include/linux/dma-iommu.h | 8 2 files changed, 17

Re: [PATCH V2 5/5] DO NOT MERGE: iommu: disable list appending in dma-iommu

2020-09-11 Thread Lu Baolu
On 2020/9/9 15:06, Christoph Hellwig wrote: On Wed, Sep 09, 2020 at 09:43:09AM +0800, Lu Baolu wrote: + /* +* The Intel graphic device driver is used to assume that the returned +* sg list is not combound. This blocks the efforts of converting the This adds pointless

Re: [PATCH V2 2/5] iommu: Add iommu_dma_free_cpu_cached_iovas function

2020-09-11 Thread Lu Baolu
On 2020/9/9 15:05, Christoph Hellwig wrote: +static inline void iommu_dma_free_cpu_cached_iovas(unsigned int cpu, + struct iommu_domain *domain) This adds a crazy long line. Which is rather pointless as other bits of code in the patch use the

Re: [PATCH V2 4/5] iommu/vt-d: Convert intel iommu driver to the iommu ops

2020-09-08 Thread Lu Baolu
On 9/4/20 4:18 AM, Tom Murphy wrote: +static int intel_iommu_needs_bounce_buffer(struct device *d) +{ + return !intel_no_bounce && dev_is_pci(d) && to_pci_dev(d)->untrusted; +} + + static void intel_iommu_probe_finalize(struct device *dev) { - struct iommu_domain *domain; +

Re: [PATCH V2 5/5] DO NOT MERGE: iommu: disable list appending in dma-iommu

2020-09-08 Thread Lu Baolu
Hi Christoph, On 9/8/20 2:23 PM, Christoph Hellwig wrote: On Tue, Sep 08, 2020 at 02:04:53PM +0800, Lu Baolu wrote: Do you mind telling where can I find Marek's series? [PATCH v10 00/30] DRM: fix struct sg_table nents vs. orig_nents misuse on various lists including the iommu one

Re: [PATCH V2 3/5] iommu: allow the dma-iommu api to use bounce buffers

2020-09-08 Thread Lu Baolu
On 9/4/20 4:18 AM, Tom Murphy wrote: 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 --- drivers/iommu/dma-iommu.c | 94 ++--- drivers/iommu/intel/iommu.c | 6

Re: [PATCH V2 2/5] iommu: Add iommu_dma_free_cpu_cached_iovas function

2020-09-08 Thread Lu Baolu
On 9/4/20 4:18 AM, Tom Murphy wrote: to dma-iommu ops 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 --- drivers/iommu/dma-iommu.c | 9 + include/linux/dma-iommu.h | 3 +++ 2 files

Re: [PATCH V2 5/5] DO NOT MERGE: iommu: disable list appending in dma-iommu

2020-09-08 Thread Lu Baolu
On 2020/9/8 14:23, Christoph Hellwig wrote: On Tue, Sep 08, 2020 at 02:04:53PM +0800, Lu Baolu wrote: Do you mind telling where can I find Marek's series? [PATCH v10 00/30] DRM: fix struct sg_table nents vs. orig_nents misuse on various lists including the iommu one. Get it. Thank you

Re: [PATCH V2 5/5] DO NOT MERGE: iommu: disable list appending in dma-iommu

2020-09-08 Thread Lu Baolu
://linuxplumbersconf.org/event/7/contributions/846/ As far as I can remember everyone seemed happy with that solution. I won't be working on this though as I don't have any more time to dedicate to this. It seems Lu Baolu will take over this. I'm absolutely again passing a flag. Tha just invites

Re: [PATCH v2 1/1] iommu/vt-d: Use device numa domain if RHSA is missing

2020-09-03 Thread Lu Baolu
Hi Kevin, On 9/4/20 10:16 AM, Tian, Kevin wrote: From: Lu Baolu Sent: Friday, September 4, 2020 9:03 AM If there are multiple NUMA domains but the RHSA is missing in ACPI/DMAR table, we could default to the device NUMA domain as fall back. This could also benefit a vIOMMU use case where only

[PATCH v2 1/1] iommu/vt-d: Use device numa domain if RHSA is missing

2020-09-03 Thread Lu Baolu
Cc: Kevin Tian Cc: Ashok Raj Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 37 +++-- 1 file changed, 35 insertions(+), 2 deletions(-) Change log: v1->v2: - Add a comment as suggested by Kevin. https://lore.kernel.org/linux-io

Re: 答复: 答复: [PATCH v3 2/2] iommu/vt-d:Add support for probing ACPI device in RMRR

2020-09-03 Thread Lu Baolu
Hi Felix, On 9/2/20 11:24 AM, FelixCui-oc wrote: hi baolu, So you have a hidden device (invisible to host kernel). But you need to setup some identity mappings for this device, so that the firmware could keep working, right? The platform designs this by putting that range in the RMRR

[PATCH 1/1] iommu/vt-d: Fix NULL pointer dereference in dev_iommu_priv_set()

2020-09-03 Thread Lu Baolu
iommu/vt-d: Use dev_iommu_priv_get/set()") Reported-by: Torsten Hilbrich Reported-by: Wendy Wang Link: https://lore.kernel.org/linux-iommu/96717683-70be-7388-3d2f-61131070a...@secunet.com/ Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 100

Re: [PATCH] iommu: Allocate dev_iommu before accessing priv data

2020-09-03 Thread Lu Baolu
4>[    3.341842]  kernel_init_freeable+0x169/0x1b2 <4>[    3.341845]  ? rest_init+0x9f/0x9f <4>[    3.341847]  kernel_init+0xa/0x101 <4>[    3.341849]  ret_from_fork+0x22/0x30 <4>[    3.341851] Modules linked in: <4>[    3.341854] CR2: 0038 <4>[    3.

Re: [Regression] [PATCH] iommu: Avoid crash in init_no_remapping_devices if iommu is NULL

2020-09-01 Thread Lu Baolu
Hi Torsten, On 9/1/20 10:41 PM, Torsten Hilbrich wrote: On 01.09.20 04:02, Lu Baolu wrote: [...] This looks more like a generic issue, used-before-allocated, and should be fixed in iommu.c instead of VT-d driver. How about diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index

Re: [Regression] [PATCH] iommu: Avoid crash in init_no_remapping_devices if iommu is NULL

2020-09-01 Thread Lu Baolu
hi Torsten, On 9/1/20 10:41 PM, Torsten Hilbrich wrote: On 01.09.20 04:02, Lu Baolu wrote: [...] This looks more like a generic issue, used-before-allocated, and should be fixed in iommu.c instead of VT-d driver. How about diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index

Re: [PATCH v2 3/9] iommu/ioasid: Introduce ioasid_set APIs

2020-09-01 Thread Lu Baolu
Hi, On 9/2/20 5:28 AM, Jacob Pan wrote: On Mon, 24 Aug 2020 10:24:11 +0800 Lu Baolu wrote: Hi Jacob, On 8/22/20 12:35 PM, Jacob Pan wrote: ioasid_set was introduced as an arbitrary token that are shared by a group of IOASIDs. For example, if IOASID #1 and #2 are allocated via the same

Re: 答复: [PATCH v3 2/2] iommu/vt-d:Add support for probing ACPI device in RMRR

2020-09-01 Thread Lu Baolu
*发件人:* Lu Baolu *发送时间:* 2020年9月1日 14:12:34 *收件人:* FelixCui-oc; Joerg Roedel; iommu@lists.linux-foundation.org; linux-ker...@vger.kernel.org; David Woodhouse; Dan Carpenter; kbu...@lists.01.org *抄送:* baolu...@linux.intel.com; CobeChen-oc; RaymondPang-oc; Tony W Wang-oc *主题

Re: [PATCH v3 2/2] iommu/vt-d:Add support for probing ACPI device in RMRR

2020-09-01 Thread Lu Baolu
Hi Felix, On 8/27/20 6:02 PM, FelixCuioc wrote: After acpi device in RMRR is detected,it is necessary to establish a mapping for these devices. In acpi_device_create_direct_mappings(),create a mapping for the acpi device in RMRR. Add a helper to achieve the acpi namespace device can access the

Re: [PATCH v3 1/2] iommu/vt-d:Add support for detecting ACPI device in RMRR

2020-09-01 Thread Lu Baolu
Hi Felix, On 8/27/20 6:02 PM, FelixCuioc wrote: Some ACPI devices need to issue dma requests to access the reserved memory area.BIOS uses the device scope type ACPI_NAMESPACE_DEVICE in RMRR to report these ACPI devices. This patch add support for detecting ACPI devices in RMRR. Signed-off-by:

Re: [PATCH v1] iommu/vt-d: Move intel_iommu_gfx_mapped to Intel IOMMU header

2020-08-31 Thread Lu Baolu
*iommu) { Looks good to me. Reviewed-by: Lu Baolu Best regards, baolu ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

[PATCH v4 4/5] vfio/type1: Use iommu_aux_at(de)tach_group() APIs

2020-08-31 Thread Lu Baolu
Replace iommu_aux_at(de)tach_device() with iommu_at(de)tach_subdev_group(). Signed-off-by: Lu Baolu --- drivers/vfio/vfio_iommu_type1.c | 43 + 1 file changed, 6 insertions(+), 37 deletions(-) diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio

[PATCH v4 1/5] iommu: Add optional subdev in aux_at(de)tach ops

2020-08-31 Thread Lu Baolu
-in. Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 10 ++ drivers/iommu/iommu.c | 4 ++-- include/linux/iommu.h | 6 -- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index bce158468abf

[PATCH v4 0/5] iommu aux-domain APIs extensions

2020-08-31 Thread Lu Baolu
domain is aux-domain for a device. - Return domain only if the domain is aux-domain in iommu_aux_get_domain_for_dev(). Lu Baolu (5): iommu: Add optional subdev in aux_at(de)tach ops iommu: Add iommu_at(de)tach_subdev_group() iommu: Add iommu_aux_get_domain_for_dev() vfio/type1: Use

[PATCH v4 5/5] iommu/vt-d: Add is_aux_domain support

2020-08-31 Thread Lu Baolu
With subdevice information opt-in through iommu_ops.aux_at(de)tach_dev() interfaces, the vendor iommu driver is able to learn the knowledge about the relationships between the subdevices and the aux-domains. Implement is_aux_domain() support based on the relationship knowledges. Signed-off-by: Lu

[PATCH v4 3/5] iommu: Add iommu_aux_get_domain_for_dev()

2020-08-31 Thread Lu Baolu
ted-by: Alex Williamson Link: https://lore.kernel.org/linux-iommu/20200708130749.1b1e1...@x1.home/ Signed-off-by: Lu Baolu --- drivers/iommu/iommu.c | 18 ++ include/linux/iommu.h | 20 2 files changed, 38 insertions(+) diff --git a/drivers/iommu/iommu.c b/driv

[PATCH v4 2/5] iommu: Add iommu_at(de)tach_subdev_group()

2020-08-31 Thread Lu Baolu
the _attach_group() interfaces while the _attach_device() interfaces are relegated to special cases. Link: https://lore.kernel.org/linux-iommu/20200730134658.44c57...@x1.home/ Link: https://lore.kernel.org/linux-iommu/20200730151703.5daf8...@x1.home/ Signed-off-by: Lu Baolu --- drivers/iommu

Re: [PATCH v8 7/7] iommu/vt-d: Check UAPI data processed by IOMMU core

2020-08-31 Thread Lu Baolu
3) /* page-level write through */ #define IOMMU_SVA_VTD_GPASID_EMTE (1 << 4) /* extended mem type enable */ #define IOMMU_SVA_VTD_GPASID_CD (1 << 5) /* PASID-level cache disable */ +#define IOMMU_SVA_VTD_GPASID_LAST (1 << 6) __u64 flags; __u32

Re: [Regression] [PATCH] iommu: Avoid crash in init_no_remapping_devices if iommu is NULL

2020-08-31 Thread Lu Baolu
Hi Torsten, Thank you for reporting this. On 8/31/20 7:03 PM, Torsten Hilbrich wrote: I noticed a kernel crash when trying to boot a v5.9-rc2 based kernel. The crash reads as: <1>[7.410192] BUG: kernel NULL pointer dereference, address: 0038 <1>[7.410196] #PF: supervisor

Re: [patch V2 00/46] x86, PCI, XEN, genirq ...: Prepare for device MSI

2020-08-31 Thread Lu Baolu
Hi Thomas, On 2020/8/31 15:10, Thomas Gleixner wrote: On Mon, Aug 31 2020 at 08:51, Lu Baolu wrote: On 8/26/20 7:16 PM, Thomas Gleixner wrote: This is the second version of providing a base to support device MSI (non PCI based) and on top of that support for IMS (Interrupt Message Storm

Re: [PATCH v1] iommu/vt-d: Move intel_iommu_ops to header file

2020-08-31 Thread Lu Baolu
Hi Andy, On 2020/8/31 14:30, Andy Shevchenko wrote: On Sat, Aug 29, 2020 at 07:58:46AM +0100, Christoph Hellwig wrote: On Fri, Aug 28, 2020 at 07:05:02PM +0300, Andy Shevchenko wrote: Compiler is not happy about hidden declaration of intel_iommu_ops. .../drivers/iommu/intel/iommu.c:414:24:

Re: [PATCH 1/1] iommu/vt-d: Use device numa domain if RHSA is missing

2020-08-30 Thread Lu Baolu
Hi Kevin, Thanks a lot for looking at my patch. On 8/28/20 10:13 AM, Tian, Kevin wrote: From: Lu Baolu Sent: Thursday, August 27, 2020 1:57 PM If there are multiple NUMA domains but the RHSA is missing in ACPI/DMAR table, we could default to the device NUMA domain as fall back. This also

Re: [patch V2 00/46] x86, PCI, XEN, genirq ...: Prepare for device MSI

2020-08-30 Thread Lu Baolu
Hi Thomas, On 8/26/20 7:16 PM, Thomas Gleixner wrote: This is the second version of providing a base to support device MSI (non PCI based) and on top of that support for IMS (Interrupt Message Storm) based devices in a halfways architecture independent way. After applying this patch series,

[PATCH v3 1/1] iommu/vt-d: Serialize IOMMU GCMD register modifications

2020-08-27 Thread Lu Baolu
) Cc: Andy Lutomirski Cc: Jacob Pan Cc: Kevin Tian Cc: Ashok Raj Signed-off-by: Lu Baolu --- drivers/iommu/intel/irq_remapping.c | 10 -- 1 file changed, 8 insertions(+), 2 deletions(-) Change log: v1->v2: - v1 posted here https://lore.kernel.org/linux-iommu/20200826025825

Re: [PATCH v2 1/1] iommu/vt-d: Serialize IOMMU GCMD register modifications

2020-08-27 Thread Lu Baolu
Hi, On 8/27/20 1:39 PM, Tian, Kevin wrote: From: Lu Baolu Sent: Thursday, August 27, 2020 12:25 PM The VT-d spec requires (10.4.4 Global Command Register, GCMD_REG General Description) that: If multiple control fields in this register need to be modified, software must serialize

[PATCH 1/1] iommu/vt-d: Use device numa domain if RHSA is missing

2020-08-27 Thread Lu Baolu
Cc: Kevin Tian Cc: Ashok Raj Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 31 +-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index e0516d64d7a3..bce158468abf 100644

[PATCH v2 1/1] iommu/vt-d: Serialize IOMMU GCMD register modifications

2020-08-26 Thread Lu Baolu
and CFI are done in one write. We need to do two separate writes with STS checking after each. Fixes: af8d102f999a4 ("x86/intel/irq_remapping: Clean up x2apic opt-out security warning mess") Cc: Andy Lutomirski Cc: Jacob Pan Cc: Kevin Tian Cc: Ashok Raj Signed-off-by: Lu Baolu --- dri

Re: [PATCH 1/1] iommu/vt-d: Serialize IOMMU GCMD register modifications

2020-08-26 Thread Lu Baolu
Hi Kevin, On 8/26/20 1:29 PM, Tian, Kevin wrote: From: Lu Baolu Sent: Wednesday, August 26, 2020 10:58 AM The VT-d spec requires (10.4.4 Global Command Register, GCMD_REG General Description) that: If multiple control fields in this register need to be modified, software must serialize

[PATCH 1/1] iommu/vt-d: Serialize IOMMU GCMD register modifications

2020-08-25 Thread Lu Baolu
and CFI are done in one write. We need to do two separate writes with STS checking after each. Fixes: af8d102f999a4 ("x86/intel/irq_remapping: Clean up x2apic opt-out security warning mess") Cc: Andy Lutomirski Cc: Jacob Pan Signed-off-by: Lu Baolu --- drivers/iommu/intel/irq_remap

Re: [PATCH] iommu/vt-d:Add support for detecting ACPI device in RMRR

2020-08-25 Thread Lu Baolu
Hi Felix, On 8/18/20 10:44 AM, FelixCuioc wrote: Some ACPI devices need to issue dma requests to access the reserved memory area.BIOS uses the device scope type ACPI_NAMESPACE_DEVICE in RMRR to report these ACPI devices. This patch add support for detecting ACPI devices in RMRR. If you are

Re: [PATCH] iommu/intel: Handle 36b addressing for x86-32

2020-08-24 Thread Lu Baolu
quot;iommu/vt-d: Delegate the dma domain to upper layer") and adjust the title as "iommu/vt-d: Handle 36bit addressing for x86-32" with above two changes, Acked-by: Lu Baolu Best regards, baolu the error looks older. Fixes: fa954e683178 ("iommu/vt-d: Delegate the dma domain to

Re: [PATCH v4 07/15] iommu/vt-d: Delegate the dma domain to upper layer

2020-08-24 Thread Lu Baolu
Hi Chris, On 8/24/20 4:35 PM, Chris Wilson wrote: Quoting Lu Baolu (2020-08-24 07:31:23) Hi Chris, On 2020/8/22 2:33, Chris Wilson wrote: Quoting Lu Baolu (2019-05-25 06:41:28) This allows the iommu generic layer to allocate a dma domain and attach it to a device through the iommu api's

Re: [PATCH v4 07/15] iommu/vt-d: Delegate the dma domain to upper layer

2020-08-24 Thread Lu Baolu
Hi Chris, On 2020/8/22 2:33, Chris Wilson wrote: Quoting Lu Baolu (2019-05-25 06:41:28) This allows the iommu generic layer to allocate a dma domain and attach it to a device through the iommu api's. With all types of domains being delegated to upper layer, we can remove an internal flag which

Re: [RESEND PATCH 4/5] iommu: intel: Drop kerneldoc marker from regular comment

2020-08-23 Thread Lu Baolu
iommu/vt-d: Drop kerneldoc marker from regular comment", Reviewed-by: Lu Baolu Best regards, baolu --- 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 93e6345f3414..ba47edf03

Re: [PATCH v2 4/9] iommu/ioasid: Add reference couting functions

2020-08-23 Thread Lu Baolu
Hi Jacob, On 8/22/20 12:35 PM, Jacob Pan wrote: There can be multiple users of an IOASID, each user could have hardware contexts associated with the IOASID. In order to align lifecycles, reference counting is introduced in this patch. It is expected that when an IOASID is being freed, each user

Re: [PATCH v2 3/9] iommu/ioasid: Introduce ioasid_set APIs

2020-08-23 Thread Lu Baolu
Hi Jacob, On 8/22/20 12:35 PM, Jacob Pan wrote: ioasid_set was introduced as an arbitrary token that are shared by a group of IOASIDs. For example, if IOASID #1 and #2 are allocated via the same ioasid_set*, they are viewed as to belong to the same set. For guest SVA usages, system-wide IOASID

Re: [PATCH v2 1/9] docs: Document IO Address Space ID (IOASID) APIs

2020-08-23 Thread Lu Baolu
Hi Jacob, On 2020/8/22 12:35, Jacob Pan wrote: IOASID is used to identify address spaces that can be targeted by device DMA. It is a system-wide resource that is essential to its many users. This document is an attempt to help developers from all vendors navigate the APIs. At this time, ARM

  1   2   3   4   5   6   7   8   9   10   >