Blame SOURCES/rh1566890-CVE_2018_3639-speculative_store_bypass_toggle.patch

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