linux/drivers/gpu/drm/amd/pm/inc
Kees Cook 4a9bd6db19 drm/amd/pm: And destination bounds checking to struct copy
In preparation for FORTIFY_SOURCE performing compile-time and run-time
field bounds checking for memcpy(), memmove(), and memset(), avoid
intentionally writing across neighboring fields.

The "Board Parameters" members of the structs:
	struct atom_smc_dpm_info_v4_5
	struct atom_smc_dpm_info_v4_6
	struct atom_smc_dpm_info_v4_7
	struct atom_smc_dpm_info_v4_10
are written to the corresponding members of the corresponding PPTable_t
variables, but they lack destination size bounds checking, which means
the compiler cannot verify at compile time that this is an intended and
safe memcpy().

Since the header files are effectively immutable[1] and a struct_group()
cannot be used, nor a common struct referenced by both sides of the
memcpy() arguments, add a new helper, amdgpu_memcpy_trailing(), to
perform the bounds checking at compile time. Replace the open-coded
memcpy()s with amdgpu_memcpy_trailing() which includes enough context
for the bounds checking.

"objdump -d" shows no object code changes.

[1] https://lore.kernel.org/lkml/e56aad3c-a06f-da07-f491-a894a570d78f@amd.com

Cc: "Christian König" <christian.koenig@amd.com>
Cc: "Pan, Xinhui" <Xinhui.Pan@amd.com>
Cc: David Airlie <airlied@linux.ie>
Cc: Daniel Vetter <daniel@ffwll.ch>
Cc: Hawking Zhang <Hawking.Zhang@amd.com>
Cc: Feifei Xu <Feifei.Xu@amd.com>
Cc: Likun Gao <Likun.Gao@amd.com>
Cc: Jiawei Gu <Jiawei.Gu@amd.com>
Cc: Evan Quan <evan.quan@amd.com>
Cc: amd-gfx@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Lijo Lazar <lijo.lazar@amd.com>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
2021-08-30 14:59:34 -04:00
..
vega12
aldebaran_ppsmc.h drm/amd/pm: Support board calibration on aldebaran 2021-07-23 10:07:59 -04:00
amd_powerplay.h
amdgpu_dpm.h drm/amd/pm: drop the unnecessary intermediate percent-based transition 2021-08-16 15:35:56 -04:00
amdgpu_pm.h drm/amd/pm: do not use drm middle layer for debugfs 2021-02-18 16:43:09 -05:00
amdgpu_smu.h drm/amd/pm: And destination bounds checking to struct copy 2021-08-30 14:59:34 -04:00
arcturus_ppsmc.h drm/amd/pm: Add LightSBR SMU MSG support 2021-03-23 23:25:43 -04:00
cz_ppsmc.h
fiji_ppsmc.h
hardwaremanager.h
hwmgr.h drm/amd/pm: drop the unnecessary intermediate percent-based transition 2021-08-16 15:35:56 -04:00
polaris10_pwrvirus.h
power_state.h
pp_debug.h
pp_endian.h
pp_thermal.h drm/amd/pm/inc/pp_thermal: Mark 'SMU7Thermal{WithDelay}Policy' as __maybe_unused 2020-12-01 16:04:44 -05:00
ppinterrupt.h
rv_ppsmc.h drm/amdgpu/powerplay/smu10: add support for gpu busy query (v2) 2021-03-23 23:27:50 -04:00
smu7_common.h
smu7_discrete.h
smu7_fusion.h
smu7_ppsmc.h drm/amd/pm: correct Polaris DIDT configurations 2020-10-27 11:59:16 -04:00
smu7.h
smu8_fusion.h
smu8.h
smu9_driver_if.h
smu9.h
smu10_driver_if.h drm/amd/pm: add Raven2 watermark WmType setting 2020-09-17 17:48:18 -04:00
smu10.h drm/amd/pm: update smu10.h WORKLOAD_PPLIB setting for raven 2020-12-08 23:06:15 -05:00
smu11_driver_if_arcturus.h
smu11_driver_if_cyan_skillfish.h drm/amdgpu: add smu interface header for cyan_skilfish 2021-07-23 10:08:02 -04:00
smu11_driver_if_navi10.h drm/amd/pm: bump Navi1x driver if version and related data structures V2 2021-03-02 14:05:18 -05:00
smu11_driver_if_sienna_cichlid.h drm/amd/pm: bump DRIVER_IF_VERSION for Sienna Cichlid 2021-07-08 17:47:28 -04:00
smu11_driver_if_vangogh.h drm/amd/pm: update the driver interface header for vangogh 2021-04-15 16:32:19 -04:00
smu11_driver_if.h
smu12_driver_if.h
smu13_driver_if_aldebaran.h drm/amd/pm: Update aldebaran pmfw interface 2021-05-19 22:29:35 -04:00
smu13_driver_if_yellow_carp.h drm/admgpu/pm: add smu v13 driver interface header for yellow carp (v3) 2021-06-04 16:03:09 -04:00
smu71_discrete.h
smu71.h
smu72_discrete.h
smu72.h
smu73_discrete.h
smu73.h
smu74_discrete.h drm/amd/pm: correct VR shared rail info 2020-10-27 11:58:57 -04:00
smu74.h
smu75_discrete.h
smu75.h
smu_11_0_cdr_table.h drm/amd/pm: implement a new umc cdr workaround 2020-09-17 17:46:40 -04:00
smu_types.h drm/amd/pm: correct DPM_XGMI/VCN_DPM feature name 2021-08-16 15:17:17 -04:00
smu_ucode_xfer_cz.h
smu_ucode_xfer_vi.h
smu_v11_0_7_ppsmc.h drm/amd/pm: new SMC message for 2nd usb2.0 port workaround 2020-12-10 16:41:49 -05:00
smu_v11_0_7_pptable.h
smu_v11_0_ppsmc.h drm/amd/pm: apply the CDR workarounds only with some specific UMC firmwares(V2) 2020-09-17 17:46:47 -04:00
smu_v11_0_pptable.h
smu_v11_0.h drm/amd/pm: drop the unnecessary intermediate percent-based transition 2021-08-16 15:35:56 -04:00
smu_v11_5_pmfw.h drm/amd/pm: update the swSMU headers for vangogh 2020-11-13 00:12:51 -05:00
smu_v11_5_ppsmc.h drm/amd/pm: update the smu v11.5 smc header for vangogh 2021-02-09 15:29:15 -05:00
smu_v11_8_pmfw.h drm/amdgpu: add smu_v11_8_pmfw header for cyan_skilfish 2021-07-23 10:08:01 -04:00
smu_v11_8_ppsmc.h drm/amdgpu: add smu_v11_8_ppsmc header for cyan_skilfish 2021-07-23 10:08:02 -04:00
smu_v12_0_ppsmc.h
smu_v12_0.h drm/amd/pm: add the callback to get the bootup values for renoir 2021-04-15 16:32:44 -04:00
smu_v13_0_1_pmfw.h drm/amd/pm: update smu v13.0.1 firmware header 2021-08-05 21:17:59 -04:00
smu_v13_0_1_ppsmc.h drm/amdgpu/pm: add smu v13.0.1 smc header for yellow carp (v2) 2021-06-04 16:03:10 -04:00
smu_v13_0_pptable.h drm/amd/swsmu: add aldebaran smu13 ip support (v3) 2021-03-23 22:54:24 -04:00
smu_v13_0.h drm/amd/pm: update yellow carp pmfw interface version 2021-08-05 21:17:40 -04:00
smumgr.h drm/amd/pm: perform SMC reset on suspend/hibernation 2020-10-30 01:00:43 -04:00
tonga_ppsmc.h
vega10_ppsmc.h
vega12_ppsmc.h
vega20_ppsmc.h