From: Konrad Rzeszutek Wilk Date: Thu, 1 Feb 2018 16:45:41 +0000 (-0500) Subject: x86/spectre: Update sysctl values if toggled only by set_{ibrs,ibpb}_disabled X-Git-Tag: v4.1.12-124.31.3~1166 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=96c806884414eac9e46fafedf9ffa3da1c727eb2;p=users%2Fjedix%2Flinux-maple.git x86/spectre: Update sysctl values if toggled only by set_{ibrs,ibpb}_disabled As otherwise we will report the wrong values in the /sys/kernel/debug/x86/{ibrs,ipbp}_enabled at first bootup - that is if you have 'noibrs' on the command line. Orabug: 27477743 CVE: CVE-2017-5715 Signed-off-by: Konrad Rzeszutek Wilk Reviewed-by: Darren Kenny Reviewed-by: Pavel Tatashin --- diff --git a/arch/x86/include/asm/spec_ctrl.h b/arch/x86/include/asm/spec_ctrl.h index b3015fb3e63f..582e116f9eb5 100644 --- a/arch/x86/include/asm/spec_ctrl.h +++ b/arch/x86/include/asm/spec_ctrl.h @@ -254,12 +254,16 @@ static inline void set_ibrs_disabled(void) use_ibrs |= SPEC_CTRL_IBRS_ADMIN_DISABLED; if (check_ibrs_inuse()) clear_ibrs_inuse(); + /* Update what sysfs shows. */ + sysctl_ibrs_enabled = ibrs_inuse ? 1 : 0; } static inline void clear_ibrs_disabled(void) { use_ibrs &= ~SPEC_CTRL_IBRS_ADMIN_DISABLED; set_ibrs_inuse(); + /* Update what sysfs shows. */ + sysctl_ibrs_enabled = ibrs_inuse ? 1 : 0; } extern u32 sysctl_lfence_enabled; @@ -320,12 +324,16 @@ static inline void set_ibpb_disabled(void) use_ibpb |= 0x4; if (check_ibpb_inuse()) clear_ibpb_inuse(); + /* Update what sysfs shows. */ + sysctl_ibpb_enabled = ibpb_inuse ? 1 : 0; } static inline void clear_ibpb_disabled(void) { use_ibpb &= ~0x4; set_ibpb_inuse(); + /* Update what sysfs shows. */ + sysctl_ibpb_enabled = ibpb_inuse ? 1 : 0; } #endif /* __ASSEMBLY__ */ diff --git a/arch/x86/kernel/cpu/spec_ctrl.c b/arch/x86/kernel/cpu/spec_ctrl.c index c27c31cea4f0..9450e116bf59 100644 --- a/arch/x86/kernel/cpu/spec_ctrl.c +++ b/arch/x86/kernel/cpu/spec_ctrl.c @@ -81,8 +81,6 @@ static ssize_t ibrs_enabled_write(struct file *file, clear_ibrs_disabled(); } - sysctl_ibrs_enabled = enable; - mutex_unlock(&spec_ctrl_mutex); return count; } @@ -132,8 +130,6 @@ static ssize_t ibpb_enabled_write(struct file *file, else clear_ibpb_disabled(); - sysctl_ibpb_enabled = enable; - mutex_unlock(&spec_ctrl_mutex); return count; }