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 v3 2/3] x86/retpoline: Use better sequences for NOSPEC_CALL/JMP
Date: Tue, 9 Jan 2018 18:28:30 -0800 [thread overview]
Message-ID: <20180110022831.29826-3-andi@firstfloor.org> (raw)
In-Reply-To: <20180110022831.29826-1-andi@firstfloor.org>
From: Andi Kleen <ak@linux.intel.com>
[This fixes a boot failure in the earlier patches
so may want to be moved earlier to keep git bisect
happy]
With the latest tip x86/pti I get oopses when booting
a 64bit VM in qemu with RETPOLINE/gcc7 and PTI enabled.
Something is wrong with the ALTERNATIVE_2 sequence
used in NOSPEC_JMP
Linus suggested a better sequence that is shorter
and simpler and avoids the problem.
It requires excluding X86_FEATURE_RETPOLINE and
X86_FEATURE_RETPOLINE_AMD, but that has been done
in the previous patch.
Use the new sequence for NOSPEC_CALL and NOSPEC_JMP.
v2: Use new sequence for CALL/RET. Add extra patch
for _COMMON.
v3: Use RETPOLINE_GENERIC for Intel
Fixes: ce004e1cb ("x86/retpoline: Add initial retpoline")
Fixes: f3433c101 ("x86/retpoline/entry: Convert entry")
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
arch/x86/include/asm/nospec-branch.h | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h
index 8ddf8513550e..dc13325a9890 100644
--- a/arch/x86/include/asm/nospec-branch.h
+++ b/arch/x86/include/asm/nospec-branch.h
@@ -46,9 +46,8 @@
*/
.macro JMP_NOSPEC reg:req
#ifdef CONFIG_RETPOLINE
- ALTERNATIVE_2 __stringify(jmp *\reg), \
- __stringify(RETPOLINE_JMP \reg), X86_FEATURE_RETPOLINE, \
- __stringify(lfence; jmp *\reg), X86_FEATURE_RETPOLINE_AMD
+ ALTERNATIVE "", "lfence", X86_FEATURE_RETPOLINE_AMD
+ ALTERNATIVE __stringify(jmp *\reg), __stringify(RETPOLINE_JMP \reg), X86_FEATURE_RETPOLINE_GENERIC
#else
jmp *\reg
#endif
@@ -56,9 +55,8 @@
.macro CALL_NOSPEC reg:req
#ifdef CONFIG_RETPOLINE
- ALTERNATIVE_2 __stringify(call *\reg), \
- __stringify(RETPOLINE_CALL \reg), X86_FEATURE_RETPOLINE,\
- __stringify(lfence; call *\reg), X86_FEATURE_RETPOLINE_AMD
+ ALTERNATIVE "", "lfence", X86_FEATURE_RETPOLINE_AMD
+ ALTERNATIVE __stringify(call *\reg), __stringify(RETPOLINE_CALL \reg), X86_FEATURE_RETPOLINE_GENERIC
#else
call *\reg
#endif
--
2.14.3
next prev parent reply other threads:[~2018-01-10 2:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-10 2:28 Update retpoline boot fix Andi Kleen
2018-01-10 2:28 ` [PATCH v3 1/3] x86/retpoline: Add X86_FEATURE_RETPOLINE_GENERIC Andi Kleen
2018-01-10 2:28 ` Andi Kleen [this message]
2018-01-10 13:26 ` [PATCH v3 2/3] x86/retpoline: Use better sequences for NOSPEC_CALL/JMP Woodhouse, David
2018-01-10 2:28 ` [PATCH v3 3/3] x86/retpoline: Convert generic specific retpolines to use RETPOLINE_GENERIC Andi Kleen
2018-01-10 13:15 ` Woodhouse, David
2018-01-10 14:23 ` Tom Lendacky
2018-01-10 14:46 ` Woodhouse, David
2018-01-10 15:18 ` Tom Lendacky
2018-01-10 15:20 ` Woodhouse, David
2018-01-10 10:41 ` Update retpoline boot fix Thomas Gleixner
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=20180110022831.29826-3-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
Powered by JetHome