Skip to content

Commit aee9d30

Browse files
Peter Zijlstrabp3tk0v
authored andcommitted
x86,static_call: Fix static-call vs return-thunk
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>
1 parent 4ba89dd commit aee9d30

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

arch/x86/kernel/alternative.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,9 @@ void __init_or_module noinline apply_returns(s32 *start, s32 *end)
720720
{
721721
s32 *s;
722722

723+
if (cpu_feature_enabled(X86_FEATURE_RETHUNK))
724+
static_call_force_reinit();
725+
723726
for (s = start; s < end; s++) {
724727
void *dest = NULL, *addr = (void *)s + *s;
725728
struct insn insn;

arch/x86/kernel/callthunks.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ void __init callthunks_patch_builtin_calls(void)
272272
pr_info("Setting up call depth tracking\n");
273273
mutex_lock(&text_mutex);
274274
callthunks_setup(&cs, &builtin_coretext);
275-
static_call_force_reinit();
276275
thunks_initialized = true;
277276
mutex_unlock(&text_mutex);
278277
}

0 commit comments

Comments
 (0)