linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: tglx@linutronix.de
Cc: torvalds@linux-foundation.org, gregkh@linux-foundation.org,
	linux-kernel@vger.kernel.org, tim.c.chen@linux.intel.com,
	Andi Kleen <ak@linux.intel.com>,
	jpoimboe@redhat.com
Subject: [PATCH v2 12/12] retpoline: Attempt to quiten objtool warning for unreachable code
Date: Wed,  3 Jan 2018 18:00:19 -0800	[thread overview]
Message-ID: <20180104020019.1173-13-andi@firstfloor.org> (raw)
In-Reply-To: <20180104020019.1173-1-andi@firstfloor.org>

From: Andi Kleen <ak@linux.intel.com>

The speculative jump trampoline has to contain unreachable code.
objtool keeps complaining

arch/x86/lib/retpoline.o: warning: objtool: __x86.indirect_thunk()+0x8: unreachable instruction

I tried to fix it here by adding ASM_UNREACHABLE annotation (after
supporting them for pure assembler), but it still complains.
Seems like a objtool bug?

So it doesn't actually fix the warning oyet.
Of course it's just a warning so the kernel will still work fine.

Perhaps Josh can figure it out

Cc: jpoimboe@redhat.com
Not-Signed-off-by: Andi Kleen <ak@linux.intel.com>
---
 arch/x86/lib/retpoline.S |  3 +++
 include/linux/compiler.h | 10 +++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/arch/x86/lib/retpoline.S b/arch/x86/lib/retpoline.S
index cb40781adbfe..f4ed556a90ee 100644
--- a/arch/x86/lib/retpoline.S
+++ b/arch/x86/lib/retpoline.S
@@ -11,6 +11,7 @@
  */
 
 #include <linux/linkage.h>
+#include <linux/compiler.h>
 #include <asm/dwarf2.h>
 #include <asm/export.h>
 
@@ -21,7 +22,9 @@ ENTRY(__x86.indirect_thunk)
 	call	retpoline_call_target
 2:
 	lfence		/* stop speculation */
+	ASM_UNREACHABLE
 	jmp	2b
+	ASM_UNREACHABLE
 retpoline_call_target:
 #ifdef CONFIG_64BIT
 	lea	8(%rsp), %rsp
diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 52e611ab9a6c..cfba91acc79a 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -269,7 +269,15 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
 
 #endif /* __KERNEL__ */
 
-#endif /* __ASSEMBLY__ */
+#else /* __ASSEMBLY__ */
+
+#define ASM_UNREACHABLE \
+	999:						\
+	.pushsection .discard.unreachable;		\
+	.long 999b - .;					\
+	.popsection
+
+#endif /* !__ASSEMBLY__ */
 
 /* Compile time object size, -1 for unknown */
 #ifndef __compiletime_object_size
-- 
2.14.3

  parent reply	other threads:[~2018-01-04  2:00 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-04  2:00 Avoid speculative indirect calls in kernel Andi Kleen
2018-01-04  2:00 ` [PATCH v2 01/12] x86/retpoline: Define retpoline indirect thunk and macros Andi Kleen
2018-01-04  2:15   ` Brian Gerst
2018-01-04  2:32     ` Alan Cox
2018-01-04  2:00 ` [PATCH v2 02/12] x86/retpoline/crypto: Convert crypto assembler indirect jumps Andi Kleen
2018-01-04  2:00 ` [PATCH v2 03/12] x86/retpoline/entry: Convert entry " Andi Kleen
2018-01-04  8:42   ` David Woodhouse
2018-01-04  2:00 ` [PATCH v2 04/12] x86/retpoline/ftrace: Convert ftrace " Andi Kleen
2018-01-04  2:00 ` [PATCH v2 05/12] x86/retpoline/hyperv: Convert " Andi Kleen
2018-01-04  2:00 ` [PATCH v2 06/12] x86/retpoline/crypto: Convert xen " Andi Kleen
2018-01-04  6:48   ` Juergen Gross
2018-01-04  6:50     ` Andi Kleen
2018-01-04  2:00 ` [PATCH v2 07/12] x86/retpoline/checksum32: Convert " Andi Kleen
2018-01-04  2:00 ` [PATCH v2 08/12] x86/retpoline/irq32: " Andi Kleen
2018-01-04  2:00 ` [PATCH v2 09/12] x86/retpoline: Finally enable retpoline for C code Andi Kleen
2018-01-04  2:00 ` [PATCH v2 10/12] retpoline/taint: Taint kernel for missing retpoline in compiler Andi Kleen
2018-01-04  2:00 ` [PATCH v2 11/12] retpoline/objtool: Disable some objtool warnings Andi Kleen
2018-01-04 14:38   ` Josh Poimboeuf
2018-01-04 14:46     ` David Woodhouse
2018-01-04 15:59     ` Andi Kleen
2018-01-04 16:06       ` Josh Poimboeuf
2018-01-04 16:13         ` Andi Kleen
2018-01-04 16:32           ` Josh Poimboeuf
2018-01-04 17:35             ` Josh Poimboeuf
2018-01-04  2:00 ` Andi Kleen [this message]
2018-01-04 11:49 ` Avoid speculative indirect calls in kernel Pavel Machek
2018-01-04 12:09   ` Alan Cox
2018-01-04 13:32     ` Pavel Machek

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=20180104020019.1173-13-andi@firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=ak@linux.intel.com \
    --cc=gregkh@linux-foundation.org \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=tim.c.chen@linux.intel.com \
    --cc=torvalds@linux-foundation.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).