All of lore.kernel.org
 help / color / mirror / Atom feed
From: "tip-bot2 for Peter Zijlstra" <tip-bot2@linutronix.de>
To: linux-tip-commits@vger.kernel.org
Cc: "Peter Zijlstra (Intel)" <peterz@infradead.org>,
	Josh Poimboeuf <jpoimboe@redhat.com>, x86 <x86@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [tip: objtool/core] x86: Simplify retpoline declaration
Date: Fri, 01 May 2020 18:22:19 -0000	[thread overview]
Message-ID: <158835733956.8414.14836642152180567436.tip-bot2@tip-bot2> (raw)
In-Reply-To: <20200428191700.091696925@infradead.org>

The following commit has been merged into the objtool/core branch of tip:

Commit-ID:     ca3f0d80dd57c8828bfb5bc0bc79750ea7a1ba26
Gitweb:        https://git.kernel.org/tip/ca3f0d80dd57c8828bfb5bc0bc79750ea7a1ba26
Author:        Peter Zijlstra <peterz@infradead.org>
AuthorDate:    Wed, 22 Apr 2020 17:03:22 +02:00
Committer:     Peter Zijlstra <peterz@infradead.org>
CommitterDate: Thu, 30 Apr 2020 20:14:34 +02:00

x86: Simplify retpoline declaration

Because of how KSYM works, we need one declaration per line. Seeing
how we're going to be doubling the amount of retpoline symbols,
simplify the machinery in order to avoid having to copy/paste even
more.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lkml.kernel.org/r/20200428191700.091696925@infradead.org
---
 arch/x86/include/asm/GEN-for-each-reg.h | 25 ++++++++++++++++-
 arch/x86/include/asm/asm-prototypes.h   | 28 +++++-------------
 arch/x86/lib/retpoline.S                | 37 ++++++++++--------------
 3 files changed, 49 insertions(+), 41 deletions(-)
 create mode 100644 arch/x86/include/asm/GEN-for-each-reg.h

diff --git a/arch/x86/include/asm/GEN-for-each-reg.h b/arch/x86/include/asm/GEN-for-each-reg.h
new file mode 100644
index 0000000..1b07fb1
--- /dev/null
+++ b/arch/x86/include/asm/GEN-for-each-reg.h
@@ -0,0 +1,25 @@
+#ifdef CONFIG_64BIT
+GEN(rax)
+GEN(rbx)
+GEN(rcx)
+GEN(rdx)
+GEN(rsi)
+GEN(rdi)
+GEN(rbp)
+GEN(r8)
+GEN(r9)
+GEN(r10)
+GEN(r11)
+GEN(r12)
+GEN(r13)
+GEN(r14)
+GEN(r15)
+#else
+GEN(eax)
+GEN(ebx)
+GEN(ecx)
+GEN(edx)
+GEN(esi)
+GEN(edi)
+GEN(ebp)
+#endif
diff --git a/arch/x86/include/asm/asm-prototypes.h b/arch/x86/include/asm/asm-prototypes.h
index ce92c4a..aa7585e 100644
--- a/arch/x86/include/asm/asm-prototypes.h
+++ b/arch/x86/include/asm/asm-prototypes.h
@@ -17,24 +17,12 @@ extern void cmpxchg8b_emu(void);
 #endif
 
 #ifdef CONFIG_RETPOLINE
-#ifdef CONFIG_X86_32
-#define INDIRECT_THUNK(reg) extern asmlinkage void __x86_indirect_thunk_e ## reg(void);
-#else
-#define INDIRECT_THUNK(reg) extern asmlinkage void __x86_indirect_thunk_r ## reg(void);
-INDIRECT_THUNK(8)
-INDIRECT_THUNK(9)
-INDIRECT_THUNK(10)
-INDIRECT_THUNK(11)
-INDIRECT_THUNK(12)
-INDIRECT_THUNK(13)
-INDIRECT_THUNK(14)
-INDIRECT_THUNK(15)
-#endif
-INDIRECT_THUNK(ax)
-INDIRECT_THUNK(bx)
-INDIRECT_THUNK(cx)
-INDIRECT_THUNK(dx)
-INDIRECT_THUNK(si)
-INDIRECT_THUNK(di)
-INDIRECT_THUNK(bp)
+
+#define DECL_INDIRECT_THUNK(reg) \
+	extern asmlinkage void __x86_indirect_thunk_ ## reg (void);
+
+#undef GEN
+#define GEN(reg) DECL_INDIRECT_THUNK(reg)
+#include <asm/GEN-for-each-reg.h>
+
 #endif /* CONFIG_RETPOLINE */
diff --git a/arch/x86/lib/retpoline.S b/arch/x86/lib/retpoline.S
index 363ec13..9cc5480 100644
--- a/arch/x86/lib/retpoline.S
+++ b/arch/x86/lib/retpoline.S
@@ -24,25 +24,20 @@ SYM_FUNC_END(__x86_indirect_thunk_\reg)
  * only see one instance of "__x86_indirect_thunk_\reg" rather
  * than one per register with the correct names. So we do it
  * the simple and nasty way...
+ *
+ * Worse, you can only have a single EXPORT_SYMBOL per line,
+ * and CPP can't insert newlines, so we have to repeat everything
+ * at least twice.
  */
