RFR: 8373630: r18_tls should not be modified on Windows AArch64
Saint Wesonga
duke at openjdk.org
Fri Dec 12 23:01:11 UTC 2025
On Windows, r18_tls is used to store the pointer to the current thread's TEB. Therefore, this register should never be modified (see details in [register_aarch64.hpp](https://github.com/openjdk/jdk/blob/23c39757ecdc834c631f98f4487cfea21c9b948b/src/hotspot/cpu/aarch64/register_aarch64.hpp#L118-L128)). One scenario that results in the modification of r18_tls involves virtual threads on Windows. Frames are frozen by [Continuation::try_preempt](https://github.com/openjdk/jdk/blob/23c39757ecdc834c631f98f4487cfea21c9b948b/src/hotspot/share/runtime/continuation.cpp#L131) on one carrier thread whose registers are saved. When the frame is thawed, execution can continue on a different carrier thread. When this happens, [rthread (x28) is fixed to point to the new carrier thread](https://github.com/openjdk/jdk/blob/23c39757ecdc834c631f98f4487cfea21c9b948b/src/hotspot/share/runtime/continuationFreezeThaw.cpp#L2670). The continuation then results in [restore_live_registers](https://github.com/open
jdk/jdk/blob/23c39757ecdc834c631f98f4487cfea21c9b948b/src/hotspot/cpu/aarch64/c1_Runtime1_aarch64.cpp#L313) restoring all the saved registers (including the fixed rthread register). However, this also restores x18, which was the TEB pointer for the previous carrier thread, causing the new carrier thread to execute with the TLS of the previous carrier thread. This causes hangs and occasional crashes in the virtual threads jtreg tests on Windows AArch64 that are resolved by this fix.
-------------
Commit messages:
- Do not modify r18_tls when restoring registers on Windows AArch64
Changes: https://git.openjdk.org/jdk/pull/28808/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=28808&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8373630
Stats: 23 lines in 1 file changed: 23 ins; 0 del; 0 mod
Patch: https://git.openjdk.org/jdk/pull/28808.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/28808/head:pull/28808
PR: https://git.openjdk.org/jdk/pull/28808
More information about the hotspot-compiler-dev
mailing list