|
|
d1af5a |
diff --git openjdk.orig/make/modules/java.base/Launcher.gmk openjdk/make/modules/java.base/Launcher.gmk
|
|
|
d1af5a |
index 700ddefda49..2882de68eb2 100644
|
|
|
d1af5a |
--- openjdk.orig/make/modules/java.base/Launcher.gmk
|
|
|
d1af5a |
+++ openjdk/make/modules/java.base/Launcher.gmk
|
|
|
d1af5a |
@@ -41,6 +41,14 @@ $(eval $(call SetupBuildLauncher, java, \
|
|
|
d1af5a |
OPTIMIZATION := HIGH, \
|
|
|
d1af5a |
))
|
|
|
d1af5a |
|
|
|
d1af5a |
+#Wno-error=cpp is present to allow commented warning in ifdef part of main.c
|
|
|
d1af5a |
+$(eval $(call SetupBuildLauncher, alt-java, \
|
|
|
d1af5a |
+ CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS -DENABLE_ARG_FILES -DREDHAT_ALT_JAVA -Wno-error=cpp, \
|
|
|
d1af5a |
+ EXTRA_RCFLAGS := $(JAVA_RCFLAGS), \
|
|
|
d1af5a |
+ VERSION_INFO_RESOURCE := $(JAVA_VERSION_INFO_RESOURCE), \
|
|
|
d1af5a |
+ OPTIMIZATION := HIGH, \
|
|
|
d1af5a |
+))
|
|
|
d1af5a |
+
|
|
|
d1af5a |
ifeq ($(call isTargetOs, windows), true)
|
|
|
d1af5a |
$(eval $(call SetupBuildLauncher, javaw, \
|
|
|
d1af5a |
CFLAGS := -DJAVAW -DEXPAND_CLASSPATH_WILDCARDS -DENABLE_ARG_FILES, \
|
|
|
d1af5a |
diff --git openjdk.orig/src/java.base/share/native/launcher/alt_main.h openjdk/src/java.base/share/native/launcher/alt_main.h
|
|
|
d1af5a |
new file mode 100644
|
|
|
d1af5a |
index 00000000000..697df2898ac
|
|
|
d1af5a |
--- /dev/null
|
|
|
d1af5a |
+++ openjdk/src/java.base/share/native/launcher/alt_main.h
|
|
|
d1af5a |
@@ -0,0 +1,73 @@
|
|
|
d1af5a |
+/*
|
|
|
d1af5a |
+ * Copyright (c) 2019, Red Hat, Inc. All rights reserved.
|
|
|
d1af5a |
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
d1af5a |
+ *
|
|
|
d1af5a |
+ * This code is free software; you can redistribute it and/or modify it
|
|
|
d1af5a |
+ * under the terms of the GNU General Public License version 2 only, as
|
|
|
d1af5a |
+ * published by the Free Software Foundation. Oracle designates this
|
|
|
d1af5a |
+ * particular file as subject to the "Classpath" exception as provided
|
|
|
d1af5a |
+ * by Oracle in the LICENSE file that accompanied this code.
|
|
|
d1af5a |
+ *
|
|
|
d1af5a |
+ * This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
d1af5a |
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
d1af5a |
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
d1af5a |
+ * version 2 for more details (a copy is included in the LICENSE file that
|
|
|
d1af5a |
+ * accompanied this code).
|
|
|
d1af5a |
+ *
|
|
|
d1af5a |
+ * You should have received a copy of the GNU General Public License version
|
|
|
d1af5a |
+ * 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
d1af5a |
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
d1af5a |
+ *
|
|
|
d1af5a |
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
d1af5a |
+ * or visit www.oracle.com if you need additional information or have any
|
|
|
d1af5a |
+ * questions.
|
|
|
d1af5a |
+ */
|
|
|
d1af5a |
+
|
|
|
d1af5a |
+#ifdef REDHAT_ALT_JAVA
|
|
|
d1af5a |
+
|
|
|
d1af5a |
+#include <sys/prctl.h>
|
|
|
d1af5a |
+
|
|
|
d1af5a |
+
|
|
|
d1af5a |
+/* Per task speculation control */
|
|
|
d1af5a |
+#ifndef PR_GET_SPECULATION_CTRL
|
|
|
d1af5a |
+# define PR_GET_SPECULATION_CTRL 52
|
|
|
d1af5a |
+#endif
|
|
|
d1af5a |
+#ifndef PR_SET_SPECULATION_CTRL
|
|
|
d1af5a |
+# define PR_SET_SPECULATION_CTRL 53
|
|
|
d1af5a |
+#endif
|
|
|
d1af5a |
+/* Speculation control variants */
|
|
|
d1af5a |
+#ifndef PR_SPEC_STORE_BYPASS
|
|
|
d1af5a |
+# define PR_SPEC_STORE_BYPASS 0
|
|
|
d1af5a |
+#endif
|
|
|
d1af5a |
+/* Return and control values for PR_SET/GET_SPECULATION_CTRL */
|
|
|
d1af5a |
+
|
|
|
d1af5a |
+#ifndef PR_SPEC_NOT_AFFECTED
|
|
|
d1af5a |
+# define PR_SPEC_NOT_AFFECTED 0
|
|
|
d1af5a |
+#endif
|
|
|
d1af5a |
+#ifndef PR_SPEC_PRCTL
|
|
|
d1af5a |
+# define PR_SPEC_PRCTL (1UL << 0)
|
|
|
d1af5a |
+#endif
|
|
|
d1af5a |
+#ifndef PR_SPEC_ENABLE
|
|
|
d1af5a |
+# define PR_SPEC_ENABLE (1UL << 1)
|
|
|
d1af5a |
+#endif
|
|
|
d1af5a |
+#ifndef PR_SPEC_DISABLE
|
|
|
d1af5a |
+# define PR_SPEC_DISABLE (1UL << 2)
|
|
|
d1af5a |
+#endif
|
|
|
d1af5a |
+#ifndef PR_SPEC_FORCE_DISABLE
|
|
|
d1af5a |
+# define PR_SPEC_FORCE_DISABLE (1UL << 3)
|
|
|
d1af5a |
+#endif
|
|
|
d1af5a |
+#ifndef PR_SPEC_DISABLE_NOEXEC
|
|
|
d1af5a |
+# define PR_SPEC_DISABLE_NOEXEC (1UL << 4)
|
|
|
d1af5a |
+#endif
|
|
|
d1af5a |
+
|
|
|
d1af5a |
+static void set_speculation() __attribute__((constructor));
|
|
|
d1af5a |
+static void set_speculation() {
|
|
|
d1af5a |
+ if ( prctl(PR_SET_SPECULATION_CTRL,
|
|
|
d1af5a |
+ PR_SPEC_STORE_BYPASS,
|
|
|
d1af5a |
+ PR_SPEC_DISABLE_NOEXEC, 0, 0) == 0 ) {
|
|
|
d1af5a |
+ return;
|
|
|
d1af5a |
+ }
|
|
|
d1af5a |
+ prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_DISABLE, 0, 0);
|
|
|
d1af5a |
+}
|
|
|
d1af5a |
+
|
|
|
d1af5a |
+#endif // REDHAT_ALT_JAVA
|
|
|
d1af5a |
diff --git openjdk.orig/src/java.base/share/native/launcher/main.c openjdk/src/java.base/share/native/launcher/main.c
|
|
|
d1af5a |
index b734fe2ba78..79dc8307650 100644
|
|
|
d1af5a |
--- openjdk.orig/src/java.base/share/native/launcher/main.c
|
|
|
d1af5a |
+++ openjdk/src/java.base/share/native/launcher/main.c
|
|
|
d1af5a |
@@ -34,6 +34,14 @@
|
|
|
d1af5a |
#include "jli_util.h"
|
|
|
d1af5a |
#include "jni.h"
|
|
|
d1af5a |
|
|
|
d1af5a |
+#ifdef REDHAT_ALT_JAVA
|
|
|
d1af5a |
+#if defined(__linux__) && defined(__x86_64__)
|
|
|
d1af5a |
+#include "alt_main.h"
|
|
|
d1af5a |
+#else
|
|
|
d1af5a |
+#warning alt-java requested but SSB mitigation not available on this platform.
|
|
|
d1af5a |
+#endif
|
|
|
d1af5a |
+#endif
|
|
|
d1af5a |
+
|
|
|
d1af5a |
#ifdef _MSC_VER
|
|
|
d1af5a |
#if _MSC_VER > 1400 && _MSC_VER < 1600
|
|
|
d1af5a |
|