提交 e9e215d4 编写于 作者: P Peter Zijlstra 提交者: Zheng Zengkai

x86: Prepare inline-asm for straight-line-speculation

stable inclusion
from stable-v5.10.133
commit 277f4ddc36c578691678b8ae59b60d76ad15fa1b
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5PTAS
CVE: CVE-2022-29900,CVE-2022-23816,CVE-2022-29901

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

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

commit b17c2baa upstream.

Replace all ret/retq instructions with ASM_RET in preparation of
making it more than a single instruction.
Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: NBorislav Petkov <bp@suse.de>
Link: https://lore.kernel.org/r/20211204134907.964635458@infradead.orgSigned-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
[bwh: Backported to 5.10: adjust context]
Signed-off-by: NBen Hutchings <ben@decadent.org.uk>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NLin Yujun <linyujun809@huawei.com>
Reviewed-by: NZhang Jianhua <chris.zjh@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 086cecf5
......@@ -18,6 +18,10 @@
#define __ALIGN_STR __stringify(__ALIGN)
#endif
#else /* __ASSEMBLY__ */
#define ASM_RET "ret\n\t"
#endif /* __ASSEMBLY__ */
#endif /* _ASM_X86_LINKAGE_H */
......
......@@ -630,7 +630,7 @@ bool __raw_callee_save___native_vcpu_is_preempted(long cpu);
"call " #func ";" \
PV_RESTORE_ALL_CALLER_REGS \
FRAME_END \
"ret;" \
ASM_RET \
".size " PV_THUNK_NAME(func) ", .-" PV_THUNK_NAME(func) ";" \
".popsection")
......
......@@ -48,7 +48,7 @@ asm (".pushsection .text;"
"jne .slowpath;"
"pop %rdx;"
FRAME_END
"ret;"
ASM_RET
".slowpath: "
"push %rsi;"
"movzbl %al,%esi;"
......@@ -56,7 +56,7 @@ asm (".pushsection .text;"
"pop %rsi;"
"pop %rdx;"
FRAME_END
"ret;"
ASM_RET
".size " PV_UNLOCK ", .-" PV_UNLOCK ";"
".popsection");
......
......@@ -819,7 +819,7 @@ asm (
" .type int3_magic, @function\n"
"int3_magic:\n"
" movl $1, (%" _ASM_ARG1 ")\n"
" ret\n"
ASM_RET
" .size int3_magic, .-int3_magic\n"
" .popsection\n"
);
......
......@@ -768,7 +768,7 @@ asm(
RESTORE_REGS_STRING
" popfl\n"
#endif
" ret\n"
ASM_RET
".size kretprobe_trampoline, .-kretprobe_trampoline\n"
);
NOKPROBE_SYMBOL(kretprobe_trampoline);
......
......@@ -40,7 +40,7 @@ extern void _paravirt_nop(void);
asm (".pushsection .entry.text, \"ax\"\n"
".global _paravirt_nop\n"
"_paravirt_nop:\n\t"
"ret\n\t"
ASM_RET
".size _paravirt_nop, . - _paravirt_nop\n\t"
".type _paravirt_nop, @function\n\t"
".popsection");
......
......@@ -316,7 +316,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
__FOP_FUNC(#name)
#define __FOP_RET(name) \
"ret \n\t" \
ASM_RET \
".size " name ", .-" name "\n\t"
#define FOP_RET(name) \
......@@ -437,7 +437,7 @@ static int fastop(struct x86_emulate_ctxt *ctxt, fastop_t fop);
asm(".pushsection .fixup, \"ax\"\n"
".global kvm_fastop_exception \n"
"kvm_fastop_exception: xor %esi, %esi; ret\n"
"kvm_fastop_exception: xor %esi, %esi; " ASM_RET
".popsection");
FOP_START(setcc)
......
// SPDX-License-Identifier: GPL-2.0
#include <linux/linkage.h>
#include <linux/error-injection.h>
#include <linux/kprobes.h>
......@@ -10,7 +11,7 @@ asm(
".type just_return_func, @function\n"
".globl just_return_func\n"
"just_return_func:\n"
" ret\n"
ASM_RET
".size just_return_func, .-just_return_func\n"
);
......
......@@ -31,7 +31,7 @@ asm (
" call my_direct_func1\n"
" leave\n"
" .size my_tramp1, .-my_tramp1\n"
" ret\n"
ASM_RET
" .type my_tramp2, @function\n"
" .globl my_tramp2\n"
" my_tramp2:"
......@@ -39,7 +39,7 @@ asm (
" movq %rsp, %rbp\n"
" call my_direct_func2\n"
" leave\n"
" ret\n"
ASM_RET
" .size my_tramp2, .-my_tramp2\n"
" .popsection\n"
);
......
......@@ -31,7 +31,7 @@ asm (
" popq %rsi\n"
" popq %rdi\n"
" leave\n"
" ret\n"
ASM_RET
" .size my_tramp, .-my_tramp\n"
" .popsection\n"
);
......
......@@ -24,7 +24,7 @@ asm (
" call my_direct_func\n"
" popq %rdi\n"
" leave\n"
" ret\n"
ASM_RET
" .size my_tramp, .-my_tramp\n"
" .popsection\n"
);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册