-#define __EXPORT_THUNK(sym) _ASM_NOKPROBE(sym); EXPORT_SYMBOL(sym)
-#define EXPORT_THUNK(reg) __EXPORT_THUNK(__x86_indirect_thunk_ ## reg)
-#define GENERATE_THUNK(reg) THUNK reg ; EXPORT_THUNK(reg)
-
-GENERATE_THUNK(_ASM_AX)
-GENERATE_THUNK(_ASM_BX)
-GENERATE_THUNK(_ASM_CX)
-GENERATE_THUNK(_ASM_DX)
-GENERATE_THUNK(_ASM_SI)
-GENERATE_THUNK(_ASM_DI)
-GENERATE_THUNK(_ASM_BP)
-#ifdef CONFIG_64BIT
-GENERATE_THUNK(r8)
-GENERATE_THUNK(r9)
-GENERATE_THUNK(r10)
-GENERATE_THUNK(r11)
-GENERATE_THUNK(r12)
-GENERATE_THUNK(r13)
-GENERATE_THUNK(r14)
-GENERATE_THUNK(r15)
-#endif
+
+#define __EXPORT_THUNK(sym)	_ASM_NOKPROBE(sym); EXPORT_SYMBOL(sym)
+#define EXPORT_THUNK(reg)	__EXPORT_THUNK(__x86_indirect_thunk_ ## reg)
+
+#undef GEN
+#define GEN(reg) THUNK reg
+#include <asm/GEN-for-each-reg.h>
+
+#undef GEN
+#define GEN(reg) EXPORT_THUNK(reg)
+#include <asm/GEN-for-each-reg.h>
+

  reply	other threads:[~2020-05-01 18:22 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28 19:11 [PATCH v2 00/14] objtool vs retpoline Peter Zijlstra
2020-04-28 19:11 ` [PATCH v2 01/14] objtool: Allow branches within the same alternative Peter Zijlstra
2020-04-28 19:53   ` Josh Poimboeuf
2020-04-28 19:11 ` [PATCH v2 02/14] objtool: Fix ORC vs alternatives Peter Zijlstra
2020-04-28 19:55   ` Josh Poimboeuf
2020-04-29 14:33   ` Miroslav Benes
2020-04-29 15:51     ` Peter Zijlstra
2020-04-29 16:41       ` Miroslav Benes
2020-05-01 18:22   ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2020-04-28 19:11 ` [PATCH v2 03/14] x86,smap: Fix smap_{save,restore}() alternatives Peter Zijlstra
2020-04-29  0:54   ` Brian Gerst
2020-04-29  8:30     ` Peter Zijlstra
2020-04-29 10:18       ` Peter Zijlstra
2020-04-29 12:12         ` Brian Gerst
2020-05-01 18:22         ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2020-04-28 19:11 ` [PATCH v2 04/14] objtool: is_fentry_call() crashes if call has no destination Peter Zijlstra
2020-04-28 19:11 ` [PATCH v2 05/14] objtool: UNWIND_HINT_RET_OFFSET should not check registers Peter Zijlstra
2020-04-28 19:11 ` [PATCH v2 06/14] objtool: Rework allocating stack_ops on decode Peter Zijlstra
2020-05-01 18:22   ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2020-04-28 19:11 ` [PATCH v2 07/14] objtool: Make handle_insn_ops() unconditional Peter Zijlstra
2020-05-01 18:22   ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2020-05-07 12:38     ` Peter Zijlstra
2020-04-28 19:11 ` [PATCH v2 08/14] objtool: Remove INSN_STACK Peter Zijlstra
2020-05-01 18:22   ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2020-04-28 19:11 ` [PATCH v2 09/14] objtool: Move the IRET hack into the arch decoder Peter Zijlstra
2020-05-01 18:22   ` [tip: objtool/core] " tip-bot2 for Miroslav Benes
2020-04-28 19:11 ` [PATCH v2 10/14] objtool: Add support for intra-function calls Peter Zijlstra
2020-04-28 19:11 ` [PATCH v2 11/14] x86/speculation: Change FILL_RETURN_BUFFER to work with objtool Peter Zijlstra
2020-05-01 18:22   ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2020-04-28 19:11 ` [PATCH v2 12/14] x86: Simplify retpoline declaration Peter Zijlstra
2020-05-01 18:22   ` tip-bot2 for Peter Zijlstra [this message]
2020-04-28 19:11 ` [PATCH v2 13/14] x86: Change {JMP,CALL}_NOSPEC argument Peter Zijlstra
2020-05-01 18:22   ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2020-04-28 19:11 ` [PATCH v2 14/14] x86/retpoline: Fix retpoline unwind Peter Zijlstra
2020-05-01 18:22   ` [tip: objtool/core] " tip-bot2 for Peter Zijlstra
2020-04-28 20:17 ` [PATCH v2 00/14] objtool vs retpoline Josh Poimboeuf
2020-04-29 10:19 ` [PATCH v2.1 01-A/14] objtool: Remove check preventing branches within alternative Peter Zijlstra
2020-04-29 10:21 ` [PATCH v2.1 01-B/14] objtool: Uniquely identify alternative instruction groups Peter Zijlstra
2020-04-29 16:46 ` [PATCH v2 00/14] objtool vs retpoline Miroslav Benes

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=158835733956.8414.14836642152180567436.tip-bot2@tip-bot2 \
    --to=tip-bot2@linutronix.de \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=peterz@infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.