Blame SOURCES/rh1750419-redhat_alt_java.patch

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