Blame SOURCES/rh1566890-CVE_2018_3639-speculative_store_bypass.patch

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