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

2021-04-16 Thread Jacob Pan
he generic code. This patch replaces void* drvdata with a unsigned int flags parameter and adjusts callers accordingly. Link: https://lore.kernel.org/linux-iommu/YFhiMLR35WWMW%2FHu@myrica/ Suggested-by: Jean-Philippe Brucker Signed-off-by: Jacob Pan --- drivers/dma/idxd/cdev.c

[PATCH v3 0/2] Simplify and restrict IOMMU SVA APIs

2021-04-16 Thread Jacob Pan
in iommu_sva_alloc_pasid() - keep generic supervisor flag separated from vt-d's SRE - move flag declaration out of CONFIG_IOMMU_API Jacob Pan (2): iommu/sva: Tighten SVA bind API with explicit flags iommu/sva: Remove mm parameter from SVA bind API drivers/dma/idxd/cdev.c

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

2021-04-16 Thread Jacob Pan
/YFhiMLR35WWMW%2FHu@myrica/ Signed-off-by: Jacob Pan --- drivers/dma/idxd/cdev.c | 2 +- drivers/dma/idxd/init.c | 2 +- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 9 + drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 3 +-- drivers

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-04-16 Thread Jacob Pan
Hi Alex, On Fri, 16 Apr 2021 09:45:47 -0600, Alex Williamson wrote: > On Fri, 16 Apr 2021 06:12:58 -0700 > Jacob Pan wrote: > > > Hi Jason, > > > > On Thu, 15 Apr 2021 20:07:32 -0300, Jason Gunthorpe > > wrote: > > > On Thu, Apr 15,

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-04-16 Thread Jacob Pan
Hi Jason, On Thu, 15 Apr 2021 20:07:32 -0300, Jason Gunthorpe wrote: > On Thu, Apr 15, 2021 at 03:11:19PM +0200, Auger Eric wrote: > > Hi Jason, > > > > On 4/1/21 6:03 PM, Jason Gunthorpe wrote: > > > On Thu, Apr 01, 2021 at 02:08:17PM +, Liu, Yi L wrote: > > > > > >> DMA page faults

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

