]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
x86/spectre: Update sysctl values if toggled only by set_{ibrs,ibpb}_disabled
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Thu, 1 Feb 2018 16:45:41 +0000 (11:45 -0500)
committerJack Vogel <jack.vogel@oracle.com>
Thu, 8 Feb 2018 18:15:03 +0000 (10:15 -0800)
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 <konrad.wilk@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Pavel Tatashin <pasha.tatashin@oracle.com>
arch/x86/include/asm/spec_ctrl.h
arch/x86/kernel/cpu/spec_ctrl.c

index b3015fb3e63fa631a066dbdd58a4781eab41d773..582e116f9eb57bd65a2e003a9b760860f44b040a 100644 (file)
@@ -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__ */
index c27c31cea4f0b6adc9fe0fd94c7e3585b0085151..9450e116bf598aeb69f9f8db6e3405bc9b17f165 100644 (file)
@@ -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;
 }