Blame SOURCES/rh1750419-redhat_alt_java.patch

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