Blame SOURCES/rh1750419-redhat_alt_java.patch

b44ac0
diff --git openjdk.orig/jdk/make/CompileLaunchers.gmk openjdk/jdk/make/CompileLaunchers.gmk
b44ac0
--- openjdk.orig/jdk/make/CompileLaunchers.gmk
b44ac0
+++ openjdk/jdk/make/CompileLaunchers.gmk
b44ac0
@@ -255,6 +255,32 @@
b44ac0
   endif
b44ac0
 endif
b44ac0
 
b44ac0
+$(eval $(call SetupLauncher,alt-java, \
b44ac0
+    -DEXPAND_CLASSPATH_WILDCARDS -DREDHAT_ALT_JAVA,,,user32.lib comctl32.lib, \
b44ac0
+    $(JDK_OUTPUTDIR)/objs/jli_static.lib, $(JAVA_RC_FLAGS), \
b44ac0
+    $(JDK_TOPDIR)/src/windows/resource/java.rc, $(JDK_OUTPUTDIR)/objs/java_objs,true))
b44ac0
+
b44ac0
+$(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/alt-java$(EXE_SUFFIX): $(BUILD_LAUNCHER_alt-java)
b44ac0
+	$(MKDIR) -p $(@D)
b44ac0
+	$(RM) $@
b44ac0
+	$(CP) $(JDK_OUTPUTDIR)/objs/java_objs$(OUTPUT_SUBDIR)/alt-java$(EXE_SUFFIX) $@
b44ac0
+
b44ac0
+$(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/alt-java$(DEBUGINFO_EXT): $(BUILD_LAUNCHER_alt-java)
b44ac0
+	$(MKDIR) -p $(@D)
b44ac0
+	$(RM) $@
b44ac0
+	$(CP) $(JDK_OUTPUTDIR)/objs/java_objs$(OUTPUT_SUBDIR)/alt-java$(DEBUGINFO_EXT) $@
b44ac0
+
b44ac0
+ifeq ($(OPENJDK_TARGET_OS), linux)
b44ac0
+  BUILD_LAUNCHERS += $(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/alt-java$(EXE_SUFFIX)
b44ac0
+  ifeq ($(ENABLE_DEBUG_SYMBOLS), true)
b44ac0
+    ifneq ($(POST_STRIP_CMD), )
b44ac0
+      ifneq ($(STRIP_POLICY), no_strip)
b44ac0
+        BUILD_LAUNCHERS += $(JDK_OUTPUTDIR)/bin$(OUTPUT_SUBDIR)/alt-java$(DEBUGINFO_EXT)
b44ac0
+      endif
b44ac0
+    endif
b44ac0
+  endif
b44ac0
+endif
b44ac0
+
b44ac0
 ifeq ($(OPENJDK_TARGET_OS), windows)
b44ac0
   $(eval $(call SetupLauncher,javaw, \
b44ac0
       -DJAVAW -DEXPAND_CLASSPATH_WILDCARDS,,,user32.lib comctl32.lib, \
b44ac0
diff --git openjdk.orig/jdk/src/share/bin/alt_main.h openjdk/jdk/src/share/bin/alt_main.h
b44ac0
new file mode 100644
b44ac0
--- /dev/null
b44ac0
+++ openjdk/jdk/src/share/bin/alt_main.h
b44ac0
@@ -0,0 +1,73 @@
b44ac0
+/*
b44ac0
+ * Copyright (c) 2019, Red Hat, Inc. All rights reserved.
b44ac0
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b44ac0
+ *
b44ac0
+ * This code is free software; you can redistribute it and/or modify it
b44ac0
+ * under the terms of the GNU General Public License version 2 only, as
b44ac0
+ * published by the Free Software Foundation.  Oracle designates this
b44ac0
+ * particular file as subject to the "Classpath" exception as provided
b44ac0
+ * by Oracle in the LICENSE file that accompanied this code.
b44ac0
+ *
b44ac0
+ * This code is distributed in the hope that it will be useful, but WITHOUT
b44ac0
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b44ac0
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b44ac0
+ * version 2 for more details (a copy is included in the LICENSE file that
b44ac0
+ * accompanied this code).
b44ac0
+ *
b44ac0
+ * You should have received a copy of the GNU General Public License version
b44ac0
+ * 2 along with this work; if not, write to the Free Software Foundation,
b44ac0
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b44ac0
+ *
b44ac0
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b44ac0
+ * or visit www.oracle.com if you need additional information or have any
b44ac0
+ * questions.
b44ac0
+ */
b44ac0
+
b44ac0
+#ifdef REDHAT_ALT_JAVA
b44ac0
+
b44ac0
+#include <sys/prctl.h>
b44ac0
+
b44ac0
+
b44ac0
+/* Per task speculation control */
b44ac0
+#ifndef PR_GET_SPECULATION_CTRL
b44ac0
+# define PR_GET_SPECULATION_CTRL    52
b44ac0
+#endif
b44ac0
+#ifndef PR_SET_SPECULATION_CTRL
b44ac0
+# define PR_SET_SPECULATION_CTRL    53
b44ac0
+#endif
b44ac0
+/* Speculation control variants */
b44ac0
+#ifndef PR_SPEC_STORE_BYPASS
b44ac0
+# define PR_SPEC_STORE_BYPASS          0
b44ac0
+#endif
b44ac0
+/* Return and control values for PR_SET/GET_SPECULATION_CTRL */
b44ac0
+
b44ac0
+#ifndef PR_SPEC_NOT_AFFECTED
b44ac0
+# define PR_SPEC_NOT_AFFECTED          0
b44ac0
+#endif
b44ac0
+#ifndef PR_SPEC_PRCTL
b44ac0
+# define PR_SPEC_PRCTL                 (1UL << 0)
b44ac0
+#endif
b44ac0
+#ifndef PR_SPEC_ENABLE
b44ac0
+# define PR_SPEC_ENABLE                (1UL << 1)
b44ac0
+#endif
b44ac0
+#ifndef PR_SPEC_DISABLE
b44ac0
+# define PR_SPEC_DISABLE               (1UL << 2)
b44ac0
+#endif
b44ac0
+#ifndef PR_SPEC_FORCE_DISABLE
b44ac0
+# define PR_SPEC_FORCE_DISABLE         (1UL << 3)
b44ac0
+#endif
b44ac0
+#ifndef PR_SPEC_DISABLE_NOEXEC
b44ac0
+# define PR_SPEC_DISABLE_NOEXEC        (1UL << 4)
b44ac0
+#endif
b44ac0
+
b44ac0
+static void set_speculation() __attribute__((constructor));
b44ac0
+static void set_speculation() {
b44ac0
+  if ( prctl(PR_SET_SPECULATION_CTRL,
b44ac0
+             PR_SPEC_STORE_BYPASS,
b44ac0
+             PR_SPEC_DISABLE_NOEXEC, 0, 0) == 0 ) {
b44ac0
+    return;
b44ac0
+  }
b44ac0
+  prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_DISABLE, 0, 0);
b44ac0
+}
b44ac0
+
b44ac0
+#endif // REDHAT_ALT_JAVA
b44ac0
diff --git openjdk.orig/jdk/src/share/bin/main.c openjdk/jdk/src/share/bin/main.c
b44ac0
--- openjdk.orig/jdk/src/share/bin/main.c
b44ac0
+++ openjdk/jdk/src/share/bin/main.c
b44ac0
@@ -32,6 +32,10 @@
b44ac0
 
b44ac0
 #include "defines.h"
b44ac0
 
b44ac0
+#if defined(linux) && defined(__x86_64)
b44ac0
+#include "alt_main.h"
b44ac0
+#endif
b44ac0
+
b44ac0
 #ifdef _MSC_VER
b44ac0
 #if _MSC_VER > 1400 && _MSC_VER < 1600
b44ac0