Blame SOURCES/rh1566890-CVE_2018_3639-speculative_store_bypass.patch

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