aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
diff options
context:
space:
mode:
authorFelix Kuehling <Felix.Kuehling@amd.com>2018-11-24 22:46:23 -0500
committerAlex Deucher <alexander.deucher@amd.com>2018-11-28 14:38:33 -0500
commit9ce2b991f7ea45b913c3c391bb652dd95dd78876 (patch)
tree2d2280cddb9fbb92849a7910c64d8718afde9cc2 /drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
parent04ac4b0ed412f65230b456fcd9aa07e13befff89 (diff)
drm/amdgpu: Cast to uint64_t before left shift
Avoid potential integer overflows with left shift in huge-page mapping code by casting the operand to uin64_t first. Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
index dad0e2342df9..be3e360b0450 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
@@ -181,7 +181,7 @@ static unsigned amdgpu_vm_num_entries(struct amdgpu_device *adev,
181 181
182 if (level == adev->vm_manager.root_level) 182 if (level == adev->vm_manager.root_level)
183 /* For the root directory */ 183 /* For the root directory */
184 return round_up(adev->vm_manager.max_pfn, 1 << shift) >> shift; 184 return round_up(adev->vm_manager.max_pfn, 1ULL << shift) >> shift;
185 else if (level != AMDGPU_VM_PTB) 185 else if (level != AMDGPU_VM_PTB)
186 /* Everything in between */ 186 /* Everything in between */
187 return 512; 187 return 512;
@@ -1666,10 +1666,10 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,
1666 } 1666 }
1667 1667
1668 /* Looks good so far, calculate parameters for the update */ 1668 /* Looks good so far, calculate parameters for the update */
1669 incr = AMDGPU_GPU_PAGE_SIZE << shift; 1669 incr = (uint64_t)AMDGPU_GPU_PAGE_SIZE << shift;
1670 mask = amdgpu_vm_entries_mask(adev, cursor.level); 1670 mask = amdgpu_vm_entries_mask(adev, cursor.level);
1671 pe_start = ((cursor.pfn >> shift) & mask) * 8; 1671 pe_start = ((cursor.pfn >> shift) & mask) * 8;
1672 entry_end = (mask + 1) << shift; 1672 entry_end = (uint64_t)(mask + 1) << shift;
1673 entry_end += cursor.pfn & ~(entry_end - 1); 1673 entry_end += cursor.pfn & ~(entry_end - 1);
1674 entry_end = min(entry_end, end); 1674 entry_end = min(entry_end, end);
1675 1675
@@ -1682,7 +1682,7 @@ static int amdgpu_vm_update_ptes(struct amdgpu_pte_update_params *params,
1682 flags | AMDGPU_PTE_FRAG(frag)); 1682 flags | AMDGPU_PTE_FRAG(frag));
1683 1683
1684 pe_start += nptes * 8; 1684 pe_start += nptes * 8;
1685 dst += nptes * AMDGPU_GPU_PAGE_SIZE << shift; 1685 dst += (uint64_t)nptes * AMDGPU_GPU_PAGE_SIZE << shift;
1686 1686
1687 frag_start = upd_end; 1687 frag_start = upd_end;
1688 if (frag_start >= frag_end) { 1688 if (frag_start >= frag_end) {