Skip to content

Commit

Permalink
x86,static_call: Fix static-call vs return-thunk
Browse files Browse the repository at this point in the history
Commit

  7825451 ("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: ee88d36 ("x86,static_call: Use alternative RET encoding")
Reported-by: David Kaplan <David.Kaplan@amd.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Ingo Molnar <mingo@kernel.org>
Tested-by: Borislav Petkov (AMD) <bp@alien8.de>
Cc: <stable@kernel.org>
  • Loading branch information
Peter Zijlstra authored and Borislav Petkov (AMD) committed Sep 22, 2023
1 parent 4ba89dd commit aee9d30
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 3 additions & 0 deletions arch/x86/kernel/alternative.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,9 @@ void __init_or_module noinline apply_returns(s32 *start, s32 *end)
{
s32 *s;

if (cpu_feature_enabled(X86_FEATURE_RETHUNK))
static_call_force_reinit();

for (s = start; s < end; s++) {
void *dest = NULL, *addr = (void *)s + *s;
struct insn insn;
Expand Down
1 change: 0 additions & 1 deletion arch/x86/kernel/callthunks.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ void __init callthunks_patch_builtin_calls(void)
pr_info("Setting up call depth tracking\n");
mutex_lock(&text_mutex);
callthunks_setup(&cs, &builtin_coretext);
static_call_force_reinit();
thunks_initialized = true;
mutex_unlock(&text_mutex);
}
Expand Down

0 comments on commit aee9d30

Please sign in to comment.