From f5d386df7e167d133c649f52ab500ea0bc5e2142 Mon Sep 17 00:00:00 2001 From: panxuefeng Date: Mon, 27 Feb 2023 16:13:17 +0800 Subject: [PATCH 1/2] Sync with Loongson code --- LoongArch64-support.patch | 43 ++++++++++++++++++++++++++++++--------- openjdk-11.spec | 8 +++++++- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/LoongArch64-support.patch b/LoongArch64-support.patch index 73f887f..0cc36eb 100644 --- a/LoongArch64-support.patch +++ b/LoongArch64-support.patch @@ -105210,7 +105210,7 @@ index 0000000000..295d20e19e +#endif // OS_CPU_LINUX_LOONGARCH_ORDERACCESS_LINUX_LOONGARCH_HPP diff --git a/src/hotspot/os_cpu/linux_loongarch/os_linux_loongarch.cpp b/src/hotspot/os_cpu/linux_loongarch/os_linux_loongarch.cpp new file mode 100644 -index 0000000000..9addc65932 +index 0000000000..cf5fff0d04 --- /dev/null +++ b/src/hotspot/os_cpu/linux_loongarch/os_linux_loongarch.cpp @@ -0,0 +1,710 @@ @@ -105606,7 +105606,7 @@ index 0000000000..9addc65932 +#endif + + // Handle signal from NativeJump::patch_verified_entry(). -+ if (sig == SIGILL & nativeInstruction_at(pc)->is_sigill_zombie_not_entrant()) { ++ if (sig == SIGILL && nativeInstruction_at(pc)->is_sigill_zombie_not_entrant()) { +#ifdef PRINT_SIGNAL_HANDLE + tty->print_cr("verified entry = %lx, sig=%d", nativeInstruction_at(pc), sig); +#endif @@ -106833,13 +106833,13 @@ index 0000000000..bf9d679730 +#endif // OS_CPU_LINUX_MIPS_VM_ORDERACCESS_LINUX_MIPS_HPP diff --git a/src/hotspot/os_cpu/linux_mips/os_linux_mips.cpp b/src/hotspot/os_cpu/linux_mips/os_linux_mips.cpp new file mode 100644 -index 0000000000..f1bdb05910 +index 0000000000..d035d8edbb --- /dev/null +++ b/src/hotspot/os_cpu/linux_mips/os_linux_mips.cpp @@ -0,0 +1,1020 @@ +/* + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. -+ * Copyright (c) 2015, 2022, Loongson Technology. All rights reserved. ++ * Copyright (c) 2015, 2023, Loongson Technology. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it @@ -107260,7 +107260,7 @@ index 0000000000..f1bdb05910 +#endif + + // Handle signal from NativeJump::patch_verified_entry(). -+ if (sig == SIGILL & nativeInstruction_at(pc)->is_sigill_zombie_not_entrant()) { ++ if (sig == SIGILL && nativeInstruction_at(pc)->is_sigill_zombie_not_entrant()) { +#ifdef PRINT_SIGNAL_HANDLE + tty->print_cr("verified entry = %lx, sig=%d", nativeInstruction_at(pc), sig); +#endif @@ -108268,16 +108268,27 @@ index 2b0fa83c1a..270e0bc180 100644 + #endif // OS_CPU_LINUX_X86_ZGLOBALS_LINUX_X86_HPP diff --git a/src/hotspot/share/asm/codeBuffer.cpp b/src/hotspot/share/asm/codeBuffer.cpp -index 4912f88056..781e26c22e 100644 +index 4912f88056..a420f7807b 100644 --- a/src/hotspot/share/asm/codeBuffer.cpp +++ b/src/hotspot/share/asm/codeBuffer.cpp -@@ -351,6 +351,9 @@ void CodeSection::relocate(address at, RelocationHolder const& spec, int format) +@@ -22,6 +22,12 @@ + * + */ + ++/* ++ * This file has been modified by Loongson Technology in 2023. These ++ * modifications are Copyright (c) 2018, 2023, Loongson Technology, and are made ++ * available on the same license terms set forth above. ++ */ ++ + #include "precompiled.hpp" + #include "asm/codeBuffer.hpp" + #include "compiler/disassembler.hpp" +@@ -351,6 +357,7 @@ void CodeSection::relocate(address at, RelocationHolder const& spec, int format) assert(rtype == relocInfo::none || rtype == relocInfo::runtime_call_type || rtype == relocInfo::internal_word_type|| -+#ifdef MIPS -+ rtype == relocInfo::internal_pc_type || -+#endif ++ NOT_ZERO(MIPS64_ONLY(rtype == relocInfo::internal_pc_type ||)) rtype == relocInfo::section_word_type || rtype == relocInfo::external_word_type, "code needs relocation information"); @@ -110064,6 +110075,18 @@ index 7d767c47c9..23ec34e5e2 100644 #else // all other { Bad, T_ILLEGAL, "vectors:", false, Op_VecS, relocInfo::none }, // VectorS { Bad, T_ILLEGAL, "vectord:", false, Op_VecD, relocInfo::none }, // VectorD +diff --git a/src/hotspot/share/runtime/java.cpp b/src/hotspot/share/runtime/java.cpp +index 84123b29ec..77fbacf2d8 100644 +--- a/src/hotspot/share/runtime/java.cpp ++++ b/src/hotspot/share/runtime/java.cpp +@@ -68,6 +68,7 @@ + #include "runtime/thread.inline.hpp" + #include "runtime/timer.hpp" + #include "runtime/vmOperations.hpp" ++#include "runtime/vmThread.hpp" + #include "services/memTracker.hpp" + #include "utilities/dtrace.hpp" + #include "utilities/globalDefinitions.hpp" diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp index e0f4a2af1f..09cc4b1ba5 100644 --- a/src/hotspot/share/runtime/os.cpp diff --git a/openjdk-11.spec b/openjdk-11.spec index 3792b4c..c1c2645 100644 --- a/openjdk-11.spec +++ b/openjdk-11.spec @@ -745,7 +745,7 @@ Provides: java-src%{?1} = %{epoch}:%{version}-%{release} Name: java-%{javaver}-%{origin} Version: %{newjavaver}.%{buildver} -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 # also included the epoch in their virtual provides. This created a @@ -1701,6 +1701,12 @@ cjc.mainProgram(arg) %changelog +* Mon Feb 27 2023 panxuefeng - 1:11.0.18.10-3 +- windows debug build failed +- [MIPS] Fix a typo in PosixSignals::pd_hotspot_signal_handler +- [MIPS] minimal build failed with --disable-precompiled-headers +- Fix a typo in PosixSignals::pd_hotspot_signal_handler + * Thu Feb 2 2023 aoqi - 1:11.0.18.10-2 - update LoongArch64 to 11.0.18+10 (GA) -- Gitee From 5614736437f77ae6abee01f4c2f08f06e8869354 Mon Sep 17 00:00:00 2001 From: panxuefeng Date: Mon, 27 Feb 2023 19:12:12 +0800 Subject: [PATCH 2/2] LoongArch uses hwcap detect cpu flags --- LoongArch-uses-hwcap-detect-cpu-flags.patch | 257 ++++++++++++++++++++ openjdk-11.spec | 8 +- 2 files changed, 261 insertions(+), 4 deletions(-) create mode 100644 LoongArch-uses-hwcap-detect-cpu-flags.patch diff --git a/LoongArch-uses-hwcap-detect-cpu-flags.patch b/LoongArch-uses-hwcap-detect-cpu-flags.patch new file mode 100644 index 0000000..301f787 --- /dev/null +++ b/LoongArch-uses-hwcap-detect-cpu-flags.patch @@ -0,0 +1,257 @@ +diff --git a/src/hotspot/cpu/loongarch/vm_version_loongarch.cpp b/src/hotspot/cpu/loongarch/vm_version_loongarch.cpp +index b954fa3e1a..0a9b55d17e 100644 +--- a/src/hotspot/cpu/loongarch/vm_version_loongarch.cpp ++++ b/src/hotspot/cpu/loongarch/vm_version_loongarch.cpp +@@ -36,7 +36,6 @@ + + #define T5 RT5 + +-int VM_Version::_cpuFeatures; + const char* VM_Version::_features_str = ""; + VM_Version::CpuidInfo VM_Version::_cpuid_info = { 0, }; + bool VM_Version::_cpu_info_is_initialized = false; +@@ -130,27 +129,9 @@ uint32_t VM_Version::get_feature_flags_by_cpucfg() { + } else if (_cpuid_info.cpucfg_info_id1.bits.ARCH == 0b10 ) { + result |= CPU_LA64; + } +- if (_cpuid_info.cpucfg_info_id1.bits.UAL != 0) +- result |= CPU_UAL; + + if (_cpuid_info.cpucfg_info_id2.bits.FP_CFG != 0) + result |= CPU_FP; +- if (_cpuid_info.cpucfg_info_id2.bits.LSX != 0) +- result |= CPU_LSX; +- if (_cpuid_info.cpucfg_info_id2.bits.LASX != 0) +- result |= CPU_LASX; +- if (_cpuid_info.cpucfg_info_id2.bits.COMPLEX != 0) +- result |= CPU_COMPLEX; +- if (_cpuid_info.cpucfg_info_id2.bits.CRYPTO != 0) +- result |= CPU_CRYPTO; +- if (_cpuid_info.cpucfg_info_id2.bits.LBT_X86 != 0) +- result |= CPU_LBT_X86; +- if (_cpuid_info.cpucfg_info_id2.bits.LBT_ARM != 0) +- result |= CPU_LBT_ARM; +- if (_cpuid_info.cpucfg_info_id2.bits.LBT_MIPS != 0) +- result |= CPU_LBT_MIPS; +- if (_cpuid_info.cpucfg_info_id2.bits.LAM != 0) +- result |= CPU_LAM; + + if (_cpuid_info.cpucfg_info_id3.bits.CCDMA != 0) + result |= CPU_CCDMA; +@@ -170,8 +151,10 @@ void VM_Version::get_processor_features() { + + clean_cpuFeatures(); + ++ get_os_cpu_info(); ++ + get_cpu_info_stub(&_cpuid_info); +- _cpuFeatures = get_feature_flags_by_cpucfg(); ++ _features |= get_feature_flags_by_cpucfg(); + + _supports_cx8 = true; + +diff --git a/src/hotspot/cpu/loongarch/vm_version_loongarch.hpp b/src/hotspot/cpu/loongarch/vm_version_loongarch.hpp +index 8b5bc4a4c8..4ed21d3e56 100644 +--- a/src/hotspot/cpu/loongarch/vm_version_loongarch.hpp ++++ b/src/hotspot/cpu/loongarch/vm_version_loongarch.hpp +@@ -198,30 +198,30 @@ public: + protected: + + enum { +- CPU_LA32 = (1 << 1), +- CPU_LA64 = (1 << 2), +- CPU_LLEXC = (1 << 3), +- CPU_SCDLY = (1 << 4), +- CPU_LLDBAR = (1 << 5), +- CPU_LBT_X86 = (1 << 6), +- CPU_LBT_ARM = (1 << 7), +- CPU_LBT_MIPS = (1 << 8), +- CPU_CCDMA = (1 << 9), +- CPU_COMPLEX = (1 << 10), +- CPU_FP = (1 << 11), +- CPU_CRYPTO = (1 << 14), +- CPU_LSX = (1 << 15), +- CPU_LASX = (1 << 17), +- CPU_LAM = (1 << 21), +- CPU_LLSYNC = (1 << 23), +- CPU_TGTSYNC = (1 << 24), +- CPU_ULSYNC = (1 << 25), +- CPU_UAL = (1 << 26), ++ CPU_LAM = (1 << 1), ++ CPU_UAL = (1 << 2), ++ CPU_LSX = (1 << 4), ++ CPU_LASX = (1 << 5), ++ CPU_COMPLEX = (1 << 7), ++ CPU_CRYPTO = (1 << 8), ++ CPU_LBT_X86 = (1 << 10), ++ CPU_LBT_ARM = (1 << 11), ++ CPU_LBT_MIPS = (1 << 12), ++ // flags above must follow Linux HWCAP ++ CPU_LA32 = (1 << 13), ++ CPU_LA64 = (1 << 14), ++ CPU_FP = (1 << 15), ++ CPU_LLEXC = (1 << 16), ++ CPU_SCDLY = (1 << 17), ++ CPU_LLDBAR = (1 << 18), ++ CPU_CCDMA = (1 << 19), ++ CPU_LLSYNC = (1 << 20), ++ CPU_TGTSYNC = (1 << 21), ++ CPU_ULSYNC = (1 << 22), + + //////////////////////add some other feature here////////////////// + } cpuFeatureFlags; + +- static int _cpuFeatures; + static const char* _features_str; + static bool _cpu_info_is_initialized; + +@@ -244,8 +244,8 @@ protected: + static CpuidInfo _cpuid_info; + + static uint32_t get_feature_flags_by_cpucfg(); +- static int get_feature_flags_by_cpuinfo(int features); + static void get_processor_features(); ++ static void get_os_cpu_info(); + + public: + // Offsets for cpuid asm stub +@@ -262,26 +262,26 @@ public: + static ByteSize Loongson_Cpucfg_id13_offset() { return byte_offset_of(CpuidInfo, cpucfg_info_id13); } + static ByteSize Loongson_Cpucfg_id14_offset() { return byte_offset_of(CpuidInfo, cpucfg_info_id14); } + +- static void clean_cpuFeatures() { _cpuFeatures = 0; } ++ static void clean_cpuFeatures() { _features = 0; } + + // Initialization + static void initialize(); + + static bool cpu_info_is_initialized() { return _cpu_info_is_initialized; } + +- static bool is_la32() { return _cpuFeatures & CPU_LA32; } +- static bool is_la64() { return _cpuFeatures & CPU_LA64; } +- static bool supports_crypto() { return _cpuFeatures & CPU_CRYPTO; } +- static bool supports_lsx() { return _cpuFeatures & CPU_LSX; } +- static bool supports_lasx() { return _cpuFeatures & CPU_LASX; } +- static bool supports_lam() { return _cpuFeatures & CPU_LAM; } +- static bool supports_llexc() { return _cpuFeatures & CPU_LLEXC; } +- static bool supports_scdly() { return _cpuFeatures & CPU_SCDLY; } +- static bool supports_lldbar() { return _cpuFeatures & CPU_LLDBAR; } +- static bool supports_ual() { return _cpuFeatures & CPU_UAL; } +- static bool supports_lbt_x86() { return _cpuFeatures & CPU_LBT_X86; } +- static bool supports_lbt_arm() { return _cpuFeatures & CPU_LBT_ARM; } +- static bool supports_lbt_mips() { return _cpuFeatures & CPU_LBT_MIPS; } ++ static bool is_la32() { return _features & CPU_LA32; } ++ static bool is_la64() { return _features & CPU_LA64; } ++ static bool supports_crypto() { return _features & CPU_CRYPTO; } ++ static bool supports_lsx() { return _features & CPU_LSX; } ++ static bool supports_lasx() { return _features & CPU_LASX; } ++ static bool supports_lam() { return _features & CPU_LAM; } ++ static bool supports_llexc() { return _features & CPU_LLEXC; } ++ static bool supports_scdly() { return _features & CPU_SCDLY; } ++ static bool supports_lldbar() { return _features & CPU_LLDBAR; } ++ static bool supports_ual() { return _features & CPU_UAL; } ++ static bool supports_lbt_x86() { return _features & CPU_LBT_X86; } ++ static bool supports_lbt_arm() { return _features & CPU_LBT_ARM; } ++ static bool supports_lbt_mips() { return _features & CPU_LBT_MIPS; } + static bool needs_llsync() { return !supports_lldbar(); } + static bool needs_tgtsync() { return 1; } + static bool needs_ulsync() { return 1; } +diff --git a/src/hotspot/os_cpu/linux_loongarch/vm_version_linux_loongarch.cpp b/src/hotspot/os_cpu/linux_loongarch/vm_version_linux_loongarch.cpp +new file mode 100644 +index 0000000000..edc148ef91 +--- /dev/null ++++ b/src/hotspot/os_cpu/linux_loongarch/vm_version_linux_loongarch.cpp +@@ -0,0 +1,93 @@ ++/* ++ * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved. ++ * Copyright (c) 2015, 2023, Loongson Technology. All rights reserved. ++ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. ++ * ++ * This code is free software; you can redistribute it and/or modify it ++ * under the terms of the GNU General Public License version 2 only, as ++ * published by the Free Software Foundation. ++ * ++ * This code is distributed in the hope that it will be useful, but WITHOUT ++ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or ++ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ++ * version 2 for more details (a copy is included in the LICENSE file that ++ * accompanied this code). ++ * ++ * You should have received a copy of the GNU General Public License version ++ * 2 along with this work; if not, write to the Free Software Foundation, ++ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. ++ * ++ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA ++ * or visit www.oracle.com if you need additional information or have any ++ * questions. ++ * ++ */ ++ ++#include "precompiled.hpp" ++#include "runtime/os.hpp" ++#include "runtime/vm_version.hpp" ++ ++#include ++#include ++ ++#ifndef HWCAP_LOONGARCH_LAM ++#define HWCAP_LOONGARCH_LAM (1 << 1) ++#endif ++ ++#ifndef HWCAP_LOONGARCH_UAL ++#define HWCAP_LOONGARCH_UAL (1 << 2) ++#endif ++ ++#ifndef HWCAP_LOONGARCH_LSX ++#define HWCAP_LOONGARCH_LSX (1 << 4) ++#endif ++ ++#ifndef HWCAP_LOONGARCH_LASX ++#define HWCAP_LOONGARCH_LASX (1 << 5) ++#endif ++ ++#ifndef HWCAP_LOONGARCH_COMPLEX ++#define HWCAP_LOONGARCH_COMPLEX (1 << 7) ++#endif ++ ++#ifndef HWCAP_LOONGARCH_CRYPTO ++#define HWCAP_LOONGARCH_CRYPTO (1 << 8) ++#endif ++ ++#ifndef HWCAP_LOONGARCH_LBT_X86 ++#define HWCAP_LOONGARCH_LBT_X86 (1 << 10) ++#endif ++ ++#ifndef HWCAP_LOONGARCH_LBT_ARM ++#define HWCAP_LOONGARCH_LBT_ARM (1 << 11) ++#endif ++ ++#ifndef HWCAP_LOONGARCH_LBT_MIPS ++#define HWCAP_LOONGARCH_LBT_MIPS (1 << 12) ++#endif ++ ++void VM_Version::get_os_cpu_info() { ++ ++ uint64_t auxv = getauxval(AT_HWCAP); ++ ++ STATIC_ASSERT(CPU_LAM == HWCAP_LOONGARCH_LAM); ++ STATIC_ASSERT(CPU_UAL == HWCAP_LOONGARCH_UAL); ++ STATIC_ASSERT(CPU_LSX == HWCAP_LOONGARCH_LSX); ++ STATIC_ASSERT(CPU_LASX == HWCAP_LOONGARCH_LASX); ++ STATIC_ASSERT(CPU_COMPLEX == HWCAP_LOONGARCH_COMPLEX); ++ STATIC_ASSERT(CPU_CRYPTO == HWCAP_LOONGARCH_CRYPTO); ++ STATIC_ASSERT(CPU_LBT_X86 == HWCAP_LOONGARCH_LBT_X86); ++ STATIC_ASSERT(CPU_LBT_ARM == HWCAP_LOONGARCH_LBT_ARM); ++ STATIC_ASSERT(CPU_LBT_MIPS == HWCAP_LOONGARCH_LBT_MIPS); ++ ++ _features = auxv & ( ++ HWCAP_LOONGARCH_LAM | ++ HWCAP_LOONGARCH_UAL | ++ HWCAP_LOONGARCH_LSX | ++ HWCAP_LOONGARCH_LASX | ++ HWCAP_LOONGARCH_COMPLEX | ++ HWCAP_LOONGARCH_CRYPTO | ++ HWCAP_LOONGARCH_LBT_X86 | ++ HWCAP_LOONGARCH_LBT_ARM | ++ HWCAP_LOONGARCH_LBT_MIPS); ++} diff --git a/openjdk-11.spec b/openjdk-11.spec index c1c2645..b4dc05e 100644 --- a/openjdk-11.spec +++ b/openjdk-11.spec @@ -807,6 +807,7 @@ Patch1000: rh1648249-add_commented_out_nss_cfg_provider_to_java_security.patch ############################################ Patch2000: LoongArch64-support.patch +Patch2001: LoongArch-uses-hwcap-detect-cpu-flags.patch ############################################# # @@ -1187,6 +1188,7 @@ pushd %{top_level_dir_name} %endif %ifarch loongarch64 %patch2000 -p1 +%patch2001 -p1 %endif popd # openjdk @@ -1702,10 +1704,8 @@ cjc.mainProgram(arg) %changelog * Mon Feb 27 2023 panxuefeng - 1:11.0.18.10-3 -- windows debug build failed -- [MIPS] Fix a typo in PosixSignals::pd_hotspot_signal_handler -- [MIPS] minimal build failed with --disable-precompiled-headers -- Fix a typo in PosixSignals::pd_hotspot_signal_handler +- update LoongArch64 port to jdk-11.0.18+10-ls-1 +- LoongArch uses hwcap detect cpu flags * Thu Feb 2 2023 aoqi - 1:11.0.18.10-2 - update LoongArch64 to 11.0.18+10 (GA) -- Gitee