summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorColin Ian King <colin.i.king@gmail.com>2022-12-02 16:51:49 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-02-01 10:23:27 +0300
commitf84c9b72fb200633774704d8020f769c88a4b249 (patch)
treebc04388033a021dc3fc8e81820204617e46d80e7 /arch
parent743435cd1705b4a3a4b8e73a538c4c1a1efc7edb (diff)
downloadlinux-f84c9b72fb200633774704d8020f769c88a4b249.tar.xz
perf/x86/amd: fix potential integer overflow on shift of a int
commit 08245672cdc6505550d1a5020603b0a8d4a6dcc7 upstream. The left shift of int 32 bit integer constant 1 is evaluated using 32 bit arithmetic and then passed as a 64 bit function argument. In the case where i is 32 or more this can lead to an overflow. Avoid this by shifting using the BIT_ULL macro instead. Fixes: 471af006a747 ("perf/x86/amd: Constrain Large Increment per Cycle events") Signed-off-by: Colin Ian King <colin.i.king@gmail.com> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Ian Rogers <irogers@google.com> Acked-by: Kim Phillips <kim.phillips@amd.com> Link: https://lore.kernel.org/r/20221202135149.1797974-1-colin.i.king@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/events/amd/core.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c
index 39eb276d0277..52eba415928a 100644
--- a/arch/x86/events/amd/core.c
+++ b/arch/x86/events/amd/core.c
@@ -976,7 +976,7 @@ static int __init amd_core_pmu_init(void)
* numbered counter following it.
*/
for (i = 0; i < x86_pmu.num_counters - 1; i += 2)
- even_ctr_mask |= 1 << i;
+ even_ctr_mask |= BIT_ULL(i);
pair_constraint = (struct event_constraint)
__EVENT_CONSTRAINT(0, even_ctr_mask, 0,