Blame SOURCES/rh1566890-CVE_2018_3639-speculative_store_bypass.patch

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