drm/amdkfd: Fix UBSAN shift-out-of-bounds warning
authorAnson Jacob <Anson.Jacob@amd.com>
Wed, 3 Mar 2021 17:33:15 +0000 (12:33 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 24 Mar 2021 03:00:57 +0000 (23:00 -0400)
commit50e2fc36e72d4ad672032ebf646cecb48656efe0
tree71c4cea7ffa56520eadd17b42ab52510fec11613
parent47bfa5f60fbfd7a1c5b4d5ba8c1ab45bc9c81bc8
drm/amdkfd: Fix UBSAN shift-out-of-bounds warning

If get_num_sdma_queues or get_num_xgmi_sdma_queues is 0, we end up
doing a shift operation where the number of bits shifted equals
number of bits in the operand. This behaviour is undefined.

Set num_sdma_queues or num_xgmi_sdma_queues to ULLONG_MAX, if the
count is >= number of bits in the operand.

Bug: https://gitlab.freedesktop.org/drm/amd/-/issues/1472

Reported-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Anson Jacob <Anson.Jacob@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Tested-by: Lyude Paul <lyude@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c