提交 2b5fdd28 编写于 作者: J Josh Poimboeuf 提交者: Zheng Zengkai

x86/speculation: Fix firmware entry SPEC_CTRL handling

stable inclusion
from stable-v5.10.133
commit d29c07912a49fce965228f73a293e2c899bc7e35
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=d29c07912a49fce965228f73a293e2c899bc7e35

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

commit e6aa1362 upstream.

The firmware entry code may accidentally clear STIBP or SSBD. Fix that.
Signed-off-by: NJosh Poimboeuf <jpoimboe@kernel.org>
Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: NBorislav Petkov <bp@suse.de>
Signed-off-by: NThadeu Lima de Souza Cascardo <cascardo@canonical.com>
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>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 1f6f2370
...@@ -293,18 +293,16 @@ extern u64 spec_ctrl_current(void); ...@@ -293,18 +293,16 @@ extern u64 spec_ctrl_current(void);
*/ */
#define firmware_restrict_branch_speculation_start() \ #define firmware_restrict_branch_speculation_start() \
do { \ do { \
u64 val = x86_spec_ctrl_base | SPEC_CTRL_IBRS; \
\
preempt_disable(); \ preempt_disable(); \
alternative_msr_write(MSR_IA32_SPEC_CTRL, val, \ alternative_msr_write(MSR_IA32_SPEC_CTRL, \
spec_ctrl_current() | SPEC_CTRL_IBRS, \
X86_FEATURE_USE_IBRS_FW); \ X86_FEATURE_USE_IBRS_FW); \
} while (0) } while (0)
#define firmware_restrict_branch_speculation_end() \ #define firmware_restrict_branch_speculation_end() \
do { \ do { \
u64 val = x86_spec_ctrl_base; \ alternative_msr_write(MSR_IA32_SPEC_CTRL, \
\ spec_ctrl_current(), \
alternative_msr_write(MSR_IA32_SPEC_CTRL, val, \
X86_FEATURE_USE_IBRS_FW); \ X86_FEATURE_USE_IBRS_FW); \
preempt_enable(); \ preempt_enable(); \
} while (0) } while (0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册