Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp3086830rwl; Tue, 27 Dec 2022 04:15:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXuH59MGiUBuW4wmZ04kd7wvuofD/zGlfCvpKOYPPorGL1xnPrTPwdwm/DVzY7qIzLWnkK9m X-Received: by 2002:a17:90a:bd95:b0:225:a202:5fb5 with SMTP id z21-20020a17090abd9500b00225a2025fb5mr23429582pjr.44.1672143348342; Tue, 27 Dec 2022 04:15:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672143348; cv=none; d=google.com; s=arc-20160816; b=Ai9iHzjLC0Vrjt9wxm2whrXsoNKAmZWZAl64HOAFoI3b6DkbHkUYF5bjbHOg9QKCiE N9rIDtGbR7fi+dMjL492qz/IEpC3lwqT0+whRBdz2CFkct8C14O3UA8Zf4fOYej5GT/0 JIy6Aweb7YcbeEgxCewcMvYz22r0DMgMuk+T8LcLQTI9uWHSrrWuhWv+vU33xCA/OwCS iQ7bBlehL142OF3wvf5gBzWlOJSphVF9b4MyQIkiu4khVLsZJ3V3i7QMxh4/I6km8tST actjlLxt1wtP+AIIYXxm5brFjva/fJr/9Vhg8bOJwvbr61Y6F8ItL/IYYZWVRWxLOi2v 2cyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=cCY749kK+ZEZys2HbS2HaPU3xVhCU0w5ngw71ZMD72M=; b=av3u+704hEdTEA7T91tplJqz3n2T7g7f0DumUAjhJO27U3E9koc8S4WLPInUe47kgh /6PY2ogkApQse84mpbnkc8golerNbYWjJd5pMrjFzgsvuUVwqtjTvN5K4G1C5mxSEVtK pcoOON+wNAgJZUPuPO+2bQ7f6ElCph5PltkC+801J0lXAXJ/jgqS+mAmDLy5LA1VmmIC mjdklFSu4mwHXFhbM+S5y0UpJ9/MnNe9Bj8tJXKtfob4oOhJtAiq9ZTNIJ2UpCUwAhKc aFDl+/mheHdoYEjK/bejMWQAtEQd1118c377qtQ0dnYEYm8QK6V4eO7HEZ+nn0InanKu qnvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=JJ4ykFeB; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mw7-20020a17090b4d0700b0021a04add441si19667204pjb.104.2022.12.27.04.15.38; Tue, 27 Dec 2022 04:15:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=JJ4ykFeB; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231527AbiL0Lvf (ORCPT + 66 others); Tue, 27 Dec 2022 06:51:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229792AbiL0Lv1 (ORCPT ); Tue, 27 Dec 2022 06:51:27 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD378767D; Tue, 27 Dec 2022 03:51:26 -0800 (PST) Date: Tue, 27 Dec 2022 11:51:23 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1672141884; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cCY749kK+ZEZys2HbS2HaPU3xVhCU0w5ngw71ZMD72M=; b=JJ4ykFeB8R6RJWc+16XbuqJ2sWnA7NHiUEIXmhxXVqxZTU5Eq6SQ6f1L/IceBEW2cvcHNX vTWe00LQYOHjq2CXnHH9YCOZ1NlKiSqXPCYlNGsdkoplBFBsP/nCEI1c3CZhOwzS/4NfS1 +r/gcZMsi7lXgw4DsncY4g9WCfSvPG7XST2OiJt2h8e8bQkbydUy+wDJVWp7VRxInmt93O BSV1wtAgj1TRVGgANcvzMwi2yd3uua9wV5P4xW4PTcc+r9iIhhkJJOtsbzAK8KED/Q5KqJ Q9m+tf/VjTjOy6YRFgj8HxXbUa+Xk0851soSepcsJRN1By2i0oeFFvFuY37GqQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1672141884; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cCY749kK+ZEZys2HbS2HaPU3xVhCU0w5ngw71ZMD72M=; b=rihS21t3ZlD3eEgwN6Bvmj9Tv7KrVUUh7HGwxha4JWYaU4l8zd0q7afjIEpIaSVFVxyuzz RFKZ1baGJ2T7feBQ== From: "tip-bot2 for Colin Ian King" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: perf/urgent] perf/x86/amd: fix potential integer overflow on shift of a int Cc: Colin Ian King , "Peter Zijlstra (Intel)" , Ian Rogers , Kim Phillips , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221202135149.1797974-1-colin.i.king@gmail.com> References: <20221202135149.1797974-1-colin.i.king@gmail.com> MIME-Version: 1.0 Message-ID: <167214188379.4906.307380073396005165.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the perf/urgent branch of tip: Commit-ID: 08245672cdc6505550d1a5020603b0a8d4a6dcc7 Gitweb: https://git.kernel.org/tip/08245672cdc6505550d1a5020603b0a8d4a6dcc7 Author: Colin Ian King AuthorDate: Fri, 02 Dec 2022 13:51:49 Committer: Peter Zijlstra CommitterDate: Tue, 27 Dec 2022 12:44:00 +01:00 perf/x86/amd: fix potential integer overflow on shift of a int 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 Signed-off-by: Peter Zijlstra (Intel) Acked-by: Ian Rogers Acked-by: Kim Phillips Link: https://lore.kernel.org/r/20221202135149.1797974-1-colin.i.king@gmail.com --- arch/x86/events/amd/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/events/amd/core.c b/arch/x86/events/amd/core.c index d6f3703..4386b10 100644 --- a/arch/x86/events/amd/core.c +++ b/arch/x86/events/amd/core.c @@ -1387,7 +1387,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,