Blame SOURCES/rh1750419-redhat_alt_java.patch

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