Commit aee9d30b authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Borislav Petkov (AMD)

x86,static_call: Fix static-call vs return-thunk

Commit

  7825451f ("static_call: Add call depth tracking support")

failed to realize the problem fixed there is not specific to call depth
tracking but applies to all return-thunk uses.

Move the fix to the appropriate place and condition.

Fixes: ee88d363 ("x86,static_call: Use alternative RET encoding")
Reported-by: default avatarDavid Kaplan <David.Kaplan@amd.com>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: default avatarIngo Molnar <mingo@kernel.org>
Tested-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Cc: <stable@kernel.org>
parent 4ba89dd6
...@@ -720,6 +720,9 @@ void __init_or_module noinline apply_returns(s32 *start, s32 *end) ...@@ -720,6 +720,9 @@ void __init_or_module noinline apply_returns(s32 *start, s32 *end)
{ {
s32 *s; s32 *s;
if (cpu_feature_enabled(X86_FEATURE_RETHUNK))
static_call_force_reinit();
for (s = start; s < end; s++) { for (s = start; s < end; s++) {
void *dest = NULL, *addr = (void *)s + *s; void *dest = NULL, *addr = (void *)s + *s;
struct insn insn; struct insn insn;
......
...@@ -272,7 +272,6 @@ void __init callthunks_patch_builtin_calls(void) ...@@ -272,7 +272,6 @@ void __init callthunks_patch_builtin_calls(void)
pr_info("Setting up call depth tracking\n"); pr_info("Setting up call depth tracking\n");
mutex_lock(&text_mutex); mutex_lock(&text_mutex);
callthunks_setup(&cs, &builtin_coretext); callthunks_setup(&cs, &builtin_coretext);
static_call_force_reinit();
thunks_initialized = true; thunks_initialized = true;
mutex_unlock(&text_mutex); mutex_unlock(&text_mutex);
} }
......
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