Commit 3d6fc92be1fe for kernel
commit 3d6fc92be1feb6436932979e4652174467e7a42a
Author: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Date: Thu Oct 29 14:14:29 2026 +0530
tools/power turbostat: Fix undefined behavior in pmt_gen_value_mask()
The function uses plain int literal '1' for bit shifting, which causes
undefined behavior when msb >= 31. This is because shifting a 32-bit int
by 32 or more bits is undefined behavior in C. Fix by using 1ULL
(unsigned long long) instead of 1 to ensure 64-bit arithmetic on all
platforms.
Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 9b848dd1d54c..0ba51e67962d 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -5194,9 +5194,9 @@ unsigned long pmt_gen_value_mask(unsigned int lsb, unsigned int msb)
if (msb == 63)
mask = 0xffffffffffffffff;
else
- mask = ((1 << (msb + 1)) - 1);
+ mask = ((1ULL << (msb + 1)) - 1);
- mask -= (1 << lsb) - 1;
+ mask -= (1ULL << lsb) - 1;
return mask;
}