From: Masami Hiramatsu <mhiramat@kernel.org>
To: Ingo Molnar <mingo@kernel.org>, David Woodhouse <dwmw@amazon.co.uk>
Cc: Masami Hiramatsu <mhiramat@kernel.org>,
linux-kernel@vger.kernel.org, Andi Kleen <ak@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linux-foundation.org>,
Arjan van de Ven <arjan@linux.intel.com>,
Peter Zijlstra <peterz@infradead.org>,
Ananth N Mavinakayanahalli <ananth@linux.vnet.ibm.com>,
Thomas Gleixner <tglx@linutronix.de>,
"H . Peter Anvin" <hpa@zytor.com>
Subject: [PATCH v1 tip/master 1/3] retpoline: Introduce start/end markers of indirect thunk
Date: Thu, 18 Jan 2018 21:01:19 +0900 [thread overview]
Message-ID: <151627687913.24682.16564356005083781238.stgit@devbox> (raw)
In-Reply-To: <151627684798.24682.2979775081582774869.stgit@devbox>
Introduce start/end markers of __x86_indirect_thunk_* functions.
These thunk functions are placed in .text.__x86.indirect_thunk.*
sections. So this puts those sections in the end of kernel text
and adds __indirect_thunk_start/end so that other subsystem
(e.g. kprobes) can identify it.
Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
arch/x86/include/asm/nospec-branch.h | 3 +++
arch/x86/kernel/vmlinux.lds.S | 35 ++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+)
diff --git a/arch/x86/include/asm/nospec-branch.h b/arch/x86/include/asm/nospec-branch.h
index 7b45d8424150..19ba5ad19c65 100644
--- a/arch/x86/include/asm/nospec-branch.h
+++ b/arch/x86/include/asm/nospec-branch.h
@@ -194,6 +194,9 @@ enum spectre_v2_mitigation {
SPECTRE_V2_IBRS,
};
+extern char __indirect_thunk_start[];
+extern char __indirect_thunk_end[];
+
/*
* On VMEXIT we must ensure that no RSB predictions learned in the guest
* can be followed in the host, by overwriting the RSB completely. Both
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index 1e413a9326aa..1a5a663620ce 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -74,6 +74,9 @@ jiffies_64 = jiffies;
#endif
+#define X86_INDIRECT_THUNK(reg) \
+ *(.text.__x86.indirect_thunk.##reg)
+
PHDRS {
text PT_LOAD FLAGS(5); /* R_E */
data PT_LOAD FLAGS(6); /* RW_ */
@@ -124,6 +127,38 @@ SECTIONS
ASSERT(. - _entry_trampoline == PAGE_SIZE, "entry trampoline is too big");
#endif
+#ifdef CONFIG_RETPOLINE
+ __indirect_thunk_start = .;
+#ifdef CONFIG_X86_64
+ X86_INDIRECT_THUNK(rax)
+ X86_INDIRECT_THUNK(rbx)
+ X86_INDIRECT_THUNK(rcx)
+ X86_INDIRECT_THUNK(rdx)
+ X86_INDIRECT_THUNK(rsi)
+ X86_INDIRECT_THUNK(rdi)
+ X86_INDIRECT_THUNK(rbp)
+ X86_INDIRECT_THUNK(rsp)
+ X86_INDIRECT_THUNK(r8)
+ X86_INDIRECT_THUNK(r9)
+ X86_INDIRECT_THUNK(r10)
+ X86_INDIRECT_THUNK(r11)
+ X86_INDIRECT_THUNK(r12)
+ X86_INDIRECT_THUNK(r13)
+ X86_INDIRECT_THUNK(r14)
+ X86_INDIRECT_THUNK(r15)
+#else
+ X86_INDIRECT_THUNK(eax)
+ X86_INDIRECT_THUNK(ebx)
+ X86_INDIRECT_THUNK(ecx)
+ X86_INDIRECT_THUNK(edx)
+ X86_INDIRECT_THUNK(esi)
+ X86_INDIRECT_THUNK(edi)
+ X86_INDIRECT_THUNK(ebp)
+ X86_INDIRECT_THUNK(esp)
+#endif
+ __indirect_thunk_end = .;
+#endif
+
/* End of text section */
_etext = .;
} :text = 0x9090
next prev parent reply other threads:[~2018-01-18 12:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-18 12:00 [PATCH v1 tip/master 0/3] kprobes/x86: retpoline: Fix kprobes for retpoline Masami Hiramatsu
2018-01-18 12:01 ` Masami Hiramatsu [this message]
2018-01-18 12:06 ` [PATCH v1 tip/master 1/3] retpoline: Introduce start/end markers of indirect thunk Woodhouse, David
2018-01-18 15:34 ` Masami Hiramatsu
2018-01-18 12:01 ` [PATCH v1 tip/master 2/3] kprobes/x86: Blacklist indirect thunk functions for kprobes Masami Hiramatsu
2018-01-18 12:02 ` [PATCH v1 tip/master 3/3] kprobes/x86: Disable optimizing on the function jumps to indirect thunk Masami Hiramatsu
2018-01-18 13:01 ` [PATCH v1 tip/master 0/3] kprobes/x86: retpoline: Fix kprobes for retpoline Andi Kleen
2018-01-18 13:03 ` David Woodhouse
2018-01-18 18:50 ` Andi Kleen
2018-01-18 15:36 ` Masami Hiramatsu
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=151627687913.24682.16564356005083781238.stgit@devbox \
--to=mhiramat@kernel.org \
--cc=ak@linux.intel.com \
--cc=ananth@linux.vnet.ibm.com \
--cc=arjan@linux.intel.com \
--cc=dwmw@amazon.co.uk \
--cc=gregkh@linux-foundation.org \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/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.