2021-04-15 Thread Jacob Pan
Hi Christoph, On Thu, 15 Apr 2021 07:44:59 +0100, Christoph Hellwig wrote: > > * > > * Returns 0 on success and < 0 on error. > > @@ -28,6 +28,9 @@ int iommu_sva_alloc_pasid(struct mm_struct *mm, > > ioasid_t min, ioasid_t max) int ret = 0; > > ioasid_t pasid; > > > > + if (mm !=

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

2021-04-15 Thread Jacob Pan
Hi Christoph, Thanks for the review. On Thu, 15 Apr 2021 07:40:33 +0100, Christoph Hellwig wrote: > On Wed, Apr 14, 2021 at 08:27:56AM -0700, Jacob Pan wrote: > > static int idxd_enable_system_pasid(struct idxd_device *idxd) > > { > > - int flags; >

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

2021-04-14 Thread Jacob Pan
/YFhiMLR35WWMW%2FHu@myrica/ Signed-off-by: Jacob Pan --- drivers/dma/idxd/cdev.c | 2 +- drivers/dma/idxd/init.c | 2 +- drivers/iommu/iommu-sva-lib.c | 11 +++ drivers/iommu/iommu.c | 20 +--- drivers/misc/uacce/uacce.c| 2 +- include/linux/iommu.h

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

2021-04-14 Thread Jacob Pan
he generic code. This patch replaces void* drvdata with a unsigned int flags parameter and adjusts callers accordingly. Link: https://lore.kernel.org/linux-iommu/YFhiMLR35WWMW%2FHu@myrica/ Suggested-by: Jean-Philippe Brucker Signed-off-by: Jacob Pan --- drivers/dma/idxd/cdev.c

[PATCH v2 0/2] Simplify and restrict IOMMU SVA APIs

2021-04-14 Thread Jacob Pan
appreciate if someone could help with the testing on ARM. Thanks, Jacob ChangeLog: V2 - retained mm argument in iommu_sva_alloc_pasid() - keep generic supervisor flag separated from vt-d's SRE - move flag declaration out of CONFIG_IOMMU_API Jacob Pan (2): iommu/sva: Tighten

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

2021-04-13 Thread Jacob Pan
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 argum

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

2021-04-13 Thread Jacob Pan
Hi Baolu, Thanks for the view. On Fri, 9 Apr 2021 20:24:22 +0800, Lu Baolu wrote: > 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

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

2021-04-09 Thread Jacob Pan
Hi Jean-Philippe, On Fri, 9 Apr 2021 12:22:21 +0200, Jean-Philippe Brucker wrote: > On Thu, Apr 08, 2021 at 10:08:55AM -0700, Jacob Pan wrote: > > The void* drvdata parameter isn't really used in iommu_sva_bind_device() > > API, > > Right, it used to be a cookie passed

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

2021-04-09 Thread Jacob Pan
Hi Lu, On Fri, 9 Apr 2021 20:45:22 +0800, Lu Baolu wrote: > > -int iommu_sva_alloc_pasid(struct mm_struct *mm, ioasid_t min, ioasid_t > > max) +int iommu_sva_alloc_pasid(ioasid_t min, ioasid_t max) > > { > > int ret = 0; > > ioasid_t pasid; > > + struct mm_struct *mm; > > > >

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

2021-04-09 Thread Jacob Pan
Hi Jean-Philippe, On Fri, 9 Apr 2021 12:11:47 +0200, Jean-Philippe Brucker wrote: > On Thu, Apr 08, 2021 at 10:08:56AM -0700, Jacob Pan wrote: > > diff --git a/drivers/iommu/iommu-sva-lib.c > > b/drivers/iommu/iommu-sva-lib.c index bd41405..bd99f6b 100644 > > --- a/drivers/

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

2021-04-08 Thread Jacob Pan
/YFhiMLR35WWMW%2FHu@myrica/ Signed-off-by: Jacob Pan --- drivers/dma/idxd/cdev.c | 2 +- drivers/dma/idxd/init.c | 2 +- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c | 6 ++--- drivers/iommu/iommu-sva-lib.c | 30

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

2021-04-08 Thread Jacob Pan
he generic code. This patch replaces void* drvdata with a unsigned int flags parameter and adjusts callers accordingly. Link: https://lore.kernel.org/linux-iommu/YFhiMLR35WWMW%2FHu@myrica/ Suggested-by: Jean-Philippe Brucker Signed-off-by: Jacob Pan --- drivers/dma/idxd/cdev.c

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-04-01 Thread Jacob Pan
Hi Jason, On Wed, 31 Mar 2021 21:37:05 -0300, Jason Gunthorpe wrote: > On Wed, Mar 31, 2021 at 04:46:21PM -0700, Jacob Pan wrote: > > Hi Jason, > > > > On Wed, 31 Mar 2021 09:38:01 -0300, Jason Gunthorpe > > wrote: > > > > > Get rid of the ioasid se

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-03-31 Thread Jacob Pan
Hi Jason, On Wed, 31 Mar 2021 09:38:01 -0300, Jason Gunthorpe wrote: > > > Get rid of the ioasid set. > > > > > > Each driver has its own list of allowed ioasids. > [...] > > The /dev/ioasid FD replaces this security check. By becoming FD > centric you don't need additional kernel

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-03-31 Thread Jacob Pan
Hi Jason, On Wed, 31 Mar 2021 15:33:24 -0300, Jason Gunthorpe wrote: > On Wed, Mar 31, 2021 at 11:20:30AM -0700, Jacob Pan wrote: > > Hi Jason, > > > > On Wed, 31 Mar 2021 14:31:48 -0300, Jason Gunthorpe > > wrote: > > > > > We should tr

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-03-31 Thread Jacob Pan
Hi Jason, On Wed, 31 Mar 2021 14:31:48 -0300, Jason Gunthorpe wrote: > > > We should try to avoid hidden behind the scenes kernel > > > interconnections between subsystems. > > > > > Can we? in case of exception. Since all these IOCTLs are coming from the > > unreliable user space, we must

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-03-31 Thread Jacob Pan
Hi Jason, On Wed, 31 Mar 2021 09:28:05 -0300, Jason Gunthorpe wrote: > On Tue, Mar 30, 2021 at 05:10:41PM -0700, Jacob Pan wrote: > [...] > [...] > [...] > > This requires the mdev driver to obtain a list of allowed > > PASIDs(possibly during PASID bind time)

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-03-30 Thread Jacob Pan
Hi Jason, On Tue, 30 Mar 2021 10:43:13 -0300, Jason Gunthorpe wrote: > > If two mdevs from the same PF dev are assigned to two VMs, the PASID > > table will be shared. IOASID set ensures one VM cannot program another > > VM's PASIDs. I assume 'secure context' is per VM when it comes to host > >

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

2021-03-30 Thread Jacob Pan
Hi Guenter, On Mon, 22 Mar 2021 10:53:38 -0700, Guenter Roeck wrote: > On Tue, Mar 02, 2021 at 02:13:57AM -0800, Jacob Pan wrote: > > Write protect bit, when set, inhibits supervisor writes to the read-only > > pages. In supervisor shared virtual addressing (SVA), wh

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-03-29 Thread Jacob Pan
Hi Jason, On Mon, 29 Mar 2021 13:31:47 -0300, Jason Gunthorpe wrote: > On Wed, Mar 24, 2021 at 12:05:28PM -0700, Jacob Pan wrote: > > > > IMHO a use created PASID is either bound to a mm (current) at creation > > > time, or it will never be bound to a mm and its page t

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-03-25 Thread Jacob Pan
Hi Jason, On Thu, 25 Mar 2021 14:16:45 -0300, Jason Gunthorpe wrote: > On Thu, Mar 25, 2021 at 10:02:36AM -0700, Jacob Pan wrote: > > Hi Jean-Philippe, > > > > On Thu, 25 Mar 2021 11:21:40 +0100, Jean-Philippe Brucker > > wrote: > > > > > On Wed, M

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-03-25 Thread Jacob Pan
Hi Jean-Philippe, On Thu, 25 Mar 2021 11:21:40 +0100, Jean-Philippe Brucker wrote: > On Wed, Mar 24, 2021 at 03:12:30PM -0700, Jacob Pan wrote: > > Hi Jason, > > > > On Wed, 24 Mar 2021 14:03:38 -0300, Jason Gunthorpe > > wrote: > > > On Wed, Mar 24, 2021

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-03-24 Thread Jacob Pan
Hi Jason, On Wed, 24 Mar 2021 14:03:38 -0300, Jason Gunthorpe wrote: > On Wed, Mar 24, 2021 at 10:02:46AM -0700, Jacob Pan wrote: > > > Also wondering about device driver allocating auxiliary domains for > > > their private use, to do iommu_map/unmap on private PASIDs (a cl

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-03-24 Thread Jacob Pan
Hi Jason, On Mon, 22 Mar 2021 09:03:00 -0300, Jason Gunthorpe wrote: > On Fri, Mar 19, 2021 at 11:22:21AM -0700, Jacob Pan wrote: > > Hi Jason, > > > > On Fri, 19 Mar 2021 10:54:32 -0300, Jason Gunthorpe > > wrote: > > > On Fri, Mar 19, 2021 at 02:

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-03-24 Thread Jacob Pan
Hi Jean-Philippe, On Mon, 22 Mar 2021 10:24:00 +0100, Jean-Philippe Brucker wrote: > On Fri, Mar 19, 2021 at 11:22:21AM -0700, Jacob Pan wrote: > > Hi Jason, > > > > On Fri, 19 Mar 2021 10:54:32 -0300, Jason Gunthorpe > > wrote: > > > On Fri, Mar 19, 202

Re: [Patch v3 1/2] cgroup: sev: Add misc cgroup controller

2021-03-24 Thread Jacob Pan
Hi Vipin, On Mon, 22 Mar 2021 11:54:39 -0700, Vipin Sharma wrote: > On Fri, Mar 19, 2021 at 02:28:01PM -0700, Jacob Pan wrote: > > On Thu, 4 Mar 2021 15:19:45 -0800, Vipin Sharma > > wrote: > > > +#ifndef _MISC_CGROUP_H_ > > > +#define _MISC_CGROUP_H_

Re: [Patch v3 1/2] cgroup: sev: Add misc cgroup controller

2021-03-19 Thread Jacob Pan
Hi Vipin, On Thu, 4 Mar 2021 15:19:45 -0800, Vipin Sharma wrote: > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * Miscellaneous cgroup controller. > + * > + * Copyright 2020 Google LLC > + * Author: Vipin Sharma > + */ > +#ifndef _MISC_CGROUP_H_ > +#define _MISC_CGROUP_H_ > + nit: should

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-03-19 Thread Jacob Pan
Hi Jason, On Fri, 19 Mar 2021 10:54:32 -0300, Jason Gunthorpe wrote: > On Fri, Mar 19, 2021 at 02:41:32PM +0100, Jean-Philippe Brucker wrote: > > On Fri, Mar 19, 2021 at 09:46:45AM -0300, Jason Gunthorpe wrote: > > > On Fri, Mar 19, 2021 at 10:58:41AM +0100, Jean-Philippe Brucker wrote: > > >

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-03-19 Thread Jacob Pan
Hi Jean-Philippe, On Fri, 19 Mar 2021 10:58:41 +0100, Jean-Philippe Brucker wrote: > > Slightly off the title. As we are moving to use cgroup to limit PASID > > allocations, it would be much simpler if we enforce on the current > > task. > > Yes I think we should do that. Is there a problem

Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-03-18 Thread Jacob Pan
Hi Jean, Slightly off the title. As we are moving to use cgroup to limit PASID allocations, it would be much simpler if we enforce on the current task. However, iommu_sva_alloc_pasid() takes an mm_struct pointer as argument which implies it can be something other the the current task mm. So far

Re: [RFC v2 2/2] cgroup: sev: Miscellaneous cgroup documentation.

2021-03-16 Thread Jacob Pan
Hi Tejun, On Mon, 15 Mar 2021 22:22:12 -0400, Tejun Heo wrote: > On Mon, Mar 15, 2021 at 06:30:30PM -0700, Jacob Pan wrote: > > I don't know if this is required. I thought utilities such as cgclassify > > need to be supported. > > " cgclassify - move runnin

Re: [RFC v2 2/2] cgroup: sev: Miscellaneous cgroup documentation.

2021-03-15 Thread Jacob Pan
Hi Tejun, On Mon, 15 Mar 2021 19:54:36 -0400, Tejun Heo wrote: > Hello, > > On Mon, Mar 15, 2021 at 04:40:12PM -0700, Jacob Pan wrote: > > 2. then we want to move/migrate Process1 to cg_B. so we need uncharge > > 10 of cg_A, charge 10 of cg_B > > So, what I don'

Re: [RFC v2 2/2] cgroup: sev: Miscellaneous cgroup documentation.

2021-03-15 Thread Jacob Pan
Hi Tejun, On Mon, 15 Mar 2021 18:19:35 -0400, Tejun Heo wrote: > Hello, > > On Mon, Mar 15, 2021 at 03:11:55PM -0700, Jacob Pan wrote: > > > Migration itself doesn't have restrictions but all resources are > > > distributed on the same hierarchy, so the controllers a

Re: [RFC v2 2/2] cgroup: sev: Miscellaneous cgroup documentation.

2021-03-15 Thread Jacob Pan
Hi Tejun, On Sat, 13 Mar 2021 13:05:36 -0500, Tejun Heo wrote: > Hello, > > On Sat, Mar 13, 2021 at 08:57:01AM -0800, Jacob Pan wrote: > > Isn't PIDs controller doing the charge/uncharge? I was under the > > impression that each resource can be independently charg

Re: [RFC v2 2/2] cgroup: sev: Miscellaneous cgroup documentation.

2021-03-13 Thread Jacob Pan
Hi Tejun, On Sat, 13 Mar 2021 05:20:39 -0500, Tejun Heo wrote: > On Fri, Mar 12, 2021 at 02:59:04PM -0800, Jacob Pan wrote: > > Our primary goal is to limit the amount of IOASIDs that VMs can > > allocate. If a VM is migrated to a different cgroup, I think we need to >

Re: [RFC v2 2/2] cgroup: sev: Miscellaneous cgroup documentation.

2021-03-12 Thread Jacob Pan
Hi Vipin, On Fri, 12 Mar 2021 13:15:14 -0800, Vipin Sharma wrote: > On Fri, Mar 12, 2021 at 12:58:21PM -0800, Jacob Pan wrote: > > Hi Vipin & Tejun, > > > > Sorry for the late reply, I sent from a different email address than I > > intended. Please see my commen

Re: [RFC v2 2/2] cgroup: sev: Miscellaneous cgroup documentation.

2021-03-12 Thread Jacob Pan
Hi Vipin & Tejun, Sorry for the late reply, I sent from a different email address than I intended. Please see my comments inline. On Thu, 4 Mar 2021 03:51:16 -0500, Tejun Heo wrote: > Hello, > > On Wed, Mar 03, 2021 at 10:22:03PM -0800, Vipin Sharma wrote: > > > I am trying to see if IOASIDs

Re: [RFC PATCH 18/18] ioasid: Add /dev/ioasid for userspace

2021-03-11 Thread Jacob Pan
Hi Jason, Thanks for the review. On Wed, 10 Mar 2021 15:23:01 -0400, Jason Gunthorpe wrote: > On Sat, Feb 27, 2021 at 02:01:26PM -0800, Jacob Pan wrote: > > > +/* IOCTLs for IOASID file descriptor (/dev/ioasid) */ > > + > > +/** > > +

Re: [RFC PATCH 15/18] cgroup: Introduce ioasids controller

2021-03-05 Thread Jacob Pan
Hi Jean-Philippe, On Fri, 5 Mar 2021 09:30:49 +0100, Jean-Philippe Brucker wrote: > On Thu, Mar 04, 2021 at 09:46:03AM -0800, Jacob Pan wrote: > > Hi Jean-Philippe, > > > > On Thu, 4 Mar 2021 10:49:37 +0100, Jean-Philippe Brucker > > wrote: > > > &g

Re: [RFC PATCH 15/18] cgroup: Introduce ioasids controller

2021-03-04 Thread Jacob Pan
Hi Jason, On Thu, 4 Mar 2021 15:02:53 -0400, Jason Gunthorpe wrote: > On Thu, Mar 04, 2021 at 11:01:44AM -0800, Jacob Pan wrote: > > > > For something like qemu I'd expect to put the qemu process in a cgroup > > > with 1 PASID. Who cares what qemu us

Re: [RFC PATCH 15/18] cgroup: Introduce ioasids controller

2021-03-04 Thread Jacob Pan
Hi Jason, On Thu, 4 Mar 2021 13:54:02 -0400, Jason Gunthorpe wrote: > On Thu, Mar 04, 2021 at 09:46:03AM -0800, Jacob Pan wrote: > > > Right, I was assuming have three use cases of IOASIDs: > > 1. host supervisor SVA (not a concern, just one init_mm to bind) > > 2. h

Re: [RFC PATCH 15/18] cgroup: Introduce ioasids controller

2021-03-04 Thread Jacob Pan
Hi Jean-Philippe, On Thu, 4 Mar 2021 10:49:37 +0100, Jean-Philippe Brucker wrote: > On Wed, Mar 03, 2021 at 04:02:05PM -0800, Jacob Pan wrote: > > Hi Jacob, > > > > On Wed, 3 Mar 2021 13:17:26 -0800, Jacob Pan > > wrote: > > > > > Hi Tejun, >

Re: [RFC v2 2/2] cgroup: sev: Miscellaneous cgroup documentation.

2021-03-03 Thread Jacob Pan
Hi Vipin, On Tue, 2 Mar 2021 00:17:05 -0800, Vipin Sharma wrote: > +Migration and Ownership > +~~~ > + > +A miscellaneous scalar resource is charged to the cgroup in which it is > used +first, and stays charged to that cgroup until that resource is > freed. Migrating +a

Re: [RFC PATCH 15/18] cgroup: Introduce ioasids controller

2021-03-03 Thread Jacob Pan
Hi Jacob, On Wed, 3 Mar 2021 13:17:26 -0800, Jacob Pan wrote: > Hi Tejun, > > On Wed, 3 Mar 2021 10:44:28 -0500, Tejun Heo wrote: > > > On Sat, Feb 27, 2021 at 02:01:23PM -0800, Jacob Pan wrote: > > > IOASIDs are used to associate DMA requests with v

Re: [RFC PATCH 15/18] cgroup: Introduce ioasids controller

2021-03-03 Thread Jacob Pan
Hi Tejun, On Wed, 3 Mar 2021 10:44:28 -0500, Tejun Heo wrote: > On Sat, Feb 27, 2021 at 02:01:23PM -0800, Jacob Pan wrote: > > IOASIDs are used to associate DMA requests with virtual address spaces. > > They are a system-wide limited resource made available to the userspace &

Re: [PATCH RFC v1 12/15] iommu/virtio: Add support for INVALIDATE request

2021-03-03 Thread Jacob Pan
Eric Auger > Cc: Alex Williamson > Cc: Kevin Tian > Cc: Jacob Pan > Cc: Liu Yi L > Cc: Lorenzo Pieralisi > Cc: Shameerali Kolothum Thodi > --- > drivers/iommu/virtio-iommu.c | 95 > 1 file changed, 95 insertions(+) > &

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

2021-03-02 Thread Jacob Pan
is set. Signed-off-by: Sanjay Kumar Signed-off-by: Jacob Pan --- drivers/iommu/intel/pasid.c | 26 ++ 1 file changed, 26 insertions(+) diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index 0cceaabc3ce6..0b7e0e726ade 100644 --- a/drivers/iommu/intel

[PATCH v2 0/4] Misc vSVA fixes for VT-d

2021-03-02 Thread Jacob Pan
Hi Baolu et al, This is a collection of SVA-related fixes. ChangeLog: v2: - For guest SVA, call pasid_set_wpe directly w/o checking host CR0.wp (Review comments by Kevin T.) - Added fixes tag Thanks, Jacob Jacob Pan (4): iommu/vt-d: Enable write protect

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

2021-03-02 Thread Jacob Pan
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 Acked-by: Lu Baolu Signed-off-by: Jacob Pan --- drivers/iommu/intel/svm.c | 9 ++--- 1 fi

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

2021-03-02 Thread Jacob Pan
responses. Fixes: 1c4f88b7f1f92 ("iommu/vt-d: Shared virtual address in scalable mode") Acked-by: Lu Baolu Signed-off-by: Jacob Pan --- drivers/iommu/intel/svm.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/i

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

2021-03-02 Thread Jacob Pan
of the supervisor PASID entry will be set to match CPU CR0.WP bit. Signed-off-by: Sanjay Kumar Signed-off-by: Jacob Pan --- drivers/iommu/intel/pasid.c | 3 +++ include/uapi/linux/iommu.h | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu

Re: [PATCH v6 08/12] fork: Clear PASID for new mm

2021-03-01 Thread Jacob Pan
Hi Fenghua, On Thu, 25 Feb 2021 22:17:11 +, Fenghua Yu wrote: > Hi, Jean, > > On Wed, Feb 24, 2021 at 11:19:27AM +0100, Jean-Philippe Brucker wrote: > > Hi Fenghua, > > > > [Trimmed the Cc list] > > > > On Mon, Jul 13, 2020 at 04:48:03PM -0700, Fenghua Yu wrote: > > > When a new mm is

[RFC PATCH 17/18] docs: cgroup-v1: Add IOASIDs controller

2021-02-27 Thread Jacob Pan
Signed-off-by: Jacob Pan --- Documentation/admin-guide/cgroup-v1/index.rst | 1 + .../admin-guide/cgroup-v1/ioasids.rst | 110 ++ 2 files changed, 111 insertions(+) create mode 100644 Documentation/admin-guide/cgroup-v1/ioasids.rst diff --git a/Documentation/admin

[RFC PATCH 18/18] ioasid: Add /dev/ioasid for userspace

2021-02-27 Thread Jacob Pan
From: Liu Yi L I/O Address Space IDs (IOASIDs) is used to tag DMA requests to target multiple DMA address spaces for physical devices. Its PCI terminology is called PASID (Process Address Space ID). Platforms with PASID support can provide PASID granularity DMA isolation, which is very useful

[RFC PATCH 16/18] iommu/ioasid: Consult IOASIDs cgroup for allocation

2021-02-27 Thread Jacob Pan
Once IOASIDs cgroup is active, we must consult the limitation set up by the cgroups during allocation. Freeing IOASIDs also need to return the quota back to the cgroup. Signed-off-by: Jacob Pan --- drivers/iommu/ioasid.c | 7 ++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git

[RFC PATCH 15/18] cgroup: Introduce ioasids controller

2021-02-27 Thread Jacob Pan
to the documentation: Documentation/admin-guide/cgroup-v1/ioasids.rst Signed-off-by: Jacob Pan --- include/linux/cgroup_subsys.h | 4 + include/linux/ioasid.h| 17 ++ init/Kconfig | 7 + kernel/cgroup/Makefile| 1 + kernel/cgroup/ioasids.c | 345

[PATCH V4 12/18] iommu/vt-d: Remove mm reference for guest SVA

2021-02-27 Thread Jacob Pan
Now that IOASID core keeps track of the IOASID to mm_struct ownership in the forms of ioasid_set with IOASID_SET_TYPE_MM token type, there is no need to keep the same mapping in VT-d driver specific data. Native SVM usage is not affected by the change. Signed-off-by: Jacob Pan --- drivers/iommu

[PATCH V4 14/18] iommu/vt-d: Listen to IOASID notifications

2021-02-27 Thread Jacob Pan
registers IOASID notification handler such that IOMMU driver can perform PASID teardown upon receiving an unexpected IOASID free event. Signed-off-by: Jacob Pan --- drivers/iommu/intel/iommu.c | 2 + drivers/iommu/intel/svm.c | 109 +++- include/linux/intel-iommu.h

[PATCH V4 13/18] iommu/ioasid: Add a workqueue for cleanup work

2021-02-27 Thread Jacob Pan
among users to tear down their contexts. Not all work can be handled in the atomic notifier handler. This patch introduces a shared, ordered workqueue for all IOASID users who wish to perform work asynchronously upon notification. Signed-off-by: Jacob Pan --- drivers/iommu/ioasid.c | 25

[PATCH V4 11/18] iommu/ioasid: Add ownership check in guest bind

2021-02-27 Thread Jacob Pan
to the ioasid_set allocated with the mm_struct pointer as a token. Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- drivers/iommu/ioasid.c | 37 + drivers/iommu/iommu.c | 16 ++-- include/linux/ioasid.h | 6 ++ 3 files changed, 57 insertions(+), 2

[PATCH V4 10/18] iommu/ioasid: Support mm token type ioasid_set notifications

2021-02-27 Thread Jacob Pan
-by: Liu Yi L Signed-off-by: Wu Hao Signed-off-by: Jacob Pan --- drivers/iommu/ioasid.c | 142 + include/linux/ioasid.h | 18 ++ 2 files changed, 160 insertions(+) diff --git a/drivers/iommu/ioasid.c b/drivers/iommu/ioasid.c index 56577e745c4b

[PATCH V4 09/18] iommu/ioasid: Introduce notification APIs

2021-02-27 Thread Jacob Pan
/ioasid.rst. Signed-off-by: Liu Yi L Signed-off-by: Wu Hao Signed-off-by: Jacob Pan --- drivers/iommu/ioasid.c | 111 +++-- include/linux/ioasid.h | 54 2 files changed, 161 insertions(+), 4 deletions(-) diff --git a/drivers/iommu/ioasid.c b

[PATCH V4 06/18] iommu/ioasid: Add free function and states

2021-02-27 Thread Jacob Pan
() and ioasid_put() decrements reference counts. Unlike ioasid_put(), the ioasid_free() function also transition the IOASID to the free pending state where further ioasid_get() is prohibited. This paves the way for FREE event notifications that will be introduced next. Signed-off-by: Jacob Pan

[PATCH V4 08/18] iommu/ioasid: Introduce ioasid_set private ID

2021-02-27 Thread Jacob Pan
is usually established when a guest page table is bound to a host PASID. Signed-off-by: Jacob Pan --- drivers/iommu/ioasid.c | 104 + include/linux/ioasid.h | 18 +++ 2 files changed, 122 insertions(+) diff --git a/drivers/iommu/ioasid.c b/drivers

[PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs

2021-02-27 Thread Jacob Pan
APIs are introduced that wire up these new data. Existing users of IOASID APIs are converted where a host IOASID set is allocated for bare-metal usages. Including VT-d driver and iommu-sva-lib. Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- .../iommu/arm/arm-smmu-v3/arm-smmu-v3-sva.c

[PATCH V4 07/18] iommu/ioasid: Add ioasid_set iterator helper functions

2021-02-27 Thread Jacob Pan
on each IOASID. This patch adds an API to iterate all the IOASIDs within the set. Signed-off-by: Jacob Pan --- drivers/iommu/ioasid.c | 84 ++ include/linux/ioasid.h | 20 ++ 2 files changed, 104 insertions(+) diff --git a/drivers/iommu/ioasid.c b

[PATCH V4 02/18] iommu/ioasid: Rename ioasid_set_data()

2021-02-27 Thread Jacob Pan
Rename ioasid_set_data() to ioasid_attach_data() to avoid confusion with struct ioasid_set. ioasid_set is a group of IOASIDs that share a common token. Reviewed-by: Jean-Philippe Brucker Signed-off-by: Jacob Pan --- drivers/iommu/intel/svm.c | 6 +++--- drivers/iommu/ioasid.c| 6

[PATCH V4 01/18] docs: Document IO Address Space ID (IOASID) APIs

2021-02-27 Thread Jacob Pan
) enabled platforms are the primary users of IOASID. Examples of how SIOV components interact with the IOASID APIs are provided. Cc: Jonathan Corbet Cc: linux-...@vger.kernel.org Cc: Randy Dunlap Signed-off-by: Liu Yi L Signed-off-by: Wu Hao Signed-off-by: Jacob Pan --- Documentation/driver-api

[PATCH V4 00/18] IOASID extensions for guest SVA

2021-02-27 Thread Jacob Pan
driver to perform teardown outside atomic context Jacob Pan (17): docs: Document IO Address Space ID (IOASID) APIs iommu/ioasid: Rename ioasid_set_data() iommu/ioasid: Add a separate function for detach data iommu/ioasid: Support setting system-wide capacity iommu/ioasid: Redefine IOASID

[PATCH V4 04/18] iommu/ioasid: Support setting system-wide capacity

2021-02-27 Thread Jacob Pan
added to support runtime capacity reservation, potentially by cgroups. Signed-off-by: Jacob Pan --- drivers/iommu/intel/iommu.c | 5 +++ drivers/iommu/ioasid.c | 70 + include/linux/ioasid.h | 18 ++ 3 files changed, 93 insertions(+) diff

[PATCH V4 03/18] iommu/ioasid: Add a separate function for detach data

2021-02-27 Thread Jacob Pan
-by: Jacob Pan --- drivers/iommu/intel/svm.c | 4 +-- drivers/iommu/ioasid.c| 54 +++ include/linux/ioasid.h| 5 +++- 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index 0053df9edffc

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

2021-02-22 Thread Jacob Pan
Hi Kevin, On Sat, 20 Feb 2021 02:38:02 +, "Tian, Kevin" wrote: > > From: Jacob Pan > > Sent: Saturday, February 20, 2021 1:09 AM > > > > Hi Kevin, > > > > On Fri, 19 Feb 2021 06:19:04 +, "Tian, Kevin" > > wrote: > >

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

2021-02-22 Thread Jacob Pan
Hi Lu, On Sat, 20 Feb 2021 09:56:26 +0800, Lu Baolu wrote: > 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

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

2021-02-19 Thread Jacob Pan
Hi Kevin, On Fri, 19 Feb 2021 06:19:04 +, "Tian, Kevin" wrote: > > From: Jacob Pan > > Sent: Friday, February 19, 2021 5:31 AM > > > > Write protect bit, when set, inhibits supervisor writes to the read-only > > pages. In guest supervisor shared vir

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

2021-02-18 Thread Jacob Pan
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 --- drivers/iommu/intel/svm.c | 9 ++--- 1 file changed, 6 insertions(+)

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

2021-02-18 Thread Jacob Pan
responses. Signed-off-by: Jacob Pan --- drivers/iommu/intel/svm.c | 12 +++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c index 23a1e4f58c54..ff7ae7cc17d5 100644 --- a/drivers/iommu/intel/svm.c +++ b/drivers/iommu/intel

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

2021-02-18 Thread Jacob Pan
is set. Signed-off-by: Sanjay Kumar Signed-off-by: Jacob Pan --- drivers/iommu/intel/pasid.c | 26 ++ 1 file changed, 26 insertions(+) diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index 0cceaabc3ce6..0b7e0e726ade 100644 --- a/drivers/iommu/intel

[PATCH 0/4] Misc vSVA fixes for VT-d

2021-02-18 Thread Jacob Pan
Hi Baolu et al, This is a collection of SVA-related fixes. Thanks, Jacob Jacob Pan (4): iommu/vt-d: Enable write protect for supervisor SVM iommu/vt-d: Enable write protect propagation from guest iommu/vt-d: Reject unsupported page request modes iommu/vt-d: Calculate and set flags

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

2021-02-18 Thread Jacob Pan
of the supervisor PASID entry will be set to match CPU CR0.WP bit. Signed-off-by: Sanjay Kumar Signed-off-by: Jacob Pan --- drivers/iommu/intel/pasid.c | 5 + include/uapi/linux/iommu.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel/pasid.c b/drivers

Re: [PATCH v13 01/15] iommu: Introduce attach/detach_pasid_table API

2020-11-18 Thread Jacob Pan
igned-off-by: Jean-Philippe Brucker > Signed-off-by: Liu, Yi L > Signed-off-by: Ashok Raj > Signed-off-by: Jacob Pan > Signed-off-by: Eric Auger > > --- > > v12 -> v13: > - Fix config check > > v11 -> v12: > - add argsz, name the union > --- >

Re: [PATCH v3 01/14] docs: Document IO Address Space ID (IOASID) APIs

2020-11-02 Thread Jacob Pan
Hi Jean-Philippe, On Fri, 30 Oct 2020 11:18:27 +0100, Jean-Philippe Brucker wrote: > On Mon, Oct 26, 2020 at 02:05:06PM -0700, Jacob Pan wrote: > > > This looks good to me, with small comments below. > > > > > Can I add your Reviewed-by tag after addressing th

Re: [PATCH v3 01/14] docs: Document IO Address Space ID (IOASID) APIs

2020-10-26 Thread Jacob Pan
Hi Jean-Philippe, Thanks a lot for the review. Comments inline. On Tue, 20 Oct 2020 15:58:09 +0200, Jean-Philippe Brucker wrote: > On Mon, Sep 28, 2020 at 02:38:28PM -0700, Jacob Pan wrote: > > IOASID is used to identify address spaces that can be targeted by device > > DMA.

Re: [RFC PATCH 0/2] iommu: Avoid unnecessary PRI queue flushes

2020-10-19 Thread Jacob Pan
Hi Jean-Philippe, On Mon, 19 Oct 2020 16:08:24 +0200, Jean-Philippe Brucker wrote: > On Sat, Oct 17, 2020 at 04:25:25AM -0700, Raj, Ashok wrote: > > > For devices that *don't* use a stop marker, the PCIe spec says > > > (10.4.1.2): > > > > > > To stop [using a PASID] without using a Stop

Re: [PATCH v3 00/14] IOASID extensions for guest SVA

2020-10-19 Thread Jacob Pan
Hi, Any comments on this? I know we have some opens w.r.t. PASID management UAPI, but I think having this common kernel API features should be justified. Thanks! Jacob On Mon, 28 Sep 2020 14:38:27 -0700, Jacob Pan wrote: > IOASID was introduced in v5.5 as a generic kernel allocator serv

[PATCH v3 11/14] iommu/ioasid: Support mm type ioasid_set notifications

2020-09-28 Thread Jacob Pan
-by: Liu Yi L Signed-off-by: Wu Hao Signed-off-by: Jacob Pan --- drivers/iommu/ioasid.c | 117 + include/linux/ioasid.h | 15 +++ 2 files changed, 132 insertions(+) diff --git a/drivers/iommu/ioasid.c b/drivers/iommu/ioasid.c index

[PATCH v3 06/14] iommu/ioasid: Introduce API to adjust the quota of an ioasid_set

2020-09-28 Thread Jacob Pan
-wide IOASID pool if the new quota is smaller than the existing one. Signed-off-by: Jacob Pan --- drivers/iommu/ioasid.c | 47 +++ include/linux/ioasid.h | 6 ++ 2 files changed, 53 insertions(+) diff --git a/drivers/iommu/ioasid.c b/drivers/iommu

[PATCH v3 07/14] iommu/ioasid: Add an iterator API for ioasid_set

2020-09-28 Thread Jacob Pan
on each IOASID. This patch adds an API to iterate all the IOASIDs within the set. Signed-off-by: Jacob Pan --- drivers/iommu/ioasid.c | 17 + include/linux/ioasid.h | 9 + 2 files changed, 26 insertions(+) diff --git a/drivers/iommu/ioasid.c b/drivers/iommu/ioasid.c index

[PATCH v3 10/14] iommu/ioasid: Introduce notification APIs

2020-09-28 Thread Jacob Pan
/ioasid.rst. Signed-off-by: Liu Yi L Signed-off-by: Wu Hao Signed-off-by: Jacob Pan --- drivers/iommu/ioasid.c | 141 + include/linux/ioasid.h | 57 +++- 2 files changed, 197 insertions(+), 1 deletion(-) diff --git a/drivers/iommu

[PATCH v3 14/14] iommu/vt-d: Store guest PASID during bind

2020-09-28 Thread Jacob Pan
IOASID core maintains the guest-host mapping in the form of SPID and IOASID. This patch assigns the guest PASID (if valid) as SPID while binding guest page table with a host PASID. This mapping will be used for lookup and notifications. Signed-off-by: Jacob Pan --- drivers/iommu/intel/svm.c | 2

[PATCH v3 12/14] iommu/vt-d: Remove mm reference for guest SVA

2020-09-28 Thread Jacob Pan
Now that IOASID core keeps track of the IOASID to mm_struct ownership in the forms of ioasid_set with IOASID_SET_TYPE_MM token type, there is no need to keep the same mapping in VT-d driver specific data. Native SVM usage is not affected by the change. Signed-off-by: Jacob Pan --- drivers/iommu

[PATCH v3 08/14] iommu/ioasid: Add reference couting functions

2020-09-28 Thread Jacob Pan
is cleared. Signed-off-by: Jacob Pan --- drivers/iommu/ioasid.c | 117 + include/linux/ioasid.h | 24 ++ 2 files changed, 141 insertions(+) diff --git a/drivers/iommu/ioasid.c b/drivers/iommu/ioasid.c index 9628e78b2ab4..828cc44b1b1c 100644

[PATCH v3 05/14] iommu/ioasid: Redefine IOASID set and allocation APIs

2020-09-28 Thread Jacob Pan
APIs are introduced that wire up these new data. Existing users of IOASID APIs are converted where a host IOASID set is allocated for bare-metal usage. Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- drivers/iommu/intel/iommu.c | 26 +++-- drivers/iommu/intel/pasid.h | 1 + drivers/iommu

[PATCH v3 13/14] iommu/vt-d: Listen to IOASID notifications

2020-09-28 Thread Jacob Pan
registers IOASID notification handler such that IOMMU driver can perform PASID teardown upon receiving an unexpected IOASID free event. Signed-off-by: Jacob Pan --- drivers/iommu/intel/svm.c | 94 - include/linux/intel-iommu.h | 2 + 2 files changed, 94

[PATCH v3 02/14] iommu/ioasid: Rename ioasid_set_data()

2020-09-28 Thread Jacob Pan
Rename ioasid_set_data() to ioasid_attach_data() to avoid confusion with struct ioasid_set. ioasid_set is a group of IOASIDs that share a common token. Reviewed-by: Jean-Philippe Brucker Signed-off-by: Jacob Pan --- drivers/iommu/intel/svm.c | 6 +++--- drivers/iommu/ioasid.c| 6

[PATCH v3 04/14] iommu/ioasid: Support setting system-wide capacity

2020-09-28 Thread Jacob Pan
-off-by: Jacob Pan --- drivers/iommu/intel/iommu.c | 5 + drivers/iommu/ioasid.c | 20 include/linux/ioasid.h | 11 +++ 3 files changed, 36 insertions(+) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 18ed3b3c70d7

  1   2   3   4   5   6   7   8   9   10   >