Skip to content

Commit 91fbb5e

Browse files
amd-yangpgregkh
authored andcommitted
drm/amdgpu: zero-initialize GART table on allocation
commit e6c2e6c upstream. GART TLB is flushed after unmapping but not after mapping. Since amdgpu_bo_create_kernel() does not zero-initialize the buffer, when a single PTE is written the TLB may speculatively load other uninitialized entries from the same cacheline. Those garbage entries can appear valid, and a subsequent write to another PTE in the same cacheline may cause the GPU to use a stale garbage PTE from the TLB. Fix this by calling memset_io() to zero-initialize the GART table with gart_pte_flags immediately after allocation. Using AMDGPU_GEM_CREATE_VRAM_CLEARED, SDMA-based clear will not work since SDMA needs GART to be initialized to work. Suggested-by: Felix Kuehling <felix.kuehling@amd.com> Signed-off-by: Philip Yang <Philip.Yang@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> (cherry picked from commit d9af826) Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent b8cbc52 commit 91fbb5e

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,12 +252,19 @@ void amdgpu_gart_table_ram_free(struct amdgpu_device *adev)
252252
*/
253253
int amdgpu_gart_table_vram_alloc(struct amdgpu_device *adev)
254254
{
255+
int r;
256+
255257
if (adev->gart.bo != NULL)
256258
return 0;
257259

258-
return amdgpu_bo_create_kernel(adev, adev->gart.table_size, PAGE_SIZE,
259-
AMDGPU_GEM_DOMAIN_VRAM, &adev->gart.bo,
260-
NULL, (void *)&adev->gart.ptr);
260+
r = amdgpu_bo_create_kernel(adev, adev->gart.table_size, PAGE_SIZE,
261+
AMDGPU_GEM_DOMAIN_VRAM, &adev->gart.bo,
262+
NULL, (void *)&adev->gart.ptr);
263+
if (r)
264+
return r;
265+
266+
memset_io(adev->gart.ptr, adev->gart.gart_pte_flags, adev->gart.table_size);
267+
return 0;
261268
}
262269

263270
/**

0 commit comments

Comments
 (0)