[PATCH v3 2/7] iommu/vt-d: Remove global page support in devTLB flush

2020-07-01 Thread Jacob Pan
Global pages support is removed from VT-d spec 3.0 for dev TLB invalidation. This patch is to remove the bits for vSVA. Similar change already made for the native SVA. See the link below. Link: https://lkml.org/lkml/2019/8/26/651 Acked-by: Lu Baolu Signed-off-by: Jacob Pan --- drivers/iommu

[PATCH v3 7/7] iommu/vt-d: Disable multiple GPASID-dev bind

2020-07-01 Thread Jacob Pan
potential glitch do not warrant this unlikely use case thereby removed by this patch. Fixes: 56722a4398a30 ("iommu/vt-d: Add bind guest PASID support") Acked-by: Lu Baolu Cc: Kevin Tian Cc: Lu Baolu Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- drivers/iommu/intel/

Re: [PATCH v2 3/7] iommu/vt-d: Fix PASID devTLB invalidation

2020-07-01 Thread Jacob Pan
On Wed, 1 Jul 2020 08:49:54 +0800 Lu Baolu wrote: > Hi Jacob, > > On 7/1/20 5:07 AM, Jacob Pan wrote: > > DevTLB flush can be used for both DMA request with and without > > PASIDs. The former uses PASID#0 (RID2PASID), latter uses non-zero > > PASID for SVA usage.

Re: [PATCH 6/7] iommu/vt-d: Warn on out-of-range invalidation address

2020-07-01 Thread Jacob Pan
On Wed, 1 Jul 2020 09:45:40 +0800 Lu Baolu wrote: > Hi Jacob, > > On 7/1/20 1:34 AM, Jacob Pan wrote: > > On Thu, 25 Jun 2020 18:10:43 +0800 > > Lu Baolu wrote: > > > >> Hi, > >> > >> On 2020/6/23 23:43, Jacob Pan wrote: > >>

[PATCH v2 5/7] iommu/vt-d: Fix devTLB flush for vSVA

2020-06-30 Thread Jacob Pan
invalidate function") Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- drivers/iommu/intel/iommu.c | 28 ++-- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 96340da57075..6a0c62c73

[PATCH v2 2/7] iommu/vt-d: Remove global page support in devTLB flush

2020-06-30 Thread Jacob Pan
Global pages support is removed from VT-d spec 3.0 for dev TLB invalidation. This patch is to remove the bits for vSVA. Similar change already made for the native SVA. See the link below. Link: https://lkml.org/lkml/2019/8/26/651 Acked-by: Lu Baolu Signed-off-by: Jacob Pan --- drivers/iommu

[PATCH v2 7/7] iommu/vt-d: Disable multiple GPASID-dev bind

2020-06-30 Thread Jacob Pan
potential glitch do not warrant this unlikely use case thereby removed by this patch. Fixes: 56722a4398a30 ("iommu/vt-d: Add bind guest PASID support") Acked-by: Lu Baolu Cc: Kevin Tian Cc: Lu Baolu Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- drivers/iommu/intel/

[PATCH v2 0/7] iommu/vt-d: Misc tweaks and fixes for vSVA

2020-06-30 Thread Jacob Pan
rom Baolu - Fixed addr field in devTLB flush (5/7) - Assign address for single page devTLB invalidation (4/7) - Coding style tweaks Jacob Pan (4): iommu/vt-d: Remove global page support in devTLB flush iommu/vt-d: Fix PASID devTLB invalidation iommu/vt-d: Warn on out

[PATCH v2 4/7] iommu/vt-d: Handle non-page aligned address

2020-06-30 Thread Jacob Pan
invalidation descriptor. Unrecoverable fault will be reported due to non-zero value in the reserved bits. Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- drivers/iommu/intel/dmar.c | 20 ++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/intel/dmar.c b

[PATCH v2 3/7] iommu/vt-d: Fix PASID devTLB invalidation

2020-06-30 Thread Jacob Pan
be used by a single device, when tearing down a PASID entry we shall flush only the devTLB specific to a PASID. Fixes: 6f7db75e1c46 ("iommu/vt-d: Add second level page table") Signed-off-by: Jacob Pan --- drivers/iommu/intel/pasid.c | 11 ++- 1 file changed, 10 insertions(+),

[PATCH v2 6/7] iommu/vt-d: Warn on out-of-range invalidation address

2020-06-30 Thread Jacob Pan
to warning and proceed with invalidation request with the given mask. Signed-off-by: Jacob Pan --- drivers/iommu/intel/iommu.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 6a0c62c7395c..88e75be5ea76

[PATCH v2 1/7] iommu/vt-d: Enforce PASID devTLB field mask

2020-06-30 Thread Jacob Pan
From: Liu Yi L Set proper masks to avoid invalid input spillover to reserved bits. Acked-by: Lu Baolu Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- include/linux/intel-iommu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/intel-iommu.h b

Re: [PATCH v3 1/5] docs: IOMMU user API

2020-06-30 Thread Jacob Pan
On Tue, 30 Jun 2020 02:52:45 + "Tian, Kevin" wrote: > > From: Jacob Pan > > Sent: Tuesday, June 30, 2020 7:05 AM > > > > On Fri, 26 Jun 2020 16:19:23 -0600 > > Alex Williamson wrote: > > > > > On Tue, 23 Jun 2020 10:03:53 -0700 >

Re: [PATCH 6/7] iommu/vt-d: Warn on out-of-range invalidation address

