Commit 8a407c4e authored by Borislav Petkov (AMD)'s avatar Borislav Petkov (AMD) Committed by sanglipeng1
Browse files

Revert "x86/ftrace: Use alternative RET encoding"

stable inclusion
from stable-v5.10.211
commit c13d42604069d934cfa509dd23e974f9d10c9da2
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAF2J4

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=c13d42604069d934cfa509dd23e974f9d10c9da2



--------------------------------

This reverts commit 3eb602ad6a94a76941f93173131a71ad36fa1324.

Revert the backport of upstream commit

  1f001e9d ("x86/ftrace: Use alternative RET encoding")

in favor of a proper backport after backporting the commit which adds
__text_gen_insn().

Signed-off-by: default avatarBorislav Petkov (AMD) <bp@alien8.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarsanglipeng1 <sanglipeng1@jd.com>
parent 7f4bb6f1
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -311,7 +311,7 @@ union ftrace_op_code_union {
	} __attribute__((packed));
};

#define RET_SIZE		(IS_ENABLED(CONFIG_RETPOLINE) ? 5 : 1 + IS_ENABLED(CONFIG_SLS))
#define RET_SIZE		1 + IS_ENABLED(CONFIG_SLS)

static unsigned long
create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
@@ -367,12 +367,7 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size)
		goto fail;

	ip = trampoline + size;

	/* The trampoline ends with ret(q) */
	if (cpu_feature_enabled(X86_FEATURE_RETHUNK))
		memcpy(ip, text_gen_insn(JMP32_INSN_OPCODE, ip, &__x86_return_thunk), JMP32_INSN_SIZE);
	else
		memcpy(ip, retq, sizeof(retq));
	memcpy(ip, retq, RET_SIZE);

	/* No need to test direct calls on created trampolines */
	if (ops->flags & FTRACE_OPS_FL_SAVE_REGS) {