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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 11 May 2021 12:47:25 +0000 (14:47 +0200)
commit1874b0ef1426b873de94c61861e38f29a8df714c
treef5046eca44f65314c8bde675053a36beaffe6f11
parent7b3eb98a3ef464d7da7dd471c63514acf4ee225d
drm/amdkfd: Fix UBSAN shift-out-of-bounds warning

[ Upstream commit 50e2fc36e72d4ad672032ebf646cecb48656efe0 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/amdkfd/kfd_device_queue_manager.c