RFR: 8309258: RISC-V: Add riscv_hwprobe syscall [v8]
Dingli Zhang
dzhang at openjdk.org
Fri Jul 14 10:49:28 UTC 2023
On Mon, 19 Jun 2023 17:13:15 GMT, Robbin Ehn <rehn at openjdk.org> wrote:
>> Hi, please consider.
>>
>> Linux kernel 6.4 will come with the new syscall https://docs.kernel.org/riscv/hwprobe.html to determine CPU and features.
>> RV cpus features/capabilities can vastly differ and it is not feasible for users to manually enable the correct feature set.
>> Today the VM uses the ELF aux vector and cpuinfo to gather some information about CPU capabilities.
>>
>> Currently features are track with a bit field, this is insufficient.
>> There are many capabilities and these can have values attached to them.
>> CPU features should also be possible to turn if we can determine vendor (hwprobe).
>>
>> This patchs adds the syscall, uses the syscall in combination with the aux and cpuinfo to enable features by default.
>> If there is a vendor specific path it calls that in addition.
>> Then we build the feature string(and bit field) and update flags accordingly.
>>
>> Tested t1 and hwprobe with:
>> https://lore.kernel.org/qemu-devel/7f8d733df6e9b6151e9efb843d55441348805e70.camel@rivosinc.com/
>
> Robbin Ehn has updated the pull request incrementally with one additional commit since the last revision:
>
> removed q and zbc from rivos common features
Hi, I noticed fastdebug building crashed when running `java -version` on SG2042 (64cores c910):
$ ./java -version
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGILL (0x4) at pc=0x0000003f73a70892, pid=347134, tid=347135
#
# JRE version: (22.0) (fastdebug build )
# Java VM: OpenJDK 64-Bit Server VM (fastdebug 22-internal-adhoc.zhangdingli.jdk, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, linux-riscv64)
# Problematic frame:
# v ~StubRoutines::jint_disjoint_arraycopy 0x0000003f73a70892
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/share/apport/apport -p%p -s%s -c%c -d%d -P%P -u%u -g%g -- %E" (or dumping to /home/perfxlab01/jdkbuild/compare/jdk_after/bin/core.347134)
#
# An error report file with more information is saved as:
# /home/perfxlab01/jdkbuild/compare/jdk_after/bin/hs_err_pid347134.log
[0.727s][warning][os] Loading hsdis library failed
#
#
Aborted (core dumped)
The instruct at the pc of crash is `020f6007`, which is `vle32.v v0,(t5)`.
Complete log: https://cr.openjdk.org/~dzhang/hs_err_pid347134.log
System Information:
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 22.10
Release: 22.10
Codename: kinetic
$ uname -a
Linux riscv-02 6.1.31 #6 SMP Tue Jul 11 18:48:27 CST 2023 riscv64 riscv64 riscv64 GNU/Linux
$ cat /proc/cpuinfo
processor : 0
hart : 4
isa : rv64imafdcv
mmu : sv39
mvendorid : 0x5b7
marchid : 0x0
mimpid : 0x0
...
The release building `java -version` doesn't cause a crash, but when set it as JAVA_HOME and then executes `jtreg -version`, it will crash for similar reasons. We can see the flag under release building:
$ ./java -XX:+PrintFlagsFinal -XX:+UnlockExperimentalVMOptions -version | grep UseRVV
bool UseRVV = true {ARCH experimental} {default}
bool UseRVVForBigIntegerShiftIntrinsics = true {ARCH product} {default}
The problem looks like c910 only supports rvv0.7.1, while openjdk only supports rvv1.0. `UseRVV` is automatically enabled on SG2042, even though it's a experimental VMOption. Maybe we should set `UPDATE_DEFAULT(UseRVV)` to `NO_UPDATE_DEFAULT` for now or do something depending on the version of rvv?
I would appreciate it if some advice is given, thank you!
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14445#issuecomment-1635676161
More information about the hotspot-dev
mailing list