Skip to contentSkip to conversation

drm/amdgpu: fix NULL pointer dereference when run App with DRI_PRIME=1

PATCH NAK Junwei Zhang 3 participants 9 messages May 25, 2018 – May 28, 2018 8 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: fix NULL pointer dereference when run App with DRI_PRIME=1

[  632.679861] BUG: unable to handle kernel NULL pointer dereference at (null)
[  632.679892] IP: drm_prime_sg_to_page_addr_arrays+0x52/0xb0 [drm]
<snip>
[  632.680011] Call Trace:
[  632.680082]  amdgpu_ttm_tt_populate+0x3e/0xa0 [amdgpu]
[  632.680092]  ttm_tt_populate.part.7+0x22/0x60 [amdttm]
[  632.680098]  amdttm_tt_bind+0x52/0x60 [amdttm]
[  632.680106]  ttm_bo_handle_move_mem+0x54b/0x5c0 [amdttm]
[  632.680112]  ? find_next_bit+0xb/0x10
[  632.680119]  amdttm_bo_validate+0x11d/0x130 [amdttm]
[  632.680176]  amdgpu_cs_bo_validate+0x9d/0x150 [amdgpu]
[  632.680232]  amdgpu_cs_validate+0x41/0x270 [amdgpu]
[  632.680288]  amdgpu_cs_list_validate+0xc7/0x1a0 [amdgpu]
[  632.680343]  amdgpu_cs_ioctl+0x1634/0x1c00 [amdgpu]
[  632.680401]  ? amdgpu_cs_find_mapping+0x120/0x120 [amdgpu]
[  632.680416]  drm_ioctl_kernel+0x6b/0xb0 [drm]
[  632.680431]  drm_ioctl+0x3e4/0x450 [drm]
[  632.680485]  ? amdgpu_cs_find_mapping+0x120/0x120 [amdgpu]
[  632.680537]  amdgpu_drm_ioctl+0x4c/0x80 [amdgpu]
[  632.680542]  do_vfs_ioctl+0xa4/0x600
[  632.680546]  ? SyS_futex+0x7f/0x180
[  632.680549]  SyS_ioctl+0x79/0x90
[  632.680554]  entry_SYSCALL_64_fastpath+0x24/0xab
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
index 57d4da6..b293809 100644
@@ -1212,7 +1212,7 @@ static struct ttm_tt *amdgpu_ttm_tt_create(struct ttm_buffer_object *bo,
 	gtt->ttm.ttm.func = &amdgpu_backend_func;
 
 	/* allocate space for the uninitialized page entries */
-	if (ttm_sg_tt_init(&gtt->ttm, bo, page_flags)) {
+	if (ttm_dma_tt_init(&gtt->ttm, bo, page_flags)) {
 		kfree(gtt);
 		return NULL;
 	}
Signature · 6 lines
1.9.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 1527226896-29270-1-git-send-email-Jerry.Zhang-5C7GfCeVMHo@public.gmane.org

#2 lore raw

NAK, that probably just fixed the symptom but not the underlying problem.

Somebody is accessing the page array when it should never be accessed.

How did you manage to trigger this?

Regards,
Christian.

Am 25.05.2018 um 07:41 schrieb Junwei Zhang:

Quoted 34 lines
[  632.679861] BUG: unable to handle kernel NULL pointer dereference at (null)
[  632.679892] IP: drm_prime_sg_to_page_addr_arrays+0x52/0xb0 [drm]
<snip>
[  632.680011] Call Trace:
[  632.680082]  amdgpu_ttm_tt_populate+0x3e/0xa0 [amdgpu]
[  632.680092]  ttm_tt_populate.part.7+0x22/0x60 [amdttm]
[  632.680098]  amdttm_tt_bind+0x52/0x60 [amdttm]
[  632.680106]  ttm_bo_handle_move_mem+0x54b/0x5c0 [amdttm]
[  632.680112]  ? find_next_bit+0xb/0x10
[  632.680119]  amdttm_bo_validate+0x11d/0x130 [amdttm]
[  632.680176]  amdgpu_cs_bo_validate+0x9d/0x150 [amdgpu]
[  632.680232]  amdgpu_cs_validate+0x41/0x270 [amdgpu]
[  632.680288]  amdgpu_cs_list_validate+0xc7/0x1a0 [amdgpu]
[  632.680343]  amdgpu_cs_ioctl+0x1634/0x1c00 [amdgpu]
[  632.680401]  ? amdgpu_cs_find_mapping+0x120/0x120 [amdgpu]
[  632.680416]  drm_ioctl_kernel+0x6b/0xb0 [drm]
[  632.680431]  drm_ioctl+0x3e4/0x450 [drm]
[  632.680485]  ? amdgpu_cs_find_mapping+0x120/0x120 [amdgpu]
[  632.680537]  amdgpu_drm_ioctl+0x4c/0x80 [amdgpu]
[  632.680542]  do_vfs_ioctl+0xa4/0x600
[  632.680546]  ? SyS_futex+0x7f/0x180
[  632.680549]  SyS_ioctl+0x79/0x90
[  632.680554]  entry_SYSCALL_64_fastpath+0x24/0xab
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
index 57d4da6..b293809 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static struct ttm_tt *amdgpu_ttm_tt_create(struct ttm_buffer_object *bo, · line 1218

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
@@ -1212,7 +1212,7 @@ static struct ttm_tt *amdgpu_ttm_tt_create(struct ttm_buffer_object *bo,
  	gtt->ttm.ttm.func = &amdgpu_backend_func;
 
  	/* allocate space for the uninitialized page entries */
-	if (ttm_sg_tt_init(&gtt->ttm, bo, page_flags)) {
+	if (ttm_dma_tt_init(&gtt->ttm, bo, page_flags)) {
  		kfree(gtt);
  		return NULL;
  	}

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): f9495673-cb9a-cd75-a569-c4eb5b2e0c63-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#4 lore raw
Quoted 3 lines · Christian König

NAK, that probably just fixed the symptom but not the underlying problem.

Somebody is accessing the page array when it should never be accessed.

If prime import as GTT bo by default(now it's CPU bo), it would happens quickly when GTT sg bo creation rather than next cs validation.

Since ttm_sg_tt_init() only allocates gtt->ttm.dma_address if sg bo is created, it would fail to access ttm->pages when ttm populate.

current error happens in ttm populate from cs validation, the sg bo is imported from exporter.

Quoted 2 lines

How did you manage to trigger this?

PRI_PRIME=1 with Unigine heaven.

Regards,
Jerry

Quoted 34 lines

Regards,
Christian.

Am 25.05.2018 um 07:41 schrieb Junwei Zhang:

Quoted 29 lines
[  632.679861] BUG: unable to handle kernel NULL pointer dereference at (null)
[  632.679892] IP: drm_prime_sg_to_page_addr_arrays+0x52/0xb0 [drm]
<snip>
[  632.680011] Call Trace:
[  632.680082]  amdgpu_ttm_tt_populate+0x3e/0xa0 [amdgpu]
[  632.680092]  ttm_tt_populate.part.7+0x22/0x60 [amdttm]
[  632.680098]  amdttm_tt_bind+0x52/0x60 [amdttm]
[  632.680106]  ttm_bo_handle_move_mem+0x54b/0x5c0 [amdttm]
[  632.680112]  ? find_next_bit+0xb/0x10
[  632.680119]  amdttm_bo_validate+0x11d/0x130 [amdttm]
[  632.680176]  amdgpu_cs_bo_validate+0x9d/0x150 [amdgpu]
[  632.680232]  amdgpu_cs_validate+0x41/0x270 [amdgpu]
[  632.680288]  amdgpu_cs_list_validate+0xc7/0x1a0 [amdgpu]
[  632.680343]  amdgpu_cs_ioctl+0x1634/0x1c00 [amdgpu]
[  632.680401]  ? amdgpu_cs_find_mapping+0x120/0x120 [amdgpu]
[  632.680416]  drm_ioctl_kernel+0x6b/0xb0 [drm]
[  632.680431]  drm_ioctl+0x3e4/0x450 [drm]
[  632.680485]  ? amdgpu_cs_find_mapping+0x120/0x120 [amdgpu]
[  632.680537]  amdgpu_drm_ioctl+0x4c/0x80 [amdgpu]
[  632.680542]  do_vfs_ioctl+0xa4/0x600
[  632.680546]  ? SyS_futex+0x7f/0x180
[  632.680549]  SyS_ioctl+0x79/0x90
[  632.680554]  entry_SYSCALL_64_fastpath+0x24/0xab
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines
Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +0 -0
index 57d4da6..b293809 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c static struct ttm_tt *amdgpu_ttm_tt_create(struct · line 1218

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
@@ -1212,7 +1212,7 @@ static struct ttm_tt *amdgpu_ttm_tt_create(struct
 ttm_buffer_object *bo,
      gtt->ttm.ttm.func = &amdgpu_backend_func;
      /* allocate space for the uninitialized page entries */
-    if (ttm_sg_tt_init(&gtt->ttm, bo, page_flags)) {
+    if (ttm_dma_tt_init(&gtt->ttm, bo, page_flags)) {
          kfree(gtt);
          return NULL;
      }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#6 lore raw

Am 25.05.2018 um 09:20 schrieb Zhang, Jerry (Junwei):

Quoted 8 lines · Christian König
Quoted 3 lines

NAK, that probably just fixed the symptom but not the underlying problem.

Somebody is accessing the page array when it should never be accessed.

If prime import as GTT bo by default(now it's CPU bo), it would happens quickly when GTT sg bo creation rather than next cs validation.

Since ttm_sg_tt_init() only allocates gtt->ttm.dma_address if sg bo is created, it would fail to access ttm->pages when ttm populate.

And exactly that's the problem, and imported BO should never populate.

Quoted 7 lines

current error happens in ttm populate from cs validation, the sg bo is imported from exporter.

Quoted 2 lines

How did you manage to trigger this?

PRI_PRIME=1 with Unigine heaven.

Going to give that a try, but the last time I check that worked as expected.

Thanks,
Christian.

Quoted 53 lines

Regards,
Jerry

Quoted 49 lines

Regards,
Christian.

Am 25.05.2018 um 07:41 schrieb Junwei Zhang:

Quoted 43 lines

[  632.679861] BUG: unable to handle kernel NULL pointer dereference at (null) [  632.679892] IP: drm_prime_sg_to_page_addr_arrays+0x52/0xb0 [drm] <snip>
[  632.680011] Call Trace:
[  632.680082]  amdgpu_ttm_tt_populate+0x3e/0xa0 [amdgpu]
[  632.680092]  ttm_tt_populate.part.7+0x22/0x60 [amdttm]
[  632.680098]  amdttm_tt_bind+0x52/0x60 [amdttm]
[  632.680106]  ttm_bo_handle_move_mem+0x54b/0x5c0 [amdttm]
[  632.680112]  ? find_next_bit+0xb/0x10
[  632.680119]  amdttm_bo_validate+0x11d/0x130 [amdttm]
[  632.680176]  amdgpu_cs_bo_validate+0x9d/0x150 [amdgpu]
[  632.680232]  amdgpu_cs_validate+0x41/0x270 [amdgpu]
[  632.680288]  amdgpu_cs_list_validate+0xc7/0x1a0 [amdgpu]
[  632.680343]  amdgpu_cs_ioctl+0x1634/0x1c00 [amdgpu]
[  632.680401]  ? amdgpu_cs_find_mapping+0x120/0x120 [amdgpu]
[  632.680416]  drm_ioctl_kernel+0x6b/0xb0 [drm]
[  632.680431]  drm_ioctl+0x3e4/0x450 [drm]
[  632.680485]  ? amdgpu_cs_find_mapping+0x120/0x120 [amdgpu]
[  632.680537]  amdgpu_drm_ioctl+0x4c/0x80 [amdgpu]
[  632.680542]  do_vfs_ioctl+0xa4/0x600
[  632.680546]  ? SyS_futex+0x7f/0x180
[  632.680549]  SyS_ioctl+0x79/0x90
[  632.680554]  entry_SYSCALL_64_fastpath+0x24/0xab

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
index 57d4da6..b293809 100644
@@ -1212,7 +1212,7 @@ static struct ttm_tt *amdgpu_ttm_tt_create(struct
 ttm_buffer_object *bo,
       gtt->ttm.ttm.func = &amdgpu_backend_func;
       /* allocate space for the uninitialized page entries */
-    if (ttm_sg_tt_init(&gtt->ttm, bo, page_flags)) {
+    if (ttm_dma_tt_init(&gtt->ttm, bo, page_flags)) {
           kfree(gtt);
           return NULL;
       }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 2a876b66-abaa-5ca0-5975-2b458ab9dba5-5C7GfCeVMHo@public.gmane.org

#8 lore raw
Quoted 19 lines · Christian König

Am 25.05.2018 um 09:20 schrieb Zhang, Jerry (Junwei):

Quoted 10 lines · Christian König
Quoted 3 lines

NAK, that probably just fixed the symptom but not the underlying problem.

Somebody is accessing the page array when it should never be accessed.

If prime import as GTT bo by default(now it's CPU bo), it would happens quickly when GTT sg bo creation rather than next cs validation.

Since ttm_sg_tt_init() only allocates gtt->ttm.dma_address if sg bo is created, it would fail to access ttm->pages when ttm populate.

And exactly that's the problem, and imported BO should never populate.

Quoted 5 lines

current error happens in ttm populate from cs validation, the sg bo is imported from exporter.

Quoted 1 line
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

How did you manage to trigger this?

PRI_PRIME=1 with Unigine heaven.

Going to give that a try, but the last time I check that worked as expected.

FYI.
PRI_PRIME=1 glxinfo will not trigger that, but the game does.

Jerry

Quoted 58 lines

Thanks,
Christian.

Quoted 53 lines

Regards,
Jerry

Quoted 49 lines

Regards,
Christian.

Am 25.05.2018 um 07:41 schrieb Junwei Zhang:

Quoted 43 lines
[  632.679861] BUG: unable to handle kernel NULL pointer dereference at (null)
[  632.679892] IP: drm_prime_sg_to_page_addr_arrays+0x52/0xb0 [drm]
<snip>
[  632.680011] Call Trace:
[  632.680082]  amdgpu_ttm_tt_populate+0x3e/0xa0 [amdgpu]
[  632.680092]  ttm_tt_populate.part.7+0x22/0x60 [amdttm]
[  632.680098]  amdttm_tt_bind+0x52/0x60 [amdttm]
[  632.680106]  ttm_bo_handle_move_mem+0x54b/0x5c0 [amdttm]
[  632.680112]  ? find_next_bit+0xb/0x10
[  632.680119]  amdttm_bo_validate+0x11d/0x130 [amdttm]
[  632.680176]  amdgpu_cs_bo_validate+0x9d/0x150 [amdgpu]
[  632.680232]  amdgpu_cs_validate+0x41/0x270 [amdgpu]
[  632.680288]  amdgpu_cs_list_validate+0xc7/0x1a0 [amdgpu]
[  632.680343]  amdgpu_cs_ioctl+0x1634/0x1c00 [amdgpu]
[  632.680401]  ? amdgpu_cs_find_mapping+0x120/0x120 [amdgpu]
[  632.680416]  drm_ioctl_kernel+0x6b/0xb0 [drm]
[  632.680431]  drm_ioctl+0x3e4/0x450 [drm]
[  632.680485]  ? amdgpu_cs_find_mapping+0x120/0x120 [amdgpu]
[  632.680537]  amdgpu_drm_ioctl+0x4c/0x80 [amdgpu]
[  632.680542]  do_vfs_ioctl+0xa4/0x600
[  632.680546]  ? SyS_futex+0x7f/0x180
[  632.680549]  SyS_ioctl+0x79/0x90
[  632.680554]  entry_SYSCALL_64_fastpath+0x24/0xab
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
index 57d4da6..b293809 100644
@@ -1212,7 +1212,7 @@ static struct ttm_tt *amdgpu_ttm_tt_create(struct
 ttm_buffer_object *bo,
      gtt->ttm.ttm.func = &amdgpu_backend_func;
      /* allocate space for the uninitialized page entries */
-    if (ttm_sg_tt_init(&gtt->ttm, bo, page_flags)) {
+    if (ttm_dma_tt_init(&gtt->ttm, bo, page_flags)) {
          kfree(gtt);
          return NULL;
      }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#10 lore raw

Am 25.05.2018 um 10:23 schrieb Zhang, Jerry (Junwei):

Quoted 20 lines · Christian König
Quoted 19 lines

Am 25.05.2018 um 09:20 schrieb Zhang, Jerry (Junwei):

Quoted 10 lines · Christian König
Quoted 3 lines

NAK, that probably just fixed the symptom but not the underlying problem.

Somebody is accessing the page array when it should never be accessed.

If prime import as GTT bo by default(now it's CPU bo), it would happens quickly when GTT sg bo creation rather than next cs validation.

Since ttm_sg_tt_init() only allocates gtt->ttm.dma_address if sg bo is created, it would fail to access ttm->pages when ttm populate.

And exactly that's the problem, and imported BO should never populate.

Quoted 5 lines

current error happens in ttm populate from cs validation, the sg bo is imported from exporter.

Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

How did you manage to trigger this?

PRI_PRIME=1 with Unigine heaven.

Going to give that a try, but the last time I check that worked as expected.

FYI.
PRI_PRIME=1 glxinfo will not trigger that, but the game does.

Just tested and it works perfectly fine.

Is that on the closed stack or the open stack?

Christian.

Quoted 62 lines

Jerry

Quoted 59 lines

Thanks,
Christian.

Quoted 54 lines

Regards,
Jerry

Quoted 50 lines

Regards,
Christian.

Am 25.05.2018 um 07:41 schrieb Junwei Zhang:

Quoted 44 lines

[  632.679861] BUG: unable to handle kernel NULL pointer dereference at (null) [  632.679892] IP: drm_prime_sg_to_page_addr_arrays+0x52/0xb0 [drm] <snip>
[  632.680011] Call Trace:
[  632.680082]  amdgpu_ttm_tt_populate+0x3e/0xa0 [amdgpu]
[  632.680092]  ttm_tt_populate.part.7+0x22/0x60 [amdttm]
[  632.680098]  amdttm_tt_bind+0x52/0x60 [amdttm]
[  632.680106]  ttm_bo_handle_move_mem+0x54b/0x5c0 [amdttm]
[  632.680112]  ? find_next_bit+0xb/0x10
[  632.680119]  amdttm_bo_validate+0x11d/0x130 [amdttm]
[  632.680176]  amdgpu_cs_bo_validate+0x9d/0x150 [amdgpu]
[  632.680232]  amdgpu_cs_validate+0x41/0x270 [amdgpu]
[  632.680288]  amdgpu_cs_list_validate+0xc7/0x1a0 [amdgpu]
[  632.680343]  amdgpu_cs_ioctl+0x1634/0x1c00 [amdgpu]
[  632.680401]  ? amdgpu_cs_find_mapping+0x120/0x120 [amdgpu]
[  632.680416]  drm_ioctl_kernel+0x6b/0xb0 [drm]
[  632.680431]  drm_ioctl+0x3e4/0x450 [drm]
[  632.680485]  ? amdgpu_cs_find_mapping+0x120/0x120 [amdgpu]
[  632.680537]  amdgpu_drm_ioctl+0x4c/0x80 [amdgpu]
[  632.680542]  do_vfs_ioctl+0xa4/0x600
[  632.680546]  ? SyS_futex+0x7f/0x180
[  632.680549]  SyS_ioctl+0x79/0x90
[  632.680554]  entry_SYSCALL_64_fastpath+0x24/0xab

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
index 57d4da6..b293809 100644
@@ -1212,7 +1212,7 @@ static struct ttm_tt 
 *amdgpu_ttm_tt_create(struct
 ttm_buffer_object *bo,
       gtt->ttm.ttm.func = &amdgpu_backend_func;
       /* allocate space for the uninitialized page entries */
-    if (ttm_sg_tt_init(&gtt->ttm, bo, page_flags)) {
+    if (ttm_dma_tt_init(&gtt->ttm, bo, page_flags)) {
           kfree(gtt);
           return NULL;

      }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 98ef8cf3-31bf-229b-fee2-88f426e3a91f-5C7GfCeVMHo@public.gmane.org

#12 lore raw
Quoted 25 lines · Christian König

Am 25.05.2018 um 10:23 schrieb Zhang, Jerry (Junwei):

Quoted 24 lines · Christian König
Quoted 23 lines

Am 25.05.2018 um 09:20 schrieb Zhang, Jerry (Junwei):

Quoted 10 lines · Christian König
Quoted 3 lines

NAK, that probably just fixed the symptom but not the underlying problem.

Somebody is accessing the page array when it should never be accessed.

If prime import as GTT bo by default(now it's CPU bo), it would happens quickly when GTT sg bo creation rather than next cs validation.

Since ttm_sg_tt_init() only allocates gtt->ttm.dma_address if sg bo is created, it would fail to access ttm->pages when ttm populate.

And exactly that's the problem, and imported BO should never populate.

Quoted 8 lines

current error happens in ttm populate from cs validation, the sg bo is imported from exporter.

Quoted 2 lines

How did you manage to trigger this?

PRI_PRIME=1 with Unigine heaven.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Going to give that a try, but the last time I check that worked as expected.

FYI.
PRI_PRIME=1 glxinfo will not trigger that, but the game does.

Just tested and it works perfectly fine.

Is that on the closed stack or the open stack?

I used unified driver(latest 18.20 build) + drm-next kernel, installed as all open stack on A+A platform. (issue was found by 18.20 build, all open stack(dkms driver))

BTW, How did you get the UMD? apt-get or build by yourself?

Jerry

Quoted 66 lines

Christian.

Quoted 62 lines

Jerry

Quoted 59 lines

Thanks,
Christian.

Quoted 54 lines

Regards,
Jerry

Quoted 50 lines

Regards,
Christian.

Am 25.05.2018 um 07:41 schrieb Junwei Zhang:

Quoted 44 lines
[  632.679861] BUG: unable to handle kernel NULL pointer dereference at
(null)
[  632.679892] IP: drm_prime_sg_to_page_addr_arrays+0x52/0xb0 [drm]
<snip>
[  632.680011] Call Trace:
[  632.680082]  amdgpu_ttm_tt_populate+0x3e/0xa0 [amdgpu]
[  632.680092]  ttm_tt_populate.part.7+0x22/0x60 [amdttm]
[  632.680098]  amdttm_tt_bind+0x52/0x60 [amdttm]
[  632.680106]  ttm_bo_handle_move_mem+0x54b/0x5c0 [amdttm]
[  632.680112]  ? find_next_bit+0xb/0x10
[  632.680119]  amdttm_bo_validate+0x11d/0x130 [amdttm]
[  632.680176]  amdgpu_cs_bo_validate+0x9d/0x150 [amdgpu]
[  632.680232]  amdgpu_cs_validate+0x41/0x270 [amdgpu]
[  632.680288]  amdgpu_cs_list_validate+0xc7/0x1a0 [amdgpu]
[  632.680343]  amdgpu_cs_ioctl+0x1634/0x1c00 [amdgpu]
[  632.680401]  ? amdgpu_cs_find_mapping+0x120/0x120 [amdgpu]
[  632.680416]  drm_ioctl_kernel+0x6b/0xb0 [drm]
[  632.680431]  drm_ioctl+0x3e4/0x450 [drm]
[  632.680485]  ? amdgpu_cs_find_mapping+0x120/0x120 [amdgpu]
[  632.680537]  amdgpu_drm_ioctl+0x4c/0x80 [amdgpu]
[  632.680542]  do_vfs_ioctl+0xa4/0x600
[  632.680546]  ? SyS_futex+0x7f/0x180
[  632.680549]  SyS_ioctl+0x79/0x90
[  632.680554]  entry_SYSCALL_64_fastpath+0x24/0xab
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +1 -1
index 57d4da6..b293809 100644
@@ -1212,7 +1212,7 @@ static struct ttm_tt *amdgpu_ttm_tt_create(struct
 ttm_buffer_object *bo,
      gtt->ttm.ttm.func = &amdgpu_backend_func;
      /* allocate space for the uninitialized page entries */
-    if (ttm_sg_tt_init(&gtt->ttm, bo, page_flags)) {
+    if (ttm_dma_tt_init(&gtt->ttm, bo, page_flags)) {
          kfree(gtt);
          return NULL;
      }

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): [email protected]

#14 lore raw

Am 25.05.2018 um 11:51 schrieb Zhang, Jerry (Junwei):

Quoted 31 lines · Christian König
Quoted 30 lines

Am 25.05.2018 um 10:23 schrieb Zhang, Jerry (Junwei):

Quoted 28 lines · Christian König
Quoted 19 lines

Am 25.05.2018 um 09:20 schrieb Zhang, Jerry (Junwei):

Quoted 10 lines · Christian König
Quoted 3 lines

NAK, that probably just fixed the symptom but not the underlying problem.

Somebody is accessing the page array when it should never be accessed.

If prime import as GTT bo by default(now it's CPU bo), it would happens quickly when GTT sg bo creation rather than next cs validation.

Since ttm_sg_tt_init() only allocates gtt->ttm.dma_address if sg bo is created, it would fail to access ttm->pages when ttm populate.

And exactly that's the problem, and imported BO should never populate.

Quoted 5 lines

current error happens in ttm populate from cs validation, the sg bo is imported from exporter.

Quoted 1 line
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

How did you manage to trigger this?

PRI_PRIME=1 with Unigine heaven.

Going to give that a try, but the last time I check that worked as expected.

FYI.
PRI_PRIME=1 glxinfo will not trigger that, but the game does.

Quoted 8 lines
Quoted 3 lines

Just tested and it works perfectly fine.

Is that on the closed stack or the open stack?

I used unified driver(latest 18.20 build) + drm-next kernel, installed as all open stack on A+A platform. (issue was found by 18.20 build, all open stack(dkms driver))

BTW, How did you get the UMD? apt-get or build by yourself?

That's self build Mesa+libdrm.

Do you have the apt url and/or package versions at hand you used for the test?

Christian.

Quoted 3 lines

Jerry

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 31572675-9d62-2acf-5cbf-7a389ac87554-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#16 lore raw
Quoted 40 lines · Christian König

Am 25.05.2018 um 11:51 schrieb Zhang, Jerry (Junwei):

Quoted 39 lines · Christian König
Quoted 25 lines

Am 25.05.2018 um 10:23 schrieb Zhang, Jerry (Junwei):

Quoted 24 lines · Christian König
Quoted 23 lines

Am 25.05.2018 um 09:20 schrieb Zhang, Jerry (Junwei):

Quoted 10 lines · Christian König
Quoted 3 lines

NAK, that probably just fixed the symptom but not the underlying problem.

Somebody is accessing the page array when it should never be accessed.

If prime import as GTT bo by default(now it's CPU bo), it would happens quickly when GTT sg bo creation rather than next cs validation.

Since ttm_sg_tt_init() only allocates gtt->ttm.dma_address if sg bo is created, it would fail to access ttm->pages when ttm populate.

And exactly that's the problem, and imported BO should never populate.

Quoted 8 lines

current error happens in ttm populate from cs validation, the sg bo is imported from exporter.

Quoted 2 lines

How did you manage to trigger this?

PRI_PRIME=1 with Unigine heaven.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Going to give that a try, but the last time I check that worked as expected.

FYI.
PRI_PRIME=1 glxinfo will not trigger that, but the game does.

Just tested and it works perfectly fine.

Is that on the closed stack or the open stack?

I used unified driver(latest 18.20 build) + drm-next kernel, installed as all open stack on A+A platform.
(issue was found by 18.20 build, all open stack(dkms driver))

Quoted 5 lines
Quoted 1 line

BTW, How did you get the UMD? apt-get or build by yourself?

That's self build Mesa+libdrm.

Do you have the apt url and/or package versions at hand you used for the test?

I found that the Ubuntu kernel 4.13/4.15 has no below patch:
*
https://cgit.freedesktop.org/~agd5f/linux/commit/?h=amd-staging-drm-next&id=186ca446aea19e49d2e1433dd170c6e1c211a52a

So we could fix that in DKMS support rather than in upstream.

Double confirmed drm-next kernel that has no such issue.
(not sure what's going on last week, I did get the latest code and build the kernel and it failed. Sorry for this inconvenience)

Thanks for your time to check it.

Jerry

Quoted 7 lines

Christian.

Quoted 3 lines

Jerry

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx