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

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

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

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

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

2021-04-19 Thread Lu Baolu
Hi Keqian, On 2021/4/19 17:32, Keqian Zhu wrote: +EXPORT_SYMBOL_GPL(iommu_split_block); Do you really have any consumers of this interface other than the dirty bit tracking? If not, I don't suggest to make this as a generic IOMMU interface. There is an implicit requirement for such

Re: [PATCH] iommu: Use passthrough mode for the Intel IPUs

2021-04-19 Thread Lu Baolu
Hi Bingbu, On 4/19/21 12:57 PM, Bingbu Cao wrote: Intel IPU(Image Processing Unit) has its own (IO)MMU hardware, The IPU driver allocates its own page table that is not mapped via the DMA, and thus the Intel IOMMU driver blocks access giving this error: DMAR: DRHD: handling fault status reg 3

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

2021-04-18 Thread Lu Baolu
Hi Keqian, On 4/16/21 5:07 PM, Keqian Zhu wrote: I am worrying about having two sets of APIs for single purpose. From vendor iommu driver's point of view, this feature is per device. Hence, it still needs to do the same thing. Yes, we can unify the granule of feature reporting and status

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

2021-04-15 Thread Lu Baolu
Hi, On 2021/4/15 15:43, Keqian Zhu wrote: design it as not switchable. I will modify the commit message of patch#12, thanks! I am not sure that I fully get your point. But I can't see any gaps of using iommu_dev_enable/disable_feature() to switch dirty log on and off. Probably I missed

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

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

Re: [PATCH v2] iommu/vt-d: Force to flush iotlb before creating superpage

2021-04-14 Thread Lu Baolu
: 0x1a30a72003 2. __domain_mapping dma_pte_free_pagetable Set the PDE entry to ZERO Set the PDE entry to 0x21d200883 So we must flush the cache after the entry switch to ZERO to avoid the obsolete info be preserved. Cc: David Woodhouse Cc: Lu Baolu Cc: Nadav Amit Cc: Alex

Re: [PATCH 2/2] iommu/sva: Remove mm parameter from SVA bind API

2021-04-14 Thread Lu Baolu
Hi Jason, On 4/14/21 7:26 PM, Jason Gunthorpe wrote: On Wed, Apr 14, 2021 at 02:22:09PM +0800, Lu Baolu wrote: I still worry about supervisor pasid allocation. If we use iommu_sva_alloc_pasid() to allocate a supervisor pasid, which mm should the pasid be set? I've ever thought about passing

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

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

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

2021-04-14 Thread Lu Baolu
Hi Keqian, On 4/13/21 4:54 PM, Keqian Zhu wrote: Some types of IOMMU are capable of tracking DMA dirty log, such as ARM SMMU with HTTU or Intel IOMMU with SLADE. This introduces the dirty log tracking framework in the IOMMU base layer. Three new essential interfaces are added, and we

Re: [PATCH 2/2] iommu/sva: Remove mm parameter from SVA bind API

2021-04-14 Thread Lu Baolu
Hi Jacob, On 4/14/21 8:09 AM, Jacob Pan wrote: Hi Jean, On Fri, 9 Apr 2021 11:03:05 -0700, Jacob Pan wrote: problems: * We don't have a use-case for binding the mm of a remote process (and it's supposedly difficult for device drivers to do it securely). So OK, we remove the mm argument

Re: [PATCH][next] iommu/vt-d: Fix out-bounds-warning in intel_svm_page_response()

2021-04-13 Thread Lu Baolu
Hi Gustavo, On 4/14/21 3:54 AM, Gustavo A. R. Silva wrote: Replace call to memcpy() with just a couple of simple assignments in order to fix the following out-of-bounds warning: drivers/iommu/intel/svm.c:1198:4: warning: 'memcpy' offset [25, 32] from the object at 'desc' is out of the bounds

Re: [PATCH 5.4 v2 1/1] iommu/vt-d: Fix agaw for a supported 48 bit guest address width

2021-04-11 Thread Lu Baolu
I guess you need to ask Greg KH with this Cc-ing to sta...@vger.kernel.org. Best regards, baolu On 2021/4/12 3:36, Saeed Mirzamohammadi wrote: Hi Lu, Thanks for the review. May I know when do we expect this to be applied to 5.4? Thanks, Saeed On Apr 7, 2021, at 5:25 PM, Lu Baolu

Re: [PATCH] iommu/vt-d: Fix an error handling path in 'intel_prepare_irq_remapping()'

2021-04-11 Thread Lu Baolu
goto error; + return -ENODEV; if (!dmar_ir_support()) return -ENODEV; Thanks! Acked-by: Lu Baolu Best regards, baolu

[PATCH 1/1] iommu/vt-d: Fix build error of pasid_enable_wpe() with !X86

2021-04-11 Thread Lu Baolu
andy Dunlap Fixes: f68c7f539b6e9 ("iommu/vt-d: Enable write protect for supervisor SVM") Signed-off-by: Lu Baolu --- drivers/iommu/intel/pasid.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index 477b2e1d303c..72646bafc52

