drm/amdgpu: fix memory overflow in the IB test
Subsystems (2)
PATCH 1/1 drm/amdgpu: fix memory overflow in the IB test
Fix a memory overflow issue in the gfx IB test
for some ASICs. At least 20 bytes are needed for
the IB test packet.
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1 -1
@@ -419,7 +419,7 @@ static int gfx_v11_0_ring_test_ib(struct amdgpu_ring *ring, long timeout) adev->wb.wb[index] =cpu_to_le32 (0xCAFEDEAD ); cpu_ptr = &adev->wb.wb[index]; - r =amdgpu_ib_get (adev,NULL ,16 ,AMDGPU_IB_POOL_DIRECT , &ib); + r =amdgpu_ib_get (adev,NULL ,20 ,AMDGPU_IB_POOL_DIRECT , &ib);if (r) {DRM_ERROR ("amdgpu: failed to get ib (%ld).\n" , r); goto err1;
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +1 -1
@@ -883,7 +883,7 @@ static int gfx_v8_0_ring_test_ib(struct amdgpu_ring *ring, long timeout) gpu_addr = adev->wb.gpu_addr + (index *4 ); adev->wb.wb[index] =cpu_to_le32 (0xCAFEDEAD );memset (&ib,0 ,sizeof (ib)); - r =amdgpu_ib_get (adev,NULL ,16 , + r =amdgpu_ib_get (adev,NULL ,20 ,AMDGPU_IB_POOL_DIRECT , &ib);if (r) goto err1;
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -1
@@ -1039,7 +1039,7 @@ static int gfx_v9_0_ring_test_ib(struct amdgpu_ring *ring, long timeout) gpu_addr = adev->wb.gpu_addr + (index *4 ); adev->wb.wb[index] =cpu_to_le32 (0xCAFEDEAD );memset (&ib,0 ,sizeof (ib)); - r =amdgpu_ib_get (adev,NULL ,16 , + r =amdgpu_ib_get (adev,NULL ,20 ,AMDGPU_IB_POOL_DIRECT , &ib);if (r) goto err1;
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +1 -1
@@ -297,7 +297,7 @@ static int gfx_v9_4_3_ring_test_ib(struct amdgpu_ring *ring, long timeout) gpu_addr = adev->wb.gpu_addr + (index *4 ); adev->wb.wb[index] =cpu_to_le32 (0xCAFEDEAD );memset (&ib,0 ,sizeof (ib)); - r =amdgpu_ib_get (adev,NULL ,16 , + r =amdgpu_ib_get (adev,NULL ,20 ,AMDGPU_IB_POOL_DIRECT , &ib);if (r) goto err1;
Signature · 1 line
2.39.2
[AMD Official Use Only - General]
-----Original Message-----
From: Huang, Tim <[email protected]>
Sent: Tuesday, November 21, 2023 2:26 PM
To: [email protected]
Cc: Deucher, Alexander <[email protected]>; Zhang, Yifan <[email protected]>; Huang, Tim <[email protected]>
Subject: [PATCH] drm/amdgpu: fix memory overflow in the IB test
Fix a memory overflow issue in the gfx IB test for some ASICs. At least 20 bytes are needed for the IB test packet.
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1 -1
@@ -419,7 +419,7 @@ static int gfx_v11_0_ring_test_ib(struct amdgpu_ring *ring, long timeout) adev->wb.wb[index] =cpu_to_le32 (0xCAFEDEAD ); cpu_ptr = &adev->wb.wb[index]; - r =amdgpu_ib_get (adev,NULL ,16 ,AMDGPU_IB_POOL_DIRECT , &ib); + r =amdgpu_ib_get (adev,NULL ,20 ,AMDGPU_IB_POOL_DIRECT , &ib);if (r) {DRM_ERROR ("amdgpu: failed to get ib (%ld).\n" , r); goto err1;
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +1 -1
@@ -883,7 +883,7 @@ static int gfx_v8_0_ring_test_ib(struct amdgpu_ring *ring, long timeout) gpu_addr = adev->wb.gpu_addr + (index *4 ); adev->wb.wb[index] =cpu_to_le32 (0xCAFEDEAD );memset (&ib,0 ,sizeof (ib)); - r =amdgpu_ib_get (adev,NULL ,16 , + r =amdgpu_ib_get (adev,NULL ,20 ,AMDGPU_IB_POOL_DIRECT , &ib);if (r) goto err1;
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -1
@@ -1039,7 +1039,7 @@ static int gfx_v9_0_ring_test_ib(struct amdgpu_ring *ring, long timeout) gpu_addr = adev->wb.gpu_addr + (index *4 ); adev->wb.wb[index] =cpu_to_le32 (0xCAFEDEAD );memset (&ib,0 ,sizeof (ib)); - r =amdgpu_ib_get (adev,NULL ,16 , + r =amdgpu_ib_get (adev,NULL ,20 ,AMDGPU_IB_POOL_DIRECT , &ib);if (r) goto err1;
drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +1 -1
@@ -297,7 +297,7 @@ static int gfx_v9_4_3_ring_test_ib(struct amdgpu_ring *ring, long timeout) gpu_addr = adev->wb.gpu_addr + (index *4 ); adev->wb.wb[index] =cpu_to_le32 (0xCAFEDEAD );memset (&ib,0 ,sizeof (ib)); - r =amdgpu_ib_get (adev,NULL ,16 , + r =amdgpu_ib_get (adev,NULL ,20 ,AMDGPU_IB_POOL_DIRECT , &ib);if (r) goto err1;
--
2.39.2
Am 21.11.23 um 07:25 schrieb Tim Huang:
Quoted 5 lines
Fix a memory overflow issue in the gfx IB test
for some ASICs. At least 20 bytes are needed for
the IB test packet.Signed-off-by Tim Huang <[email protected]>
Good catch.
Quoted 25 lines
--- drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 +- drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)drivers/gpu/drm/amd/amdgpu/gfx_v11_0.c +1
-1@@ -419,7 +419,7 @@ static int gfx_v11_0_ring_test_ib(struct amdgpu_ring *ring, long timeout) adev->wb.wb[index] =cpu_to_le32 (0xCAFEDEAD ); cpu_ptr = &adev->wb.wb[index]; - r =amdgpu_ib_get (adev,NULL ,16 ,AMDGPU_IB_POOL_DIRECT , &ib); + r =amdgpu_ib_get (adev,NULL ,20 ,AMDGPU_IB_POOL_DIRECT , &ib);if (r) {DRM_ERROR ("amdgpu: failed to get ib (%ld).\n" , r); goto err1;drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c static int gfx_v8_0_ring_test_ib(struct amdgpu_ring *ring, long timeout) · line 887
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +1
-1@@ -883,7 +883,7 @@ static int gfx_v8_0_ring_test_ib(struct amdgpu_ring *ring, long timeout) gpu_addr = adev->wb.gpu_addr + (index *4 ); adev->wb.wb[index] =cpu_to_le32 (0xCAFEDEAD );memset (&ib,0 ,sizeof (ib)); - r =amdgpu_ib_get (adev,NULL ,16 , + r =amdgpu_ib_get (adev,NULL ,20 ,AMDGPU_IB_POOL_DIRECT , &ib);
Not the fault of your patch, but the indentation here and below seems to be wrong, please check your patch with checkpatch.pl.
When you don't get a warning feel free to add Reviewed-by: Christian König <[email protected]>.
Regards,
Christian.
Quoted 28 lines
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c +0
-0if (r) goto err1;drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1
-1@@ -1039,7 +1039,7 @@ static int gfx_v9_0_ring_test_ib(struct amdgpu_ring *ring, long timeout) gpu_addr = adev->wb.gpu_addr + (index *4 ); adev->wb.wb[index] =cpu_to_le32 (0xCAFEDEAD );memset (&ib,0 ,sizeof (ib)); - r =amdgpu_ib_get (adev,NULL ,16 , + r =amdgpu_ib_get (adev,NULL ,20 ,AMDGPU_IB_POOL_DIRECT , &ib);if (r) goto err1;drivers/gpu/drm/amd/amdgpu/gfx_v9_4_3.c +1
-1@@ -297,7 +297,7 @@ static int gfx_v9_4_3_ring_test_ib(struct amdgpu_ring *ring, long timeout) gpu_addr = adev->wb.gpu_addr + (index *4 ); adev->wb.wb[index] =cpu_to_le32 (0xCAFEDEAD );memset (&ib,0 ,sizeof (ib)); - r =amdgpu_ib_get (adev,NULL ,16 , + r =amdgpu_ib_get (adev,NULL ,20 ,AMDGPU_IB_POOL_DIRECT , &ib);if (r) goto err1;