drm/amdkfd: dqm fence memory corruption
Subsystems (3)
PATCH 1/1 drm/amdkfd: dqm fence memory corruption
Amdgpu driver uses 4-byte data type as DQM fence memory, and transmits GPU address of fence memory to microcode through query status PM4 message. However, query status PM4 message definition and microcode processing are all processed according to 8 bytes. Fence memory only allocates 4 bytes of memory, but microcode does write 8 bytes of memory, so there is a memory corruption.
--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1 -1
@@ -1161,7 +1161,7 @@ static int start_cpsch(struct device_queue_manager *dqm)pr_debug ("Allocating fence memory\n" );/* allocate fence memory on the gart */ - retval =kfd_gtt_sa_allocate (dqm->dev,sizeof (*dqm->fence_addr), + retval =kfd_gtt_sa_allocate (dqm->dev,sizeof (uint64_t ), &dqm->fence_mem);if (retval)
Signature · 1 line
1.8.3.1
Felix Kuehling
maintainerAm 2021-01-27 um 7:33 a.m. schrieb Qu Huang:
Quoted 7 lines
Amdgpu driver uses 4-byte data type as DQM fence memory, and transmits GPU address of fence memory to microcode through query status PM4 message. However, query status PM4 message definition and microcode processing are all processed according to 8 bytes. Fence memory only allocates 4 bytes of memory, but microcode does write 8 bytes of memory, so there is a memory corruption.
Thank you for pointing out that discrepancy. That's a good catch!
I'd prefer to fix this properly by making dqm->fence_addr a u64 pointer. We should probably also fix up the query_status and amdkfd_fence_wait_timeout function interfaces to use a 64 bit fence values everywhere to be consistent.
Regards,
Felix
Quoted 11 lines
Signed-off-by Qu Huang <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static int start_cpsch(struct device_queue_manager *dqm) · line 1167
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1
-1@@ -1161,7 +1161,7 @@ static int start_cpsch(struct device_queue_manager *dqm)pr_debug ("Allocating fence memory\n" );/* allocate fence memory on the gart */ - retval =kfd_gtt_sa_allocate (dqm->dev,sizeof (*dqm->fence_addr), + retval =kfd_gtt_sa_allocate (dqm->dev,sizeof (uint64_t ), &dqm->fence_mem);if (retval)
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Quoted 11 lines · Felix Kuehling
Am 2021-01-27 um 7:33 a.m. schrieb Qu Huang:
Quoted 7 lines
Amdgpu driver uses 4-byte data type as DQM fence memory, and transmits GPU address of fence memory to microcode through query status PM4 message. However, query status PM4 message definition and microcode processing are all processed according to 8 bytes. Fence memory only allocates 4 bytes of memory, but microcode does write 8 bytes of memory, so there is a memory corruption.
Thank you for pointing out that discrepancy. That's a good catch!
Quoted 7 lines
I'd prefer to fix this properly by making
dqm->fence_addra u64 pointer. We should probably also fix up thequery_statusandamdkfd_fence_wait_timeoutfunction interfaces to use a 64 bit fence values everywhere to be consistent.Regards,
Felix
Hi Felix, Thanks for your advice, please check v2 at https://lore.kernel.org/patchwork/patch/1372584/
Thanks,
Qu.
Quoted 15 lines
Quoted 15 lines
Signed-off-by Qu Huang <[email protected]>--- drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0@@ -1161,7 +1161,7 @@ static int start_cpsch(struct device_queue_manager *dqm)pr_debug ("Allocating fence memory\n" );
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static int start_cpsch(struct device_queue_manager *dqm) · line 1167
Quoted 6 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1
-1/* allocate fence memory on the gart */ - retval =kfd_gtt_sa_allocate (dqm->dev,sizeof (*dqm->fence_addr), + retval =kfd_gtt_sa_allocate (dqm->dev,sizeof (uint64_t ), &dqm->fence_mem);if (retval)
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Felix Kuehling
maintainerAm 2021-03-26 um 5:38 a.m. schrieb Qu Huang:
Quoted 17 lines · Felix Kuehling
Quoted 16 lines
Am 2021-01-27 um 7:33 a.m. schrieb Qu Huang:
Quoted 7 lines
Amdgpu driver uses 4-byte data type as DQM fence memory, and transmits GPU address of fence memory to microcode through query status PM4 message. However, query status PM4 message definition and microcode processing are all processed according to 8 bytes. Fence memory only allocates 4 bytes of memory, but microcode does write 8 bytes of memory, so there is a memory corruption.
Thank you for pointing out that discrepancy. That's a good catch!
I'd prefer to fix this properly by making
dqm->fence_addra u64 pointer. We should probably also fix up thequery_statusandamdkfd_fence_wait_timeoutfunction interfaces to use a 64 bit fence values everywhere to be consistent.
Quoted 4 lines
Quoted 2 lines
Regards,
FelixHi Felix, Thanks for your advice, please check v2 at
https://lore.kernel.org/patchwork/patch/1372584/
Thank you for the reminder. I somehow missed your v2 patch on the mailing list. I have reviewed and applied it to amd-staging-drm-next now.
Regards,
Felix
Quoted 10 lines
Thanks,
Qu.Quoted 8 lines
Quoted 8 lines
Signed-off-by Qu Huang <[email protected]>---
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines
Quoted 5 lines
Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +0
-0Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c static int start_cpsch(struct · line 1166
Quoted 8 lines
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c +1
-1@@ -1161,7 +1161,7 @@ static int start_cpsch(struct device_queue_manager *dqm) pr_debug("Allocating fence memory\n"); /* allocate fence memory on the gart */ - retval = kfd_gtt_sa_allocate(dqm->dev, sizeof(*dqm->fence_addr), + retval = kfd_gtt_sa_allocate(dqm->dev, sizeof(uint64_t), &dqm->fence_mem); if (retval)
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel