Blame SOURCES/rh1566890_speculative_store_bypass_so_added_more_per_task_speculation_control_CVE_2018_3639.patch

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