Blame SOURCES/rh1566890-CVE_2018_3639-speculative_store_bypass_toggle.patch

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