Re: [PATCH 2/2] iommu/sva: Remove mm parameter from SVA bind API

2021-04-09 Thread Lu Baolu
Hi, On 2021/4/9 1:08, Jacob Pan wrote: /** * iommu_sva_alloc_pasid - Allocate a PASID for the mm - * @mm: the mm * @min: minimum PASID value (inclusive) * @max: maximum PASID value (inclusive) * - * Try to allocate a PASID for this mm, or take a reference to the existing one - *

Re: [PATCH 1/2] iommu/sva: Tighten SVA bind API with explicit flags

2021-04-09 Thread Lu Baolu
Hi Jacob, On 2021/4/9 1:08, Jacob Pan wrote: The void* drvdata parameter isn't really used in iommu_sva_bind_device() API, the current IDXD code "borrows" the drvdata for a VT-d private flag for supervisor SVA usage. Supervisor/Privileged mode request is a generic feature. It should be

Re: [PATCH] iommu/vt-d: Force to flush iotlb before creating superpage

2021-04-08 Thread Lu Baolu
Hi Longpeng, On 4/8/21 3:37 PM, Longpeng (Mike, Cloud Infrastructure Service Product Dept.) wrote: Hi Baolu, -Original Message- From: Lu Baolu [mailto:baolu...@linux.intel.com] Sent: Thursday, April 8, 2021 12:32 PM To: Longpeng (Mike, Cloud Infrastructure Service Product Dept.) ; io

Re: [PATCH] iommu/vt-d: Force to flush iotlb before creating superpage

2021-04-07 Thread Lu Baolu
Hi Longpeng, On 4/7/21 2:35 PM, Longpeng (Mike, Cloud Infrastructure Service Product Dept.) wrote: Hi Baolu, -Original Message- From: Lu Baolu [mailto:baolu...@linux.intel.com] Sent: Friday, April 2, 2021 12:44 PM To: Longpeng (Mike, Cloud Infrastructure Service Product Dept.) ; io

Re: [PATCH 5.4 v2 1/1] iommu/vt-d: Fix agaw for a supported 48 bit guest address width

2021-04-07 Thread Lu Baolu
= cap_width; domain->gaw = guest_width; adjust_width = guestwidth_to_adjustwidth(guest_width); agaw = width_to_agaw(adjust_width); Reviewed-by: Lu Baolu Best regards, baolu

Re: [PATCH v8 7/9] vfio/mdev: Add iommu related member in mdev_device

2021-04-06 Thread Lu Baolu
Hi Jason, On 4/7/21 4:00 AM, Jason Gunthorpe wrote: On Mon, Mar 25, 2019 at 09:30:34AM +0800, Lu Baolu wrote: A parent device might create different types of mediated devices. For example, a mediated device could be created by the parent device with full isolation and protection provided

Re: [PATCH v5.4 1/1] iommu/vt-d: Fix agaw for a supported 48 bit guest address width

2021-04-06 Thread Lu Baolu
Hi Saeed, On 4/7/21 12:35 AM, Saeed Mirzamohammadi wrote: The IOMMU driver calculates the guest addressability for a DMA request based on the value of the mgaw reported from the IOMMU. However, this is a fused value and as mentioned in the spec, the guest width should be calculated based on the

Re: [PATCH v2 4/5] iommu/vt-d: Use user privilege for RID2PASID translation

2021-04-05 Thread Lu Baolu
On 3/20/21 10:54 AM, Lu Baolu wrote: When first-level page tables are used for IOVA translation, we use user privilege by setting U/S bit in the page table entry. This is to make it consistent with the second level translation, where the U/S enforcement is not available. Clear the SRE

Re: [PATCH] iommu/vt-d: Force to flush iotlb before creating superpage

2021-04-01 Thread Lu Baolu
On 4/2/21 11:41 AM, Longpeng (Mike, Cloud Infrastructure Service Product Dept.) wrote: Hi Baolu, 在 2021/4/2 11:06, Lu Baolu 写道: Hi Longpeng, On 4/1/21 3:18 PM, Longpeng(Mike) wrote: The translation caches may preserve obsolete data when the mapping size is changed, suppose the following

Re: [PATCH] iommu/vt-d: Force to flush iotlb before creating superpage

2021-04-01 Thread Lu Baolu
Hi Longpeng, On 4/1/21 3:18 PM, Longpeng(Mike) wrote: diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index ee09323..cbcb434 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -2342,9 +2342,20 @@ static inline int hardware_largepage_caps(struct

Re: [PATCH] iommu/vt-d: Force to flush iotlb before creating superpage

2021-04-01 Thread Lu Baolu
: 0x1a30a72003 2. __domain_mapping dma_pte_free_pagetable Set the PDE entry to ZERO Set the PDE entry to 0x21d200883 So we must flush the cache after the entry switch to ZERO to avoid the obsolete info be preserved. Cc: David Woodhouse Cc: Lu Baolu Cc: Nadav Amit Cc: Alex

[PATCH 1/1] iommu/vt-d: Report right snoop capability when using FL for IOVA

2021-03-29 Thread Lu Baolu
Ashok Raj Signed-off-by: Lu Baolu --- drivers/iommu/intel/pasid.h | 1 + drivers/iommu/intel/iommu.c | 11 ++- drivers/iommu/intel/pasid.c | 16 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/pasid.h b/drivers/iommu/intel/pasid.h index 07

Re: A problem of Intel IOMMU hardware ?

2021-03-26 Thread Lu Baolu
Hi Nadav, On 3/27/21 12:36 PM, Nadav Amit wrote: On Mar 26, 2021, at 7:31 PM, Lu Baolu wrote: Hi Nadav, On 3/19/21 12:46 AM, Nadav Amit wrote: So here is my guess: Intel probably used as a basis for the IOTLB an implementation of some other (regular) TLB design. Intel SDM says regarding

Re: A problem of Intel IOMMU hardware ?

2021-03-26 Thread Lu Baolu
Hi Nadav, On 3/19/21 12:46 AM, Nadav Amit wrote: So here is my guess: Intel probably used as a basis for the IOTLB an implementation of some other (regular) TLB design. Intel SDM says regarding TLBs (4.10.4.2 “Recommended Invalidation”): "Software wishing to prevent this uncertainty should

Re: [PATCH 3/5] iommu/vt-d: Remove SVM_FLAG_PRIVATE_PASID

2021-03-24 Thread Lu Baolu
Hi Christoph, On 3/24/21 1:33 AM, Christoph Hellwig wrote: On Tue, Mar 23, 2021 at 09:05:58AM +0800, Lu Baolu wrote: The SVM_FLAG_PRIVATE_PASID has never been referenced in the tree, and there's no plan to have anything to use it. So cleanup it. Signed-off-by: Lu Baolu Looks good

Re: [PATCH 2/3] iommu/vt-d: Remove IOVA domain rcache flushing for CPU offlining

2021-03-22 Thread Lu Baolu
@ -57,7 +57,6 @@ enum cpuhp_state { CPUHP_PAGE_ALLOC_DEAD, CPUHP_NET_DEV_DEAD, CPUHP_PCI_XGENE_DEAD, - CPUHP_IOMMU_INTEL_DEAD, CPUHP_IOMMU_IOVA_DEAD, CPUHP_LUSTRE_CFS_DEAD, CPUHP_AP_ARM_CACHE_B15_RAC_DEAD, Reviewed-by: Lu Baolu Best regards, baolu

[PATCH 5/5] iommu/vt-d: Make unnecessarily global functions static

2021-03-22 Thread Lu Baolu
Make some functions static as they are only used inside pasid.c. Signed-off-by: Lu Baolu --- drivers/iommu/intel/pasid.c | 4 ++-- drivers/iommu/intel/pasid.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index

[PATCH 2/5] iommu/vt-d: Remove svm_dev_ops

2021-03-22 Thread Lu Baolu
The svm_dev_ops has never been referenced in the tree, and there's no plan to have anything to use it. Remove it to make the code neat. Signed-off-by: Lu Baolu --- drivers/iommu/intel/svm.c | 15 +-- include/linux/intel-iommu.h | 3 --- include/linux/intel-svm.h | 7 --- 3

[PATCH 3/5] iommu/vt-d: Remove SVM_FLAG_PRIVATE_PASID

2021-03-22 Thread Lu Baolu
The SVM_FLAG_PRIVATE_PASID has never been referenced in the tree, and there's no plan to have anything to use it. So cleanup it. Signed-off-by: Lu Baolu --- drivers/iommu/intel/svm.c | 40 ++- include/linux/intel-svm.h | 16 +++- 2 files changed

[PATCH 0/5] iommu/vt-d: Several misc cleanups

2021-03-22 Thread Lu Baolu
Hi Joerg et al, This series includes several cleanups in the VT-d driver. Please help to review. Best regards, baolu Lu Baolu (5): iommu/vt-d: Remove unused dma map/unmap trace events iommu/vt-d: Remove svm_dev_ops iommu/vt-d: Remove SVM_FLAG_PRIVATE_PASID iommu/vt-d: Remove unused

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

2021-03-22 Thread Lu Baolu
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. Cleanup them to make the code neat. Signed-off-by: Lu Baolu --- include/trace/events/intel_iommu.h | 120 ---

[PATCH 4/5] iommu/vt-d: Remove unused function declarations

2021-03-22 Thread Lu Baolu
Some functions have been deprecated. Remove the remaining function delarations. Signed-off-by: Lu Baolu --- drivers/iommu/intel/pasid.h | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/iommu/intel/pasid.h b/drivers/iommu/intel/pasid.h index 444c0bec221a..90a3268d7a77 100644

[PATCH v2 5/5] iommu/vt-d: Avoid unnecessary cache flush in pasid entry teardown

2021-03-19 Thread Lu Baolu
-by: Lu Baolu --- drivers/iommu/intel/pasid.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index dd69df5a188a..7a73385edcc0 100644 --- a/drivers/iommu/intel/pasid.c +++ b/drivers/iommu/intel/pasid.c @@ -502,6 +502,9 @@ void

[PATCH v2 3/5] iommu/vt-d: Invalidate PASID cache when root/context entry changed

2021-03-19 Thread Lu Baolu
mu/vt-d: Setup context and enable RID2PASID support") Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 18 +- include/linux/intel-iommu.h | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iom

[PATCH v2 4/5] iommu/vt-d: Use user privilege for RID2PASID translation

2021-03-19 Thread Lu Baolu
table entry of RID2PASID so that requests requesting the supervisor privilege are blocked and treated as DMA remapping faults. Suggested-by: Jacob Pan Fixes: b802d070a52a1 ("iommu/vt-d: Use iova over first level") Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 7 +-- dri

[PATCH v2 0/5] iommu/vt-d: Several misc fixes

2021-03-19 Thread Lu Baolu
ons on second-level paging entries - Refine the commit message to make the intention clear. Lu Baolu (5): iommu/vt-d: Report the right page fault address iommu/vt-d: Remove WO permissions on second-level paging entries iommu/vt-d: Invalidate PASID cache when root/context entry changed io

[PATCH v2 1/5] iommu/vt-d: Report the right page fault address

2021-03-19 Thread Lu Baolu
The Address field of the Page Request Descriptor only keeps bit [63:12] of the offending address. Convert it to a full address before reporting it to device drivers. Fixes: eb8d93ea3c1d3 ("iommu/vt-d: Report page request faults for guest SVA") Signed-off-by: Lu Baolu --- drivers/i

[PATCH v2 2/5] iommu/vt-d: Remove WO permissions on second-level paging entries

2021-03-19 Thread Lu Baolu
/vt-d: Use iova over first level") Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 167219ea8d70..132cbf9f214f 100644 --- a/drivers/iommu/intel/iommu.c +++

[PATCH v2 1/1] iommu/vt-d: Don't set then clear private data in prq_event_thread()

2021-03-19 Thread Lu Baolu
cleared in prq_event_thread(). This breaks the rule defined by the VT-d specification. Fix it by moving clearing code up. Fixes: 5b438f4ba315d ("iommu/vt-d: Support page request in scalable mode") Cc: Jacob Pan Reviewed-by: Liu Yi L Signed-off-by: Lu Baolu --- drivers/iommu/intel

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

2021-03-19 Thread Lu Baolu
e pasid_lock with an atomic exchange operation. Reported-and-tested-by: Dave Jiang Signed-off-by: Lu Baolu --- drivers/iommu/intel/pasid.c | 21 + 1 file changed, 13 insertions(+), 8 deletions(-) Log: v1->v2: - v1: https://lore.kernel.org/linux-iommu/20210317005834

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

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

Re: [PATCH 1/1] iommu/vt-d: Don't set then immediately clear in prq_event_thread()

2021-03-18 Thread Lu Baolu
Hi Joerg, On 3/18/21 6:10 PM, Joerg Roedel wrote: Hi Baolu, On Tue, Mar 09, 2021 at 08:46:41AM +0800, Lu Baolu wrote: The private data field of a page group response descriptor is set then immediately cleared in prq_event_thread(). Fix this by moving clearing code up. Fixes: 5b438f4ba315d

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

2021-03-18 Thread Lu Baolu
Hi Joerg, On 3/18/21 6:21 PM, Joerg Roedel wrote: On Wed, Mar 17, 2021 at 08:58:34AM +0800, Lu Baolu wrote: The pasid_lock is used to synchronize different threads from modifying a same pasid directory entry at the same time. It causes below lockdep splat. [ 83.296538

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

2021-03-18 Thread Lu Baolu
On 3/18/21 7:53 PM, Shenming Lu wrote: On 2021/3/18 17:07, Tian, Kevin wrote: From: Shenming Lu Sent: Thursday, March 18, 2021 3:53 PM On 2021/2/4 14:52, Tian, Kevin wrote:>>> In reality, many devices allow I/O faulting only in selective contexts. However, there is no standard way (e.g.

Re: [PATCH 2/5] iommu/vt-d: Remove WO permissions on second-level paging entries

2021-03-18 Thread Lu Baolu
Hi Joerg, On 3/18/21 5:12 PM, Joerg Roedel wrote: Hi, On Mon, Mar 08, 2021 at 11:47:46AM -0800, Raj, Ashok wrote: That is the primary motivation, given that we have moved to 1st level for general IOVA, first level doesn't have a WO mapping. I didn't know enough about the history to determine

Re: A problem of Intel IOMMU hardware ?

2021-03-18 Thread Lu Baolu
On 3/18/21 4:56 PM, Tian, Kevin wrote: From: Longpeng (Mike, Cloud Infrastructure Service Product Dept.) -Original Message- From: Tian, Kevin [mailto:kevin.t...@intel.com] Sent: Thursday, March 18, 2021 4:27 PM To: Longpeng (Mike, Cloud Infrastructure Service Product Dept.) ; Nadav

Re: A problem of Intel IOMMU hardware ?

2021-03-17 Thread Lu Baolu
Hi Nadav, On 3/18/21 2:12 AM, Nadav Amit wrote: On Mar 17, 2021, at 2:35 AM, Longpeng (Mike, Cloud Infrastructure Service Product Dept.) wrote: Hi Nadav, -Original Message- From: Nadav Amit [mailto:nadav.a...@gmail.com] reproduce the problem with high probability (~50%). I

Re: A problem of Intel IOMMU hardware ?

2021-03-17 Thread Lu Baolu
Hi Alex, On 3/17/21 11:18 PM, Alex Williamson wrote: {MAP, 0x0, 0xc000}, - (b) use GDB to pause at here, and then DMA read IOVA=0, IOVA 0 seems to be a special one. Have you verified with other addresses than IOVA 0? It is???

[PATCH 1/1] iommu/vt-d: Report more information about invalidation errors

2021-03-17 Thread Lu Baolu
When the invalidation queue errors are encountered, dump the information logged by the VT-d hardware together with the pending queue invalidation descriptors. Signed-off-by: Ashok Raj Tested-by: Guo Kaijie Signed-off-by: Lu Baolu --- drivers/iommu/intel/dmar.c | 68

Re: A problem of Intel IOMMU hardware ?

2021-03-16 Thread Lu Baolu
Hi Longpeng, On 3/17/21 11:16 AM, Longpeng (Mike, Cloud Infrastructure Service Product Dept.) wrote: Hi guys, We find the Intel iommu cache (i.e. iotlb) maybe works wrong in a special situation, it would cause DMA fails or get wrong data. The reproducer (based on Alex's vfio testsuite[1]) is

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

2021-03-16 Thread Lu Baolu
e pasid_lock with an atomic exchange operation. Reported-and-tested-by: Dave Jiang Signed-off-by: Lu Baolu --- drivers/iommu/intel/pasid.c | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index

Re: [PATCH] iommu/vt-d: Disable SVM when ATS/PRI/PASID are not enabled in the device

2021-03-14 Thread Lu Baolu
) return -EINVAL; + if (!info->pasid_enabled || !info->pri_enabled || !info->ats_enabled) + return -EINVAL; + if (info->iommu->flags & VTD_FLAG_SVM_CAPABLE) return 0; } Thanks for the p

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

2021-03-09 Thread Lu Baolu
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 scenarios of using IOPF (mainly consider the nested extension), besides keeping IOMMU_DEV_FEAT_IOPF as a general

[PATCH 1/1] iommu/vt-d: Don't set then immediately clear in prq_event_thread()

2021-03-08 Thread Lu Baolu
The private data field of a page group response descriptor is set then immediately cleared in prq_event_thread(). Fix this by moving clearing code up. Fixes: 5b438f4ba315d ("iommu/vt-d: Support page request in scalable mode") Cc: Jacob Pan Reviewed-by: Liu Yi L Signed-off-by

Re: [PATCH 2/5] iommu/vt-d: Remove WO permissions on second-level paging entries

2021-03-07 Thread Lu Baolu
Hi Joerg, On 3/4/21 8:26 PM, Joerg Roedel wrote: On Thu, Feb 25, 2021 at 02:26:51PM +0800, Lu Baolu wrote: When the first level page table is used for IOVA translation, it only supports Read-Only and Read-Write permissions. The Write-Only permission is not supported as the PRESENT bit

Re: [PATCH] iommu/dma: Resurrect the "forcedac" option

2021-03-07 Thread Lu Baolu
-git a/include/linux/dma-iommu.h b/include/linux/dma-iommu.h index 706b68d1359b..13d1f4c14d7b 100644 --- a/include/linux/dma-iommu.h +++ b/include/linux/dma-iommu.h @@ -40,6 +40,8 @@ void iommu_dma_get_resv_regions(struct device *dev, struct list_head *list); void iommu_dma_free_cpu_cached_iovas(unsigned int cpu

Re: [PATCH v2 1/4] iommu/vt-d: Enable write protect for supervisor SVM

2021-03-03 Thread Lu Baolu
return -EINVAL; } pasid_set_sre(pte); + if (pasid_enable_wpe(pte)) + return -EINVAL; + } if (flags & PASID_FLAG_FL5LP) { Acked-by: Lu Baolu Best regards, baolu

Re: [PATCH v2 2/4] iommu/vt-d: Enable write protect propagation from guest

2021-03-03 Thread Lu Baolu
ID_WPE (1 << 6) /* Write protect enable */ +#define IOMMU_SVA_VTD_GPASID_LAST (1 << 7) __u64 flags; __u32 pat; __u32 emt; Acked-by: Lu Baolu Best regards, baolu

