Skip to content

Commit 7b9a3a9

Browse files
Intel-ArvindYadavrodrigovivi
authored andcommitted
drm/xe/madvise: Accept canonical GPU addresses in xe_vm_madvise_ioctl
Userspace passes canonical (sign-extended) GPU addresses where bits 63:48 mirror bit 47. The internal GPUVM uses non-canonical form (upper bits zeroed), so passing raw canonical addresses into GPUVM lookups causes mismatches for addresses above 128TiB. Strip the sign extension with xe_device_uncanonicalize_addr() at the top of xe_vm_madvise_ioctl(). Non-canonical addresses are unaffected. Fixes: ada7486 ("drm/xe: Implement madvise ioctl for xe") Suggested-by: Matthew Brost <matthew.brost@intel.com> Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Signed-off-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com> Signed-off-by: Arvind Yadav <arvind.yadav@intel.com> Signed-off-by: Matthew Brost <matthew.brost@intel.com> Link: https://patch.msgid.link/20260326130843.3545241-13-arvind.yadav@intel.com (cherry picked from commit 05c8b1c) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent 6d192b4 commit 7b9a3a9

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

drivers/gpu/drm/xe/xe_vm_madvise.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -408,8 +408,15 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil
408408
struct xe_device *xe = to_xe_device(dev);
409409
struct xe_file *xef = to_xe_file(file);
410410
struct drm_xe_madvise *args = data;
411-
struct xe_vmas_in_madvise_range madvise_range = {.addr = args->start,
412-
.range = args->range, };
411+
struct xe_vmas_in_madvise_range madvise_range = {
412+
/*
413+
* Userspace may pass canonical (sign-extended) addresses.
414+
* Strip the sign extension to get the internal non-canonical
415+
* form used by the GPUVM, matching xe_vm_bind_ioctl() behavior.
416+
*/
417+
.addr = xe_device_uncanonicalize_addr(xe, args->start),
418+
.range = args->range,
419+
};
413420
struct xe_madvise_details details;
414421
struct xe_vm *vm;
415422
struct drm_exec exec;
@@ -439,7 +446,7 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil
439446
if (err)
440447
goto unlock_vm;
441448

442-
err = xe_vm_alloc_madvise_vma(vm, args->start, args->range);
449+
err = xe_vm_alloc_madvise_vma(vm, madvise_range.addr, args->range);
443450
if (err)
444451
goto madv_fini;
445452

@@ -482,7 +489,8 @@ int xe_vm_madvise_ioctl(struct drm_device *dev, void *data, struct drm_file *fil
482489
madvise_funcs[attr_type](xe, vm, madvise_range.vmas, madvise_range.num_vmas, args,
483490
&details);
484491

485-
err = xe_vm_invalidate_madvise_range(vm, args->start, args->start + args->range);
492+
err = xe_vm_invalidate_madvise_range(vm, madvise_range.addr,
493+
madvise_range.addr + args->range);
486494

487495
if (madvise_range.has_svm_userptr_vmas)
488496
xe_svm_notifier_unlock(vm);

0 commit comments

Comments
 (0)