Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1791979ybb; Fri, 29 Mar 2019 11:24:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqwnW4DUJ4ueswzoWdWowtIluK6lKv9+7UpD7+vsPNI2G6v4414Aas6YzLTq9Wq8ulq2otJg X-Received: by 2002:a17:902:7c8a:: with SMTP id y10mr9237851pll.232.1553883882838; Fri, 29 Mar 2019 11:24:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553883882; cv=none; d=google.com; s=arc-20160816; b=uzj8fcPUlmd2RYXvfpyFP1TyDTH9gX2jYaSq0GKH6lFBy2M+NG/rGI2ih64UgMhLgU JzSxrMytqJY8QXTDIrnT5FKXUig/H9RjGGXfRpE5UChSbvtN4YtGb7u7myvZidZqUlZZ fK7sYOaHUrn0D8tQtWLKkg+cD2dT3ujk++Hns1ZgrwTZlnIcQKpMCiN+LoV7hvX9kvdK 2uF7dmgBKfmNi58wtV5p1Nknd9LsuU5efsbncjt8yebNbu2edwfP9LyoT7siygiACOO6 PJYMWG3snogrENEYM4H8JTyf+qe2uIOCZLPPUR0Y89a8I/tjrEkFl7lqbJwQCddWhW4b QGdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date; bh=Jbk8EL/2Dkfv3/a/2dmdGNpzWJTi+RN5T3ZvZ9Smq7A=; b=pHaNhdiFERKH3l+D8f4hpPDM4L/byAl4fReEMKiWoVKRsPUwIQ5hyXTfFNjB+1AcJI Tj6Ee5srq5TmvGRPT+3aIPxExxCCy7jFVzGTaIESMzZv77U9wsWGQ8XsMhPwtH9rFoAH 67BlFJY+besNIhsdXDZNp0GtLL0gP3btYe1X/jiJfFXyEI98T+phoqQISQ6qmRPX1qZz EnS/8JNP6yWz0C5FWI1gcidowm4qg1P4rsaXRE92rdIShm0U+rCXk3Lw20d2aMyCgCqO 8Uyo/2QfYIxC6At7wzgNKr8t3lcVPFe02cG85NaPep/xUpv6Ff+g1fMBrqRuznJJzd+Z Odmg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d21si2357463pll.437.2019.03.29.11.24.26; Fri, 29 Mar 2019 11:24:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730016AbfC2SWf (ORCPT + 99 others); Fri, 29 Mar 2019 14:22:35 -0400 Received: from terminus.zytor.com ([198.137.202.136]:59265 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729950AbfC2SWe (ORCPT ); Fri, 29 Mar 2019 14:22:34 -0400 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x2TIMF3E3895679 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Fri, 29 Mar 2019 11:22:15 -0700 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x2TIMEQN3895676; Fri, 29 Mar 2019 11:22:14 -0700 Date: Fri, 29 Mar 2019 11:22:14 -0700 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Borislav Petkov Message-ID: Cc: nadav.amit@gmail.com, peterz@infradead.org, hpa@zytor.com, mingo@kernel.org, linux-kernel@vger.kernel.org, bp@suse.de, tglx@linutronix.de Reply-To: peterz@infradead.org, nadav.amit@gmail.com, hpa@zytor.com, mingo@kernel.org, linux-kernel@vger.kernel.org, bp@suse.de, tglx@linutronix.de In-Reply-To: <20190307151036.GD26566@zn.tnic> References: <20190307151036.GD26566@zn.tnic> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/asm] x86/cpufeature: Remove __pure attribute to _static_cpu_has() Git-Commit-ID: ae37a8cd9b0ad3416d71e54cfaeb3744178189a8 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=1.1 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_06_12,FREEMAIL_FORGED_REPLYTO autolearn=no autolearn_force=no version=3.4.2 X-Spam-Level: * X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: ae37a8cd9b0ad3416d71e54cfaeb3744178189a8 Gitweb: https://git.kernel.org/tip/ae37a8cd9b0ad3416d71e54cfaeb3744178189a8 Author: Borislav Petkov AuthorDate: Thu, 7 Mar 2019 15:54:51 +0100 Committer: Borislav Petkov CommitDate: Fri, 29 Mar 2019 19:13:48 +0100 x86/cpufeature: Remove __pure attribute to _static_cpu_has() __pure is used to make gcc do Common Subexpression Elimination (CSE) and thus save subsequent invocations of a function which does a complex computation (without side effects). As a simple example: bool a = _static_cpu_has(x); bool b = _static_cpu_has(x); gets turned into bool a = _static_cpu_has(x); bool b = a; However, gcc doesn't do CSE with asm()s when those get inlined - like it is done with _static_cpu_has() - because, for example, the t_yes/t_no labels are different for each inlined function body and thus cannot be detected as equivalent anymore for the CSE heuristic to hit. However, this all is beside the point because best it should be avoided to have more than one call to _static_cpu_has(X) in the same function due to the fact that each such call is an alternatives patch site and it is simply pointless. Therefore, drop the __pure attribute as it is not doing anything. Reported-by: Nadav Amit Signed-off-by: Borislav Petkov Cc: Peter Zijlstra Cc: x86@kernel.org Link: https://lkml.kernel.org/r/20190307151036.GD26566@zn.tnic --- arch/x86/include/asm/cpufeature.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h index ce95b8cbd229..2fb791a1b479 100644 --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -159,7 +159,7 @@ extern void clear_cpu_cap(struct cpuinfo_x86 *c, unsigned int bit); * These will statically patch the target code for additional * performance. */ -static __always_inline __pure bool _static_cpu_has(u16 bit) +static __always_inline bool _static_cpu_has(u16 bit) { asm_volatile_goto("1: jmp 6f\n" "2:\n"