Blame SOURCES/rh1750419-redhat_alt_java.patch

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