Re: [PATCH] iommu/vt-d: Fix status code for Allocate/Free PASID command

2021-02-28 Thread Lu Baolu
((e) >> 8) & 0xf) #define VCMD_CMD_OPERAND(e) ((e) << 8) /* Thanks a lot for catching this. Acked-by: Lu Baolu Best regards, baolu

[PATCH 5/5] iommu/vt-d: Avoid unnecessary cache flush in pasid entry teardown

2021-02-24 Thread Lu Baolu
-by: Lu Baolu --- drivers/iommu/intel/pasid.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index 07531e5edfa2..9fb3d3e80408 100644 --- a/drivers/iommu/intel/pasid.c +++ b/drivers/iommu/intel/pasid.c @@ -493,6 +493,9 @@ void

[PATCH 4/5] iommu/vt-d: Use user privilege for RID2PASID translation

2021-02-24 Thread Lu Baolu
table entry of RID2PASID so that requests requesting the supervisor privilege are blocked and treated as DMA remapping faults. Suggested-by: Jacob Pan Fixes: b802d070a52a1 ("iommu/vt-d: Use iova over first level") Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 7 +-- dri

[PATCH 2/5] iommu/vt-d: Remove WO permissions on second-level paging entries

2021-02-24 Thread Lu Baolu
WriteOnly which seems inconsistent and awkward. There is no use case we can think off, hence remove that configuration to make it consistent. Suggested-by: Ashok Raj Fixes: b802d070a52a1 ("iommu/vt-d: Use iova over first level") Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c

