Integrated: 8373630: r18_tls should not be modified on Windows AArch64

Saint Wesonga duke at openjdk.org
Tue Dec 16 18:39:11 UTC 2025


On Fri, 12 Dec 2025 22:54:45 GMT, Saint Wesonga <duke at openjdk.org> wrote:

> 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/op
 enjdk/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.

This pull request has now been integrated.

Changeset: a0dd66f9
Author:    Saint Wesonga <saint.wesonga at microsoft.com>
Committer: Andrew Haley <aph at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/a0dd66f92d7f8400b9800847e36d036315628afb
Stats:     23 lines in 1 file changed: 23 ins; 0 del; 0 mod

8373630: r18_tls should not be modified on Windows AArch64

Reviewed-by: pchilanomate, aph

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

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


More information about the hotspot-compiler-dev mailing list