Blame SOURCES/rh1566890-CVE_2018_3639-speculative_store_bypass.patch

9fd28f
diff --git openjdk.orig/hotspot/src/os/linux/vm/os_linux.cpp openjdk/hotspot/src/os/linux/vm/os_linux.cpp
9fd28f
--- openjdk.orig/hotspot/src/os/linux/vm/os_linux.cpp
9fd28f
+++ openjdk/hotspot/src/os/linux/vm/os_linux.cpp
9fd28f
@@ -103,6 +103,8 @@
b29910
 # include <inttypes.h>
b29910
 # include <sys/ioctl.h>
b29910
 
b29910
+#include <sys/prctl.h>
b29910
+
b29910
 PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC
b29910
 
b29910
 #ifndef _GNU_SOURCE
9fd28f
@@ -4997,6 +4999,31 @@
b29910
   }
b29910
 }
b29910
 
b29910
+/* Per task speculation control */
b29910
+#ifndef PR_GET_SPECULATION_CTRL
b29910
+#define PR_GET_SPECULATION_CTRL    52
b29910
+#endif
b29910
+#ifndef PR_SET_SPECULATION_CTRL
b29910
+#define PR_SET_SPECULATION_CTRL    53
b29910
+#endif
b29910
+/* Speculation control variants */
b29910
+# undef PR_SPEC_STORE_BYPASS
b29910
+# define PR_SPEC_STORE_BYPASS          0
b29910
+/* Return and control values for PR_SET/GET_SPECULATION_CTRL */
b29910
+# undef PR_SPEC_NOT_AFFECTED
b29910
+# undef PR_SPEC_PRCTL
b29910
+# undef PR_SPEC_ENABLE
b29910
+# undef PR_SPEC_DISABLE
b29910
+# define PR_SPEC_NOT_AFFECTED          0
b29910
+# define PR_SPEC_PRCTL                 (1UL << 0)
b29910
+# define PR_SPEC_ENABLE                (1UL << 1)
b29910
+# define PR_SPEC_DISABLE               (1UL << 2)
b29910
+
b29910
+static void set_speculation() __attribute__((constructor));
b29910
+static void set_speculation() {
b29910
+  prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_DISABLE, 0, 0);
b29910
+}
b29910
+
9fd28f
 // this is called _before_ most of the global arguments have been parsed
b29910
 void os::init(void) {
b29910
   char dummy;   /* used to get a guess on initial stack address */