RFR: 8368366: RISC-V: AlignVector is mistakenly set to AvoidUnalignedAccesses

Fei Yang fyang at openjdk.org
Tue Sep 23 07:29:50 UTC 2025


Hi, please consider this small change fixing setting of `AlignVector` flag.

According to the latest RISC-V linux hardware probing syscall [1], the performance of misaligned memory accesses
has been divided into two cases: `RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF` and `RISCV_HWPROBE_KEY_MISALIGNED_VECTOR_PERF`
for scalar and vector respectively. And `RISCV_HWPROBE_KEY_CPUPERF_0` is now deprecated and it now returns similar values
to `RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF`.

Previously, we use `RISCV_HWPROBE_KEY_CPUPERF_0` to detect support for misaligned memory accesses and reflect the result
on VM flags like `AvoidUnalignedAccesses`, `UseUnalignedAccesses` and `AlignVector`. But it doesn't seem correct to update
AlignVector according to this value. And this is causing issues on hardwares which have fast misaligned accesses only
for scalar. I see they will trigger SIGBUG error in the case of vector misaligned accesses.

So we should align AlignVector with `RISCV_HWPROBE_KEY_MISALIGNED_VECTOR_PERF` instead. This patch just reverts the previous
setting of AlignVector and just let it have the default value which is true. I will try to add detection in a separate PR
for `RISCV_HWPROBE_KEY_MISALIGNED_VECTOR_PERF` and update `AlignVector` accordingly.

[1] https://docs.kernel.org/arch/riscv/hwprobe.html

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

Commit messages:
 - 8368366: RISC-V: AlignVector is mistakenly set to AvoidUnalignedAccesses

Changes: https://git.openjdk.org/jdk/pull/27445/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=27445&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8368366
  Stats: 4 lines in 1 file changed: 0 ins; 4 del; 0 mod
  Patch: https://git.openjdk.org/jdk/pull/27445.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/27445/head:pull/27445

PR: https://git.openjdk.org/jdk/pull/27445


More information about the hotspot-dev mailing list