From 0846cdf553aa509a04d56c3dca2dc822abaefb98 Mon Sep 17 00:00:00 2001 From: Jiri Slaby Date: May 17 2023 19:15:56 +0000 Subject: drm/amd/pm: avoid potential UBSAN issue on legacy asics (bsc#1012628). --- diff --git a/patches.kernel.org/6.3.3-207-drm-amd-pm-avoid-potential-UBSAN-issue-on-legac.patch b/patches.kernel.org/6.3.3-207-drm-amd-pm-avoid-potential-UBSAN-issue-on-legac.patch new file mode 100644 index 0000000..2e36468 --- /dev/null +++ b/patches.kernel.org/6.3.3-207-drm-amd-pm-avoid-potential-UBSAN-issue-on-legac.patch @@ -0,0 +1,57 @@ +From: Guchun Chen +Date: Tue, 9 May 2023 09:36:49 +0800 +Subject: [PATCH] drm/amd/pm: avoid potential UBSAN issue on legacy asics +References: bsc#1012628 +Patch-mainline: 6.3.3 +Git-commit: 5247f05eadf1081a74b2233f291cee2efed25e3a + +commit 5247f05eadf1081a74b2233f291cee2efed25e3a upstream. + +Prevent further dpm casting on legacy asics without od_enabled in +amdgpu_dpm_is_overdrive_supported. This can avoid UBSAN complain +in init sequence. + +v2: add a macro to check legacy dpm instead of checking asic family/type +v3: refine macro name for naming consistency + +Suggested-by: Evan Quan +Signed-off-by: Guchun Chen +Reviewed-by: Lijo Lazar +Signed-off-by: Alex Deucher +Cc: stable@vger.kernel.org +Signed-off-by: Greg Kroah-Hartman +Signed-off-by: Jiri Slaby +--- + drivers/gpu/drm/amd/pm/amdgpu_dpm.c | 9 +++++++-- + 1 file changed, 7 insertions(+), 2 deletions(-) + +diff --git a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c +index 29720d0b..bdacc0a7 100644 +--- a/drivers/gpu/drm/amd/pm/amdgpu_dpm.c ++++ b/drivers/gpu/drm/amd/pm/amdgpu_dpm.c +@@ -36,6 +36,8 @@ + #define amdgpu_dpm_enable_bapm(adev, e) \ + ((adev)->powerplay.pp_funcs->enable_bapm((adev)->powerplay.pp_handle, (e))) + ++#define amdgpu_dpm_is_legacy_dpm(adev) ((adev)->powerplay.pp_handle == (adev)) ++ + int amdgpu_dpm_get_sclk(struct amdgpu_device *adev, bool low) + { + const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs; +@@ -1439,8 +1441,11 @@ 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) ++ /* ++ * dpm on some legacy asics don't carry od_enabled member ++ * as its pp_handle is casted directly from adev. ++ */ ++ if (amdgpu_dpm_is_legacy_dpm(adev)) + return false; + + hwmgr = (struct pp_hwmgr *)adev->powerplay.pp_handle; +-- +2.35.3 + diff --git a/series.conf b/series.conf index 87b084a..0a35fbd 100644 --- a/series.conf +++ b/series.conf @@ -940,6 +940,7 @@ patches.kernel.org/6.3.3-204-drm-amd-pm-parse-pp_handle-under-appropriate-co.patch patches.kernel.org/6.3.3-205-drm-amdgpu-drop-gfx_v11_0_cp_ecc_error_irq_func.patch patches.kernel.org/6.3.3-206-drm-amdgpu-disable-sdma-ecc-irq-only-when-sdma-.patch + patches.kernel.org/6.3.3-207-drm-amd-pm-avoid-potential-UBSAN-issue-on-legac.patch ######################################################## # Build fixes that apply to the vanilla kernel too.