[PATCH 1/4] drm/xe/vm: Validate userptr during gpu vma prefetching
Thomas Hellström
thomas.hellstrom at linux.intel.com
Wed Feb 26 15:46:36 UTC 2025
On Wed, 2025-02-26 at 07:40 -0800, Matthew Brost wrote:
> On Wed, Feb 26, 2025 at 04:33:41PM +0100, Thomas Hellström wrote:
> > If a userptr vma subject to prefetching was already invalidated
> > or invalidated during the prefetch operation, the operation would
> > repeatedly return -EAGAIN which would typically cause an infinite
> > loop.
> >
> > Validate the userptr to ensure this doesn't happen.
> >
> > Fixes: 5bd24e78829a ("drm/xe/vm: Subclass userptr vmas")
> > Fixes: 617eebb9c480 ("drm/xe: Fix array of binds")
> > Cc: Matthew Brost <matthew.brost at intel.com>
> > Cc: <stable at vger.kernel.org> # v6.9+
> > Suggested-by: Matthew Brost <matthew.brost at intel.com>
> > Signed-off-by: Thomas Hellström <thomas.hellstrom at linux.intel.com>
> > ---
> > drivers/gpu/drm/xe/xe_vm.c | 9 ++++++++-
> > 1 file changed, 8 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/xe/xe_vm.c
> > b/drivers/gpu/drm/xe/xe_vm.c
> > index 996000f2424e..4c1ca47667ad 100644
> > --- a/drivers/gpu/drm/xe/xe_vm.c
> > +++ b/drivers/gpu/drm/xe/xe_vm.c
> > @@ -2307,7 +2307,14 @@ static int vm_bind_ioctl_ops_parse(struct
> > xe_vm *vm, struct drm_gpuva_ops *ops,
> > }
> > case DRM_GPUVA_OP_UNMAP:
> > case DRM_GPUVA_OP_PREFETCH:
> > - /* FIXME: Need to skip some prefetch ops
> > */
>
> The UNMAP case statement is falling through to pretech case which I
> believe is not the intent.
>
> So I think:
>
> case DRM_GPUVA_OP_UNMAP:
> xe_vma_ops_incr_pt_update_ops(vops, op->tile_mask);
> break;
> case DRM_GPUVA_OP_PREFETCH:
> <new code>
>
> Matt
Right.
Will fix.
/Thomas
>
> > + vma = gpuva_to_vma(op->base.prefetch.va);
> > +
> > + if (xe_vma_is_userptr(vma)) {
> > + err =
> > xe_vma_userptr_pin_pages(to_userptr_vma(vma));
> > + if (err)
> > + return err;
> > + }
> > +
> > xe_vma_ops_incr_pt_update_ops(vops, op-
> > >tile_mask);
> > break;
> > default:
> > --
> > 2.48.1
> >
More information about the Intel-xe
mailing list