[PATCH] drm/xe/userptr: properly setup pfn_flags_mask
Upadhyay, Tejas
tejas.upadhyay at intel.com
Thu Feb 27 05:03:02 UTC 2025
> -----Original Message-----
> From: Intel-xe <intel-xe-bounces at lists.freedesktop.org> On Behalf Of
> Matthew Auld
> Sent: Wednesday, February 26, 2025 10:47 PM
> To: intel-xe at lists.freedesktop.org
> Cc: Brost, Matthew <matthew.brost at intel.com>; Hellstrom, Thomas
> <thomas.hellstrom at intel.com>; stable at vger.kernel.org
> Subject: [PATCH] drm/xe/userptr: properly setup pfn_flags_mask
>
> Currently we just leave it uninitialised, which at first looks harmless, however
> we also don't zero out the pfn array, and with pfn_flags_mask the idea is to be
> able set individual flags for a given range of pfn or completely ignore them,
> outside of default_flags. So here we end up with pfn[i] & pfn_flags_mask, and
> if both are uninitialised we might get back an unexpected flags value, like
> asking for read only with default_flags, but getting back write on top, leading
> to potentially bogus behaviour.
>
> To fix this ensure we zero the pfn_flags_mask, such that hmm only considers
> the default_flags and not also the initial pfn[i] value.
>
> Fixes: 81e058a3e7fd ("drm/xe: Introduce helper to populate userptr")
> Signed-off-by: Matthew Auld <matthew.auld at intel.com>
> Cc: Matthew Brost <matthew.brost at intel.com>
> Cc: Thomas Hellström <thomas.hellstrom at intel.com>
> Cc: <stable at vger.kernel.org> # v6.10+
> ---
> drivers/gpu/drm/xe/xe_hmm.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_hmm.c b/drivers/gpu/drm/xe/xe_hmm.c
> index 089834467880..8c3cd65fa4b3 100644
> --- a/drivers/gpu/drm/xe/xe_hmm.c
> +++ b/drivers/gpu/drm/xe/xe_hmm.c
> @@ -206,6 +206,7 @@ int xe_hmm_userptr_populate_range(struct
> xe_userptr_vma *uvma,
> goto free_pfns;
> }
>
> + hmm_range.pfn_flags_mask = 0;
Looks correct to me,
Reviewed-by: Tejas Upadhyay <tejas.upadhyay at intel.com>
Tejas
> hmm_range.default_flags = flags;
> hmm_range.hmm_pfns = pfns;
> hmm_range.notifier = &userptr->notifier;
> --
> 2.48.1
More information about the Intel-xe
mailing list