[PATCH 1/5] iommu/vt-d: Report the right page fault address

2021-02-24 Thread Lu Baolu
The Address field of the Page Request Descriptor only keeps bit [63:12] of the offending address. Convert it to a full address before reporting it to device drivers. Fixes: eb8d93ea3c1d3 ("iommu/vt-d: Report page request faults for guest SVA") Signed-off-by: Lu Baolu --- drivers/i

[PATCH 3/5] iommu/vt-d: Invalidate PASID cache when root/context entry changed

2021-02-24 Thread Lu Baolu
mu/vt-d: Setup context and enable RID2PASID support") Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 18 +- include/linux/intel-iommu.h | 1 + 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iom

[PATCH 0/5] iommu/vt-d: Several misc fixes

2021-02-24 Thread Lu Baolu
Hi Joerg, This series includes some misc fixes for the VT-d iommu driver. Please help to review and merge. Best regards, baolu Lu Baolu (5): iommu/vt-d: Report the right page fault address iommu/vt-d: Remove WO permissions on second-level paging entries iommu/vt-d: Invalidate PASID cache

[PATCH 1/1] iommu: Don't use lazy flush for untrusted device

2021-02-24 Thread Lu Baolu
obtain. Fixes: c588072bba6b5 ("iommu/vt-d: Convert intel iommu driver to the iommu ops") Signed-off-by: Lu Baolu --- drivers/iommu/dma-iommu.c | 15 --- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index f6

