From patchwork Tue Dec 27 11:51:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 36830 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1352866wrt; Tue, 27 Dec 2022 03:55:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXvyQUeGnN4b8LUkAdfv0/QdWyIrg2/cyK4Ok3pAkSB/uGf8dFfdCEfm1jRxIRXF1Yc3soQv X-Received: by 2002:a05:6402:c14:b0:45c:835b:ac66 with SMTP id co20-20020a0564020c1400b0045c835bac66mr16725303edb.33.1672142147667; Tue, 27 Dec 2022 03:55:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672142147; cv=none; d=google.com; s=arc-20160816; b=fCLNo5yq4Z17T035XO0SDB4Evp7KbIFoE/GwCVsT46ujUUsX3FG2cAdqxdXkSL3hjH zdZVTe5U8Wer1Txuv4hjKQOUlOH3MmRAQHczlpIs7ey56MP2tBgD6hwiffw3up1rjVkD 57rcN0lYG7kLwZ0Ce5MJcC4bUZ0b+6xVQzyXTThC9tUu60BlwTaCWXQwS+0Seqk+HiL/ 27cLj0+u3EZVFkGgI7V1KnHlJY8v3VsqMLWFEyDQnY2/WWwlXMCAEAMocCPpjGQ2HCgi P4plrgBqBOa81A0IRgFLwSk908s2wv2T8mqABxWGMvz8y4mkA/zxM0dWD9dBLgUdgdVB XU0w== 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 header.s=2020e; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v18-20020a056402349200b0047b405e7746si12018898edc.1.2022.12.27.03.55.24; Tue, 27 Dec 2022 03:55:47 -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 header.s=2020e; 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 + 99 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751110646508930775?= X-GMAIL-MSGID: =?utf-8?q?1753368124995428955?= 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,