Commit bbaceb18 authored by Thomas Gleixner's avatar Thomas Gleixner Committed by Peter Zijlstra

x86/retbleed: Add SKL call thunk

Add the actual SKL call thunk for call depth accounting.
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220915111148.101125588@infradead.org
parent 3b6c1747
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <linux/moduleloader.h> #include <linux/moduleloader.h>
#include <asm/alternative.h> #include <asm/alternative.h>
#include <asm/asm-offsets.h>
#include <asm/cpu.h> #include <asm/cpu.h>
#include <asm/ftrace.h> #include <asm/ftrace.h>
#include <asm/insn.h> #include <asm/insn.h>
...@@ -55,7 +56,21 @@ static const struct core_text builtin_coretext = { ...@@ -55,7 +56,21 @@ static const struct core_text builtin_coretext = {
.name = "builtin", .name = "builtin",
}; };
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))
extern void error_entry(void); extern void error_entry(void);
extern void xen_error_entry(void); extern void xen_error_entry(void);
...@@ -157,11 +172,11 @@ static const u8 nops[] = { ...@@ -157,11 +172,11 @@ static const u8 nops[] = {
static __init_or_module void *patch_dest(void *dest, bool direct) static __init_or_module void *patch_dest(void *dest, bool direct)
{ {
unsigned int tsize = callthunk_desc.template_size; unsigned int tsize = SKL_TMPL_SIZE;
u8 *pad = dest - tsize; u8 *pad = dest - tsize;
/* Already patched? */ /* Already patched? */
if (!bcmp(pad, callthunk_desc.template, tsize)) if (!bcmp(pad, skl_call_thunk_template, tsize))
return pad; return pad;
/* Ensure there are nops */ /* Ensure there are nops */
...@@ -171,9 +186,9 @@ static __init_or_module void *patch_dest(void *dest, bool direct) ...@@ -171,9 +186,9 @@ static __init_or_module void *patch_dest(void *dest, bool direct)
} }
if (direct) if (direct)
memcpy(pad, callthunk_desc.template, tsize); memcpy(pad, skl_call_thunk_template, tsize);
else else
text_poke_copy_locked(pad, callthunk_desc.template, tsize, true); text_poke_copy_locked(pad, skl_call_thunk_template, tsize, true);
return pad; return pad;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment