[PATCH] drm/amdgpu: potential shift wrapping bug

Christian König deathsimple at vodafone.de
Thu Aug 10 12:30:15 UTC 2017


Am 10.08.2017 um 14:16 schrieb Dan Carpenter:
> "frag_align" is a u64, so presumably we want to use the high bits as
> well instead of shift wrapping.
>
> Fixes: 6be7adb37d9b ("drm/amdgpu: increase fragmentation size for Vega10 v2")
> Signed-off-by: Dan Carpenter <dan.carpenter at oracle.com>

The fragment field has only 5bits in hardware and can never be more than 
31, so the correct fix would actually be using uint32_t here instead.

Christian.

>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> index ba0407d12525..d9a8e942ac3b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c
> @@ -1459,7 +1459,7 @@ static int amdgpu_vm_frag_ptes(struct amdgpu_pte_update_params	*params,
>   	/* SI and newer are optimized for 64KB */
>   	unsigned pages_per_frag = AMDGPU_LOG2_PAGES_PER_FRAG(params->adev);
>   	uint64_t frag_flags = AMDGPU_PTE_FRAG(pages_per_frag);
> -	uint64_t frag_align = 1 << pages_per_frag;
> +	uint64_t frag_align = 1ULL << pages_per_frag;
>   
>   	uint64_t frag_start = ALIGN(start, frag_align);
>   	uint64_t frag_end = end & ~(frag_align - 1);
> _______________________________________________
> amd-gfx mailing list
> amd-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx




More information about the dri-devel mailing list