Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdgpu: restrict bo mapping within gpu address limits

Have strict check on bo mapping since on some systems, such as A+A or
hybrid, the cpu might support 5 level paging or can address memory above
48 bits but gpu might be limited by hardware to just use 48 bits. In
general, this applies to all asics where this limitation can be checked
against their max_pfn range. This restricts the range to map bo within
pratical limits of cpu and gpu for shared virtual memory access.

Reviewed-by: Oak Zeng <oak.zeng@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Rajneesh Bhardwaj and committed by
Alex Deucher
8b80d74b 81a16241

+4 -2
+4 -2
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
··· 2208 2208 /* make sure object fit at this offset */ 2209 2209 eaddr = saddr + size - 1; 2210 2210 if (saddr >= eaddr || 2211 - (bo && offset + size > amdgpu_bo_size(bo))) 2211 + (bo && offset + size > amdgpu_bo_size(bo)) || 2212 + (eaddr >= adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT)) 2212 2213 return -EINVAL; 2213 2214 2214 2215 saddr /= AMDGPU_GPU_PAGE_SIZE; ··· 2274 2273 /* make sure object fit at this offset */ 2275 2274 eaddr = saddr + size - 1; 2276 2275 if (saddr >= eaddr || 2277 - (bo && offset + size > amdgpu_bo_size(bo))) 2276 + (bo && offset + size > amdgpu_bo_size(bo)) || 2277 + (eaddr >= adev->vm_manager.max_pfn << AMDGPU_GPU_PAGE_SHIFT)) 2278 2278 return -EINVAL; 2279 2279 2280 2280 /* Allocate all the needed memory */