Skip to content

Commit ad5013d

Browse files
Colin KingKAGA-KOKO
authored andcommitted
perf/x86/intel: Use ULL constant to prevent undefined shift behaviour
When x86_pmu.num_counters is 32 the shift of the integer constant 1 is exceeding 32bit and therefor undefined behaviour. Fix this by shifting 1ULL instead of 1. Reported-by: CoverityScan CID#1192105 ("Bad bit shift operation") Signed-off-by: Colin Ian King <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Kan Liang <[email protected]> Cc: Stephane Eranian <[email protected]> Cc: Alexander Shishkin <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Thomas Gleixner <[email protected]>
1 parent 6d6daa2 commit ad5013d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/x86/events/intel/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3987,7 +3987,7 @@ __init int intel_pmu_init(void)
39873987
x86_pmu.num_counters, INTEL_PMC_MAX_GENERIC);
39883988
x86_pmu.num_counters = INTEL_PMC_MAX_GENERIC;
39893989
}
3990-
x86_pmu.intel_ctrl = (1 << x86_pmu.num_counters) - 1;
3990+
x86_pmu.intel_ctrl = (1ULL << x86_pmu.num_counters) - 1;
39913991

39923992
if (x86_pmu.num_counters_fixed > INTEL_PMC_MAX_FIXED) {
39933993
WARN(1, KERN_ERR "hw perf events fixed %d > max(%d), clipping!",

0 commit comments

Comments
 (0)