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

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
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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;
+0 −1
Original line number Diff line number Diff line
@@ -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);
}