ttm->pages NULL dereference with radeon driver
Subsystems (2)
Hi,
we've received a regression report showing NULL dereference Oops with radeon driver on 5.12 kernel:
https://bugzilla.opensuse.org/show_bug.cgi?id=1185516
It turned out that the recent TTM cleanup / refactoring via commit 0575ff3d33cd ("drm/radeon: stop using pages with drm_prime_sg_to_page_addr_arrays v2") is the culprit. On 5.12 kernel, ttm->pages is no longer allocated / set up, while the radeon driver still has a few places assuming the valid ttm->pages, and for the reporter (running the modesettig driver), radeon_gart_bind() hits the problem.
A hackish patch below was confirmed to work, at least, but obviously we need a proper fix.
Could you take a look at it?
thanks,
Takashi
drivers/gpu/drm/radeon/radeon_gart.c +2 -2
@@ -253,7 +253,7 @@ void radeon_gart_unbind(struct radeon_de t = offset /RADEON_GPU_PAGE_SIZE ; p = t / (PAGE_SIZE /RADEON_GPU_PAGE_SIZE );for (i =0 ; i < pages; i++, p++) { -if (rdev->gart.pages[p]) { +if (1 /*rdev->gart.pages[p]*/ ) { rdev->gart.pages[p] =NULL ;for (j =0 ; j < (PAGE_SIZE /RADEON_GPU_PAGE_SIZE ); j++, t++) { rdev->gart.pages_entry[t] = rdev->dummy_page.entry;
@@ -301,7 +301,7 @@ int radeon_gart_bind(struct radeon_devic p = t / (PAGE_SIZE /RADEON_GPU_PAGE_SIZE );for (i =0 ; i < pages; i++, p++) { - rdev->gart.pages[p] = pagelist[i]; +/* rdev->gart.pages[p] = pagelist[i]; */ page_base = dma_addr[i];for (j =0 ; j < (PAGE_SIZE /RADEON_GPU_PAGE_SIZE ); j++, t++) { page_entry =radeon_gart_get_page_entry (page_base, flags);
drivers/gpu/drm/radeon/radeon_ttm.c +2 -0
@@ -360,6 +360,8 @@ static int radeon_ttm_tt_pin_userptr(strif (current->mm != gtt->usermm)return -EPERM ; +if (!ttm->pages) +return -EPERM ;if (gtt->userflags &RADEON_GEM_USERPTR_ANONONLY ) {/* check that we only pin down anonymous memory
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Hi Takashi,
Am 07.05.21 um 17:08 schrieb Takashi Iwai:
Quoted 14 lines
Hi,
we've received a regression report showing NULL dereference Oops with radeon driver on 5.12 kernel:
https://bugzilla.opensuse.org/show_bug.cgi?id=1185516It turned out that the recent TTM cleanup / refactoring via commit
0575ff3d33cd("drm/radeon: stop using pages withdrm_prime_sg_to_page_addr_arraysv2") is the culprit. On 5.12 kernel,ttm->pagesis no longer allocated / set up, while the radeon driver still has a few places assuming the validttm->pages, and for the reporter (running the modesettig driver),radeon_gart_bind()hits the problem.
Quoted 4 lines
A hackish patch below was confirmed to work, at least, but obviously we need a proper fix.
Could you take a look at it?
If that's all then that looks trivial to me.
Going to provide a patch on Monday.
Thanks for the notice,
Christian.
Quoted 37 lines
thanks,
Takashi
drivers/gpu/drm/radeon/radeon_gart.c +2
-2@@ -253,7 +253,7 @@ void radeon_gart_unbind(struct radeon_de t = offset /RADEON_GPU_PAGE_SIZE ; p = t / (PAGE_SIZE /RADEON_GPU_PAGE_SIZE );for (i =0 ; i < pages; i++, p++) { -if (rdev->gart.pages[p]) { +if (1 /*rdev->gart.pages[p]*/ ) { rdev->gart.pages[p] =NULL ;for (j =0 ; j < (PAGE_SIZE /RADEON_GPU_PAGE_SIZE ); j++, t++) { rdev->gart.pages_entry[t] = rdev->dummy_page.entry;@@ -301,7 +301,7 @@ int radeon_gart_bind(struct radeon_devic p = t / (PAGE_SIZE /RADEON_GPU_PAGE_SIZE );for (i =0 ; i < pages; i++, p++) { - rdev->gart.pages[p] = pagelist[i]; +/* rdev->gart.pages[p] = pagelist[i]; */ page_base = dma_addr[i];for (j =0 ; j < (PAGE_SIZE /RADEON_GPU_PAGE_SIZE ); j++, t++) { page_entry =radeon_gart_get_page_entry (page_base, flags);drivers/gpu/drm/radeon/radeon_ttm.c +2
-0@@ -360,6 +360,8 @@ static int radeon_ttm_tt_pin_userptr(strif (current->mm != gtt->usermm)return -EPERM ; +if (!ttm->pages) +return -EPERM ;if (gtt->userflags &RADEON_GEM_USERPTR_ANONONLY ) {/* check that we only pin down anonymous memory
Quoted 4 lines
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Christian König
maintainerHi guys,
adding a few people who ran into the problem as well and opened a kernel bug.
Am 07.05.21 um 17:11 schrieb Christian König:
Quoted 17 lines
Hi Takashi,
Am 07.05.21 um 17:08 schrieb Takashi Iwai:
Quoted 14 lines
Hi,
we've received a regression report showing NULL dereference Oops with radeon driver on 5.12 kernel:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.opensuse.org%2Fshow_bug.cgi%3Fid%3D1185516&data=04%7C01%7Cchristian.koenig%40amd.com%7C64447e9e97604aaf117008d9116a742a%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637559971181187178%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=1LJMLxuuMjkfgnIt%2B5Z5n19ri%2BMTLMQvEEB%2F%2Fd6SVkg%3D&reserved=0It turned out that the recent TTM cleanup / refactoring via commit
0575ff3d33cd("drm/radeon: stop using pages withdrm_prime_sg_to_page_addr_arraysv2") is the culprit. On 5.12 kernel,ttm->pagesis no longer allocated / set up, while the radeon driver still has a few places assuming the validttm->pages, and for the reporter (running the modesettig driver),radeon_gart_bind()hits the problem.
Quoted 8 lines
Quoted 4 lines
A hackish patch below was confirmed to work, at least, but obviously we need a proper fix.
Could you take a look at it?
If that's all then that looks trivial to me.
Going to provide a patch on Monday.
Sorry, was a busy start into the week. I've just send a patch which should address the issue to you and the mailing list.
Please test since I can't reproduce the problem locally.
Thanks,
Christian.
Quoted 35 lines
Thanks for the notice,
Christian.Quoted 31 lines
thanks,
Takashi
drivers/gpu/drm/radeon/radeon_gart.c +2
-2@@ -253,7 +253,7 @@ void radeon_gart_unbind(struct radeon_de t = offset / RADEON_GPU_PAGE_SIZE; p = t / (PAGE_SIZE / RADEON_GPU_PAGE_SIZE); for (i = 0; i < pages; i++, p++) { - if (rdev->gart.pages[p]) { + if (1 /*rdev->gart.pages[p]*/) { rdev->gart.pages[p] = NULL; for (j = 0; j < (PAGE_SIZE / RADEON_GPU_PAGE_SIZE); j++, t++) { rdev->gart.pages_entry[t] = rdev->dummy_page.entry;@@ -301,7 +301,7 @@ int radeon_gart_bind(struct radeon_devic p = t / (PAGE_SIZE / RADEON_GPU_PAGE_SIZE); for (i = 0; i < pages; i++, p++) { - rdev->gart.pages[p] = pagelist[i]; + /* rdev->gart.pages[p] = pagelist[i]; */ page_base = dma_addr[i]; for (j = 0; j < (PAGE_SIZE / RADEON_GPU_PAGE_SIZE); j++, t++) { page_entry = radeon_gart_get_page_entry(page_base, flags);drivers/gpu/drm/radeon/radeon_ttm.c +1
-0@@ -360,6 +360,8 @@ static int radeon_ttm_tt_pin_userptr(str if (current->mm != gtt->usermm) return -EPERM; + if (!ttm->pages)
Quoted 9 lines
Quoted 8 lines
drivers/gpu/drm/radeon/radeon_ttm.c +1
-0+ return -EPERM; if (gtt->userflags & RADEON_GEM_USERPTR_ANONONLY) { /* check that we only pin down anonymous memory_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7Cchristian.koenig%40amd.com%7C64447e9e97604aaf117008d9116a742a%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637559971181187178%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=RdzGp1FLxBKE%2ByPclrUBfQomRU0pQT%2F78Ewcj%2FBZ73g%3D&reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Hi Christian,
I can confirm that the patch provided fixes the issue in kernel version 5.12.2 Thank you.
Quoted 33 lines · Christian König
Hi guys,
adding a few people who ran into the problem as well and opened a kernel bug.
Am 07.05.21 um 17:11 schrieb Christian König:
Quoted 17 lines
Hi Takashi,
Am 07.05.21 um 17:08 schrieb Takashi Iwai:
Quoted 14 lines
Hi,
we've received a regression report showing NULL dereference Oops with radeon driver on 5.12 kernel:
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fbugzilla.opensuse.org%2Fshow_bug.cgi%3Fid%3D1185516&data=04%7C01%7Cchristian.koenig%40amd.com%7C64447e9e97604aaf117008d9116a742a%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637559971181187178%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=1LJMLxuuMjkfgnIt%2B5Z5n19ri%2BMTLMQvEEB%2F%2Fd6SVkg%3D&reserved=0It turned out that the recent TTM cleanup / refactoring via commit
0575ff3d33cd("drm/radeon: stop using pages withdrm_prime_sg_to_page_addr_arraysv2") is the culprit. On 5.12 kernel,ttm->pagesis no longer allocated / set up, while the radeon driver still has a few places assuming the validttm->pages, and for the reporter (running the modesettig driver),radeon_gart_bind()hits the problem.Quoted 8 lines
Quoted 4 lines
A hackish patch below was confirmed to work, at least, but obviously we need a proper fix.
Could you take a look at it?
If that's all then that looks trivial to me.
Going to provide a patch on Monday.
Quoted 54 lines
Sorry, was a busy start into the week. I've just send a patch which should address the issue to you and the mailing list.
Please test since I can't reproduce the problem locally.
Thanks,
Christian.Quoted 46 lines
Thanks for the notice,
Christian.Quoted 41 lines
thanks,
Takashi
drivers/gpu/drm/radeon/radeon_gart.c +1
-1@@ -253,7 +253,7 @@ void radeon_gart_unbind(struct radeon_de t = offset /RADEON_GPU_PAGE_SIZE ; p = t / (PAGE_SIZE /RADEON_GPU_PAGE_SIZE );for (i =0 ; i < pages; i++, p++) { -if (rdev->gart.pages[p]) { +if (1 /*rdev->gart.pages[p]*/ ) { rdev->gart.pages[p] =NULL ;for (j =0 ; j < (PAGE_SIZE /RADEON_GPU_PAGE_SIZE ); j++, t++) {rdev->gart.pages_entry[t] = rdev->dummy_page.entry;drivers/gpu/drm/radeon/radeon_gart.c +1
-1@@ -301,7 +301,7 @@ int radeon_gart_bind(struct radeon_devic p = t / (PAGE_SIZE /RADEON_GPU_PAGE_SIZE );for (i =0 ; i < pages; i++, p++) { - rdev->gart.pages[p] = pagelist[i]; +/* rdev->gart.pages[p] = pagelist[i]; */ page_base = dma_addr[i];for (j =0 ; j < (PAGE_SIZE /RADEON_GPU_PAGE_SIZE ); j++, t++) { page_entry =radeon_gart_get_page_entry (page_base, flags);drivers/gpu/drm/radeon/radeon_ttm.c +2
-0@@ -360,6 +360,8 @@ static int radeon_ttm_tt_pin_userptr(strif (current->mm != gtt->usermm)return -EPERM ; +if (!ttm->pages) +return -EPERM ;if (gtt->userflags &RADEON_GEM_USERPTR_ANONONLY ) {/* check that we only pin down anonymous memory _______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&data=04%7C01%7Cchristian.koenig%40amd.com%7C64447e9e97604aaf117008d9116a742a%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637559971181187178%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=RdzGp1FLxBKE%2ByPclrUBfQomRU0pQT%2F78Ewcj%2FBZ73g%3D&reserved=0
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx