]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
Revert "UBUNTU: SAUCE: turn off IBPB when full retpoline is present"
authorAndy Whitcroft <apw@canonical.com>
Sun, 11 Feb 2018 10:18:38 +0000 (10:18 +0000)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 16 Feb 2018 17:43:10 +0000 (12:43 -0500)
CVE-2017-5715 (Spectre v2 Intel)

This reverts commit 4c04cc2c2dd1dd856238f53ee6f84b53f0c34caa.

Signed-off-by: Andy Whitcroft <apw@canonical.com>
arch/x86/kernel/cpu/bugs.c
include/linux/smp.h

index 5c36bd9aafe2e50759407b557b7196291440bfb1..8d04cbdd490fbfe5a64a039fe7097c34aa04a1c1 100644 (file)
@@ -231,17 +231,6 @@ retpoline_auto:
        spectre_v2_enabled = mode;
        pr_info("%s\n", spectre_v2_strings[mode]);
 
-       /*
-        * If we have a full retpoline mode and then disable IBPB in kernel mode
-        * we do not require both.
-        */
-       if (mode == SPECTRE_V2_RETPOLINE_AMD ||
-           mode == SPECTRE_V2_RETPOLINE_GENERIC)
-       {
-               pr_info("Retpoline compiled kernel disabling IBPB in kernel");
-               set_ibpb_retpoline_enabled();
-       }
-
        /*
         * If neither SMEP or KPTI are available, there is a risk of
         * hitting userspace addresses in the RSB after a context switch
@@ -290,7 +279,6 @@ ssize_t cpu_show_spectre_v2(struct device *dev,
        if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V2))
                return sprintf(buf, "Not affected\n");
 
-       return sprintf(buf, "%s%s\n", spectre_v2_strings[spectre_v2_enabled],
-                      ibpb_enabled_user ? ", IBPB (Intel v4)" : "");
+       return sprintf(buf, "%s\n", spectre_v2_strings[spectre_v2_enabled]);
 }
 #endif
index ce772a364389267db5656f96ca9faabfd63c67be..e2935c0a1bb4448d1e1dcb1c53b83fa2841cc1a4 100644 (file)
@@ -97,26 +97,20 @@ static inline void clear_ibrs_disabled(void)
 /* indicate usage of IBPB to control execution speculation */
 extern int use_ibpb;
 extern u32 sysctl_ibpb_enabled;
-/*      ibpb_enabled_kernel    (use_ibpb & 0x1) */
 #define ibpb_supported         (use_ibpb & 0x2)
 #define ibpb_disabled          (use_ibpb & 0x4)
-#define ibpb_retpoline_enabled  (use_ibpb & 0x8)
-#define ibpb_enabled_user      (use_ibpb & 0x10)
-static inline void sync_ibpb_inuse(void)
+static inline void set_ibpb_inuse(void)
 {
-       if (ibpb_supported && !ibpb_disabled) {
-               use_ibpb |= 0x10; /* Enable flushing on context/VM switch. */
-               if (!ibpb_retpoline_enabled)
-                       use_ibpb |= 0x1; /* Enable for kernel proper (entry). */
-               else
-                       use_ibpb &= ~0x1;
-       } else {
-               use_ibpb &= ~(0x10|0x1);
-       }
+       if (ibpb_supported)
+               use_ibpb |= 0x1;
+}
+static inline void clear_ibpb_inuse(void)
+{
+       use_ibpb &= ~0x1;
 }
 static inline int check_ibpb_inuse(void)
 {
-       if (use_ibpb & 0x10)
+       if (use_ibpb & 0x1)
                return 1;
        else
                /* rmb to prevent wrong speculation for security */
@@ -126,22 +120,19 @@ static inline int check_ibpb_inuse(void)
 static inline void set_ibpb_supported(void)
 {
        use_ibpb |= 0x2;
-       sync_ibpb_inuse();
+       if (!ibpb_disabled)
+               set_ibpb_inuse();
 }
 static inline void set_ibpb_disabled(void)
 {
        use_ibpb |= 0x4;
-       sync_ibpb_inuse();
+       if (check_ibpb_inuse())
+               clear_ibpb_inuse();
 }
 static inline void clear_ibpb_disabled(void)
 {
        use_ibpb &= ~0x4;
-       sync_ibpb_inuse();
-}
-static inline void set_ibpb_retpoline_enabled(void)
-{
-       use_ibpb |= 0x8;
-       sync_ibpb_inuse();
+       set_ibpb_inuse();
 }
 #define ibpb_inuse             (check_ibpb_inuse())
 #endif