[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220716230954.470918864@linutronix.de>
Date: Sun, 17 Jul 2022 01:17:58 +0200 (CEST)
From: Thomas Gleixner <tglx@...utronix.de>
To: LKML <linux-kernel@...r.kernel.org>
Cc: x86@...nel.org, Linus Torvalds <torvalds@...ux-foundation.org>,
Tim Chen <tim.c.chen@...ux.intel.com>,
Josh Poimboeuf <jpoimboe@...nel.org>,
Andrew Cooper <Andrew.Cooper3@...rix.com>,
Pawan Gupta <pawan.kumar.gupta@...ux.intel.com>,
Johannes Wikner <kwikner@...z.ch>,
Alyssa Milburn <alyssa.milburn@...ux.intel.com>,
Jann Horn <jannh@...gle.com>, "H.J. Lu" <hjl.tools@...il.com>,
Joao Moreira <joao.moreira@...el.com>,
Joseph Nuzman <joseph.nuzman@...el.com>,
Steven Rostedt <rostedt@...dmis.org>
Subject: [patch 30/38] x86/retbleed: Add SKL call thunk
Add the actual SKL call thunk for call depth accounting.
Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
---
arch/x86/kernel/callthunks.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
--- a/arch/x86/kernel/callthunks.c
+++ b/arch/x86/kernel/callthunks.c
@@ -52,6 +52,24 @@ struct thunk_desc {
static struct thunk_desc callthunk_desc __ro_after_init;
+asm (
+ ".pushsection .rodata \n"
+ ".global skl_call_thunk_template \n"
+ "skl_call_thunk_template: \n"
+ __stringify(INCREMENT_CALL_DEPTH)" \n"
+ ".global skl_call_thunk_tail \n"
+ "skl_call_thunk_tail: \n"
+ ".popsection \n"
+);
+
+extern u8 skl_call_thunk_template[];
+extern u8 skl_call_thunk_tail[];
+
+#define SKL_TMPL_SIZE \
+ ((unsigned int)(skl_call_thunk_tail - skl_call_thunk_template))
+#define SKL_CALLTHUNK_CODE_SIZE (SKL_TMPL_SIZE + JMP32_INSN_SIZE + INT3_INSN_SIZE)
+#define SKL_CALLTHUNK_SIZE roundup_pow_of_two(SKL_CALLTHUNK_CODE_SIZE)
+
struct thunk_mem {
void *base;
unsigned int size;
@@ -447,6 +465,12 @@ static __init noinline void callthunks_i
{
int ret;
+ if (cpu_feature_enabled(X86_FEATURE_CALL_DEPTH)) {
+ callthunk_desc.template = skl_call_thunk_template;
+ callthunk_desc.template_size = SKL_TMPL_SIZE;
+ callthunk_desc.thunk_size = SKL_CALLTHUNK_SIZE;
+ }
+
if (!callthunk_desc.template)
return;
Powered by blists - more mailing lists