Blame SOURCES/rh1566890-CVE_2018_3639-speculative_store_bypass_toggle.patch

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