Blame SOURCES/rh1566890-CVE_2018_3639-speculative_store_bypass.patch

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