2020-06-30 Thread Jacob Pan
On Thu, 25 Jun 2020 18:10:43 +0800 Lu Baolu wrote: > Hi, > > On 2020/6/23 23:43, Jacob Pan wrote: > > For guest requested IOTLB invalidation, address and mask are > > provided as part of the invalidation data. VT-d HW silently ignores > > any address bits below th

Re: [PATCH 4/7] iommu/vt-d: Handle non-page aligned address

2020-06-30 Thread Jacob Pan
On Thu, 25 Jun 2020 18:05:52 +0800 Lu Baolu wrote: > Hi, > > On 2020/6/23 23:43, Jacob Pan wrote: > > From: Liu Yi L > > > > Address information for device TLB invalidation comes from userspace > > when device is directly assigned to a guest with vIOMMU suppor

Re: [PATCH 3/7] iommu/vt-d: Fix PASID devTLB invalidation

2020-06-29 Thread Jacob Pan
On Tue, 30 Jun 2020 03:01:29 + "Tian, Kevin" wrote: > > From: Lu Baolu > > Sent: Thursday, June 25, 2020 3:26 PM > > > > On 2020/6/23 23:43, Jacob Pan wrote: > > > DevTLB flush can be used for both DMA request with and without > > >

Re: [PATCH 3/7] iommu/vt-d: Fix PASID devTLB invalidation

2020-06-29 Thread Jacob Pan
On Thu, 25 Jun 2020 15:25:57 +0800 Lu Baolu wrote: > On 2020/6/23 23:43, Jacob Pan wrote: > > DevTLB flush can be used for both DMA request with and without > > PASIDs. The former uses PASID#0 (RID2PASID), latter uses non-zero > > PASID for SVA usage. > > > >

Re: [PATCH v3 1/5] docs: IOMMU user API

2020-06-29 Thread Jacob Pan
On Fri, 26 Jun 2020 16:19:23 -0600 Alex Williamson wrote: > On Tue, 23 Jun 2020 10:03:53 -0700 > Jacob Pan wrote: > > > IOMMU UAPI is newly introduced to support communications between > > guest virtual IOMMU and host IOMMU. There has been lots of > > discussions

Re: [PATCH v3 4/5] iommu/uapi: Handle data and argsz filled by users

2020-06-24 Thread Jacob Pan
On Wed, 24 Jun 2020 14:54:49 +0800 Lu Baolu wrote: > Hi Jacob, > > On 2020/6/24 1:03, Jacob Pan wrote: > > IOMMU UAPI data has a user filled argsz field which indicates the > > data length comes with the API call. User data is not trusted, > > argsz must be validated

Re: [PATCH v3 3/5] iommu/uapi: Use named union for user data

