From: Andi Kleen <andi@firstfloor.org>
To: tglx@linutronix.de
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
torvalds@linux-foundation.org, dwmw@amazon.co.uk, pjt@google.com,
luto@kernel.org, peterz@infradead.org, thomas.lendacky@amd.com,
tim.c.chen@linux.intel.com, gregkh@linux-foundation.org,
dave.hansen@intel.com, jikos@kernel.org,
Andi Kleen <ak@linux.intel.com>
Subject: [PATCH v2 1/2] x86/retpoline: Add X86_FEATURE_RETPOLINE_COMMON and split RETPLINE/RETPOLINE_AMD
Date: Tue, 9 Jan 2018 17:56:00 -0800 [thread overview]
Message-ID: <20180110015601.27370-1-andi@firstfloor.org> (raw)
From: Andi Kleen <ak@linux.intel.com>
On 64bit we want to split X86_FEATURE_RETPOLINE and X86_FEATURE_RETPOLINE_AMD,
so that only one is set. This enables new simpler ALTERNATIVE sequences.
But 32bit requires a common flag because it uses common code for both.
So add a new X86_FEATURE_RETPOLINE_COMMON that is always set
when either X86_FEATURE_RETPOLINE or X86_FEATURE_RETPOLINE_AMD are set.
And then unset X86_FEATURE_RETPOLINE for AMD.
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
arch/x86/include/asm/cpufeatures.h | 1 +
arch/x86/kernel/cpu/bugs.c | 5 ++++-
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/cpufeatures.h b/arch/x86/include/asm/cpufeatures.h
index f275447862f4..54ec16ef08d8 100644
--- a/arch/x86/include/asm/cpufeatures.h
+++ b/arch/x86/include/asm/cpufeatures.h
@@ -211,6 +211,7 @@
#define X86_FEATURE_AVX512_4FMAPS ( 7*32+17) /* AVX-512 Multiply Accumulation Single precision */
#define X86_FEATURE_MBA ( 7*32+18) /* Memory Bandwidth Allocation */
+#define X86_FEATURE_RETPOLINE_COMMON ( 7*32+19) /* Common code for both RETPOLINE and RETPOLINE_AMD */
/* Virtualization flags: Linux defined, word 8 */
#define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */
diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
index b957f771a5b7..241eae66a86b 100644
--- a/arch/x86/kernel/cpu/bugs.c
+++ b/arch/x86/kernel/cpu/bugs.c
@@ -155,8 +155,10 @@ void __init spectre_v2_check_boottime_disable(void)
retpoline_generic:
spectre_v2_enabled = retp_compiler() ?
SPECTRE_V2_RETPOLINE_GENERIC : SPECTRE_V2_RETPOLINE_MINIMAL;
+ setup_force_cpu_cap(X86_FEATURE_RETPOLINE);
}
- setup_force_cpu_cap(X86_FEATURE_RETPOLINE);
+ setup_force_cpu_cap(X86_FEATURE_RETPOLINE_COMMON);
+
return;
#else
retpoline:
@@ -167,6 +169,7 @@ void __init spectre_v2_check_boottime_disable(void)
disable:
setup_clear_cpu_cap(X86_FEATURE_RETPOLINE);
setup_clear_cpu_cap(X86_FEATURE_RETPOLINE_AMD);
+ setup_clear_cpu_cap(X86_FEATURE_RETPOLINE_COMMON);
return;
}
--
2.14.3
next reply other threads:[~2018-01-10 1:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-10 1:56 Andi Kleen [this message]
2018-01-10 1:56 ` [PATCH v2 2/2] x86/retpoline: Use X86_RETPOLINE_COMMON to enable 32bit retpoline Andi Kleen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180110015601.27370-1-andi@firstfloor.org \
--to=andi@firstfloor.org \
--cc=ak@linux.intel.com \
--cc=dave.hansen@intel.com \
--cc=dwmw@amazon.co.uk \
--cc=gregkh@linux-foundation.org \
--cc=jikos@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=tglx@linutronix.de \
--cc=thomas.lendacky@amd.com \
--cc=tim.c.chen@linux.intel.com \
--cc=torvalds@linux-foundation.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).