Blame SOURCES/rh1750419-redhat_alt_java.patch

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