Re: [PATCH 4/4] iommu/vt-d: Calculate and set flags for handle_mm_fault

2021-02-19 Thread Lu Baolu
key enforcement. Therefore, we should set FAULT_FLAG_REMOTE to avoid faults when both SVM and PKEY are used. References: commit 1b2ee1266ea6 ("mm/core: Do not enforce PKEY permissions on remote mm access") Reviewed-by: Raj Ashok Signed-off-by: Jacob Pan Acked-by: Lu Baolu Best r

Re: [PATCH 3/4] iommu/vt-d: Reject unsupported page request modes

2021-02-19 Thread Lu Baolu
configurations, reject them both with invalid responses. Signed-off-by: Jacob Pan Fixes: 1c4f88b7f1f92 ("iommu/vt-d: Shared virtual address in scalable mode") Acked-by: Lu Baolu Best regards, baolu --- drivers/iommu/intel/svm.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletio

Re: [PATCH 1/4] iommu/vt-d: Enable write protect for supervisor SVM

2021-02-19 Thread Lu Baolu
Hi Jacob and Sanjay, On 2/19/21 5:31 AM, Jacob Pan wrote: Write protect bit, when set, inhibits supervisor writes to the read-only pages. In supervisor shared virtual addressing (SVA), where page tables are shared between CPU and DMA, IOMMU PASID entry WPE bit should match CR0.WP bit in the

