Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-13 Thread Jason Gunthorpe
On Wed, Dec 13, 2023 at 01:47:54PM +, Liu, Yi L wrote: > > From: Jason Gunthorpe > > Sent: Tuesday, December 12, 2023 10:40 PM > > > > On Tue, Dec 12, 2023 at 01:45:16PM +, Liu, Yi L wrote: > > > > From: Jason Gunthorpe > > > > Sent: Monday, December 11, 2023 9:22 PM > > > > > > > > On

RE: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-13 Thread Liu, Yi L
> From: Jason Gunthorpe > Sent: Tuesday, December 12, 2023 10:40 PM > > On Tue, Dec 12, 2023 at 01:45:16PM +, Liu, Yi L wrote: > > > From: Jason Gunthorpe > > > Sent: Monday, December 11, 2023 9:22 PM > > > > > > On Mon, Dec 11, 2023 at 03:53:40PM +0800, Yi Liu wrote: > > > > > > > > >

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-12 Thread Jason Gunthorpe
On Tue, Dec 12, 2023 at 01:45:16PM +, Liu, Yi L wrote: > > From: Jason Gunthorpe > > Sent: Monday, December 11, 2023 9:22 PM > > > > On Mon, Dec 11, 2023 at 03:53:40PM +0800, Yi Liu wrote: > > > > > > > From that thread Jason mentioned to make the invalidation format > > > > > part of

