Blame SOURCES/rh1750419-redhat_alt_java.patch

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