Blame rh1566890-CVE_2018_3639-speculative_store_bypass.patch

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