2020-06-24 Thread Jacob Pan
On Wed, 24 Jun 2020 14:29:57 +0800 Lu Baolu wrote: > > case IOMMU_CACHE_INV_TYPE_IOTLB: > > /* HW will ignore LSB bits based on > > address mask */ if (inv_info->granularity == IOMMU_INV_GRANU_ADDR && > > size && > > -

Re: [PATCH 5/7] iommu/vt-d: Fix devTLB flush for vSVA

2020-06-23 Thread Jacob Pan
On Tue, 23 Jun 2020 08:43:14 -0700 Jacob Pan wrote: > From: Liu Yi L > > For guest SVA usage, in order to optimize for less VMEXIT, guest > request of IOTLB flush also includes device TLB. > > On the host side, IOMMU driver performs IOTLB and implicit devTLB > inv

[PATCH v3 2/5] iommu/uapi: Add argsz for user filled data

2020-06-23 Thread Jacob Pan
: Documentation/userspace-api/iommu.rst Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- include/uapi/linux/iommu.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/include/uapi/linux/iommu.h b/include/uapi/linux/iommu.h index e907b7091a46..303f148a5cd7 100644 --- a/include/uapi/linux

[PATCH v3 5/5] iommu/uapi: Support both kernel and user unbind guest PASID

2020-06-23 Thread Jacob Pan
be parsed and sanitized before calling into the kernel unbind function. Common user data copy code also consolidated. Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- drivers/iommu/iommu.c | 70 ++- include/linux/iommu.h | 13 -- 2

[PATCH v3 3/5] iommu/uapi: Use named union for user data

2020-06-23 Thread Jacob Pan
minimum size is the offset of the union. To use offsetof() on the union, we must make it named. Link: https://lkml.org/lkml/2020/6/11/834 Signed-off-by: Jacob Pan --- drivers/iommu/intel/iommu.c | 24 drivers/iommu/intel/svm.c | 2 +- include/uapi/linux/iommu.h | 4

[PATCH v3 1/5] docs: IOMMU user API

2020-06-23 Thread Jacob Pan
extensions should be achieved are also covered in this documentation. Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- Documentation/userspace-api/iommu.rst | 244 ++ 1 file changed, 244 insertions(+) create mode 100644 Documentation/userspace-api/iommu.rst diff

[PATCH v3 0/5] IOMMU user API enhancement

2020-06-23 Thread Jacob Pan
Jacob Pan (5): docs: IOMMU user API iommu/uapi: Add argsz for user filled data iommu/uapi: Use named union for user data iommu/uapi: Handle data and argsz filled by users iommu/uapi: Support both kernel and user unbind guest PASID Documentation/userspace-api/iommu.rst | 244

[PATCH v3 4/5] iommu/uapi: Handle data and argsz filled by users

2020-06-23 Thread Jacob Pan
increase. Backward compatibility is ensured based on size and flags checking. Details are documented in Documentation/userspace-api/iommu.rst This patch adds sanity checks in both IOMMU layer and vendor code, where VT-d is the only user for now. Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan

[PATCH 2/7] iommu/vt-d: Remove global page support in devTLB flush

2020-06-23 Thread Jacob Pan
Global pages support is removed from VT-d spec 3.0 for dev TLB invalidation. This patch is to remove the bits for vSVA. Similar change already made for the native SVA. See the link below. Link: https://lkml.org/lkml/2019/8/26/651 Signed-off-by: Jacob Pan --- drivers/iommu/intel/dmar.c | 4

[PATCH 5/7] iommu/vt-d: Fix devTLB flush for vSVA

2020-06-23 Thread Jacob Pan
invalidate function") Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- drivers/iommu/intel/iommu.c | 25 + 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 96340da57075..5ea5732d5ec4 1006

[PATCH 1/7] iommu/vt-d: Enforce PASID devTLB field mask

2020-06-23 Thread Jacob Pan
From: Liu Yi L Set proper masks to avoid invalid input spillover to reserved bits. Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- include/linux/intel-iommu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/intel-iommu.h b/include/linux/intel

[PATCH 0/7] iommu/vt-d: Misc tweaks and fixes for vSVA

2020-06-23 Thread Jacob Pan
Hi Baolu and all, This a series to address some of the issues we found in vSVA support. Most of the patches deal with exception handling, we also removed some bits that are not currently supported. Many thanks to Kevin Tian's review. Jacob & Yi Jacob Pan (4): iommu/vt-d: Remove gl

[PATCH 4/7] iommu/vt-d: Handle non-page aligned address

2020-06-23 Thread Jacob Pan
invalidation descriptor. Unrecoverable fault will be reported due to non-zero value in the reserved bits. Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- drivers/iommu/intel/dmar.c | 19 +-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/intel/dmar.c b

[PATCH 3/7] iommu/vt-d: Fix PASID devTLB invalidation

2020-06-23 Thread Jacob Pan
be used by a single device, when tearing down a PASID entry we shall flush only the devTLB specific to a PASID. Fixes: 6f7db75e1c46 ("iommu/vt-d: Add second level page table") Signed-off-by: Jacob Pan --- drivers/iommu/intel/pasid.c | 11 ++- 1 file changed, 10 insertions(+),

[PATCH 6/7] iommu/vt-d: Warn on out-of-range invalidation address

2020-06-23 Thread Jacob Pan
to warning and proceed with invalidation request with the given mask. Signed-off-by: Jacob Pan --- drivers/iommu/intel/iommu.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 5ea5732d5ec4..50fc62413a35

[PATCH 7/7] iommu/vt-d: Disable multiple GPASID-dev bind

2020-06-23 Thread Jacob Pan
potential glitch do not warrant this unlikely use case thereby removed by this patch. Cc: Kevin Tian Cc: Lu Baolu Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- drivers/iommu/intel/svm.c | 22 +- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/iommu

Re: [PATCH v2 1/3] docs: IOMMU user API

2020-06-16 Thread Jacob Pan
On Thu, 11 Jun 2020 17:27:27 -0700 Jacob Pan wrote: > > > > But then I thought it even better if VFIO leaves the entire > > copy_from_user() to the layer consuming it. > > > OK. Sounds good, that was what Kevin suggested also. I just wasn't > sure how mu

Re: [PATCH v2 1/3] docs: IOMMU user API

2020-06-12 Thread Jacob Pan
Hi Jon, On Thu, 11 Jun 2020 10:30:32 +0100 Jonathan Cameron wrote: > On Wed, 10 Jun 2020 21:12:13 -0700 > Jacob Pan wrote: > > > IOMMU UAPI is newly introduced to support communications between > > guest virtual IOMMU and host IOMMU. There has been lots of > > d

Re: [PATCH v2 1/3] docs: IOMMU user API

2020-06-12 Thread Jacob Pan
On Thu, 11 Jun 2020 14:33:08 +0800 Lu Baolu wrote: > Hi Jacob, > > On 2020/6/11 12:12, Jacob Pan wrote: > > IOMMU UAPI is newly introduced to support communications between > > guest virtual IOMMU and host IOMMU. There has been lots of > > discussions on how it sho

Re: [PATCH v2 1/3] docs: IOMMU user API

2020-06-12 Thread Jacob Pan
On Fri, 12 Jun 2020 07:38:44 + "Tian, Kevin" wrote: > > From: Jacob Pan > > Sent: Friday, June 12, 2020 8:27 AM > > > > On Thu, 11 Jun 2020 14:40:47 -0600 > > Alex Williamson wrote: > > > > > On Thu, 11 Jun 2020 12:52:0

Re: [PATCH v2 1/3] docs: IOMMU user API

2020-06-11 Thread Jacob Pan
On Thu, 11 Jun 2020 14:40:47 -0600 Alex Williamson wrote: > On Thu, 11 Jun 2020 12:52:05 -0700 > Jacob Pan wrote: > > > Hi Alex, > > > > On Thu, 11 Jun 2020 09:47:41 -0600 > > Alex Williamson wrote: > > > > > On Wed, 1

Re: [PATCH v2 2/3] iommu/uapi: Add argsz for user filled data

2020-06-11 Thread Jacob Pan
On Thu, 11 Jun 2020 10:49:36 -0600 Alex Williamson wrote: > On Wed, 10 Jun 2020 21:12:14 -0700 > Jacob Pan wrote: > > > As IOMMU UAPI gets extended, user data size may increase. To support > > backward compatibiliy, this patch introduces a size field to each > >

Re: [PATCH v2 3/3] iommu/vt-d: Sanity check uapi argsz filled by users

2020-06-11 Thread Jacob Pan
On Thu, 11 Jun 2020 14:55:18 -0600 Alex Williamson wrote: > On Thu, 11 Jun 2020 13:02:24 -0700 > Jacob Pan wrote: > > > On Thu, 11 Jun 2020 11:08:16 -0600 > > Alex Williamson wrote: > > > > > On Wed, 10 Jun 2020 21:12:15 -0700 > > > Jacob Pan

Re: [PATCH v2 3/3] iommu/vt-d: Sanity check uapi argsz filled by users

2020-06-11 Thread Jacob Pan
On Thu, 11 Jun 2020 11:08:16 -0600 Alex Williamson wrote: > On Wed, 10 Jun 2020 21:12:15 -0700 > Jacob Pan wrote: > > > IOMMU UAPI data has an argsz field which is filled by user. As the > > data structures expands, argsz may change. As the UAPI data are >

Re: [PATCH v2 1/3] docs: IOMMU user API

2020-06-11 Thread Jacob Pan
Hi Alex, On Thu, 11 Jun 2020 09:47:41 -0600 Alex Williamson wrote: > On Wed, 10 Jun 2020 21:12:13 -0700 > Jacob Pan wrote: > > > IOMMU UAPI is newly introduced to support communications between > > guest virtual IOMMU and host IOMMU. There has been lots of > > d

Re: [PATCH v2 1/3] docs: IOMMU user API

2020-06-11 Thread Jacob Pan
Hi Jon, On Thu, 11 Jun 2020 07:55:00 -0600 Jonathan Corbet wrote: > On Wed, 10 Jun 2020 21:12:13 -0700 > Jacob Pan wrote: > > A little nit but...this pattern: > > > +pattern below: > > + > > +:: > > + > > + struct { > > + _

[PATCH v2 3/3] iommu/vt-d: Sanity check uapi argsz filled by users

2020-06-10 Thread Jacob Pan
checks are performed in the model specific IOMMU drivers. This patch adds sanity checks in the VT-d to ensure argsz passed by userspace matches feature flags and other contents. Signed-off-by: Jacob Pan --- drivers/iommu/intel-iommu.c | 16 drivers/iommu/intel-svm.c | 12

[PATCH v2 2/3] iommu/uapi: Add argsz for user filled data

2020-06-10 Thread Jacob Pan
: Documentation/userspace-api/iommu.rst Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- include/uapi/linux/iommu.h | 6 ++ 1 file changed, 6 insertions(+) diff --git a/include/uapi/linux/iommu.h b/include/uapi/linux/iommu.h index e907b7091a46..303f148a5cd7 100644 --- a/include/uapi/linux

[PATCH v2 0/3] IOMMU user API enhancement

2020-06-10 Thread Jacob Pan
each UAPI data - Introduced UAPI doc Jacob Pan (3): docs: IOMMU user API iommu/uapi: Add argsz for user filled data iommu/vt-d: Sanity check uapi argsz filled by users Documentation/userspace-api/iommu.rst | 210 ++ drivers/iommu/intel-iommu.c

[PATCH v2 1/3] docs: IOMMU user API

2020-06-10 Thread Jacob Pan
extensions should be achieved are also covered in this documentation. Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- Documentation/userspace-api/iommu.rst | 210 ++ 1 file changed, 210 insertions(+) create mode 100644 Documentation/userspace-api/iommu.rst diff

Re: [PATCH] iommu/vt-d: Fix compile warning

2020-05-29 Thread Jacob Pan
On Fri, 29 May 2020 15:15:45 +0200 Joerg Roedel wrote: > Applied, thanks. > > On Thu, May 28, 2020 at 11:03:51AM -0700, Jacob Pan wrote: > > Make intel_svm_unbind_mm() a static function. > > > > Fixes: 064a57d7ddfc ("iommu/vt-d: Replace intel SVM APIs with >

[PATCH] iommu/vt-d: Fix compile warning

2020-05-28 Thread Jacob Pan
Make intel_svm_unbind_mm() a static function. Fixes: 064a57d7ddfc ("iommu/vt-d: Replace intel SVM APIs with generic SVA APIs") Reported-by: kbuild test robot Signed-off-by: Jacob Pan --- drivers/iommu/intel-svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dri

Re: [PATCH v2 0/2] iommu: Remove iommu_sva_ops::mm_exit()

2020-05-28 Thread Jacob Pan
from the Intel people) > > before going ahead with this. > > > > Patch 2 in this series looks good to me. > > Acked-by: Lu Baolu > > +Jacob, he participated in the discussions. > Patch 2 looks good to me, VT-d has a similar flow and challenge to stop DMA

Re: [PATCH v13 4/8] iommu/vt-d: Add bind guest PASID support

2020-05-14 Thread Jacob Pan
Hi Christoph, Thanks a lot for the reviews, comments below. Jacob On Wed, 13 May 2020 22:59:30 -0700 Christoph Hellwig wrote: > > + if (dev_is_pci(dev)) { > > + /* VT-d supports devices with full 20 bit PASIDs > > only */ > > + if (pci_max_pasids(to_pci_dev(dev)) != PASID

Re: [PATCH v13 3/8] iommu/vt-d: Add nested translation helper function

2020-05-14 Thread Jacob Pan
On Wed, 13 May 2020 22:54:24 -0700 Christoph Hellwig wrote: > > +* 1. CPU vs. IOMMU > > +* 2. Guest vs. Host. > > +*/ > > + switch (addr_width) { > > +#ifdef CONFIG_X86 > > + case ADDR_WIDTH_5LEVEL: > > + if (cpu_feature_enabled(X86_FEATURE_LA57) && > > + c

Re: [PATCH v13 2/8] iommu/vt-d: Use a helper function to skip agaw for SL

2020-05-14 Thread Jacob Pan
On Wed, 13 May 2020 22:51:32 -0700 Christoph Hellwig wrote: > On Wed, May 13, 2020 at 04:01:43PM -0700, Jacob Pan wrote: > > An Intel iommu domain uses 5-level page table by default. If the > > iommu that the domain tries to attach supports less page levels, > > the top lev

[PATCH v13 0/8] Nested Shared Virtual Address (SVA) VT-d support

2020-05-13 Thread Jacob Pan
es for common APIs (https://github.com/eauger/linux/tree/v5.1-rc3-2stage-v7) - Addressed review comments from Andy Shevchenko and Alex Williamson on IOASID custom allocator. - Support multiple custom IOASID allocators (vIOMMUs) and dynamic registra

[PATCH v13 8/8] iommu/vt-d: Add custom allocator for IOASID

2020-05-13 Thread Jacob Pan
PASID namespace is system- wide. Virtual command registers are used in the guest only, to prevent vmexit cost, we cache the capability and store it during initialization. Signed-off-by: Liu, Yi L Signed-off-by: Jacob Pan Reviewed-by: Eric Auger --- v12 - squashed virtual command register

[PATCH v13 4/8] iommu/vt-d: Add bind guest PASID support

2020-05-13 Thread Jacob Pan
| | |SL for GPA-HPA, default domain| | | '--' '-' Where: - FL = First level/stage one page tables - SL = Second level/stage two page tables Signed-off-by: Jacob Pan Signed-off-by: Liu Yi L --- v13 Only allow multiple bind if device has

[PATCH v13 6/8] iommu/vt-d: Add svm/sva invalidate function

2020-05-13 Thread Jacob Pan
device handle, host IOMMU driver can replace certain fields before submit to the invalidation queue. Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan Reviewed-by: Eric Auger --- drivers/iommu/intel-iommu.c | 171 1 file changed, 171 insertions

[PATCH v13 5/8] iommu/vt-d: Support flushing more translation cache types

2020-05-13 Thread Jacob Pan
When Shared Virtual Memory is exposed to a guest via vIOMMU, scalable IOTLB invalidation may be passed down from outside IOMMU subsystems. This patch adds invalidation functions that can be used for additional translation cache types. Signed-off-by: Jacob Pan Reviewed-by: Eric Auger

[PATCH v13 2/8] iommu/vt-d: Use a helper function to skip agaw for SL

2020-05-13 Thread Jacob Pan
An Intel iommu domain uses 5-level page table by default. If the iommu that the domain tries to attach supports less page levels, the top level page tables should be skipped. Add a helper to do this so that it could be used in other places. Signed-off-by: Jacob Pan Reviewed-by: Eric Auger

[PATCH v13 1/8] iommu/vt-d: Move domain helper to header

2020-05-13 Thread Jacob Pan
Move domain helper to header to be used by SVA code. Signed-off-by: Jacob Pan Reviewed-by: Eric Auger Reviewed-by: Kevin Tian --- drivers/iommu/intel-iommu.c | 6 -- include/linux/intel-iommu.h | 6 ++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/intel

[PATCH v13 7/8] iommu/vt-d: Enlightened PASID allocation

2020-05-13 Thread Jacob Pan
s the enlightened PASID allocation/free interfaces via the virtual command interface. Signed-off-by: Liu Yi L Signed-off-by: Lu Baolu Signed-off-by: Jacob Pan Reviewed-by: Eric Auger Reviewed-by: Kevin Tian --- drivers/iommu/intel-pasid.c | 57 + dr

[PATCH v13 3/8] iommu/vt-d: Add nested translation helper function

2020-05-13 Thread Jacob Pan
physical translation and SL performs guest physical to host physical translation. This patch adds a helper function for setting up nested translation where second level comes from a domain and first level comes from a guest PGD. Signed-off-by: Jacob Pan Signed-off-by: Liu Yi L Reviewed-by: Eric

Re: [PATCH v4 3/5] iommu/vt-d: Disable non-recoverable fault processing before unbind

2020-05-07 Thread Jacob Pan
reused soon, we don't want to > @@ -643,7 +645,8 @@ int intel_svm_unbind_mm(struct device *dev, int > pasid) >* to use. We have a *shared* PASID table, > because it's >* large and has to be physically > contiguous. So it's >* hard to be as defensive as we might like. > */ > - intel_pasid_tear_down_entry(iommu, dev, > svm->pasid); > + intel_pasid_tear_down_entry(iommu, dev, > + svm->pasid, > false); intel_flush_svm_range_dev(svm, sdev, 0, -1, 0); > kfree_rcu(sdev, rcu); > Reviewed-by: Jacob Pan ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v4 2/5] iommu/vt-d: debugfs: Add support to show inv queue internals

2020-05-07 Thread Jacob Pan
> struct intel_iommu *iommu) > @@ -490,6 +550,8 @@ void __init intel_iommu_debugfs_init(void) > debugfs_create_file("domain_translation_struct", 0444, > intel_iommu_debug, NULL, > &domain_translation_struct_fops); > + debugfs_create_file("invalidation_queue", 0444, > intel_iommu_debug, > + NULL, &invalidation_queue_fops); > #ifdef CONFIG_IRQ_REMAP > debugfs_create_file("ir_translation_struct", 0444, > intel_iommu_debug, NULL, &ir_translation_struct_fops); [Jacob Pan] ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v6 17/25] iommu/arm-smmu-v3: Implement iommu_sva_bind/unbind()

2020-05-07 Thread Jacob Pan
On Tue, 5 May 2020 11:15:31 +0200 Jean-Philippe Brucker wrote: > On Mon, May 04, 2020 at 01:47:23PM -0700, Jacob Pan wrote: > > > > > + arm_smmu_write_ctx_desc(smmu_domain, mm->pasid, > > > > > &invalid_cd); + > > > > > + arm_smm

Re: [PATCH v6 17/25] iommu/arm-smmu-v3: Implement iommu_sva_bind/unbind()

2020-05-04 Thread Jacob Pan
On Mon, 4 May 2020 18:43:51 +0200 Jean-Philippe Brucker wrote: > On Thu, Apr 30, 2020 at 02:16:17PM -0700, Jacob Pan wrote: > > > +static void arm_smmu_mm_invalidate_range(struct mmu_notifier *mn, > > > +

Re: [PATCH v6 02/25] iommu/ioasid: Add ioasid references

2020-05-04 Thread Jacob Pan
On Mon, 4 May 2020 16:25:48 +0200 Jean-Philippe Brucker wrote: > On Thu, Apr 30, 2020 at 11:39:31AM -0700, Jacob Pan wrote: > > > +/** > > > + * ioasid_get - obtain a reference to the IOASID > > > + */ > > > +void ioasid_get(ioasid_t ioasid) > &

Re: [PATCH v6 02/25] iommu/ioasid: Add ioasid references

2020-05-04 Thread Jacob Pan
On Mon, 4 May 2020 16:39:32 +0200 Jean-Philippe Brucker wrote: > On Thu, Apr 30, 2020 at 01:48:42PM -0700, Jacob Pan wrote: > > On Thu, 30 Apr 2020 11:39:31 -0700 > > Jacob Pan wrote: > > > > > > -void ioasid_free(ioasid_t ioasid) > >

Re: [PATCH v6 00/25] iommu: Shared Virtual Addressing for SMMUv3

2020-04-30 Thread Jacob Pan
u/iommu-sva.c | 85 + > drivers/iommu/of_iommu.c |5 +- > drivers/pci/ats.c |4 + > MAINTAINERS |3 +- > 21 files changed, 2275 insertions(+), 158 deletions(-)

Re: [PATCH v6 17/25] iommu/arm-smmu-v3: Implement iommu_sva_bind/unbind()

2020-04-30 Thread Jacob Pan
if (smmu_domain->stage != ARM_SMMU_DOMAIN_S1) > + return ERR_PTR(-EINVAL); > + > + mutex_lock(&arm_smmu_sva_lock); > + handle = __arm_smmu_sva_bind(dev, mm); > + mutex_unlock(&arm_smmu_sva_lock); > + return handle; > +} > + > +static void arm_smmu_sva_unbind(struct iommu_sva *handle) > +{ > + mutex_lock(&arm_smmu_sva_lock); > + __arm_smmu_sva_unbind(handle); > + mutex_unlock(&arm_smmu_sva_lock); > +} > + > +static int arm_smmu_sva_get_pasid(struct iommu_sva *handle) > +{ > + struct arm_smmu_bond *bond = sva_to_bond(handle); > + > + return bond->mm->pasid; > +} > + > static struct platform_driver arm_smmu_driver; > > static > @@ -3426,6 +3665,12 @@ static int arm_smmu_dev_disable_sva(struct > device *dev) master->sva_enabled = false; > mutex_unlock(&arm_smmu_sva_lock); > > + /* > + * Since the MMU notifier ops are held in the domain, it is > not safe to > + * free the domain until all MMU notifiers are freed. > + */ > + mmu_notifier_synchronize(); > + > return 0; > } > > @@ -3482,6 +3727,9 @@ static struct iommu_ops arm_smmu_ops = { > .dev_feat_enabled = arm_smmu_dev_feature_enabled, > .dev_enable_feat= arm_smmu_dev_enable_feature, > .dev_disable_feat = arm_smmu_dev_disable_feature, > + .sva_bind = arm_smmu_sva_bind, > + .sva_unbind = arm_smmu_sva_unbind, > + .sva_get_pasid = arm_smmu_sva_get_pasid, > .pgsize_bitmap = -1UL, /* Restricted during > device attach */ }; > [Jacob Pan] ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v6 02/25] iommu/ioasid: Add ioasid references

2020-04-30 Thread Jacob Pan
On Thu, 30 Apr 2020 11:39:31 -0700 Jacob Pan wrote: > > -void ioasid_free(ioasid_t ioasid) > > +bool ioasid_free(ioasid_t ioasid) > > { Sorry I missed this in the last reply. I think free needs to be unconditional since there is not a good way to fail it. Also can we have m

Re: [PATCH v6 02/25] iommu/ioasid: Add ioasid references

2020-04-30 Thread Jacob Pan
;refs); > + if (!free) > + goto exit_unlock; > + Just FYI, we may need to add states for the IOASID, i.g. mark the IOASID inactive after free. And prohibit ioasid_get() after freed. For VT-d, this is useful when KVM queries the IOASID. > active_allocator->ops-&

Re: [PATCH v12 4/8] iommu/vt-d: Add bind guest PASID support

2020-04-29 Thread Jacob Pan
On Wed, 29 Apr 2020 16:12:01 +0200 Auger Eric wrote: > >> in last review Eric raised the open about what about binding the > >> same PASID to the same pdev multiple times. We discussed that > >> should be disallowed. Here can you check whether aux_domain is > >> enabled on pdev to restrict multip

Re: [PATCH v3 3/4] iommu/vt-d: Add page request draining support

2020-04-29 Thread Jacob Pan
On Wed, 29 Apr 2020 14:00:05 +0800 Lu Baolu wrote: > Hi Jacob, > > On 2020/4/29 11:36, Jacob Pan wrote: > > On Wed, 22 Apr 2020 16:06:10 +0800 > > Lu Baolu wrote: > > > >> When a PASID is stopped or terminated, there can be pending PRQs > >>

Re: [PATCH v3 3/4] iommu/vt-d: Add page request draining support

2020-04-28 Thread Jacob Pan
gt; > Signed-off-by: Jacob Pan > Signed-off-by: Liu Yi L > Signed-off-by: Lu Baolu > --- > drivers/iommu/intel-svm.c | 103 > ++-- include/linux/intel-iommu.h | > 4 ++ 2 files changed, 102 insertions(+), 5 deletions(-) > > diff --

Re: [PATCH 5/7] x86/mmu: Allocate/free PASID

2020-04-28 Thread Jacob Pan (Jun)
On Tue, 28 Apr 2020 13:59:43 -0700 "Luck, Tony" wrote: > >> So the driver needs to use flush/drain operations to make sure all > >> the in-flight work has completed before releasing/re-using the > >> PASID. > > Are you suggesting we should let driver also hold a reference of the > > PASID? >

Re: [PATCH 5/7] x86/mmu: Allocate/free PASID

2020-04-28 Thread Jacob Pan (Jun)
On Tue, 28 Apr 2020 12:07:25 -0700 "Luck, Tony" wrote: > > If fd release cleans up then how should there be something in > > flight at the final mmdrop? > > ENQCMD from the user is only synchronous in that it lets the user > know their request has been added to a queue (or not). Execution of

Re: [PATCH 5/7] x86/mmu: Allocate/free PASID

2020-04-28 Thread Jacob Pan (Jun)
On Tue, 28 Apr 2020 20:54:01 +0200 Thomas Gleixner wrote: > "Jacob Pan (Jun)" writes: > > On Sun, 26 Apr 2020 16:55:25 +0200 > > Thomas Gleixner wrote: > >> Fenghua Yu writes: > >> > The PASID is freed when the process exits (so no need t

Re: [PATCH 5/7] x86/mmu: Allocate/free PASID

2020-04-28 Thread Jacob Pan (Jun)
On Sun, 26 Apr 2020 16:55:25 +0200 Thomas Gleixner wrote: > Fenghua Yu writes: > > > PASID is shared by all threads in a process. So the logical place > > to keep track of it is in the "mm". Add the field to the > > architecture specific mm_context_t structure. > > > > A PASID is allocated for

Re: [PATCH v12 4/8] iommu/vt-d: Add bind guest PASID support

2020-04-27 Thread Jacob Pan
On Fri, 24 Apr 2020 10:47:45 + "Tian, Kevin" wrote: > > From: Jacob Pan > > Sent: Wednesday, April 22, 2020 2:53 AM > > > > When supporting guest SVA with emulated IOMMU, the guest PASID > > table is shadowed in VMM. Updates to guest vIOMMU PASID ta

Re: [PATCH v11 05/10] iommu/vt-d: Add bind guest PASID support

2020-04-27 Thread Jacob Pan
On Fri, 17 Apr 2020 23:46:13 + "Tian, Kevin" wrote: > > From: Jacob Pan > > Sent: Friday, April 17, 2020 11:29 PM > > > > On Fri, 17 Apr 2020 09:46:55 +0200 > > Auger Eric wrote: > > > > > Hi Kevin, > > > On 4/17/20 4:45

Re: [PATCH 03/10] iommu/ioasid: Introduce per set allocation APIs

2020-04-21 Thread Jacob Pan
Hi Jean, Sorry for the late reply, been trying to redesign the notification part. On Tue, 7 Apr 2020 13:01:07 +0200 Jean-Philippe Brucker wrote: > On Mon, Apr 06, 2020 at 01:02:45PM -0700, Jacob Pan wrote: > > > > + sdata = kzalloc(sizeof(*sdata), GFP_KERNEL); > > &

[PATCH v12 8/8] iommu/vt-d: Add custom allocator for IOASID

2020-04-21 Thread Jacob Pan
Baolu Signed-off-by: Liu, Yi L Signed-off-by: Jacob Pan Reviewed-by: Eric Auger --- drivers/iommu/dmar.c| 1 + drivers/iommu/intel-iommu.c | 85 + include/linux/intel-iommu.h | 7 3 files changed, 93 insertions(+) diff --git a/drivers

[PATCH v12 1/8] iommu/vt-d: Move domain helper to header

2020-04-21 Thread Jacob Pan
Move domain helper to header to be used by SVA code. Signed-off-by: Jacob Pan Reviewed-by: Eric Auger Reviewed-by: Kevin Tian --- drivers/iommu/intel-iommu.c | 6 -- include/linux/intel-iommu.h | 6 ++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/intel

[PATCH v12 2/8] iommu/vt-d: Use a helper function to skip agaw for SL

2020-04-21 Thread Jacob Pan
An Intel iommu domain uses 5-level page table by default. If the iommu that the domain tries to attach supports less page levels, the top level page tables should be skipped. Add a helper to do this so that it could be used in other places. Signed-off-by: Jacob Pan Reviewed-by: Eric Auger

[PATCH v12 5/8] iommu/vt-d: Support flushing more translation cache types

2020-04-21 Thread Jacob Pan
When Shared Virtual Memory is exposed to a guest via vIOMMU, scalable IOTLB invalidation may be passed down from outside IOMMU subsystems. This patch adds invalidation functions that can be used for additional translation cache types. Signed-off-by: Jacob Pan Reviewed-by: Eric Auger

[PATCH v12 3/8] iommu/vt-d: Add nested translation helper function

2020-04-21 Thread Jacob Pan
physical translation and SL performs guest physical to host physical translation. This patch adds a helper function for setting up nested translation where second level comes from a domain and first level comes from a guest PGD. Signed-off-by: Jacob Pan Signed-off-by: Liu, Yi L Reviewed-by

[PATCH v12 6/8] iommu/vt-d: Add svm/sva invalidate function

2020-04-21 Thread Jacob Pan
device handle, host IOMMU driver can replace certain fields before submit to the invalidation queue. --- v12 - Use ratelimited prints for all user called APIs. - Check for domain nesting attr --- Signed-off-by: Jacob Pan Signed-off-by: Ashok Raj Signed-off-by: Liu, Yi L Signed-off-by

[PATCH v12 7/8] iommu/vt-d: Enlightened PASID allocation

2020-04-21 Thread Jacob Pan
s the enlightened PASID allocation/free interfaces via the virtual command interface. Signed-off-by: Liu Yi L Signed-off-by: Lu Baolu Signed-off-by: Jacob Pan Reviewed-by: Eric Auger Reviewed-by: Kevin Tian --- drivers/iommu/intel-pasid.c | 57 + dr

[PATCH v12 0/8] Nested Shared Virtual Address (SVA) VT-d support

2020-04-21 Thread Jacob Pan
es for common APIs (https://github.com/eauger/linux/tree/v5.1-rc3-2stage-v7) - Addressed review comments from Andy Shevchenko and Alex Williamson on IOASID custom allocator. - Support multiple custom IOASID allocators (vIOMMUs) and dynamic registr

[PATCH v12 4/8] iommu/vt-d: Add bind guest PASID support

2020-04-21 Thread Jacob Pan
| | |SL for GPA-HPA, default domain| | | '--' '-' Where: - FL = First level/stage one page tables - SL = Second level/stage two page tables Signed-off-by: Jacob Pan Signed-off-by: Liu, Yi L ---

Re: [PATCH v5 02/25] iommu/sva: Manage process address spaces

2020-04-20 Thread Jacob Pan
ructure. That avoid the whole multiplexing > > > layer. > > > > Right, I can see the appeal. I still like having a single mmu > > notifier per mm because it ensures we allocate a single PASID per > > mm (as required by x86). I suppos

Re: [PATCH v5 02/25] iommu/sva: Manage process address spaces

2020-04-20 Thread Jacob Pan
; Because the IOMMUv2 supports only smaller PASIDs, we want to avoid > exhausting that space with PASID allocations that don't use the > IOMMUv2. So our PASID allocation function has a "size" parameter, and > we try to allocated a PASID as big as possible in order to leav

Re: [PATCH v11 07/10] iommu/vt-d: Add svm/sva invalidate function

2020-04-17 Thread Jacob Pan
On Thu, 16 Apr 2020 12:59:14 +0200 Auger Eric wrote: > Hi Jacob, > On 4/10/20 11:56 PM, Jacob Pan wrote: > > On Thu, 9 Apr 2020 10:50:34 +0200 > > Auger Eric wrote: > > > >> Hi Jacob, > >> > >> On 4/3/20 8:42 PM, Jacob Pan wrote: >

Re: [PATCH v11 05/10] iommu/vt-d: Add bind guest PASID support

2020-04-17 Thread Jacob Pan
from happening, otherwise VFIO > > also needs to track the bind count and do multiple unbinds at > > mm_exit. But it's not necessary to prevent it in VFIO. We can check > > here upon whether aux_domain is valid, and if not return -EBUSY. > Ah OK. So if we can detect the case

Re: [PATCH 0/2] iommu: Remove iommu_sva_ops::mm_exit()

2020-04-16 Thread Jacob Pan
On Wed, 15 Apr 2020 09:47:36 +0200 Jean-Philippe Brucker wrote: > On Fri, Apr 10, 2020 at 08:52:49AM -0700, Jacob Pan wrote: > > On Thu, 9 Apr 2020 16:50:58 +0200 > > Jean-Philippe Brucker wrote: > > > > > > So unbind is coming anyway, the difference i

Re: [PATCH v11 01/13] iommu: Introduce attach/detach_pasid_table API

2020-04-15 Thread Jacob Pan
On Wed, 15 Apr 2020 16:52:10 +0200 Auger Eric wrote: > Hi Jacob, > On 4/15/20 12:15 AM, Jacob Pan wrote: > > Hi Eric, > > > > There are some discussions about how to size the uAPI data. > > https://lkml.org/lkml/2020/4/14/939 > > > > I think the pr

Re: [PATCH v2 1/3] iommu/uapi: Define uapi version and capabilities

2020-04-15 Thread Jacob Pan
On Tue, 14 Apr 2020 23:47:40 + "Tian, Kevin" wrote: > > From: Jacob Pan > > Sent: Wednesday, April 15, 2020 6:32 AM > > > > On Tue, 14 Apr 2020 10:13:04 -0700 > > Jacob Pan wrote: > > > > > > > > In any of the proposed s

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