[riscv-port] RFR: 8277036: riscv: Get CPU features from the auxiliary vector on Linux

Yanhong Zhu yzhu at openjdk.java.net
Fri Nov 19 02:46:29 UTC 2021


Due to the lack of native environment in our early development of riscv port, we detect riscv CPU ISA extensions through checking whether simulator (e.g. QEMU) supports execution of one of the instructions in the corresponding feature spec or not. Fortunately, there are several riscv hardwares available now, we can directly get this CPU info from the auxiliary vector on Linux. Note that the aarch64 port also did the same thing on Linux platform.

This has been tested on HiFive Unleashed board (rv64imafdc) and NeZha D1 board (rv64imafdcvu):

# HiFive Unmatched
$jdk/bin/java -XX:+UseVExt -XX:+PrintFlagsFinal -version |grep UseVExt
OpenJDK 64-Bit Server VM warning: RVV is not supported on this CPU
    bool UseVExt                                          = false                             {ARCH product} {command line}
openjdk version "18-internal" 2022-03-15
OpenJDK Runtime Environment (build 18-internal+0-adhoc..riscv-port)
OpenJDK 64-Bit Server VM (build 18-internal+0-adhoc..riscv-port, mixed mode)

$jdk/bin/java -XX:-UseVExt -XX:+PrintFlagsFinal -version |grep UseVExt
    bool UseVExt                                          = false                             {ARCH product} {command line}
openjdk version "18-internal" 2022-03-15
OpenJDK Runtime Environment (build 18-internal+0-adhoc..riscv-port)
OpenJDK 64-Bit Server VM (build 18-internal+0-adhoc..riscv-port, mixed mode)

$jdk/bin/java -XX:+PrintFlagsFinal -version |grep UseVExt
    bool UseVExt                                          = false                             {ARCH product} {command line}
openjdk version "18-internal" 2022-03-15
OpenJDK Runtime Environment (build 18-internal+0-adhoc..riscv-port)
OpenJDK 64-Bit Server VM (build 18-internal+0-adhoc..riscv-port, mixed mode)

# NeZha D1 
$jdk/bin/java -XX:+UseVExt -XX:+PrintFlagsFinal -version |grep UseVExt
    bool UseVExt                                          = true                             {ARCH product} {command line}
openjdk version "18-internal" 2022-03-15
OpenJDK Runtime Environment (build 18-internal+0-adhoc..riscv-port)
OpenJDK 64-Bit Server VM (build 18-internal+0-adhoc..riscv-port, mixed mode)

$jdk/bin/java -XX:-UseVExt -XX:+PrintFlagsFinal -version |grep UseVExt
    bool UseVExt                                          = false                             {ARCH product} {command line}
openjdk version "18-internal" 2022-03-15
OpenJDK Runtime Environment (build 18-internal+0-adhoc..riscv-port)
OpenJDK 64-Bit Server VM (build 18-internal+0-adhoc..riscv-port, mixed mode)

$jdk/bin/java -XX:+PrintFlagsFinal -version |grep UseVExt
    bool UseVExt                                          = false                             {ARCH product} {command line}
openjdk version "18-internal" 2022-03-15
OpenJDK Runtime Environment (build 18-internal+0-adhoc..riscv-port)
OpenJDK 64-Bit Server VM (build 18-internal+0-adhoc..riscv-port, mixed mode)

-------------

Commit messages:
 - 8277036: riscv: Get CPU features from the auxiliary vector on Linux

Changes: https://git.openjdk.java.net/riscv-port/pull/10/files
 Webrev: https://webrevs.openjdk.java.net/?repo=riscv-port&pr=10&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8277036
  Stats: 245 lines in 13 files changed: 115 ins; 112 del; 18 mod
  Patch: https://git.openjdk.java.net/riscv-port/pull/10.diff
  Fetch: git fetch https://git.openjdk.java.net/riscv-port pull/10/head:pull/10

PR: https://git.openjdk.java.net/riscv-port/pull/10


More information about the riscv-port-dev mailing list