Blame SOURCES/rh1750419-redhat_alt_java.patch

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