Re: [PATCH 11/12] platform-msi: Add platform check for subdevice irq domain

2021-02-08 Thread Lu Baolu
Hi Leon, On 2/8/21 4:21 PM, Leon Romanovsky wrote: On Wed, Feb 03, 2021 at 12:56:44PM -0800, Megha Dey wrote: From: Lu Baolu 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

Re: [PATCH 11/12] platform-msi: Add platform check for subdevice irq domain

2021-02-04 Thread Lu Baolu
Hi Jason, On 2021/2/4 20:14, Jason Gunthorpe wrote: On Wed, Feb 03, 2021 at 12:56:44PM -0800, Megha Dey wrote: +bool arch_support_pci_device_ims(struct pci_dev *pdev) +{ Consistent language please, we are not using IMS elsewhere, this feature is called device_msi in Linux. Thanks for

Re: [PATCH v2 3/3] iommu/vt-d: Apply SATC policy

2021-02-03 Thread Lu Baolu
Hi Kevin, On 2/4/21 9:59 AM, Tian, Kevin wrote: From: Lu Baolu Sent: Wednesday, February 3, 2021 5:33 PM From: Yian Chen Starting from Intel VT-d v3.2, Intel platform BIOS can provide a new SATC table structure. SATC table lists a set of SoC integrated devices that require ATC to work (VT-d

Re: [PATCH v2 0/3] iommu/vt-d: Add support for ACPI/SATC table

2021-02-03 Thread Lu Baolu
Add the change log. Sorry for the quick sent. On 2021/2/3 17:33, Lu Baolu wrote: The Intel VT-d specification v3.2 comes with a new ACPI SATC (SoC- Integrated Address Translation Cache) reporting structure. The SoC integrated device enumerated in this table has a functional requirement

[PATCH v2 3/3] iommu/vt-d: Apply SATC policy

2021-02-03 Thread Lu Baolu
to the software. As the result, software shouldn't enable ATS on that device, otherwise duplicate device TLB invalidations will occur. Signed-off-by: Yian Chen Signed-off-by: Lu Baolu --- drivers/iommu/intel/iommu.c | 73 +++-- 1 file changed, 69 insertions(+), 4 deletions

[PATCH v2 0/3] iommu/vt-d: Add support for ACPI/SATC table

2021-02-03 Thread Lu Baolu
The Intel VT-d specification v3.2 comes with a new ACPI SATC (SoC- Integrated Address Translation Cache) reporting structure. The SoC integrated device enumerated in this table has a functional requirement to enable its ATC (Address Translation Cache) via the ATS capability for device operation.

[PATCH v2 1/3] iommu/vt-d: Add new enum value and structure for SATC

2021-02-03 Thread Lu Baolu
as needed. Signed-off-by: Yian Chen Signed-off-by: Lu Baolu --- include/acpi/actbl1.h | 11 ++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/include/acpi/actbl1.h b/include/acpi/actbl1.h index 43549547ed3e..c38e08cf1b9e 100644 --- a/include/acpi/actbl1.h +++ b/include/acpi

[PATCH v2 2/3] iommu/vt-d: Parse SATC reporting structure

2021-02-03 Thread Lu Baolu
From: Yian Chen Software should parse every SATC table and all devices in the tables reported by the BIOS and keep the information in kernel list for further reference. Signed-off-by: Yian Chen Signed-off-by: Lu Baolu --- drivers/iommu/intel/dmar.c | 8 drivers/iommu/intel/iommu.c

Re: [PATCH 0/3] iommu/vt-d: Add support for ACPI/SATC table

2021-02-03 Thread Lu Baolu
Hi Christoph, On 2021/2/3 16:41, Christoph Hellwig wrote: On Tue, Feb 02, 2021 at 12:40:54PM +0800, Lu Baolu wrote: Intel platform VT-d (v3.2) comes with a new type of DMAR subtable SATC. The SATC table includes a list of SoC integrated devices that require SATC. OS software can use this table

Re: [PATCH 3/3] iommu/vt-d: Apply SATC policy

2021-02-02 Thread Lu Baolu
On 2/2/21 9:55 PM, Joerg Roedel wrote: On Tue, Feb 02, 2021 at 12:40:57PM +0800, Lu Baolu wrote: + list_for_each_entry_rcu(satcu, _satc_units, list) { + satc = container_of(satcu->hdr, struct acpi_dmar_satc, header); + if (satc->segment == pci_domain_

Re: [PATCH 2/3] iommu/vt-d: Parse SATC reporting structure

2021-02-02 Thread Lu Baolu
Hi Ashok, On 2/3/21 12:41 AM, Raj, Ashok wrote: On Tue, Feb 02, 2021 at 12:40:56PM +0800, Lu Baolu wrote: From: Yian Chen Software should parse every SATC table and all devices in the tables reported by the BIOS and keep the information in kernel list for further SATC policy deployment

Re: [PATCH 2/3] iommu/vt-d: Parse SATC reporting structure

2021-02-02 Thread Lu Baolu
Hi Joerg, On 2/2/21 9:53 PM, Joerg Roedel wrote: On Tue, Feb 02, 2021 at 12:40:56PM +0800, Lu Baolu wrote: + case ACPI_DMAR_TYPE_SATC: + satc = container_of(header, struct acpi_dmar_satc, header); + pr_info("SATC flags: 0x%x\n", s

Re: [PATCH 1/3] iommu/vt-d: Add new enum value and structure for SATC

2021-02-02 Thread Lu Baolu
Hi Ashok, On 2/3/21 12:02 AM, Raj, Ashok wrote: On Tue, Feb 02, 2021 at 12:40:55PM +0800, Lu Baolu wrote: From: Yian Chen Starting from Intel Platform VT-d v3.2, BIOS may provide new remapping structure SATC for SOC integrated devices, according to section 8.8 of Intel VT-d architecture

Re: [PATCH 1/3] iommu/vt-d: Add new enum value and structure for SATC

2021-02-02 Thread Lu Baolu
Hi Joerg, On 2/2/21 9:51 PM, Joerg Roedel wrote: Hi Baolu, On Tue, Feb 02, 2021 at 12:40:55PM +0800, Lu Baolu wrote: @@ -514,7 +514,8 @@ enum acpi_dmar_type { ACPI_DMAR_TYPE_ROOT_ATS = 2, ACPI_DMAR_TYPE_HARDWARE_AFFINITY = 3, ACPI_DMAR_TYPE_NAMESPACE = 4

[PATCH 3/3] iommu/vt-d: Apply SATC policy

2021-02-01 Thread Lu Baolu
From: Yian Chen Starting from Intel VT-d v3.2, Intel platform BIOS can provide a new SATC table structure. SATC table lists a set of SoC integrated devices that require ATC to work (VT-d specification v3.2, section 8.8). Furthermore, the new version of IOMMU supports SoC device ATS in both its

[PATCH 2/3] iommu/vt-d: Parse SATC reporting structure

2021-02-01 Thread Lu Baolu
From: Yian Chen Software should parse every SATC table and all devices in the tables reported by the BIOS and keep the information in kernel list for further SATC policy deployment. Signed-off-by: Yian Chen --- drivers/iommu/intel/dmar.c | 9 drivers/iommu/intel/iommu.c | 89

[PATCH 1/3] iommu/vt-d: Add new enum value and structure for SATC

2021-02-01 Thread Lu Baolu
From: Yian Chen Starting from Intel Platform VT-d v3.2, BIOS may provide new remapping structure SATC for SOC integrated devices, according to section 8.8 of Intel VT-d architecture specification v3.2. The SATC structure reports a list of the devices that require SATC enabling via ATS capacity.

[PATCH 0/3] iommu/vt-d: Add support for ACPI/SATC table

2021-02-01 Thread Lu Baolu
Intel platform VT-d (v3.2) comes with a new type of DMAR subtable SATC. The SATC table includes a list of SoC integrated devices that require SATC. OS software can use this table to enable ATS only for the devices in the list. Yian Chen (3): iommu/vt-d: Add new enum value and structure for SATC

[PATCH 1/1] iommu/vt-d: Fix compile error [-Werror=implicit-function-declaration]

2021-01-30 Thread Lu Baolu
ndy Dunlap Signed-off-by: Lu Baolu --- drivers/iommu/intel/Makefile | 2 +- drivers/iommu/intel/iommu.c| 1 - include/trace/events/intel_iommu.h | 2 -- 3 files changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/iommu/intel/Makefile b/drivers/iommu/intel/Makefile index fb

Re: [PATCH v3] iommu/vt-d: do not use flush-queue when caching-mode is on

2021-01-27 Thread Lu Baolu
ched TLB flushes when caching-mode is on, as the performance benefit from using batched TLB invalidations is likely to be much smaller than the overhead of the virtual-to-physical IOMMU page-tables synchronization. Fixes: 13cf01744608 ("iommu/vt-d: Make use of iova deferred flushing") Signed-o

Re: [PATCH v2] iommu/vt-d: do not use flush-queue when caching-mode is on

2021-01-27 Thread Lu Baolu
Isn't it Fixes: 13cf01744608 ("iommu/vt-d: Make use of iova deferred flushing") ? Best regards, baolu Signed-off-by: Nadav Amit Cc: David Woodhouse Cc: Lu Baolu Cc: Joerg Roedel Cc: Will Deacon Cc: sta...@vger.kernel.org > --- v1->v2: * disable flush queue for all domai

Re: [PATCH] iommu/vt-d: do not use flush-queue when caching-mode is on

2021-01-26 Thread Lu Baolu
On 1/27/21 8:26 AM, Lu Baolu wrote: +{ +    struct dmar_domain *dmar_domain = to_dmar_domain(domain); +    struct intel_iommu *iommu = domain_get_iommu(dmar_domain); + +    if (intel_iommu_strict) +    return 0; + +    /* + * The flush queue implementation does not perform page-selective

Re: [PATCH] iommu/vt-d: do not use flush-queue when caching-mode is on

2021-01-26 Thread Lu Baolu
flushes with caching mode.") Signed-off-by: Nadav Amit Cc: David Woodhouse Cc: Lu Baolu Cc: Joerg Roedel Cc: Will Deacon Cc: sta...@vger.kernel.org --- drivers/iommu/intel/iommu.c | 26 +- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/driver

[PATCH v2 1/2] iommu/vt-d: Clear PRQ overflow only when PRQ is empty

2021-01-26 Thread Lu Baolu
/mwhpr11mb18862d2ea5bd432bf22d99a48c...@mwhpr11mb1886.namprd11.prod.outlook.com/ Signed-off-by: Lu Baolu --- drivers/iommu/intel/svm.c | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index 033b25886e57..d7c98c5fa4e7 100644

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

2021-01-26 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

  1   2   3   4   5   6   7   8   9   10   >