Skip to contentSkip to conversation

drm/amdgpu: Init data to avoid oops while reading pp_num_states.

PATCH Applied limingyu 2 participants 2 messages Apr 22, 2020

Subsystems (2)
lore
Share & tools
lore

limingyu

author
#0 lore raw

PATCH 1/1 drm/amdgpu: Init data to avoid oops while reading pp_num_states.

For chip like CHIP_OLAND with si enabled(amdgpu.si_support=1), the amdgpu will expose pp_num_states to the /sys directory. In this moment, read the pp_num_states file will excute the amdgpu_get_pp_num_states func. In our case, the data hasn't been initialized, so the kernel will access some ilegal address, trigger the segmentfault and system will reboot soon:

    uos@uos-PC:~$ cat /sys/devices/pci0000\:00/0000\:00\:00.0/0000\:01\:00
    .0/pp_num_states
    Message from syslogd@uos-PC at Apr 22 09:26:20 ...
     kernel:[   82.154129] Internal error: Oops: 96000004 [#1] SMP

This patch aims to fix this problem, avoid that reading file triggers the kernel sementfault.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +3 -1
index abe94a55ecad..17de9dc60ea1 100644
@@ -444,8 +444,10 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,
 		ret = smu_get_power_num_states(&adev->smu, &data);
 		if (ret)
 			return ret;
-	} else if (adev->powerplay.pp_funcs->get_pp_num_states)
+	} else if (adev->powerplay.pp_funcs->get_pp_num_states) {
 		amdgpu_dpm_get_pp_num_states(adev, &data);
+	} else
+		memset(&data, 0, sizeof(data));
 
 	pm_runtime_mark_last_busy(ddev->dev);
 	pm_runtime_put_autosuspend(ddev->dev);
Signature · 8 lines
2.20.1



_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Applied
#1 lore raw
Quoted 11 lines · limingyu

For chip like CHIP_OLAND with si enabled(amdgpu.si_support=1), the amdgpu will expose pp_num_states to the /sys directory. In this moment, read the pp_num_states file will excute the amdgpu_get_pp_num_states func. In our case, the data hasn't been initialized, so the kernel will access some ilegal address, trigger the segmentfault and system will reboot soon:

    uos@uos-PC:~$ cat /sys/devices/pci0000\:00/0000\:00\:00.0/0000\:01\:00
    .0/pp_num_states
Quoted 8 lines
    Message from syslogd@uos-PC at Apr 22 09:26:20 ...
     kernel:[   82.154129] Internal error: Oops: 96000004 [#1] SMP

This patch aims to fix this problem, avoid that reading file triggers the kernel sementfault.

Applied. Thanks!

Alex

Quoted 25 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c +3 -2
index abe94a55ecad..17de9dc60ea1 100644
@@ -444,8 +444,10 @@ static ssize_t amdgpu_get_pp_num_states(struct device *dev,
                ret = smu_get_power_num_states(&adev->smu, &data);
                if (ret)
                        return ret;
-       } else if (adev->powerplay.pp_funcs->get_pp_num_states)
+       } else if (adev->powerplay.pp_funcs->get_pp_num_states) {
                amdgpu_dpm_get_pp_num_states(adev, &data);
+       } else
+               memset(&data, 0, sizeof(data));
 
        pm_runtime_mark_last_busy(ddev->dev);
        pm_runtime_put_autosuspend(ddev->dev);
--

2.20.1

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