History

x86/speculation: Fix firmware entry SPEC_CTRL handling

The firmware entry code may accidentally clear STIBP or SSBD. Fix that.

Josh Poimboeuf committed 4 years ago

Commit e6aa1361 parent b2620fa1 file · +4 −6Browse files

Unified · Split

arch/x86/include/asm/nospec-branch.h+4−6
@@ -285,18 +285,16 @@ extern u64 spec_ctrl_current(void); · 284 unmodified lines
285 */285 */
286#define firmware_restrict_branch_speculation_start() \286#define firmware_restrict_branch_speculation_start() \
287do { \287do { \
288 u64 val = x86_spec_ctrl_base | SPEC_CTRL_IBRS; \
289 \
290 preempt_disable(); \288 preempt_disable(); \
291 alternative_msr_write(MSR_IA32_SPEC_CTRL, val, \289 alternative_msr_write(MSR_IA32_SPEC_CTRL, \
290 spec_ctrl_current() | SPEC_CTRL_IBRS, \
292 X86_FEATURE_USE_IBRS_FW); \291 X86_FEATURE_USE_IBRS_FW); \
293} while (0)292} while (0)
294 293
295#define firmware_restrict_branch_speculation_end() \294#define firmware_restrict_branch_speculation_end() \
296do { \295do { \
297 u64 val = x86_spec_ctrl_base; \296 alternative_msr_write(MSR_IA32_SPEC_CTRL, \
298 \297 spec_ctrl_current(), \
299 alternative_msr_write(MSR_IA32_SPEC_CTRL, val, \
300 X86_FEATURE_USE_IBRS_FW); \298 X86_FEATURE_USE_IBRS_FW); \
301 preempt_enable(); \299 preempt_enable(); \
302} while (0)300} while (0)