Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932077AbeADOmd (ORCPT + 1 other); Thu, 4 Jan 2018 09:42:33 -0500 Received: from merlin.infradead.org ([205.233.59.134]:46828 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753253AbeADOh1 (ORCPT ); Thu, 4 Jan 2018 09:37:27 -0500 From: David Woodhouse To: ak@linux.intel.com Cc: Paul Turner , LKML , Linus Torvalds , Greg Kroah-Hartman , Tim Chen , Dave Hansen , tglx@linutronix.de, Kees Cook , Rik van Riel , Peter Zijlstra , Andy Lutomirski , Jiri Kosina , gnomes@lxorguk.ukuu.org.uk, jpoimboe@redhat.com Subject: [PATCH v3 13/13] retpoline: Attempt to quiten objtool warning for unreachable code Date: Thu, 4 Jan 2018 14:37:10 +0000 Message-Id: <20180104143710.8961-13-dwmw@amazon.co.uk> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180104143710.8961-1-dwmw@amazon.co.uk> References: <20180104143710.8961-1-dwmw@amazon.co.uk> In-Reply-To: <1515058213.12987.89.camel@amazon.co.uk> References: <1515058213.12987.89.camel@amazon.co.uk> X-SRS-Rewrite: SMTP reverse-path rewritten from by merlin.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: From: Andi Kleen 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 Not-Signed-off-by: David Woodhouse --- 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 #include +#include #include #include #include @@ -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