drm/radeon: avoid kernel segfault in vce when gpu fails to resume
authorJérôme Glisse <jglisse@redhat.com>
Mon, 6 Feb 2017 20:13:18 +0000 (15:13 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 9 Feb 2017 01:59:16 +0000 (20:59 -0500)
When GPU fails to resume we can not trust that value we write to GPU
memory will post and we might get garbage (more like 0xffffffff on
x86) when reading them back. This trigger out of range memory access
in the kernel inside the vce resume code path.

This patch use canonical value to compute offset instead of reading
back value from GPU memory.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Jérôme Glisse <jglisse@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/vce_v1_0.c

index a01efe39a8206ec1b1d1fd26a3192c5d72abb885..f541a4b5ac5113e1f239a3b2ddd7dba785e7b2c2 100644 (file)
@@ -196,7 +196,7 @@ int vce_v1_0_load_fw(struct radeon_device *rdev, uint32_t *data)
        memset(&data[5], 0, 44);
        memcpy(&data[16], &sign[1], rdev->vce_fw->size - sizeof(*sign));
 
-       data += le32_to_cpu(data[4]) / 4;
+       data += (le32_to_cpu(sign->len) + 64) / 4;
        data[0] = sign->val[i].sigval[0];
        data[1] = sign->val[i].sigval[1];
        data[2] = sign->val[i].sigval[2];