From b443c9b7266e2b6a234f6d5da7ce749eb9b6f01d Mon Sep 17 00:00:00 2001 From: Dingli Zhang Date: Mon, 6 May 2024 13:35:27 +0800 Subject: [PATCH] Backport JDK-8316859 for riscv64 (cherry picked from commit a40dafa4457de957574fbeb86ec396c2c3dd1498) --- ...Disable-detection-of-V-through-HWCAP.patch | 38 +++++++++++++++++++ openjdk-latest.spec | 18 ++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 8316859-RISC-V-Disable-detection-of-V-through-HWCAP.patch diff --git a/8316859-RISC-V-Disable-detection-of-V-through-HWCAP.patch b/8316859-RISC-V-Disable-detection-of-V-through-HWCAP.patch new file mode 100644 index 0000000..95c3bff --- /dev/null +++ b/8316859-RISC-V-Disable-detection-of-V-through-HWCAP.patch @@ -0,0 +1,38 @@ +From 1013f0b0b911d24eed216485767ec6eb080afa81 Mon Sep 17 00:00:00 2001 +From: Ludovic Henry +Date: Mon, 25 Sep 2023 08:01:45 +0000 +Subject: [PATCH] 8316859: RISC-V: Disable detection of V through HWCAP + +--- + .../os_cpu/linux_riscv/vm_version_linux_riscv.cpp | 15 ++++++++++++--- + 1 file changed, 12 insertions(+), 3 deletions(-) + +diff --git a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp +index 454ffbb06d390..69bbf9f366b31 100644 +--- a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp ++++ b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp +@@ -149,12 +149,21 @@ void VM_Version::setup_cpu_available_features() { + + void VM_Version::os_aux_features() { + uint64_t auxv = getauxval(AT_HWCAP); +- int i = 0; +- while (_feature_list[i] != nullptr) { ++ for (int i = 0; _feature_list[i] != nullptr; i++) { ++ if (_feature_list[i]->feature_bit() == HWCAP_ISA_V) { ++ // Special case for V: some dev boards only support RVV version 0.7, while ++ // the OpenJDK only supports RVV version 1.0. These two versions are not ++ // compatible with each other. Given the V bit is set through HWCAP on ++ // some custom kernels, regardless of the version, it can lead to ++ // generating V instructions on boards that don't support RVV version 1.0 ++ // (ex: Sipeed LicheePi), leading to a SIGILL. ++ // That is an acceptable workaround as only Linux Kernel v6.5+ supports V, ++ // and that version already support hwprobe anyway ++ continue; ++ } + if ((_feature_list[i]->feature_bit() & auxv) != 0) { + _feature_list[i]->enable_feature(); + } +- i++; + } + } + diff --git a/openjdk-latest.spec b/openjdk-latest.spec index 0b01d72..90755d6 100644 --- a/openjdk-latest.spec +++ b/openjdk-latest.spec @@ -894,7 +894,7 @@ Name: java-latest-%{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: 1 +Release: 2 # 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 @@ -977,6 +977,13 @@ Patch6: rh1684077-openjdk_should_depend_on_pcsc-lite-libs_instead_of_pcsc-lite-d Patch7: downgrade-the-glibc-symver-of-memcpy.patch Patch8: downgrade-the-glibc-symver-of-log2f-posix_spawn.patch +############################################ +# +# RISC-V specific patches +# +############################################ +Patch2000: 8316859-RISC-V-Disable-detection-of-V-through-HWCAP.patch + BuildRequires: autoconf BuildRequires: automake BuildRequires: alsa-lib-devel @@ -1210,6 +1217,12 @@ popd # openjdk %patch1000 +%ifarch riscv64 +pushd %{top_level_dir_name} +%patch2000 -p1 +popd +%endif + # Extract systemtap tapsets %if %{with_systemtap} tar --strip-components=1 -x -I xz -f %{SOURCE8} @@ -1773,6 +1786,9 @@ cjc.mainProgram(arg) %changelog +* Mon May 06 2024 Dingli Zhang - 1:21.0.0.35-2 +- Backport JDK-8316859 for riscv64 + * Mon Nov 27 2023 kuenking111 - 1:21.0.0.35-1 - Change vendor name to BiSheng -- Gitee