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