62 lines
1.8 KiB
Diff
62 lines
1.8 KiB
Diff
|
diff --git openjdk/src/hotspot/os/linux/os_linux.cpp openjdk/src/hotspot/os/linux/os_linux.cpp
|
||
|
--- openjdk/src/hotspot/os/linux/os_linux.cpp
|
||
|
+++ openjdk/src/hotspot/os/linux/os_linux.cpp
|
||
|
@@ -107,6 +107,8 @@
|
||
|
# include <inttypes.h>
|
||
|
# include <sys/ioctl.h>
|
||
|
|
||
|
+#include <sys/prctl.h>
|
||
|
+
|
||
|
#ifndef _GNU_SOURCE
|
||
|
#define _GNU_SOURCE
|
||
|
#include <sched.h>
|
||
|
@@ -4984,6 +4986,48 @@
|
||
|
extern void report_error(char* file_name, int line_no, char* title,
|
||
|
char* format, ...);
|
||
|
|
||
|
+/* Per task speculation control */
|
||
|
+#ifndef PR_GET_SPECULATION_CTRL
|
||
|
+# define PR_GET_SPECULATION_CTRL 52
|
||
|
+#endif
|
||
|
+#ifndef PR_SET_SPECULATION_CTRL
|
||
|
+# define PR_SET_SPECULATION_CTRL 53
|
||
|
+#endif
|
||
|
+/* Speculation control variants */
|
||
|
+#ifndef PR_SPEC_STORE_BYPASS
|
||
|
+# define PR_SPEC_STORE_BYPASS 0
|
||
|
+#endif
|
||
|
+/* Return and control values for PR_SET/GET_SPECULATION_CTRL */
|
||
|
+
|
||
|
+#ifndef PR_SPEC_NOT_AFFECTED
|
||
|
+# define PR_SPEC_NOT_AFFECTED 0
|
||
|
+#endif
|
||
|
+#ifndef PR_SPEC_PRCTL
|
||
|
+# define PR_SPEC_PRCTL (1UL << 0)
|
||
|
+#endif
|
||
|
+#ifndef PR_SPEC_ENABLE
|
||
|
+# define PR_SPEC_ENABLE (1UL << 1)
|
||
|
+#endif
|
||
|
+#ifndef PR_SPEC_DISABLE
|
||
|
+# define PR_SPEC_DISABLE (1UL << 2)
|
||
|
+#endif
|
||
|
+#ifndef PR_SPEC_FORCE_DISABLE
|
||
|
+# define PR_SPEC_FORCE_DISABLE (1UL << 3)
|
||
|
+#endif
|
||
|
+#ifndef PR_SPEC_DISABLE_NOEXEC
|
||
|
+# define PR_SPEC_DISABLE_NOEXEC (1UL << 4)
|
||
|
+#endif
|
||
|
+
|
||
|
+static void set_speculation() __attribute__((constructor));
|
||
|
+static void set_speculation() {
|
||
|
+ if ( prctl(PR_SET_SPECULATION_CTRL,
|
||
|
+ PR_SPEC_STORE_BYPASS,
|
||
|
+ PR_SPEC_DISABLE_NOEXEC, 0, 0) == 0 ) {
|
||
|
+ return;
|
||
|
+ }
|
||
|
+ prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_DISABLE, 0, 0);
|
||
|
+}
|
||
|
+
|
||
|
// this is called _before_ most of the global arguments have been parsed
|
||
|
void os::init(void) {
|
||
|
char dummy; // used to get a guess on initial stack address
|