[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180104143710.8961-13-dwmw@amazon.co.uk>
Date: Thu, 4 Jan 2018 14:37:10 +0000
From: David Woodhouse <dwmw@...zon.co.uk>
To: ak@...ux.intel.com
Cc: Paul Turner <pjt@...gle.com>, LKML <linux-kernel@...r.kernel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Greg Kroah-Hartman <gregkh@...ux-foundation.org>,
Tim Chen <tim.c.chen@...ux.intel.com>,
Dave Hansen <dave.hansen@...el.com>, tglx@...utronix.de,
Kees Cook <keescook@...gle.com>,
Rik van Riel <riel@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Andy Lutomirski <luto@...capital.net>,
Jiri Kosina <jikos@...nel.org>, gnomes@...rguk.ukuu.org.uk,
jpoimboe@...hat.com
Subject: [PATCH v3 13/13] retpoline: Attempt to quiten objtool warning for unreachable code
From: Andi Kleen <ak@...ux.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@...hat.com
Not-Signed-off-by: Andi Kleen <ak@...ux.intel.com>
Not-Signed-off-by: David Woodhouse <dwmw@...zon.co.uk>
---
arch/x86/lib/retpoline.S | 5 +++++
include/linux/compiler.h | 10 +++++++++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/arch/x86/lib/retpoline.S b/arch/x86/lib/retpoline.S
index bbdda5cc136e..8112feaea6ff 100644
--- a/arch/x86/lib/retpoline.S
+++ b/arch/x86/lib/retpoline.S
@@ -2,6 +2,7 @@
#include <linux/stringify.h>
#include <linux/linkage.h>
+#include <linux/compiler.h>
#include <asm/dwarf2.h>
#include <asm/cpufeatures.h>
#include <asm/alternative-asm.h>
@@ -14,7 +15,9 @@ ENTRY(__x86.indirect_thunk.\reg)
ALTERNATIVE "call 2f", __stringify(jmp *%\reg), X86_BUG_NO_RETPOLINE
1:
lfence
+ ASM_UNREACHABLE
jmp 1b
+ ASM_UNREACHABLE
2:
mov %\reg, (%\sp)
ret
@@ -40,7 +43,9 @@ ENTRY(__x86.indirect_thunk)
ALTERNATIVE "call 2f", "ret", X86_BUG_NO_RETPOLINE
1:
lfence
+ ASM_UNREACHABLE
jmp 1b
+ ASM_UNREACHABLE
2:
lea 4(%esp), %esp
ret
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
Powered by blists - more mailing lists