drm/amdkfd: fix units when unmapping a PROT_NONE VMA from GPUs
Subsystems (3)
PATCH 1/1 drm/amdkfd: fix units when unmapping a PROT_NONE VMA from GPUs
In svm_range_validate_and_map(), start and end are byte addresses while prange->start and prange->last are page numbers. Mixing them makes e >= s false in practice, so a VMA without VM_READ is never unmapped from the GPUs. The bounds also covered the whole request instead of the current VMA.
Use the page numbers of the current VMA, [addr, next).
--- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +2 -2
@@ -1857,8 +1857,8 @@ static int svm_range_validate_and_map(struct mm_struct *mm,svm_range_lock (prange);if (vma->vm_flags &VM_WRITE )pr_debug ("VM_WRITE without VM_READ is not supported" ); - s =max (start, prange->start); - e =min (end, prange->last); + s =max (addr >>PAGE_SHIFT , prange->start); + e =min ((next >>PAGE_SHIFT ) -1 , prange->last);if (e >= s) r = svm_range_unmap_from_gpus(prange, s, e, prange->bitmap_mapped,
Signature · 1 line
2.34.1
Public
This patch is:
-----Original Message-----
From: Yuan, Perry <[email protected]>
Sent: Monday, November 9, 2026 2:21 PM
To: Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; [email protected]
Cc: Zhang, Yifan <[email protected]>; Yuan, Perry <[email protected]>
Subject: [PATCH] drm/amdkfd: fix units when unmapping a PROT_NONE VMA from GPUs
In svm_range_validate_and_map(), start and end are byte addresses while prange->start and prange->last are page numbers. Mixing them makes e >= s false in practice, so a VMA without VM_READ is never unmapped from the GPUs. The bounds also covered the whole request instead of the current VMA.
Use the page numbers of the current VMA, [addr, next).
--- drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_svm.c +2 -2
@@ -1857,8 +1857,8 @@ static int svm_range_validate_and_map(struct mm_struct *mm,svm_range_lock (prange);if (vma->vm_flags &VM_WRITE )pr_debug ("VM_WRITE without VM_READ is not supported" ); - s =max (start, prange->start); - e =min (end, prange->last); + s =max (addr >>PAGE_SHIFT , prange->start); + e =min ((next >>PAGE_SHIFT ) -1 , prange->last);if (e >= s) r = svm_range_unmap_from_gpus(prange, s, e, prange->bitmap_mapped,
--
2.34.1