From: Alexandre Chartre <alexandre.chartre@oracle.com>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org, jpoimboe@redhat.com,
peterz@infradead.org, jthierry@redhat.com, tglx@linutronix.de,
alexandre.chartre@oracle.com
Subject: [PATCH 6/7] x86/speculation: Annotate retpoline return instructions
Date: Thu, 2 Apr 2020 10:22:19 +0200 [thread overview]
Message-ID: <20200402082220.808-7-alexandre.chartre@oracle.com> (raw)
In-Reply-To: <20200402082220.808-1-alexandre.chartre@oracle.com>
With retpoline, the return instruction (ret) is used to branch to an
address stored on the stack. Provide a macro to annotate such trampoline
returns so they can be properly handled by objtool, and use this macro
to annotate retpoline return instructions.
Signed-off-by: Alexandre Chartre <alexandre.chartre@oracle.com>
---
arch/x86/include/asm/nospec-branch.h | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h
index a2885f801e13..9ae6dde2f10b 100644
--- a/arch/x86/include/asm/nospec-branch.h
+++ b/arch/x86/include/asm/nospec-branch.h
@@ -91,6 +91,20 @@
call \dst
.endm
+/*
+ * Retpoline return instruction. This should be used as a substitute
+ * for the ret instruction when doing a trampoline return. It is
+ * similar to the ret instruction but it tells objtool this is a
+ * trampoline return.
+ */
+.macro RETPOLINE_RET
+ .Lannotate_\@:
+ .pushsection .discard.retpoline_ret
+ _ASM_PTR .Lannotate_\@
+ .popsection
+ ret
+.endm
+
/*
* These are the bare retpoline primitives for indirect jmp and call.
* Do not use these directly; they only exist to make the ALTERNATIVE
@@ -104,7 +118,7 @@
jmp .Lspec_trap_\@
.Ldo_rop_\@:
mov \reg, (%_ASM_SP)
- ret
+ RETPOLINE_RET
.endm
/*
--
2.18.2
next prev parent reply other threads:[~2020-04-02 8:19 UTC|newest]
Thread overview: 51+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-02 8:22 [PATCH 0/7] objtool changes to remove most ANNOTATE_NOSPEC_ALTERNATIVE Alexandre Chartre
2020-04-02 8:22 ` [PATCH 1/7] objtool: is_fentry_call() crashes if call has no destination Alexandre Chartre
2020-04-02 8:22 ` [PATCH 2/7] objtool: Allow branches within the same alternative Alexandre Chartre
2020-04-02 12:03 ` Julien Thierry
2020-04-02 12:38 ` Alexandre Chartre
2020-04-02 8:22 ` [PATCH 3/7] objtool: Add support for intra-function calls Alexandre Chartre
2020-04-02 12:53 ` Julien Thierry
2020-04-02 13:24 ` Alexandre Chartre
2020-04-02 13:38 ` Julien Thierry
2020-04-02 14:56 ` Alexandre Chartre
2020-04-02 15:04 ` Peter Zijlstra
2020-04-02 15:54 ` Josh Poimboeuf
2020-04-03 7:06 ` Alexandre Chartre
2020-04-02 15:49 ` Josh Poimboeuf
2020-04-02 17:27 ` Josh Poimboeuf
2020-04-03 8:01 ` Julien Thierry
2020-04-03 12:41 ` Peter Zijlstra
2020-04-03 12:49 ` Julien Thierry
2020-04-03 14:37 ` Peter Zijlstra
2020-04-03 14:44 ` Josh Poimboeuf
2020-04-02 8:22 ` [PATCH 4/7] objtool: Add support for return trampoline call Alexandre Chartre
2020-04-02 13:26 ` Julien Thierry
2020-04-02 14:46 ` Alexandre Chartre
2020-04-02 15:31 ` Julien Thierry
2020-04-02 15:40 ` Peter Zijlstra
2020-04-03 8:11 ` Julien Thierry
2020-04-03 15:17 ` Josh Poimboeuf
2020-04-03 15:22 ` Josh Poimboeuf
2020-04-03 15:32 ` Josh Poimboeuf
2020-04-03 15:46 ` Peter Zijlstra
2020-04-03 15:55 ` Josh Poimboeuf
2020-04-04 13:32 ` Peter Zijlstra
2020-04-04 14:22 ` Josh Poimboeuf
2020-04-04 15:51 ` Peter Zijlstra
2020-04-06 8:19 ` Alexandre Chartre
2020-04-06 9:31 ` Peter Zijlstra
2020-04-06 11:03 ` Alexandre Chartre
2020-04-06 14:16 ` Josh Poimboeuf
2020-04-02 15:27 ` Peter Zijlstra
2020-04-03 7:19 ` Alexandre Chartre
2020-04-06 14:34 ` Alexandre Chartre
2020-04-06 14:55 ` Alexandre Chartre
2020-04-02 8:22 ` [PATCH 5/7] x86/speculation: Annotate intra-function calls Alexandre Chartre
2020-04-03 16:05 ` Josh Poimboeuf
2020-04-03 16:16 ` Josh Poimboeuf
2020-04-03 17:14 ` Alexandre Chartre
2020-04-03 17:18 ` Peter Zijlstra
2020-04-03 17:24 ` Josh Poimboeuf
2020-04-03 18:20 ` Peter Zijlstra
2020-04-02 8:22 ` Alexandre Chartre [this message]
2020-04-02 8:22 ` [PATCH 7/7] x86/speculation: Remove most ANNOTATE_NOSPEC_ALTERNATIVE Alexandre Chartre
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=20200402082220.808-7-alexandre.chartre@oracle.com \
--to=alexandre.chartre@oracle.com \
--cc=jpoimboe@redhat.com \
--cc=jthierry@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--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