drm/amdgpu: restrict bo mapping within gpu address limits
Subsystems (2)
PATCH 1/1 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.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +4 -2
@@ -2208,7 +2208,8 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,/* make sure object fit at this offset */ eaddr = saddr + size -1 ;if (saddr >= eaddr || - (bo && offset + size >amdgpu_bo_size (bo))) + (bo && offset + size >amdgpu_bo_size (bo)) || + (eaddr >= adev->vm_manager.max_pfn <<AMDGPU_GPU_PAGE_SHIFT ))return -EINVAL ; saddr /=AMDGPU_GPU_PAGE_SIZE ;
@@ -2273,7 +2274,8 @@ int amdgpu_vm_bo_replace_map(struct amdgpu_device *adev,/* make sure object fit at this offset */ eaddr = saddr + size -1 ;if (saddr >= eaddr || - (bo && offset + size >amdgpu_bo_size (bo))) + (bo && offset + size >amdgpu_bo_size (bo)) || + (eaddr >= adev->vm_manager.max_pfn <<AMDGPU_GPU_PAGE_SHIFT ))return -EINVAL ;/* Allocate all the needed memory */
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerHi Rajneesh,
I think we have reviewed the patch multiple times now, you can push it to the amd-staging-drm-next branch.
Regards,
Christian.
Am 02.06.20 um 20:27 schrieb Rajneesh Bhardwaj:
Quoted 31 lines
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_pfnrange. This restricts the range to map bo within pratical limits of cpu and gpu for shared virtual memory access.Reviewed-by Oak Zeng <[email protected]>Reviewed-by Christian König <[email protected]>Reviewed-by Hawking Zhang <[email protected]>Acked-by Alex Deucher <[email protected]>Signed-off-by Rajneesh Bhardwaj <[email protected]>--- drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1@@ -2208,7 +2208,8 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev,/* make sure object fit at this offset */ eaddr = saddr + size -1 ;if (saddr >= eaddr || - (bo && offset + size >amdgpu_bo_size (bo))) + (bo && offset + size >amdgpu_bo_size (bo)) || + (eaddr >= adev->vm_manager.max_pfn <<AMDGPU_GPU_PAGE_SHIFT ))return -EINVAL ; saddr /=AMDGPU_GPU_PAGE_SIZE ;
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c int amdgpu_vm_bo_replace_map(struct amdgpu_device *adev, · line 2281
Quoted 9 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2
-1@@ -2273,7 +2274,8 @@ int amdgpu_vm_bo_replace_map(struct amdgpu_device *adev,/* make sure object fit at this offset */ eaddr = saddr + size -1 ;if (saddr >= eaddr || - (bo && offset + size >amdgpu_bo_size (bo))) + (bo && offset + size >amdgpu_bo_size (bo)) || + (eaddr >= adev->vm_manager.max_pfn <<AMDGPU_GPU_PAGE_SHIFT ))return -EINVAL ;/* Allocate all the needed memory */
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 3 lines · Christian König
Hi Rajneesh,
I think we have reviewed the patch multiple times now, you can push it to the amd-staging-drm-next branch.
Thanks Christian. Just wanted to make sure its sent once on the public list. I'll push it to the branch now.
Quoted 36 lines
Regards,
Christian.Am 02.06.20 um 20:27 schrieb Rajneesh Bhardwaj:
Quoted 31 lines
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_pfnrange. This restricts the range to map bo within pratical limits of cpu and gpu for shared virtual memory access.Reviewed-by Oak Zeng <[email protected]>Reviewed-by Christian König <[email protected]>Reviewed-by Hawking Zhang <[email protected]>Acked-by Alex Deucher <[email protected]>Signed-off-by Rajneesh Bhardwaj <[email protected]>---
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c| 6 ++++--1 file changed, 4 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0@@ -2208,7 +2208,8 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev, /* make sure object fit at this offset */ eaddr = saddr + size - 1;if (saddr >= eaddr ||
- (bo && offset + size >amdgpu_bo_size(bo)))
+ (bo && offset + size >amdgpu_bo_size(bo)) ||
+ (eaddr >=adev->vm_manager.max_pfn<<AMDGPU_GPU_PAGE_SHIFT)) return-EINVAL;
saddr /=AMDGPU_GPU_PAGE_SIZE;drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0@@ -2273,7 +2274,8 @@ int amdgpu_vm_bo_replace_map(struct amdgpu_device *adev,
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0
-0/* make sure object fit at this offset */ eaddr = saddr + size - 1;if (saddr >= eaddr ||
- (bo && offset + size >amdgpu_bo_size(bo)))
+ (bo && offset + size >amdgpu_bo_size(bo)) ||
+ (eaddr >=adev->vm_manager.max_pfn<<AMDGPU_GPU_PAGE_SHIFT)) return-EINVAL;
/* Allocate all the needed memory */
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx