drm/amdgpu: Fix type of second parameter in trans_msg() callback
Subsystems (3)
PATCH 1/2 drm/amdgpu: Fix type of second parameter in trans_msg() callback
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c:412:15: error: incompatible function pointer types initializing 'void (*)(struct amdgpu_device *, u32, u32, u32, u32)' (aka 'void (*)(struct amdgpu_device *, unsigned int, unsigned int, unsigned int, unsigned int)') with an expression of type 'void (struct amdgpu_device *, enum idh_request, u32, u32, u32)' (aka 'void (struct amdgpu_device *, enum idh_request, unsigned int, unsigned int, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict]
.trans_msg = xgpu_ai_mailbox_trans_msg,
^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c:435:15: error: incompatible function pointer types initializing 'void (*)(struct amdgpu_device *, u32, u32, u32, u32)' (aka 'void (*)(struct amdgpu_device *, unsigned int, unsigned int, unsigned int, unsigned int)') with an expression of type 'void (struct amdgpu_device *, enum idh_request, u32, u32, u32)' (aka 'void (struct amdgpu_device *, enum idh_request, unsigned int, unsigned int, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict]
.trans_msg = xgpu_nv_mailbox_trans_msg,
^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
The type of the second parameter in the prototype should be 'enum idh_request' instead of 'u32'. Update it to clear up the warnings.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_virt.h +4 -1
@@ -74,6 +74,8 @@ struct amdgpu_vf_error_buffer {uint64_t data[AMDGPU_VF_ERROR_ENTRY_SIZE ]; }; +enum idh_request ; +/** * struct amdgpu_virt_ops - amdgpu device virt operations */
@@ -83,7 +85,8 @@ struct amdgpu_virt_ops {int (*req_init_data)(struct amdgpu_device *adev);int (*reset_gpu)(struct amdgpu_device *adev);int (*wait_reset)(struct amdgpu_device *adev); -void (*trans_msg)(struct amdgpu_device *adev,u32 req,u32 data1,u32 data2,u32 data3); +void (*trans_msg)(struct amdgpu_device *adev,enum idh_request req, +u32 data1,u32 data2,u32 data3); };/*
base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780
Signature · 1 line
2.38.1
PATCH 2/2 drm/amdgpu: Fix type of second parameter in odn_edit_dpm_table() callback
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/gpu/drm/amd/amdgpu/../pm/swsmu/amdgpu_smu.c:3008:29: error: incompatible function pointer types initializing 'int (*)(void *, uint32_t, long *, uint32_t)' (aka 'int (*)(void *, unsigned int, long *, unsigned int)') with an expression of type 'int (void *, enum PP_OD_DPM_TABLE_COMMAND, long *, uint32_t)' (aka 'int (void *, enum PP_OD_DPM_TABLE_COMMAND, long *, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict]
.odn_edit_dpm_table = smu_od_edit_dpm_table,
^~~~~~~~~~~~~~~~~~~~~
1 error generated.
There are only two implementations of ->odn_edit_dpm_table() in 'struct amd_pm_funcs': smu_od_edit_dpm_table() and pp_odn_edit_dpm_table(). One has a second parameter type of 'enum PP_OD_DPM_TABLE_COMMAND' and the other uses 'u32'. Ultimately, smu_od_edit_dpm_table() calls ->od_edit_dpm_table() from 'struct pptable_funcs' and pp_odn_edit_dpm_table() calls ->odn_edit_dpm_table() from 'struct pp_hwmgr_func', which both have a second parameter type of 'enum PP_OD_DPM_TABLE_COMMAND'.
Update the type parameter in both the prototype in 'struct amd_pm_funcs' and pp_odn_edit_dpm_table() to 'enum PP_OD_DPM_TABLE_COMMAND', which cleans up the warning.
--- drivers/gpu/drm/amd/include/kgd_pp_interface.h | 3 ++- drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/include/kgd_pp_interface.h +2 -1
@@ -354,7 +354,8 @@ struct amd_pm_funcs {int (*get_power_profile_mode)(void *handle,char *buf);int (*set_power_profile_mode)(void *handle,long *input,uint32_t size);int (*set_fine_grain_clk_vol)(void *handle,uint32_t type,long *input,uint32_t size); -int (*odn_edit_dpm_table)(void *handle,uint32_t type,long *input,uint32_t size); +int (*odn_edit_dpm_table)(void *handle,enum PP_OD_DPM_TABLE_COMMAND type, +long *input,uint32_t size);int (*set_mp1_state)(void *handle,enum pp_mp1_state mp1_state);int (*smu_i2c_bus_access)(void *handle,bool acquire);int (*gfx_state_change_set)(void *handle,uint32_t state);
drivers/gpu/drm/amd/pm/powerplay/amd_powerplay.c +2 -1
@@ -838,7 +838,8 @@ static int pp_set_fine_grain_clk_vol(void *handle, uint32_t type, long *input, ureturn hwmgr->hwmgr_func->set_fine_grain_clk_vol (hwmgr, type, input, size); } -static int pp_odn_edit_dpm_table (void *handle,uint32_t type,long *input,uint32_t size) +static int pp_odn_edit_dpm_table (void *handle,enum PP_OD_DPM_TABLE_COMMAND type, +long *input,uint32_t size) {struct pp_hwmgr *hwmgr = handle;
Signature · 1 line
2.38.1
Re: [PATCH 2/2] drm/amdgpu: Fix type of second parameter in odn_edit_dpm_table() callback
Quoted 22 lines · Nathan Chancellor
With clang's kernel control flow integrity (kCFI,
CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/gpu/drm/amd/amdgpu/../pm/swsmu/amdgpu_smu.c:3008:29: error: incompatible function pointer types initializing 'int (*)(void *,uint32_t, long *,uint32_t)' (aka 'int (*)(void *, unsigned int, long *, unsigned int)') with an expression of type 'int (void *, enumPP_OD_DPM_TABLE_COMMAND, long *,uint32_t)' (aka 'int (void *, enumPP_OD_DPM_TABLE_COMMAND, long *, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict]
.odn_edit_dpm_table =smu_od_edit_dpm_table,
^~~~~~~~~~~~~~~~~~~~~
1 error generated.There are only two implementations of ->odn_edit_dpm_table() in 'struct
amd_pm_funcs':smu_od_edit_dpm_table()andpp_odn_edit_dpm_table(). One has a second parameter type of 'enumPP_OD_DPM_TABLE_COMMAND' and the other uses 'u32'. Ultimately,smu_od_edit_dpm_table()calls ->od_edit_dpm_table() from 'structpptable_funcs' andpp_odn_edit_dpm_table()calls ->odn_edit_dpm_table() from 'structpp_hwmgr_func', which both have a second parameter type of 'enumPP_OD_DPM_TABLE_COMMAND'.
Quoted 7 lines
Update the type parameter in both the prototype in 'struct
amd_pm_funcs' andpp_odn_edit_dpm_table()to 'enumPP_OD_DPM_TABLE_COMMAND', which cleans up the warning.Reported-by Sami Tolvanen <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>
Signature · 1 line
Kees Cook
Alex Deucher
AppliedRe: [PATCH 2/2] drm/amdgpu: Fix type of second parameter in odn_edit_dpm_table() callback
Applied the series. Thanks!
Alex
Quoted 36 lines · Kees Cook
Quoted 22 lines · Nathan Chancellor
With clang's kernel control flow integrity (kCFI,
CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/gpu/drm/amd/amdgpu/../pm/swsmu/amdgpu_smu.c:3008:29: error: incompatible function pointer types initializing 'int (*)(void *,uint32_t, long *,uint32_t)' (aka 'int (*)(void *, unsigned int, long *, unsigned int)') with an expression of type 'int (void *, enumPP_OD_DPM_TABLE_COMMAND, long *,uint32_t)' (aka 'int (void *, enumPP_OD_DPM_TABLE_COMMAND, long *, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict]
.odn_edit_dpm_table =smu_od_edit_dpm_table,
^~~~~~~~~~~~~~~~~~~~~
1 error generated.There are only two implementations of ->odn_edit_dpm_table() in 'struct
amd_pm_funcs':smu_od_edit_dpm_table()andpp_odn_edit_dpm_table(). One has a second parameter type of 'enumPP_OD_DPM_TABLE_COMMAND' and the other uses 'u32'. Ultimately,smu_od_edit_dpm_table()calls ->od_edit_dpm_table() from 'structpptable_funcs' andpp_odn_edit_dpm_table()calls ->odn_edit_dpm_table() from 'structpp_hwmgr_func', which both have a second parameter type of 'enumPP_OD_DPM_TABLE_COMMAND'.Quoted 7 lines
Update the type parameter in both the prototype in 'struct
amd_pm_funcs' andpp_odn_edit_dpm_table()to 'enumPP_OD_DPM_TABLE_COMMAND', which cleans up the warning.Reported-by Sami Tolvanen <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>Reviewed-by Kees Cook <[email protected]>--
Kees Cook
Quoted 18 lines · Nathan Chancellor
With clang's kernel control flow integrity (kCFI,
CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/gpu/drm/amd/amdgpu/mxgpu_ai.c:412:15: error: incompatible function pointer types initializing 'void (*)(structamdgpu_device*, u32, u32, u32, u32)' (aka 'void (*)(structamdgpu_device*, unsigned int, unsigned int, unsigned int, unsigned int)') with an expression of type 'void (structamdgpu_device*, enumidh_request, u32, u32, u32)' (aka 'void (structamdgpu_device*, enumidh_request, unsigned int, unsigned int, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict]
.trans_msg =xgpu_ai_mailbox_trans_msg,
^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
drivers/gpu/drm/amd/amdgpu/mxgpu_nv.c:435:15: error: incompatible function pointer types initializing 'void (*)(structamdgpu_device*, u32, u32, u32, u32)' (aka 'void (*)(structamdgpu_device*, unsigned int, unsigned int, unsigned int, unsigned int)') with an expression of type 'void (structamdgpu_device*, enumidh_request, u32, u32, u32)' (aka 'void (structamdgpu_device*, enumidh_request, unsigned int, unsigned int, unsigned int)') [-Werror,-Wincompatible-function-pointer-types-strict]
.trans_msg =xgpu_nv_mailbox_trans_msg,
^~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Quoted 6 lines
The type of the second parameter in the prototype should be 'enum
idh_request' instead of 'u32'. Update it to clear up the warnings.Reported-by Sami Tolvanen <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>
Signature · 1 line
Kees Cook