Re: [PATCH] drm/amdkfd: Fix the shift-out-of-bounds warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2024-01-10 04:39, Ma Jun wrote:
There is following shift-out-of-bounds warning if ecode=0.
"shift exponent 4294967295 is too large for 64-bit type 'long long unsigned int'"

Signed-off-by: Ma Jun <Jun.Ma2@xxxxxxx>
---
  include/uapi/linux/kfd_ioctl.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/uapi/linux/kfd_ioctl.h b/include/uapi/linux/kfd_ioctl.h
index 2aa88afe305b..129325b02a91 100644
--- a/include/uapi/linux/kfd_ioctl.h
+++ b/include/uapi/linux/kfd_ioctl.h
@@ -1004,7 +1004,7 @@ enum kfd_dbg_trap_exception_code {
  };
/* Mask generated by ecode in kfd_dbg_trap_exception_code */
-#define KFD_EC_MASK(ecode)	(1ULL << (ecode - 1))
+#define KFD_EC_MASK(ecode)	(BIT(ecode) - 1)

This is not the same thing. We want a bit mask with one bit set. And ecode=1 should set bit 0. ecode=0 is not a valid code and doesn't have a valid mask. You could use BIT((ecode) - 1), but I think that would give you the same warning for ecode=0. I also don't see BIT defined anywhere under include/uapi, so I think using this in the API header would break the build in user mode.

Where are you seeing the warning about the bad shift exponent? Looks like someone is using the KFD_EC_MASK macro incorrectly. Or if there is a legitimate use of it with ecode=0, then the correct fix would be

#define KFD_EC_MASK(ecode)	((ecode) ? 1ULL << (ecode - 1) : 0ULL)

Regards,
  Felix


/* Masks for exception code type checks below */
  #define KFD_EC_MASK_QUEUE	(KFD_EC_MASK(EC_QUEUE_WAVE_ABORT) |	\



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux