Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1065367imu; Wed, 16 Jan 2019 12:08:07 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Kj5IF4bdwtH+kx4N1nRv5o8V2WJzBDEDYePfMKS78z8oPSss0lpD/p+FdvauKEd22p6gO X-Received: by 2002:a17:902:f64:: with SMTP id 91mr11659941ply.132.1547669287246; Wed, 16 Jan 2019 12:08:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547669287; cv=none; d=google.com; s=arc-20160816; b=aW7EYyQmzEhynEE/eY/gqeEzlLUfmHp9A7w924ctLW3/nC0mrShj7eeIbiykTwB4Un s64CxVcvciMqKZc/Gry1fyWjr2CrcaEegSU4TJ+PBD54pAX00iRuMaaTlBq+xsooAgx4 YTsAVQrvwNJb20qDxH5Co5txOJNMuabt+4qkwVb2SpEew5xu1WAhd+9bCuHwGqjLHGub stxwhAr1jQD8lqecN0kH7TsTsPTlickPsbAYLxohdhbyhPTGndhC1GOfggpIQnKW1x5j wFBL7a6CZM/QWpO2DP5nNDLMTeOI88Hm/OJ8x10JNksU0gbUnkCiwxg7vFBaI1nJmqXP RitA== 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=Lsztl0uvrPSLtxAs1XFNyHqtJmAX6y3lHyUs7Pp5a2M=; b=lsA6VkjEcyPOlRL/tedt5g7fkFpHi4iqHImqoNoQdICbQDeAaOLb8fRD3lOJ9W2IF4 u4n5L296u6Hi2bm+3/w+zZkFq1YYvgmGYzYLYaoHq5TOuxF5JPtakIVdyvIiZ1BCifJ3 cH8XBmqXmF49WdR02g2xuEtR20o1idN7xhme2WXJXKEoNsjX9XuDsfRnjqEEeF1+yBsc HZSAbtQm4JFp6yTdI9+AV1vhBTfTBAA6b6hSkufL4nLQgrPr7b668OojIDFEhyId52be DD6U17zFqoMgaTnh7IWzczq6iozVnMqMjN0uw6Aogha0D/mQtrDx2LPZLF1bpBcDi5U+ Pv8A== 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 k15si6612439pgi.99.2019.01.16.12.07.49; Wed, 16 Jan 2019 12:08:07 -0800 (PST) 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 S2389354AbfAPL72 (ORCPT + 99 others); Wed, 16 Jan 2019 06:59:28 -0500 Received: from terminus.zytor.com ([198.137.202.136]:39235 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732396AbfAPL72 (ORCPT ); Wed, 16 Jan 2019 06:59:28 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTPS id x0GBxDad252994 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NO); Wed, 16 Jan 2019 03:59:13 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id x0GBxDYT252991; Wed, 16 Jan 2019 03:59:13 -0800 Date: Wed, 16 Jan 2019 03:59:13 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Borislav Petkov Message-ID: Cc: x86@kernel.org, luto@amacapital.net, peterz@infradead.org, bp@suse.de, hpa@zytor.com, jpoimboe@redhat.com, linux-kernel@vger.kernel.org, thomas.lendacky@amd.com, mingo@kernel.org, tglx@linutronix.de Reply-To: mingo@kernel.org, tglx@linutronix.de, thomas.lendacky@amd.com, linux-kernel@vger.kernel.org, jpoimboe@redhat.com, hpa@zytor.com, bp@suse.de, peterz@infradead.org, luto@amacapital.net, x86@kernel.org In-Reply-To: <20181211222326.14581-4-bp@alien8.de> References: <20181211222326.14581-4-bp@alien8.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/alternatives] x86/alternatives: Add an ALTERNATIVE_3() macro Git-Commit-ID: 71a93c26930471e976dd184ef91931b2a5393afc 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=0.3 required=5.0 tests=ALL_TRUSTED,BAYES_00, DATE_IN_FUTURE_12_24 autolearn=no autolearn_force=no version=3.4.2 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: 71a93c26930471e976dd184ef91931b2a5393afc Gitweb: https://git.kernel.org/tip/71a93c26930471e976dd184ef91931b2a5393afc Author: Borislav Petkov AuthorDate: Mon, 10 Dec 2018 16:17:23 +0100 Committer: Borislav Petkov CommitDate: Wed, 16 Jan 2019 12:42:50 +0100 x86/alternatives: Add an ALTERNATIVE_3() macro Similar to ALTERNATIVE_2(), ALTERNATIVE_3() selects between 3 possible variants. Will be used for adding RDTSCP to the rdtsc_ordered() alternatives. Signed-off-by: Borislav Petkov Cc: Andy Lutomirski Cc: "H. Peter Anvin" Cc: Josh Poimboeuf Cc: Peter Zijlstra Cc: Tom Lendacky Cc: X86 ML Link: https://lkml.kernel.org/r/20181211222326.14581-4-bp@alien8.de --- arch/x86/include/asm/alternative.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h index 373e2baca6ce..4c74073a19cc 100644 --- a/arch/x86/include/asm/alternative.h +++ b/arch/x86/include/asm/alternative.h @@ -122,6 +122,16 @@ static inline int alternatives_text_reserved(void *start, void *end) "(" alt_max_short(alt_rlen(num1), alt_rlen(num2)) " - (" alt_slen ")), 0x90\n" \ alt_end_marker ":\n" +#define OLDINSTR_3(oldinsn, n1, n2, n3) \ + "# ALT: oldinstr3\n" \ + "661:\n\t" oldinsn "\n662:\n" \ + "# ALT: padding3\n" \ + ".skip -((" alt_max_short(alt_max_short(alt_rlen(n1), alt_rlen(n2)), alt_rlen(n3)) \ + " - (" alt_slen ")) > 0) * " \ + "(" alt_max_short(alt_max_short(alt_rlen(n1), alt_rlen(n2)), alt_rlen(n3)) \ + " - (" alt_slen ")), 0x90\n" \ + alt_end_marker ":\n" + #define ALTINSTR_ENTRY(feature, num) \ " .long 661b - .\n" /* label */ \ " .long " b_replacement(num)"f - .\n" /* new instruction */ \ @@ -155,6 +165,19 @@ static inline int alternatives_text_reserved(void *start, void *end) ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \ ".popsection\n" +#define ALTERNATIVE_3(oldinsn, newinsn1, feat1, newinsn2, feat2, newinsn3, feat3) \ + OLDINSTR_3(oldinsn, 1, 2, 3) \ + ".pushsection .altinstructions,\"a\"\n" \ + ALTINSTR_ENTRY(feat1, 1) \ + ALTINSTR_ENTRY(feat2, 2) \ + ALTINSTR_ENTRY(feat3, 3) \ + ".popsection\n" \ + ".pushsection .altinstr_replacement, \"ax\"\n" \ + ALTINSTR_REPLACEMENT(newinsn1, feat1, 1) \ + ALTINSTR_REPLACEMENT(newinsn2, feat2, 2) \ + ALTINSTR_REPLACEMENT(newinsn3, feat3, 3) \ + ".popsection\n" + /* * Alternative instructions for different CPU types or capabilities. *