1. 13 May, 2024 35 commits
  2. 08 May, 2024 5 commits
    • Michael Chen's avatar
      drm/amdkfd: Reconcile the definition and use of oem_id in struct kfd_topology_device · 10f624ef
      Michael Chen authored
      Currently oem_id is defined as uint8_t[6] and casted to uint64_t*
      in some use case. This would lead code scanner to complain about
      access beyond. Re-define it in union to enforce 8-byte size and
      alignment to avoid potential issue.
      Signed-off-by: default avatarMichael Chen <michael.chen@amd.com>
      Reviewed-by: default avatarFelix Kuehling <felix.kuehling@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      10f624ef
    • Michel Dänzer's avatar
      drm/amdgpu: Fix comparison in amdgpu_res_cpu_visible · c4dcb47d
      Michel Dänzer authored
      It incorrectly claimed a resource isn't CPU visible if it's located at
      the very end of CPU visible VRAM.
      
      Fixes: a6ff969f ("drm/amdgpu: fix visible VRAM handling during faults")
      Closes: https://gitlab.freedesktop.org/drm/amd/-/issues/3343Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
      Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Reported-and-Tested-by: default avatarJeremy Day <jsday@noreason.ca>
      Signed-off-by: default avatarMichel Dänzer <mdaenzer@redhat.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      CC: stable@vger.kernel.org
      c4dcb47d
    • Srinivasan Shanmugam's avatar
      drm/amdgpu: Fix buffer size to prevent truncation in gfx_v12_0_init_microcode · e35ba81b
      Srinivasan Shanmugam authored
      This commit fixes multiple potential truncations when writing the
      strings _pfp.bin, _me.bin, _rlc.bin, and _mec.bin into the fw_name
      buffer in the gfx_v12_0_init_microcode function in the gfx_v12_0.c file
      
      The ucode_prefix size was reduced from 30 to 15 to ensure the snprintf
      function does not exceed the size of the fw_name buffer.
      
      Thus fixing the below with gcc W=1:
      drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c: In function ‘gfx_v12_0_early_init’:
      drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c:421:54: warning: ‘_pfp.bin’ directive output may be truncated writing 8 bytes into a region of size between 4 and 33 [-Wformat-truncation=]
        421 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_pfp.bin", ucode_prefix);
            |                                                      ^~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c:421:9: note: ‘snprintf’ output between 16 and 45 bytes into a destination of size 40
        421 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_pfp.bin", ucode_prefix);
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c:428:54: warning: ‘_me.bin’ directive output may be truncated writing 7 bytes into a region of size between 4 and 33 [-Wformat-truncation=]
        428 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_me.bin", ucode_prefix);
            |                                                      ^~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c:428:9: note: ‘snprintf’ output between 15 and 44 bytes into a destination of size 40
        428 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_me.bin", ucode_prefix);
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c:436:62: warning: ‘_rlc.bin’ directive output may be truncated writing 8 bytes into a region of size between 4 and 33 [-Wformat-truncation=]
        436 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc.bin", ucode_prefix);
            |                                                              ^~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c:436:17: note: ‘snprintf’ output between 16 and 45 bytes into a destination of size 40
        436 |                 snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_rlc.bin", ucode_prefix);
            |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c:448:54: warning: ‘_mec.bin’ directive output may be truncated writing 8 bytes into a region of size between 4 and 33 [-Wformat-truncation=]
        448 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec.bin", ucode_prefix);
            |                                                      ^~~~~~~~
      drivers/gpu/drm/amd/amdgpu/gfx_v12_0.c:448:9: note: ‘snprintf’ output between 16 and 45 bytes into a destination of size 40
        448 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_mec.bin", ucode_prefix);
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Cc: Lijo Lazar <lijo.lazar@amd.com>
      Cc: Christian König <christian.koenig@amd.com>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
      Reviewed-by: default avatarLijo Lazar <lijo.lazar@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      e35ba81b
    • Srinivasan Shanmugam's avatar
      drm/amdgpu: Fix truncation by resizing ucode_prefix in imu_v12_0_init_microcode · ffd57445
      Srinivasan Shanmugam authored
      This commit fixes potential truncation when writing the string _imu.bin
      into the fw_name buffer in the imu_v12_0_init_microcode function in the
      imu_v12_0.c file
      
      The ucode_prefix size was reduced from 30 to 15 to ensure the snprintf
      function does not exceed the size of the fw_name buffer.
      
      Thus fixing the below with gcc W=1:
      drivers/gpu/drm/amd/amdgpu/imu_v12_0.c: In function ‘imu_v12_0_init_microcode’:
      drivers/gpu/drm/amd/amdgpu/imu_v12_0.c:51:54: warning: ‘_imu.bin’ directive output may be truncated writing 8 bytes into a region of size between 4 and 33 [-Wformat-truncation=]
         51 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_imu.bin", ucode_prefix);
            |                                                      ^~~~~~~~
      drivers/gpu/drm/amd/amdgpu/imu_v12_0.c:51:9: note: ‘snprintf’ output between 16 and 45 bytes into a destination of size 40
         51 |         snprintf(fw_name, sizeof(fw_name), "amdgpu/%s_imu.bin", ucode_prefix);
            |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      
      Cc: Lijo Lazar <lijo.lazar@amd.com>
      Cc: Christian König <christian.koenig@amd.com>
      Cc: Alex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarSrinivasan Shanmugam <srinivasan.shanmugam@amd.com>
      Reviewed-by: default avatarLijo Lazar <lijo.lazar@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      ffd57445
    • Tim Huang's avatar
      drm/amdgpu: fix mc_data out-of-bounds read warning · 51dfc0a4
      Tim Huang authored
      Clear warning that read mc_data[i-1] may out-of-bounds.
      Signed-off-by: default avatarTim Huang <Tim.Huang@amd.com>
      Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
      51dfc0a4