Blame SOURCES/rh1750419-redhat_alt_java.patch

0f3be5
diff -r 1356affa5e44 make/launcher/Launcher-java.base.gmk
0f3be5
--- openjdk/make/launcher/Launcher-java.base.gmk      Wed Nov 25 08:27:15 2020 +0100
0f3be5
+++ openjdk/make/launcher/Launcher-java.base.gmk      Tue Dec 01 12:29:30 2020 +0100
0f3be5
@@ -41,6 +41,15 @@
0f3be5
     OPTIMIZATION := HIGH, \
0f3be5
 ))
660215
 
0f3be5
+$(eval $(call SetupBuildLauncher, alt-java, \
0f3be5
+    CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS -DENABLE_ARG_FILES -DREDHAT_ALT_JAVA, \
0f3be5
+    LDFLAGS_solaris := -R$(OPENWIN_HOME)/lib$(OPENJDK_TARGET_CPU_ISADIR), \
0f3be5
+    LIBS_windows := user32.lib comctl32.lib, \
0f3be5
+    EXTRA_RC_FLAGS := $(JAVA_RC_FLAGS), \
0f3be5
+    VERSION_INFO_RESOURCE := $(JAVA_VERSION_INFO_RESOURCE), \
0f3be5
+    OPTIMIZATION := HIGH, \
0f3be5
+))
0f3be5
+
0f3be5
 ifeq ($(OPENJDK_TARGET_OS), windows)
0f3be5
   $(eval $(call SetupBuildLauncher, javaw, \
0f3be5
       CFLAGS := -DJAVAW -DEXPAND_CLASSPATH_WILDCARDS -DENABLE_ARG_FILES, \
0f3be5
0f3be5
diff -r 25e94aa812b2 src/share/bin/alt_main.h
0f3be5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
0f3be5
+++ openjdk/src/java.base/share/native/launcher/alt_main.h	Tue Jun 02 17:15:28 2020 +0100
0f3be5
@@ -0,0 +1,73 @@
0f3be5
+/*
0f3be5
+ * Copyright (c) 2019, Red Hat, Inc. All rights reserved.
0f3be5
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0f3be5
+ *
0f3be5
+ * This code is free software; you can redistribute it and/or modify it
0f3be5
+ * under the terms of the GNU General Public License version 2 only, as
0f3be5
+ * published by the Free Software Foundation.  Oracle designates this
0f3be5
+ * particular file as subject to the "Classpath" exception as provided
0f3be5
+ * by Oracle in the LICENSE file that accompanied this code.
0f3be5
+ *
0f3be5
+ * This code is distributed in the hope that it will be useful, but WITHOUT
0f3be5
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0f3be5
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
0f3be5
+ * version 2 for more details (a copy is included in the LICENSE file that
0f3be5
+ * accompanied this code).
0f3be5
+ *
0f3be5
+ * You should have received a copy of the GNU General Public License version
0f3be5
+ * 2 along with this work; if not, write to the Free Software Foundation,
0f3be5
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0f3be5
+ *
0f3be5
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
0f3be5
+ * or visit www.oracle.com if you need additional information or have any
0f3be5
+ * questions.
0f3be5
+ */
0f3be5
+
0f3be5
+#ifdef REDHAT_ALT_JAVA
0f3be5
+
660215
+#include <sys/prctl.h>
660215
+
0f3be5
+
660215
+/* Per task speculation control */
660215
+#ifndef PR_GET_SPECULATION_CTRL
660215
+# define PR_GET_SPECULATION_CTRL    52
660215
+#endif
660215
+#ifndef PR_SET_SPECULATION_CTRL
660215
+# define PR_SET_SPECULATION_CTRL    53
660215
+#endif
660215
+/* Speculation control variants */
660215
+#ifndef PR_SPEC_STORE_BYPASS
660215
+# define PR_SPEC_STORE_BYPASS          0
660215
+#endif
660215
+/* Return and control values for PR_SET/GET_SPECULATION_CTRL */
660215
+
660215
+#ifndef PR_SPEC_NOT_AFFECTED
660215
+# define PR_SPEC_NOT_AFFECTED          0
660215
+#endif
660215
+#ifndef PR_SPEC_PRCTL
660215
+# define PR_SPEC_PRCTL                 (1UL << 0)
660215
+#endif
660215
+#ifndef PR_SPEC_ENABLE
660215
+# define PR_SPEC_ENABLE                (1UL << 1)
660215
+#endif
660215
+#ifndef PR_SPEC_DISABLE
660215
+# define PR_SPEC_DISABLE               (1UL << 2)
660215
+#endif
660215
+#ifndef PR_SPEC_FORCE_DISABLE
660215
+# define PR_SPEC_FORCE_DISABLE         (1UL << 3)
660215
+#endif
660215
+#ifndef PR_SPEC_DISABLE_NOEXEC
660215
+# define PR_SPEC_DISABLE_NOEXEC        (1UL << 4)
660215
+#endif
660215
+
660215
+static void set_speculation() __attribute__((constructor));
660215
+static void set_speculation() {
660215
+  if ( prctl(PR_SET_SPECULATION_CTRL,
660215
+             PR_SPEC_STORE_BYPASS,
660215
+             PR_SPEC_DISABLE_NOEXEC, 0, 0) == 0 ) {
660215
+    return;
660215
+  }
660215
+  prctl(PR_SET_SPECULATION_CTRL, PR_SPEC_STORE_BYPASS, PR_SPEC_DISABLE, 0, 0);
660215
+}
660215
+
0f3be5
+#endif // REDHAT_ALT_JAVA
0f3be5
diff -r 25e94aa812b2 src/share/bin/main.c
0f3be5
--- openjdk/src/java.base/share/native/launcher/main.c	Wed Feb 05 12:20:36 2020 -0300
0f3be5
+++ openjdk/src/java.base/share/native/launcher/main.c	Tue Jun 02 17:15:28 2020 +0100
0f3be5
@@ -34,6 +34,10 @@
0f3be5
 #include "jli_util.h"
0f3be5
 #include "jni.h"
0f3be5
 
0f3be5
+#if defined(linux) && defined(__x86_64)
0f3be5
+#include "alt_main.h"
0f3be5
+#endif
0f3be5
+
0f3be5
 #ifdef _MSC_VER
0f3be5
 #if _MSC_VER > 1400 && _MSC_VER < 1600
0f3be5