Blame rh1566890-CVE_2018_3639-speculative_store_bypass_toggle.patch

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