Blame SOURCES/rh1750419-redhat_alt_java.patch

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