drm/amd/pm: avoid potential UBSAN issue on legacy asics
Subsystems (3)
PATCH 1/1 drm/amd/pm: avoid potential UBSAN issue on legacy asics
Prevent further casting on chip MULLINS/KABINI/KAVERI when calling amdgpu_dpm_is_overdrive_supported, this can avoid UBSAN complain in init sequence.
--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +8 -2
@@ -1467,8 +1467,14 @@ int amdgpu_dpm_is_overdrive_supported(struct amdgpu_device *adev) }else {struct pp_hwmgr *hwmgr; -/* SI asic does not carry od_enabled */ -if (adev->family ==AMDGPU_FAMILY_SI ) +/* +* SI asic and chip MULLINS/KABINI/KAVERI do not carry +* od_enabled, as its pp_handle is casted from adev. +*/ +if ((adev->family ==AMDGPU_FAMILY_SI ) || + (adev->asic_type ==CHIP_MULLINS ) || + (adev->asic_type ==CHIP_KABINI ) || + (adev->asic_type ==CHIP_KAVERI ))return false; hwmgr = (struct pp_hwmgr *)adev->powerplay.pp_handle;
Signature · 1 line
2.25.1
[AMD Official Use Only - General]
Quoted 45 lines
-----Original Message-----
From: Chen, Guchun <[email protected]>
Sent: Tuesday, May 9, 2023 9:43 AM
To: [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Lazar, Lijo <[email protected]>; Quan, Evan <[email protected]>
Cc: Chen, Guchun <[email protected]>
Subject: [PATCH] drm/amd/pm: avoid potential UBSAN issue on legacy asicsPrevent further casting on chip MULLINS/KABINI/KAVERI when calling
amdgpu_dpm_is_overdrive_supported, this can avoid UBSAN complain in init sequence.Suggested-by Evan Quan <[email protected]>Signed-off-by Guchun Chen <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +8
-2@@ -1467,8 +1467,14 @@ int amdgpu_dpm_is_overdrive_supported(struct amdgpu_device *adev) }else {struct pp_hwmgr *hwmgr; -/* SI asic does not carry od_enabled */ -if (adev->family ==AMDGPU_FAMILY_SI ) +/* +* SI asic and chip MULLINS/KABINI/KAVERI do not carry +* od_enabled, as its pp_handle is casted from adev. +*/ +if ((adev->family ==AMDGPU_FAMILY_SI ) || + (adev->asic_type ==CHIP_MULLINS ) || + (adev->asic_type ==CHIP_KABINI ) || + (adev->asic_type ==CHIP_KAVERI ))return false;hwmgr = (struct
pp_hwmgr*)adev->powerplay.pp_handle;
--
2.25.1
Quoted 15 lines · Guchun Chen
Prevent further casting on chip MULLINS/KABINI/KAVERI when calling
amdgpu_dpm_is_overdrive_supported, this can avoid UBSAN complain in init sequence.Suggested-by Evan Quan <[email protected]>Signed-off-by Guchun Chen <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0
drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_is_overdrive_supported(struct amdgpu_device *adev) · line 1469
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1467,8 +1467,14 @@ int amdgpu_dpm_is_overdrive_supported(struct amdgpu_device *adev) }else {struct pp_hwmgr *hwmgr;
Instead of family check, what if you wrap it like -
is_legacy_dpm(adev)
return (adev->powerplay.pp_handle == adev)
Could be useful for legacy dpm checks.
Thanks,
Lijo
Quoted 13 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +8
-2-/* SI asic does not carry od_enabled */ -if (adev->family ==AMDGPU_FAMILY_SI ) +/* +* SI asic and chip MULLINS/KABINI/KAVERI do not carry +* od_enabled, as its pp_handle is casted from adev. +*/ +if ((adev->family ==AMDGPU_FAMILY_SI ) || + (adev->asic_type ==CHIP_MULLINS ) || + (adev->asic_type ==CHIP_KABINI ) || + (adev->asic_type ==CHIP_KAVERI ))return false; hwmgr = (struct pp_hwmgr *)adev->powerplay.pp_handle;
Quoted 36 lines
-----Original Message-----
From: Lazar, Lijo <[email protected]>
Sent: Tuesday, May 9, 2023 11:47 AM
To: Chen, Guchun <[email protected]>; amd- [email protected]; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>; Quan, Evan <[email protected]>
Subject: Re: [PATCH] drm/amd/pm: avoid potential UBSAN issue on legacy asicsdrivers/gpu/drm/amd/pm/amdgpu_dpm.c int
Quoted 16 lines · Guchun Chen
Prevent further casting on chip MULLINS/KABINI/KAVERI when calling
amdgpu_dpm_is_overdrive_supported, this can avoid UBSAN complain in init sequence.Suggested-by Evan Quan <[email protected]>Signed-off-by Guchun Chen <[email protected]>--- drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0@@ -1467,8 +1467,14 @@ int
amdgpu_dpm_is_overdrive_supported(struct amdgpu_device *adev)drivers/gpu/drm/amd/pm/amdgpu_dpm.c int amdgpu_dpm_is_overdrive_supported(struct amdgpu_device *adev) · line 1469
Quoted 3 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +0
-0}else {struct pp_hwmgr *hwmgr;
Quoted 6 lines
Instead of family check, what if you wrap it like -
is_legacy_dpm(adev)return (adev->powerplay.pp_handle == adev)Could be useful for legacy dpm checks.
Sounds good. Will address it in v2.
Regards,
Guchun
Quoted 16 lines
Thanks,
LijoQuoted 13 lines
drivers/gpu/drm/amd/pm/amdgpu_dpm.c +8
-2-/* SI asic does not carry od_enabled */ -if (adev->family ==AMDGPU_FAMILY_SI ) +/* +* SI asic and chip MULLINS/KABINI/KAVERI do not carry +* od_enabled, as its pp_handle is casted from adev. +*/ +if ((adev->family ==AMDGPU_FAMILY_SI ) || + (adev->asic_type ==CHIP_MULLINS ) || + (adev->asic_type ==CHIP_KABINI ) || + (adev->asic_type ==CHIP_KAVERI ))return false; hwmgr = (struct pp_hwmgr *)adev->powerplay.pp_handle;