RE: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-12 Thread Liu, Yi L
> From: Jason Gunthorpe > Sent: Monday, December 11, 2023 9:22 PM > > On Mon, Dec 11, 2023 at 03:53:40PM +0800, Yi Liu wrote: > > > > > From that thread Jason mentioned to make the invalidation format > > > > part of domain allocation. If that is the direction to go then there > > > > won't be

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-11 Thread Jason Gunthorpe
On Mon, Dec 11, 2023 at 03:53:40PM +0800, Yi Liu wrote: > > > From that thread Jason mentioned to make the invalidation format > > > part of domain allocation. If that is the direction to go then there > > > won't be multiple invalidation formats per hwpt. The user should > > > create multiple

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-10 Thread Yi Liu
On 2023/12/7 22:42, Jason Gunthorpe wrote: On Thu, Dec 07, 2023 at 09:04:00AM +, Tian, Kevin wrote: From: Liu, Yi L Sent: Thursday, December 7, 2023 2:59 PM On 2023/11/17 21:07, Yi Liu wrote: @@ -613,4 +614,38 @@ struct iommu_hwpt_get_dirty_bitmap { #define IOMMU_HWPT_GET_DIRTY_BITMAP

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-10 Thread Yi Liu
On 2023/12/7 17:04, Tian, Kevin wrote: From: Liu, Yi L Sent: Thursday, December 7, 2023 2:59 PM On 2023/11/17 21:07, Yi Liu wrote: @@ -613,4 +614,38 @@ struct iommu_hwpt_get_dirty_bitmap { #define IOMMU_HWPT_GET_DIRTY_BITMAP _IO(IOMMUFD_TYPE, \ IOMMUFD_CMD_HWPT_GET_DIRTY_BITMAP)

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-07 Thread Jason Gunthorpe
On Thu, Dec 07, 2023 at 09:04:00AM +, Tian, Kevin wrote: > > From: Liu, Yi L > > Sent: Thursday, December 7, 2023 2:59 PM > > > > On 2023/11/17 21:07, Yi Liu wrote: > > > @@ -613,4 +614,38 @@ struct iommu_hwpt_get_dirty_bitmap { > > > #define IOMMU_HWPT_GET_DIRTY_BITMAP _IO(IOMMUFD_TYPE, \

RE: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-07 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Thursday, December 7, 2023 2:59 PM > > On 2023/11/17 21:07, Yi Liu wrote: > > @@ -613,4 +614,38 @@ struct iommu_hwpt_get_dirty_bitmap { > > #define IOMMU_HWPT_GET_DIRTY_BITMAP _IO(IOMMUFD_TYPE, \ > > > IOMMUFD_CMD_HWPT_GET_DIRTY_BITMAP) > > > > +/** > > + *

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-06 Thread Yi Liu
On 2023/11/17 21:07, Yi Liu wrote: In nested translation, the stage-1 page table is user-managed but cached by the IOMMU hardware, so an update on present page table entries in the stage-1 page table should be followed with a cache invalidation. Add an IOMMU_HWPT_INVALIDATE ioctl to support

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-06 Thread Jason Gunthorpe
On Fri, Nov 17, 2023 at 05:07:13AM -0800, Yi Liu wrote: > +/** > + * struct iommu_hwpt_invalidate - ioctl(IOMMU_HWPT_INVALIDATE) > + * @size: sizeof(struct iommu_hwpt_invalidate) > + * @hwpt_id: HWPT ID of a nested HWPT for cache invalidation > + * @reqs_uptr: User pointer to an array having

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-06 Thread Jason Gunthorpe
On Tue, Dec 05, 2023 at 09:33:30AM -0800, Nicolin Chen wrote: > On Mon, Dec 04, 2023 at 10:48:50AM -0400, Jason Gunthorpe wrote: > > > > Or am I missing some point here? > > > > It sounds Ok, we just have to understand what userspace should be > > doing and how much of this the kernel should

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-05 Thread Nicolin Chen
On Mon, Dec 04, 2023 at 10:48:50AM -0400, Jason Gunthorpe wrote: > > Or am I missing some point here? > > It sounds Ok, we just have to understand what userspace should be > doing and how much of this the kernel should implement. > > It seems to me that the error code should return the gerror

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-04 Thread Jason Gunthorpe
On Fri, Dec 01, 2023 at 02:12:28PM -0800, Nicolin Chen wrote: > > Why is timeout linked to these two? Or rather, it doesn't have to be > > linked like that. Any gerror is effectively synchronous because it > > halts the queue and allows SW time to inspect which command failed and > > record the

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-01 Thread Nicolin Chen
On Fri, Dec 01, 2023 at 04:43:40PM -0400, Jason Gunthorpe wrote: > On Fri, Dec 01, 2023 at 11:58:07AM -0800, Nicolin Chen wrote: > > > It seems there is not a simple way to realize this error back to > > > userspace since we can't block the global command queue and we proceed > > > to complete

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-01 Thread Jason Gunthorpe
On Fri, Dec 01, 2023 at 11:58:07AM -0800, Nicolin Chen wrote: > > It seems there is not a simple way to realize this error back to > > userspace since we can't block the global command queue and we proceed > > to complete commands that the real HW would not have completed. > > > > To actually

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-01 Thread Nicolin Chen
On Fri, Dec 01, 2023 at 08:55:38AM -0400, Jason Gunthorpe wrote: > On Thu, Nov 30, 2023 at 08:29:34PM -0800, Nicolin Chen wrote: > > On Thu, Nov 30, 2023 at 08:45:23PM -0400, Jason Gunthorpe wrote: > > > On Thu, Nov 30, 2023 at 12:41:20PM -0800, Nicolin Chen wrote: > > > > > > > > So userspace

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-01 Thread Jason Gunthorpe
On Thu, Nov 30, 2023 at 08:29:34PM -0800, Nicolin Chen wrote: > On Thu, Nov 30, 2023 at 08:45:23PM -0400, Jason Gunthorpe wrote: > > On Thu, Nov 30, 2023 at 12:41:20PM -0800, Nicolin Chen wrote: > > > > > > So userspace would have to read the event FD > > > > before returning to be correct? > > >

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-12-01 Thread Yi Liu
On 2023/12/1 15:10, Tian, Kevin wrote: From: Liu, Yi L Sent: Friday, December 1, 2023 3:05 PM On 2023/12/1 13:19, Tian, Kevin wrote: From: Nicolin Chen Sent: Friday, December 1, 2023 12:50 PM On Fri, Dec 01, 2023 at 11:51:26AM +0800, Yi Liu wrote: On 2023/11/29 08:57, Jason Gunthorpe

RE: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-30 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Friday, December 1, 2023 3:05 PM > > On 2023/12/1 13:19, Tian, Kevin wrote: > >> From: Nicolin Chen > >> Sent: Friday, December 1, 2023 12:50 PM > >> > >> On Fri, Dec 01, 2023 at 11:51:26AM +0800, Yi Liu wrote: > >>> On 2023/11/29 08:57, Jason Gunthorpe wrote: >

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-30 Thread Yi Liu
On 2023/12/1 13:19, Tian, Kevin wrote: From: Nicolin Chen Sent: Friday, December 1, 2023 12:50 PM On Fri, Dec 01, 2023 at 11:51:26AM +0800, Yi Liu wrote: On 2023/11/29 08:57, Jason Gunthorpe wrote: On Tue, Nov 28, 2023 at 04:51:21PM -0800, Nicolin Chen wrote: I also thought about making

RE: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-30 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Friday, December 1, 2023 12:50 PM > > On Fri, Dec 01, 2023 at 11:51:26AM +0800, Yi Liu wrote: > > On 2023/11/29 08:57, Jason Gunthorpe wrote: > > > On Tue, Nov 28, 2023 at 04:51:21PM -0800, Nicolin Chen wrote: > > > > > > I also thought about making this

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-30 Thread Nicolin Chen
On Fri, Dec 01, 2023 at 11:51:26AM +0800, Yi Liu wrote: > On 2023/11/29 08:57, Jason Gunthorpe wrote: > > On Tue, Nov 28, 2023 at 04:51:21PM -0800, Nicolin Chen wrote: > > > > > I also thought about making this out_driver_error_code per HW. > > > > > Yet, an error can be either per array or per

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-30 Thread Nicolin Chen
On Thu, Nov 30, 2023 at 08:45:23PM -0400, Jason Gunthorpe wrote: > On Thu, Nov 30, 2023 at 12:41:20PM -0800, Nicolin Chen wrote: > > > > So userspace would have to read the event FD > > > before returning to be correct? > > > > > > Maybe the kernel can somehow return a flag to indicate the event

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-30 Thread Yi Liu
On 2023/11/29 08:57, Jason Gunthorpe wrote: On Tue, Nov 28, 2023 at 04:51:21PM -0800, Nicolin Chen wrote: I also thought about making this out_driver_error_code per HW. Yet, an error can be either per array or per entry/quest. The array-related error should be reported in the array structure

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-30 Thread Jason Gunthorpe
On Thu, Nov 30, 2023 at 12:41:20PM -0800, Nicolin Chen wrote: > > So userspace would have to read the event FD > > before returning to be correct? > > > > Maybe the kernel can somehow return a flag to indicate the event fd > > has data in it? > > > > If yes then all errors would flow through

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-30 Thread Nicolin Chen
On Wed, Nov 29, 2023 at 08:08:16PM -0400, Jason Gunthorpe wrote: > On Wed, Nov 29, 2023 at 02:07:58PM -0800, Nicolin Chen wrote: > > On Wed, Nov 29, 2023 at 03:58:04PM -0400, Jason Gunthorpe wrote: > > > On Tue, Nov 28, 2023 at 05:09:07PM -0800, Nicolin Chen wrote: > > > > > > > > > With that

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-29 Thread Jason Gunthorpe
On Wed, Nov 29, 2023 at 02:07:58PM -0800, Nicolin Chen wrote: > On Wed, Nov 29, 2023 at 03:58:04PM -0400, Jason Gunthorpe wrote: > > On Tue, Nov 28, 2023 at 05:09:07PM -0800, Nicolin Chen wrote: > > > > > > > With that being said, I think errno (-EIO) could do the job, > > > > > as you suggested

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-29 Thread Nicolin Chen
On Wed, Nov 29, 2023 at 03:58:04PM -0400, Jason Gunthorpe wrote: > On Tue, Nov 28, 2023 at 05:09:07PM -0800, Nicolin Chen wrote: > > > > > With that being said, I think errno (-EIO) could do the job, > > > > as you suggested too. > > > > > > Do we have any idea what HW failures can be generated

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-28 Thread Jason Gunthorpe
On Tue, Nov 28, 2023 at 04:51:21PM -0800, Nicolin Chen wrote: > > > I also thought about making this out_driver_error_code per HW. > > > Yet, an error can be either per array or per entry/quest. The > > > array-related error should be reported in the array structure > > > that is a core uAPI, v.s.

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-28 Thread Nicolin Chen
On Tue, Nov 28, 2023 at 08:03:35AM +, Tian, Kevin wrote: > > From: Nicolin Chen > > Sent: Tuesday, November 28, 2023 3:53 AM > > > > On Fri, Nov 24, 2023 at 02:36:29AM +, Tian, Kevin wrote: > > > > > > > > > > >> + * @out_driver_error_code: Report a driver speicifc error > > > > > > > >

RE: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-28 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Tuesday, November 28, 2023 3:53 AM > > On Fri, Nov 24, 2023 at 02:36:29AM +, Tian, Kevin wrote: > > > > > > > > >> + * @out_driver_error_code: Report a driver speicifc error code > > > upon > > > > > > > failure. > > > > > > > >> + * It's

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-27 Thread Yi Liu
On 2023/11/28 03:53, Nicolin Chen wrote: On Fri, Nov 24, 2023 at 02:36:29AM +, Tian, Kevin wrote: + * @out_driver_error_code: Report a driver speicifc error code upon failure. + * It's optional, driver has a choice to fill it or + * not.

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-27 Thread Nicolin Chen
On Fri, Nov 24, 2023 at 02:36:29AM +, Tian, Kevin wrote: > > > > > > >> + * @out_driver_error_code: Report a driver speicifc error code > > upon > > > > > > failure. > > > > > > >> + * It's optional, driver has a choice > > > > > > >> to fill it or > > > > > > >> + *

RE: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-23 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Tuesday, November 21, 2023 1:24 PM > > On Tue, Nov 21, 2023 at 02:50:05AM +, Tian, Kevin wrote: > > > From: Nicolin Chen > > > Sent: Tuesday, November 21, 2023 1:37 AM > > > > > > On Mon, Nov 20, 2023 at 08:34:58AM +, Tian, Kevin wrote: > > > > > From: Liu,

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-20 Thread Nicolin Chen
On Tue, Nov 21, 2023 at 02:50:05AM +, Tian, Kevin wrote: > > From: Nicolin Chen > > Sent: Tuesday, November 21, 2023 1:37 AM > > > > On Mon, Nov 20, 2023 at 08:34:58AM +, Tian, Kevin wrote: > > > > From: Liu, Yi L > > > > Sent: Monday, November 20, 2023 4:30 PM > > > > > > > > On

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-20 Thread Nicolin Chen
On Tue, Nov 21, 2023 at 01:02:49PM +0800, Baolu Lu wrote: > On 11/17/23 9:07 PM, Yi Liu wrote: > > In nested translation, the stage-1 page table is user-managed but cached > > by the IOMMU hardware, so an update on present page table entries in the > > stage-1 page table should be followed with a

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-20 Thread Baolu Lu
On 11/17/23 9:07 PM, Yi Liu wrote: In nested translation, the stage-1 page table is user-managed but cached by the IOMMU hardware, so an update on present page table entries in the stage-1 page table should be followed with a cache invalidation. Add an IOMMU_HWPT_INVALIDATE ioctl to support

RE: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-20 Thread Tian, Kevin
> From: Nicolin Chen > Sent: Tuesday, November 21, 2023 1:37 AM > > On Mon, Nov 20, 2023 at 08:34:58AM +, Tian, Kevin wrote: > > > From: Liu, Yi L > > > Sent: Monday, November 20, 2023 4:30 PM > > > > > > On 2023/11/20 16:09, Tian, Kevin wrote: > > > >> From: Liu, Yi L > > > >> Sent:

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-20 Thread Nicolin Chen
On Mon, Nov 20, 2023 at 08:34:58AM +, Tian, Kevin wrote: > > From: Liu, Yi L > > Sent: Monday, November 20, 2023 4:30 PM > > > > On 2023/11/20 16:09, Tian, Kevin wrote: > > >> From: Liu, Yi L > > >> Sent: Friday, November 17, 2023 9:07 PM > > >> + * @req_len: Length (in bytes) of a request

RE: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-20 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Monday, November 20, 2023 4:30 PM > > On 2023/11/20 16:09, Tian, Kevin wrote: > >> From: Liu, Yi L > >> Sent: Friday, November 17, 2023 9:07 PM > >> + * @req_len: Length (in bytes) of a request entry in the request array > >> + * @req_num: Input the number of cache

Re: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-20 Thread Yi Liu
On 2023/11/20 16:09, Tian, Kevin wrote: From: Liu, Yi L Sent: Friday, November 17, 2023 9:07 PM + + hwpt = iommufd_hw_pagetable_get_nested(ucmd, cmd->hwpt_id); + if (IS_ERR(hwpt)) + return PTR_ERR(hwpt); + + rc =

RE: [PATCH v6 2/6] iommufd: Add IOMMU_HWPT_INVALIDATE

2023-11-20 Thread Tian, Kevin
> From: Liu, Yi L > Sent: Friday, November 17, 2023 9:07 PM > + > + hwpt = iommufd_hw_pagetable_get_nested(ucmd, cmd->hwpt_id); > + if (IS_ERR(hwpt)) > + return PTR_ERR(hwpt); > + > + rc = hwpt->domain->ops->cache_invalidate_user(hwpt->domain, > _array, > +