Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2043554imm; Mon, 16 Jul 2018 00:46:22 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcT+O7/N2ysyrOf+swdJVbwqieADX2yZabWnR26adlPkzMxm+Y6l6jA5z4m0fwXthXOLoeo X-Received: by 2002:a63:3e0a:: with SMTP id l10-v6mr14844236pga.355.1531727182752; Mon, 16 Jul 2018 00:46:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531727182; cv=none; d=google.com; s=arc-20160816; b=DHb0UuyeDOYEjgKIGs/Qlz8eZd8440cHhTHw3j/X+53mDJ3KTPLFGeczYISKJ2arFG GZr2qYrlw5RhCS3lxDp5r/X9m+2PVuwHuT6ClB5OwfYqZqzj+zcfmH4BzNVdeQeJuikz pyNwTZAsM766wQFWPgw3Sh8L3X5dbFnuV3O3xOkIWdOo0hRLWTtIDyW4q3R4qZrnut4J nNZvPlihemJekuNzVzu8bVALuDQDSvf6baoqPLd8TXdX4rMhg/dRLgQu5v/i9DHZyoss 7J4TIwwsEDiSKlt/TJzlvc3fAMHBs7GuL1JRPHIPHuUbGHQYGCxOTng/jkFMNqB4i8KK z79A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=YvdEgT31O5MVtE6YUnM/CUzbrK/+QnsDJqioqqHt7I0=; b=gJ9gj7+bqu6hlylwHL4/ljx/tIW+06PVO1OTZ7OWPhzdp9yXgR0UlG+DghgyRhwdhI bqr/0+oBJII0Cag6R70R6lDqEF0+viCiqrygqgZ7RPOkLrnn+SPy9+Il2jlgUa07WVr3 NEIW6yhxBNW1iJCpqNUnbGXT6wFPfHBkV11UDyMXnwWOn6FvhlzevKcb3KJwmY2hLiDw GlUuh2H8ttq41CYEzrPS0KXx9anbjwxoSxzIepmBh07g4wMSSNK5jX0mhQv2k4iI8xrp wErzqCYYx4alMUQ4E2ki4opZa6RR9kGToiLTXXN8dRika9m22vxlLVxKgmKJQX0bU3gS NO7g== 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 r25-v6si28066377pge.104.2018.07.16.00.46.08; Mon, 16 Jul 2018 00:46:22 -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 S2389470AbeGPIK4 (ORCPT + 99 others); Mon, 16 Jul 2018 04:10:56 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48310 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388522AbeGPIKy (ORCPT ); Mon, 16 Jul 2018 04:10:54 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 27A93CA1; Mon, 16 Jul 2018 07:44:51 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Borislav Petkov , Joerg Roedel , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , "Srivatsa S. Bhat" , "Matt Helsley (VMware)" , Alexey Makhalov , Bo Gan Subject: [PATCH 4.4 29/43] x86/cpufeature: Speed up cpu_feature_enabled() Date: Mon, 16 Jul 2018 09:36:34 +0200 Message-Id: <20180716073515.091090877@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180716073511.796555857@linuxfoundation.org> References: <20180716073511.796555857@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Borislav Petkov commit f2cc8e0791c70833758101d9756609a08dd601ec upstream When GCC cannot do constant folding for this macro, it falls back to cpu_has(). But static_cpu_has() is optimal and it works at all times now. So use it and speedup the fallback case. Before we had this: mov 0x99d674(%rip),%rdx # ffffffff81b0d9f4 shr $0x2e,%rdx and $0x1,%edx jne ffffffff811704e9 After alternatives patching, it turns into: jmp 0xffffffff81170390 nopl (%rax) ... callq ffffffff81056e00 ffffffff81170390: mov 0x170(%r12),%rdi Signed-off-by: Borislav Petkov Cc: Joerg Roedel Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1455578358-28347-1-git-send-email-bp@alien8.de Signed-off-by: Ingo Molnar Signed-off-by: Srivatsa S. Bhat Reviewed-by: Matt Helsley (VMware) Reviewed-by: Alexey Makhalov Reviewed-by: Bo Gan Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/cpufeature.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/arch/x86/include/asm/cpufeature.h +++ b/arch/x86/include/asm/cpufeature.h @@ -88,8 +88,7 @@ extern const char * const x86_bug_flags[ * is not relevant. */ #define cpu_feature_enabled(bit) \ - (__builtin_constant_p(bit) && DISABLED_MASK_BIT_SET(bit) ? 0 : \ - cpu_has(&boot_cpu_data, bit)) + (__builtin_constant_p(bit) && DISABLED_MASK_BIT_SET(bit) ? 0 : static_cpu_has(bit)) #define boot_cpu_has(bit) cpu_has(&boot_cpu_data, bit)