Blame SOURCES/rh1566890-CVE_2018_3639-speculative_store_bypass_toggle.patch

259888
diff --git openjdk.orig/hotspot/src/os/linux/vm/os_linux.cpp openjdk/hotspot/src/os/linux/vm/os_linux.cpp
259888
--- openjdk.orig/hotspot/src/os/linux/vm/os_linux.cpp
259888
+++ openjdk/hotspot/src/os/linux/vm/os_linux.cpp
259888
@@ -5001,26 +5001,43 @@
259888
 
259888
 /* Per task speculation control */
259888
 #ifndef PR_GET_SPECULATION_CTRL
259888
-#define PR_GET_SPECULATION_CTRL    52
259888
+# define PR_GET_SPECULATION_CTRL    52
259888
 #endif
259888
 #ifndef PR_SET_SPECULATION_CTRL
259888
-#define PR_SET_SPECULATION_CTRL    53
259888
+# define PR_SET_SPECULATION_CTRL    53
259888
 #endif
259888
 /* Speculation control variants */
259888
-# undef PR_SPEC_STORE_BYPASS
259888
+#ifndef PR_SPEC_STORE_BYPASS
259888
 # define PR_SPEC_STORE_BYPASS          0
259888
+#endif
259888
 /* Return and control values for PR_SET/GET_SPECULATION_CTRL */
259888
-# undef PR_SPEC_NOT_AFFECTED
259888
-# undef PR_SPEC_PRCTL
259888
-# undef PR_SPEC_ENABLE
259888
-# undef PR_SPEC_DISABLE
259888
+
259888
+#ifndef PR_SPEC_NOT_AFFECTED
259888
 # define PR_SPEC_NOT_AFFECTED          0
259888
+#endif
259888
+#ifndef PR_SPEC_PRCTL
259888
 # define PR_SPEC_PRCTL                 (1UL << 0)
259888
+#endif
259888
+#ifndef PR_SPEC_ENABLE
259888
 # define PR_SPEC_ENABLE                (1UL << 1)
259888
+#endif
259888
+#ifndef PR_SPEC_DISABLE
259888
 # define PR_SPEC_DISABLE               (1UL << 2)
259888
+#endif
259888
+#ifndef PR_SPEC_FORCE_DISABLE
259888
+# define PR_SPEC_FORCE_DISABLE         (1UL << 3)
259888
+#endif
259888
+#ifndef PR_SPEC_DISABLE_NOEXEC
259888
+# define PR_SPEC_DISABLE_NOEXEC        (1UL << 4)
259888
+#endif
259888
 
259888
 static void set_speculation() __attribute__((constructor));
259888
 static void set_speculation() {
259888
+  if ( prctl(PR_SET_SPECULATION_CTRL,
259888
+             PR_SPEC_STORE_BYPASS,
259888
+             PR_SPEC_DISABLE_NOEXEC, 0, 0) == 0 ) {
259888
+    return;
259888
+  }
259888
   prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_DISABLE, 0, 0);
259888
 }
259888