diff --git a/Backport-JDK-8315338-RISC-V-Change-flags-for-stable-.patch b/Backport-JDK-8315338-RISC-V-Change-flags-for-stable-.patch new file mode 100644 index 0000000000000000000000000000000000000000..29dfaaf6f5fc13fb6f1a079983444b5f7ad147b5 --- /dev/null +++ b/Backport-JDK-8315338-RISC-V-Change-flags-for-stable-.patch @@ -0,0 +1,29 @@ +From 845c2409581d1c2435b1f9b0eab1169649042236 Mon Sep 17 00:00:00 2001 +From: Dingli Zhang +Date: Mon, 17 Mar 2025 16:24:36 +0800 +Subject: [PATCH] Backport JDK-8315338: RISC-V: Change flags for stable + extensions to non-experimental + + +diff --git a/src/hotspot/cpu/riscv/globals_riscv.hpp b/src/hotspot/cpu/riscv/globals_riscv.hpp +index ce572fd9a4d..53c4f2c2842 100644 +--- a/src/hotspot/cpu/riscv/globals_riscv.hpp ++++ b/src/hotspot/cpu/riscv/globals_riscv.hpp +@@ -101,10 +101,10 @@ define_pd_global(intx, InlineSmallCode, 1000); + product(bool, UseRVA20U64, true, "Use RVA20U64 profile") \ + product(bool, UseRVC, false, "Use RVC instructions") \ + product(bool, UseRVA22U64, false, EXPERIMENTAL, "Use RVA22U64 profile") \ +- product(bool, UseRVV, false, EXPERIMENTAL, "Use RVV instructions") \ +- product(bool, UseZba, false, EXPERIMENTAL, "Use Zba instructions") \ +- product(bool, UseZbb, false, EXPERIMENTAL, "Use Zbb instructions") \ +- product(bool, UseZbs, false, EXPERIMENTAL, "Use Zbs instructions") \ ++ product(bool, UseRVV, false, "Use RVV instructions") \ ++ product(bool, UseZba, false, "Use Zba instructions") \ ++ product(bool, UseZbb, false, "Use Zbb instructions") \ ++ product(bool, UseZbs, false, "Use Zbs instructions") \ + product(bool, UseZic64b, false, EXPERIMENTAL, "Use Zic64b instructions") \ + product(bool, UseZicbom, false, EXPERIMENTAL, "Use Zicbom instructions") \ + product(bool, UseZicbop, false, EXPERIMENTAL, "Use Zicbop instructions") \ +-- +2.34.1 + diff --git a/Backport-JDK-8329083-RISC-V-Update-profiles-supporte.patch b/Backport-JDK-8329083-RISC-V-Update-profiles-supporte.patch new file mode 100644 index 0000000000000000000000000000000000000000..f55980f9207e1e38cc70544a7cfaca0dd68c4c15 --- /dev/null +++ b/Backport-JDK-8329083-RISC-V-Update-profiles-supporte.patch @@ -0,0 +1,151 @@ +From 0d7ae782a1460d07b4c421539d6270b75e42f7eb Mon Sep 17 00:00:00 2001 +From: Dingli Zhang +Date: Mon, 17 Mar 2025 16:27:36 +0800 +Subject: [PATCH] Backport JDK-8329083: RISC-V: Update profiles supported on + riscv + + +diff --git a/src/hotspot/cpu/riscv/globals_riscv.hpp b/src/hotspot/cpu/riscv/globals_riscv.hpp +index 53c4f2c2842..85aaa3d239d 100644 +--- a/src/hotspot/cpu/riscv/globals_riscv.hpp ++++ b/src/hotspot/cpu/riscv/globals_riscv.hpp +@@ -99,8 +99,9 @@ define_pd_global(intx, InlineSmallCode, 1000); + product(bool, AvoidUnalignedAccesses, true, \ + "Avoid generating unaligned memory accesses") \ + product(bool, UseRVA20U64, true, "Use RVA20U64 profile") \ +- product(bool, UseRVC, false, "Use RVC instructions") \ + product(bool, UseRVA22U64, false, EXPERIMENTAL, "Use RVA22U64 profile") \ ++ product(bool, UseRVA23U64, false, EXPERIMENTAL, "Use RVA23U64 profile") \ ++ product(bool, UseRVC, false, "Use RVC instructions") \ + product(bool, UseRVV, false, "Use RVV instructions") \ + product(bool, UseZba, false, "Use Zba instructions") \ + product(bool, UseZbb, false, "Use Zbb instructions") \ +diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.cpp b/src/hotspot/cpu/riscv/vm_version_riscv.cpp +index 4ad0b16b623..febe7cc0d73 100644 +--- a/src/hotspot/cpu/riscv/vm_version_riscv.cpp ++++ b/src/hotspot/cpu/riscv/vm_version_riscv.cpp +@@ -45,6 +45,18 @@ VM_Version::RVFeatureValue* VM_Version::_feature_list[] = { + RV_FEATURE_FLAGS(ADD_RV_FEATURE_IN_LIST) + nullptr}; + ++void VM_Version::useRVA20U64Profile() { ++ RV_USE_RVA20U64; ++} ++ ++void VM_Version::useRVA22U64Profile() { ++ RV_USE_RVA22U64; ++} ++ ++void VM_Version::useRVA23U64Profile() { ++ RV_USE_RVA23U64; ++} ++ + void VM_Version::initialize() { + _supports_cx8 = true; + _supports_atomic_getset4 = true; +@@ -62,41 +74,14 @@ void VM_Version::initialize() { + (int)satp_mode.value())); + } + +- // https://github.com/riscv/riscv-profiles/blob/main/profiles.adoc#rva20-profiles + if (UseRVA20U64) { +- if (FLAG_IS_DEFAULT(UseRVC)) { +- FLAG_SET_DEFAULT(UseRVC, true); +- } ++ useRVA20U64Profile(); + } +- // https://github.com/riscv/riscv-profiles/blob/main/profiles.adoc#rva22-profiles + if (UseRVA22U64) { +- if (FLAG_IS_DEFAULT(UseRVC)) { +- FLAG_SET_DEFAULT(UseRVC, true); +- } +- if (FLAG_IS_DEFAULT(UseZba)) { +- FLAG_SET_DEFAULT(UseZba, true); +- } +- if (FLAG_IS_DEFAULT(UseZbb)) { +- FLAG_SET_DEFAULT(UseZbb, true); +- } +- if (FLAG_IS_DEFAULT(UseZbs)) { +- FLAG_SET_DEFAULT(UseZbs, true); +- } +- if (FLAG_IS_DEFAULT(UseZic64b)) { +- FLAG_SET_DEFAULT(UseZic64b, true); +- } +- if (FLAG_IS_DEFAULT(UseZicbom)) { +- FLAG_SET_DEFAULT(UseZicbom, true); +- } +- if (FLAG_IS_DEFAULT(UseZicbop)) { +- FLAG_SET_DEFAULT(UseZicbop, true); +- } +- if (FLAG_IS_DEFAULT(UseZicboz)) { +- FLAG_SET_DEFAULT(UseZicboz, true); +- } +- if (FLAG_IS_DEFAULT(UseZihintpause)) { +- FLAG_SET_DEFAULT(UseZihintpause, true); +- } ++ useRVA22U64Profile(); ++ } ++ if (UseRVA23U64) { ++ useRVA23U64Profile(); + } + + if (UseZic64b) { +diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.hpp b/src/hotspot/cpu/riscv/vm_version_riscv.hpp +index 0de6e9a19e1..01c5cf0c600 100644 +--- a/src/hotspot/cpu/riscv/vm_version_riscv.hpp ++++ b/src/hotspot/cpu/riscv/vm_version_riscv.hpp +@@ -161,6 +161,51 @@ class VM_Version : public Abstract_VM_Version { + RV_FEATURE_FLAGS(DECLARE_RV_FEATURE) + #undef DECLARE_RV_FEATURE + ++ // enable extensions based on profile, current supported profiles: ++ // RVA20U64 ++ // RVA22U64 ++ // RVA23U64 ++ // NOTE: we only enable the mandatory extensions, not optional extension. ++ #define RV_ENABLE_EXTENSION(UseExtension) \ ++ if (FLAG_IS_DEFAULT(UseExtension)) { \ ++ FLAG_SET_DEFAULT(UseExtension, true); \ ++ } \ ++ ++ // https://github.com/riscv/riscv-profiles/blob/main/profiles.adoc#rva20-profiles ++ #define RV_USE_RVA20U64 \ ++ RV_ENABLE_EXTENSION(UseRVC) \ ++ ++ static void useRVA20U64Profile(); ++ ++ // https://github.com/riscv/riscv-profiles/blob/main/profiles.adoc#rva22-profiles ++ #define RV_USE_RVA22U64 \ ++ RV_ENABLE_EXTENSION(UseRVC) \ ++ RV_ENABLE_EXTENSION(UseZba) \ ++ RV_ENABLE_EXTENSION(UseZbb) \ ++ RV_ENABLE_EXTENSION(UseZbs) \ ++ RV_ENABLE_EXTENSION(UseZic64b) \ ++ RV_ENABLE_EXTENSION(UseZicbom) \ ++ RV_ENABLE_EXTENSION(UseZicbop) \ ++ RV_ENABLE_EXTENSION(UseZicboz) \ ++ RV_ENABLE_EXTENSION(UseZihintpause) \ ++ ++ static void useRVA22U64Profile(); ++ ++ // https://github.com/riscv/riscv-profiles/blob/main/rva23-profile.adoc#rva23u64-profile ++ #define RV_USE_RVA23U64 \ ++ RV_ENABLE_EXTENSION(UseRVC) \ ++ RV_ENABLE_EXTENSION(UseRVV) \ ++ RV_ENABLE_EXTENSION(UseZba) \ ++ RV_ENABLE_EXTENSION(UseZbb) \ ++ RV_ENABLE_EXTENSION(UseZbs) \ ++ RV_ENABLE_EXTENSION(UseZic64b) \ ++ RV_ENABLE_EXTENSION(UseZicbom) \ ++ RV_ENABLE_EXTENSION(UseZicbop) \ ++ RV_ENABLE_EXTENSION(UseZicboz) \ ++ RV_ENABLE_EXTENSION(UseZihintpause) \ ++ ++ static void useRVA23U64Profile(); ++ + // VM modes (satp.mode) privileged ISA 1.10 + enum VM_MODE : int { + VM_NOTSET = -1, +-- +2.34.1 + diff --git a/Backport-JDK-8343555-RISC-V-make-some-verified-on-ha.patch b/Backport-JDK-8343555-RISC-V-make-some-verified-on-ha.patch new file mode 100644 index 0000000000000000000000000000000000000000..95b0e8f31e691edba2d5f5020a6b1d63024b6408 --- /dev/null +++ b/Backport-JDK-8343555-RISC-V-make-some-verified-on-ha.patch @@ -0,0 +1,31 @@ +From 2966967606532deac3dde80fcdbce301eecc19d1 Mon Sep 17 00:00:00 2001 +From: Dingli Zhang +Date: Mon, 17 Mar 2025 16:28:35 +0800 +Subject: [PATCH] Backport JDK-8343555: RISC-V: make some verified (on + hardware) extension options diagnostic + + +diff --git a/src/hotspot/cpu/riscv/globals_riscv.hpp b/src/hotspot/cpu/riscv/globals_riscv.hpp +index 85aaa3d239d..2ee0b4b9421 100644 +--- a/src/hotspot/cpu/riscv/globals_riscv.hpp ++++ b/src/hotspot/cpu/riscv/globals_riscv.hpp +@@ -101,11 +101,11 @@ define_pd_global(intx, InlineSmallCode, 1000); + product(bool, UseRVA20U64, true, "Use RVA20U64 profile") \ + product(bool, UseRVA22U64, false, EXPERIMENTAL, "Use RVA22U64 profile") \ + product(bool, UseRVA23U64, false, EXPERIMENTAL, "Use RVA23U64 profile") \ +- product(bool, UseRVC, false, "Use RVC instructions") \ +- product(bool, UseRVV, false, "Use RVV instructions") \ +- product(bool, UseZba, false, "Use Zba instructions") \ +- product(bool, UseZbb, false, "Use Zbb instructions") \ +- product(bool, UseZbs, false, "Use Zbs instructions") \ ++ product(bool, UseRVC, false, DIAGNOSTIC, "Use RVC instructions") \ ++ product(bool, UseRVV, false, DIAGNOSTIC, "Use RVV instructions") \ ++ product(bool, UseZba, false, DIAGNOSTIC, "Use Zba instructions") \ ++ product(bool, UseZbb, false, DIAGNOSTIC, "Use Zbb instructions") \ ++ product(bool, UseZbs, false, DIAGNOSTIC, "Use Zbs instructions") \ + product(bool, UseZic64b, false, EXPERIMENTAL, "Use Zic64b instructions") \ + product(bool, UseZicbom, false, EXPERIMENTAL, "Use Zicbom instructions") \ + product(bool, UseZicbop, false, EXPERIMENTAL, "Use Zicbop instructions") \ +-- +2.34.1 + diff --git a/Backport-JDK-8348384-RISC-V-Disable-auto-enable-Vect.patch b/Backport-JDK-8348384-RISC-V-Disable-auto-enable-Vect.patch new file mode 100644 index 0000000000000000000000000000000000000000..222968ccda3d0e4a40844da7ad50218046416ca0 --- /dev/null +++ b/Backport-JDK-8348384-RISC-V-Disable-auto-enable-Vect.patch @@ -0,0 +1,43 @@ +From 0310b533d409704f349b9e9bf861ee6afb9d67ee Mon Sep 17 00:00:00 2001 +From: Dingli Zhang +Date: Mon, 17 Mar 2025 16:31:52 +0800 +Subject: [PATCH] Backport JDK-8348384: RISC-V: Disable auto-enable Vector on + buggy kernels + + +diff --git a/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp b/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp +index 243c4b850ee..991ce07bb7c 100644 +--- a/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp ++++ b/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp +@@ -25,6 +25,8 @@ + + #include "precompiled.hpp" + #include "logging/log.hpp" ++#include "logging/logMessage.hpp" ++#include "os_linux.hpp" + #include "riscv_hwprobe.hpp" + #include "runtime/os.hpp" + #include "runtime/vm_version.hpp" +@@ -134,7 +136,18 @@ void RiscvHwprobe::add_features_from_query_result() { + VM_Version::ext_C.enable_feature(); + } + if (is_set(RISCV_HWPROBE_KEY_IMA_EXT_0, RISCV_HWPROBE_IMA_V)) { +- VM_Version::ext_V.enable_feature(); ++ // Linux signal return bug when using vector with vlen > 128b in pre 6.8.5. ++ long major, minor, patch; ++ os::Linux::kernel_version(&major, &minor, &patch); ++ if (os::Linux::kernel_version_compare(major, minor, patch, 6, 8, 5) == -1) { ++ LogMessage(os) log; ++ if (log.is_info()) { ++ log.info("Linux kernels before 6.8.5 (current %ld.%ld.%ld) have a known bug when using Vector and signals.", major, minor, patch); ++ log.info("Vector not enabled automatically via hwprobe, but can be turned on with -XX:+UseRVV."); ++ } ++ } else { ++ VM_Version::ext_V.enable_feature(); ++ } + } + if (is_set(RISCV_HWPROBE_KEY_IMA_EXT_0, RISCV_HWPROBE_EXT_ZBA)) { + VM_Version::ext_Zba.enable_feature(); +-- +2.34.1 + diff --git a/Backport-JDK-8348554-Enhance-Linux-kernel-version-ch.patch b/Backport-JDK-8348554-Enhance-Linux-kernel-version-ch.patch new file mode 100644 index 0000000000000000000000000000000000000000..0e74d63883d714b350a9d8c2d4fe87c28cb76ec5 --- /dev/null +++ b/Backport-JDK-8348554-Enhance-Linux-kernel-version-ch.patch @@ -0,0 +1,100 @@ +From 2565e265b0381ed00428d33fc8040d9367ee394d Mon Sep 17 00:00:00 2001 +From: Dingli Zhang +Date: Mon, 17 Mar 2025 16:31:03 +0800 +Subject: [PATCH] Backport JDK-8348554: Enhance Linux kernel version checks + + +diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp +index 7cb862d7c3e..22216a568bc 100644 +--- a/src/hotspot/os/linux/os_linux.cpp ++++ b/src/hotspot/os/linux/os_linux.cpp +@@ -311,9 +311,10 @@ static void next_line(FILE *f) { + } while (c != '\n' && c != EOF); + } + +-void os::Linux::kernel_version(long* major, long* minor) { +- *major = -1; +- *minor = -1; ++void os::Linux::kernel_version(long* major, long* minor, long* patch) { ++ *major = 0; ++ *minor = 0; ++ *patch = 0; + + struct utsname buffer; + int ret = uname(&buffer); +@@ -321,12 +322,29 @@ void os::Linux::kernel_version(long* major, long* minor) { + log_warning(os)("uname(2) failed to get kernel version: %s", os::errno_name(ret)); + return; + } +- int nr_matched = sscanf(buffer.release, "%ld.%ld", major, minor); +- if (nr_matched != 2) { +- log_warning(os)("Parsing kernel version failed, expected 2 version numbers, only matched %d", nr_matched); ++ int nr_matched = sscanf(buffer.release, "%ld.%ld.%ld", major, minor, patch); ++ if (nr_matched != 3) { ++ log_warning(os)("Parsing kernel version failed, expected 3 version numbers, only matched %d", nr_matched); + } + } + ++int os::Linux::kernel_version_compare(long major1, long minor1, long patch1, ++ long major2, long minor2, long patch2) { ++ // Compare major versions ++ if (major1 > major2) return 1; ++ if (major1 < major2) return -1; ++ ++ // Compare minor versions ++ if (minor1 > minor2) return 1; ++ if (minor1 < minor2) return -1; ++ ++ // Compare patchlevel versions ++ if (patch1 > patch2) return 1; ++ if (patch1 < patch2) return -1; ++ ++ return 0; ++} ++ + bool os::Linux::get_tick_information(CPUPerfTicks* pticks, int which_logical_cpu) { + FILE* fh; + uint64_t userTicks, niceTicks, systemTicks, idleTicks; +diff --git a/src/hotspot/os/linux/os_linux.hpp b/src/hotspot/os/linux/os_linux.hpp +index 029f2aa7a52..f2901480d29 100644 +--- a/src/hotspot/os/linux/os_linux.hpp ++++ b/src/hotspot/os/linux/os_linux.hpp +@@ -109,7 +109,13 @@ class os::Linux { + bool has_steal_ticks; + }; + +- static void kernel_version(long* major, long* minor); ++ static void kernel_version(long* major, long* minor, long* patch); ++ ++ // If kernel1 > kernel2 return 1 ++ // If kernel1 < kernel2 return -1 ++ // If kernel1 = kernel2 return 0 ++ static int kernel_version_compare(long major1, long minor1, long patch1, ++ long major2, long minor2, long patch2); + + // which_logical_cpu=-1 returns accumulated ticks for all cpus. + static bool get_tick_information(CPUPerfTicks* pticks, int which_logical_cpu); +diff --git a/src/hotspot/os/linux/systemMemoryBarrier_linux.cpp b/src/hotspot/os/linux/systemMemoryBarrier_linux.cpp +index 51397b139d8..43122a58bce 100644 +--- a/src/hotspot/os/linux/systemMemoryBarrier_linux.cpp ++++ b/src/hotspot/os/linux/systemMemoryBarrier_linux.cpp +@@ -76,11 +76,11 @@ bool LinuxSystemMemoryBarrier::initialize() { + // RISCV port was introduced in kernel 4.4. + // 4.4 also made membar private expedited mandatory. + // But RISCV actually don't support it until 6.9. +- long major, minor; +- os::Linux::kernel_version(&major, &minor); +- if (!(major > 6 || (major == 6 && minor >= 9))) { +- log_info(os)("Linux kernel %ld.%ld does not support MEMBARRIER PRIVATE_EXPEDITED on RISC-V.", +- major, minor); ++ long major, minor, patch; ++ os::Linux::kernel_version(&major, &minor, &patch); ++ if (os::Linux::kernel_version_compare(major, minor, patch, 6, 9, 0) == -1) { ++ log_info(os)("Linux kernel %ld.%ld.%ld does not support MEMBARRIER PRIVATE_EXPEDITED on RISC-V.", ++ major, minor, patch); + return false; + } + #endif +-- +2.34.1 + diff --git a/openjdk-21.spec b/openjdk-21.spec index 957afb6713b750769c32f7053453215cc4524d22..4431875ccceb5c4eb43d14b7bb1377e9856c9b0b 100644 --- a/openjdk-21.spec +++ b/openjdk-21.spec @@ -899,7 +899,7 @@ Name: java-21-%{origin} Version: %{newjavaver}.%{buildver} # This package needs `.rolling` as part of Release so as to not conflict on install with # java-X-openjdk. I.e. when latest rolling release is also an LTS release packaged as -Release: 2 +Release: 3 # java-1.5.0-ibm from jpackage.org set Epoch to 1 for unknown reasons # and this change was brought into RHEL-4. java-1.5.0-ibm packages @@ -1037,6 +1037,17 @@ Patch86: huawei-Add-KAE-SM2.patch ############################################ Patch2000: LoongArch64-support.patch +############################################ +# +# RISC-V specific patches +# +############################################ +Patch3001: Backport-JDK-8315338-RISC-V-Change-flags-for-stable-.patch +Patch3002: Backport-JDK-8329083-RISC-V-Update-profiles-supporte.patch +Patch3003: Backport-JDK-8343555-RISC-V-make-some-verified-on-ha.patch +Patch3004: Backport-JDK-8348554-Enhance-Linux-kernel-version-ch.patch +Patch3005: Backport-JDK-8348384-RISC-V-Disable-auto-enable-Vect.patch + BuildRequires: autoconf BuildRequires: automake BuildRequires: alsa-lib-devel @@ -1329,6 +1340,16 @@ pushd %{top_level_dir_name} popd %endif +%ifarch riscv64 +pushd %{top_level_dir_name} +%patch3001 -p1 +%patch3002 -p1 +%patch3003 -p1 +%patch3004 -p1 +%patch3005 -p1 +popd +%endif + # Extract systemtap tapsets %if %{with_systemtap} tar --strip-components=1 -x -I xz -f %{SOURCE8} @@ -1880,6 +1901,14 @@ cjc.mainProgram(args) -- the returns from copy_jdk_configs.lua should not affect %changelog +* Mon Mar 24 2025 Dingli Zhang - 1:21.0.6.7-3 +- add RVA23 profile and disable auto-enable Vector on buggy kernels for riscv64 +- add Backport-JDK-8315338-RISC-V-Change-flags-for-stable-.patch +- add Backport-JDK-8329083-RISC-V-Update-profiles-supporte.patch +- add Backport-JDK-8343555-RISC-V-make-some-verified-on-ha.patch +- add Backport-JDK-8348554-Enhance-Linux-kernel-version-ch.patch +- add Backport-JDK-8348384-RISC-V-Disable-auto-enable-Vect.patch + * Sat Mar 22 2025 wulongyao - 1:21.0.6.7-2 - add huawei-8347965-tz-Update-Timezone-Data-to-2025a.patch - add huawei-Add-KAE-Provider.patch