Blame SOURCES/rh1566890-CVE_2018_3639-speculative_store_bypass.patch

8eabd2
diff --git openjdk/src/hotspot/os/linux/os_linux.cpp openjdk/src/hotspot/os/linux/os_linux.cpp
8eabd2
--- openjdk/src/hotspot/os/linux/os_linux.cpp
8eabd2
+++ openjdk/src/hotspot/os/linux/os_linux.cpp
8eabd2
@@ -107,6 +107,8 @@
8eabd2
 # include <inttypes.h>
8eabd2
 # include <sys/ioctl.h>
8eabd2
 
8eabd2
+#include <sys/prctl.h>
8eabd2
+
8eabd2
 #ifndef _GNU_SOURCE
8eabd2
   #define _GNU_SOURCE
8eabd2
   #include <sched.h>
8eabd2
@@ -4984,6 +4986,48 @@
8eabd2
 extern void report_error(char* file_name, int line_no, char* title,
8eabd2
                          char* format, ...);
8eabd2
 
8eabd2
+/* Per task speculation control */
8eabd2
+#ifndef PR_GET_SPECULATION_CTRL
8eabd2
+# define PR_GET_SPECULATION_CTRL    52
8eabd2
+#endif
8eabd2
+#ifndef PR_SET_SPECULATION_CTRL
8eabd2
+# define PR_SET_SPECULATION_CTRL    53
8eabd2
+#endif
8eabd2
+/* Speculation control variants */
8eabd2
+#ifndef PR_SPEC_STORE_BYPASS
8eabd2
+# define PR_SPEC_STORE_BYPASS          0
8eabd2
+#endif
8eabd2
+/* Return and control values for PR_SET/GET_SPECULATION_CTRL */
8eabd2
+
8eabd2
+#ifndef PR_SPEC_NOT_AFFECTED
8eabd2
+# define PR_SPEC_NOT_AFFECTED          0
8eabd2
+#endif
8eabd2
+#ifndef PR_SPEC_PRCTL
8eabd2
+# define PR_SPEC_PRCTL                 (1UL << 0)
8eabd2
+#endif
8eabd2
+#ifndef PR_SPEC_ENABLE
8eabd2
+# define PR_SPEC_ENABLE                (1UL << 1)
8eabd2
+#endif
8eabd2
+#ifndef PR_SPEC_DISABLE
8eabd2
+# define PR_SPEC_DISABLE               (1UL << 2)
8eabd2
+#endif
8eabd2
+#ifndef PR_SPEC_FORCE_DISABLE
8eabd2
+# define PR_SPEC_FORCE_DISABLE         (1UL << 3)
8eabd2
+#endif
8eabd2
+#ifndef PR_SPEC_DISABLE_NOEXEC
8eabd2
+# define PR_SPEC_DISABLE_NOEXEC        (1UL << 4)
8eabd2
+#endif
8eabd2
+
8eabd2
+static void set_speculation() __attribute__((constructor));
8eabd2
+static void set_speculation() {
8eabd2
+  if ( prctl(PR_SET_SPECULATION_CTRL,
8eabd2
+             PR_SPEC_STORE_BYPASS,
8eabd2
+             PR_SPEC_DISABLE_NOEXEC, 0, 0) == 0 ) {
8eabd2
+    return;
8eabd2
+  }
8eabd2
+  prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_DISABLE, 0, 0);
8eabd2
+}
8eabd2
+
8eabd2
 // this is called _before_ most of the global arguments have been parsed
8eabd2
 void os::init(void) {
8eabd2
   char dummy;   // used to get a guess on initial stack address