Blame SOURCES/rh1750419-redhat_alt_java.patch

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