Re: [PATCH v2 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-01-28 Thread Thomas Gleixner
On Thu, Jan 27 2022 at 18:42, Fenghua Yu wrote: > On Wed, Jan 26, 2022 at 10:38:04PM +0100, Thomas Gleixner wrote: >> Against Linus tree please so that the bugfix applies. >> >> > I will fold the following patch into patch #5. The patch #11 (the doc >> > patch) >> > also needs to remove one

Re: [PATCH v2 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-01-27 Thread Fenghua Yu
Hi, Thomas, On Wed, Jan 26, 2022 at 10:38:04PM +0100, Thomas Gleixner wrote: > On Wed, Jan 26 2022 at 09:36, Fenghua Yu wrote: > > On Wed, Jan 26, 2022 at 03:23:42PM +0100, Thomas Gleixner wrote: > >> On Tue, Jan 25 2022 at 07:18, Fenghua Yu wrote: > >> While looking at ioasid_put() usage I

Re: [PATCH v2 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-01-26 Thread Thomas Gleixner
On Wed, Jan 26 2022 at 09:36, Fenghua Yu wrote: > On Wed, Jan 26, 2022 at 03:23:42PM +0100, Thomas Gleixner wrote: >> On Tue, Jan 25 2022 at 07:18, Fenghua Yu wrote: >> While looking at ioasid_put() usage I tripped over the following UAF >> issue: >> >> --- a/drivers/iommu/intel/iommu.c >> +++

Re: [PATCH v2 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-01-26 Thread Fenghua Yu
Hi, Thomas, On Wed, Jan 26, 2022 at 03:23:42PM +0100, Thomas Gleixner wrote: > On Tue, Jan 25 2022 at 07:18, Fenghua Yu wrote: > > On Mon, Jan 24, 2022 at 09:55:56PM +0100, Thomas Gleixner wrote: > > /** > > * ioasid_put - Release a reference to an ioasid > > * @ioasid: the ID to remove > >

Re: [PATCH v2 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-01-26 Thread Thomas Gleixner
On Tue, Jan 25 2022 at 07:18, Fenghua Yu wrote: > On Mon, Jan 24, 2022 at 09:55:56PM +0100, Thomas Gleixner wrote: > /** > * ioasid_put - Release a reference to an ioasid > * @ioasid: the ID to remove which in turn makes ioasid_put() a misnomer and the whole refcounting of the ioasid a

Re: [PATCH v2 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-01-25 Thread Fenghua Yu
Hi, Thomas, On Mon, Jan 24, 2022 at 09:55:56PM +0100, Thomas Gleixner wrote: > On Mon, Jan 24 2022 at 12:52, Fenghua Yu wrote: > > On Mon, Jan 24, 2022 at 09:36:00PM +0100, Thomas Gleixner wrote: > >> On Mon, Jan 24 2022 at 21:21, Thomas Gleixner wrote: > > Ah. This patch should remove

Re: [PATCH v2 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-01-24 Thread Thomas Gleixner
On Mon, Jan 24 2022 at 12:52, Fenghua Yu wrote: > On Mon, Jan 24, 2022 at 09:36:00PM +0100, Thomas Gleixner wrote: >> On Mon, Jan 24 2022 at 21:21, Thomas Gleixner wrote: > Ah. This patch should remove ioasid_get(). So I will change this patch > as follows: > > 1. Remove ioasid_get() because it's

Re: [PATCH v2 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-01-24 Thread Fenghua Yu
Hi, Thomas, On Mon, Jan 24, 2022 at 09:36:00PM +0100, Thomas Gleixner wrote: > On Mon, Jan 24 2022 at 21:21, Thomas Gleixner wrote: > > > > Hrm. This is odd. > > > >> +/* Associate a PASID with an mm_struct: */ > >> +static inline void mm_pasid_get(struct mm_struct *mm, u32 pasid) > >> +{ > >> +

Re: [PATCH v2 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-01-24 Thread Thomas Gleixner
On Mon, Jan 24 2022 at 21:21, Thomas Gleixner wrote: > > Hrm. This is odd. > >> +/* Associate a PASID with an mm_struct: */ >> +static inline void mm_pasid_get(struct mm_struct *mm, u32 pasid) >> +{ >> +mm->pasid = pasid; >> +} > > This does not get anything. It sets the allocated PASID in the

Re: [PATCH v2 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-01-24 Thread Fenghua Yu
Hi, Thomas, On Mon, Jan 24, 2022 at 09:21:24PM +0100, Thomas Gleixner wrote: > On Fri, Dec 17 2021 at 22:01, Fenghua Yu wrote: > > diff --git a/drivers/iommu/iommu-sva-lib.c b/drivers/iommu/iommu-sva-lib.c > > index bd41405d34e9..ee2294e02716 100644 > > --- a/drivers/iommu/iommu-sva-lib.c > > +++

Re: [PATCH v2 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2022-01-24 Thread Thomas Gleixner
On Fri, Dec 17 2021 at 22:01, Fenghua Yu wrote: > diff --git a/drivers/iommu/iommu-sva-lib.c b/drivers/iommu/iommu-sva-lib.c > index bd41405d34e9..ee2294e02716 100644 > --- a/drivers/iommu/iommu-sva-lib.c > +++ b/drivers/iommu/iommu-sva-lib.c > @@ -18,8 +18,7 @@ static

[PATCH v2 05/11] iommu/sva: Assign a PASID to mm on PASID allocation and free it on mm exit

2021-12-17 Thread Fenghua Yu
To avoid complexity of updating each thread's PASID status (e.g. sending IPI to update IA32_PASID MSR) on allocating and freeing PASID, once allocated and assigned to an mm, the PASID stays with the mm for the rest of the mm's lifetime. A reference to the PASID is taken on allocating the PASID.