LATX, feat: Add opt-in Guest TLS and explicit libc boundaries - #470
Draft
LaurenIsACoder wants to merge 5 commits into
Draft
LaurenIsACoder wants to merge 5 commits into
LaurenIsACoder wants to merge 5 commits into
Conversation
LaurenIsACoder
force-pushed
the
lauren/kzt-guest-tls
branch
2 times, most recently
from
September 13, 2026 08:25
4d7379d to
e1262a7
Compare
Extract CPU clone initialization without changing existing callers or thread policy. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Preserve the existing callback ABI, including float results and Host floating-point register preservation. Add explicit helper-call entry points for subsequent TLS initialization. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Keep common runtime options available in release builds and propagate an explicit -L selection through LAT_LD_PREFIX. A re-executed Guest must use the same loader and libc as its parent. Add test-runtime-prefix-exec to check the exported selection and mapped Guest libc before and after exec. Reverting the runtime-root fix makes the fixture fail; the fixed build passes on LoongArch ABI1. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
Keep Guest TLS management disabled unless LATX_KZT_GUEST_TLS=1 and KZT is effective. Attach native-created threads from an immutable template, initialize Guest TLS from live loader state, and coordinate generation refresh, callback execution, fork and thread exit. Keep existing library registration and disabled-mode loader behavior. Add policy, loader and native-thread callback tests. Initialize the attached TCB thread ID and robust-list fields before calling the Guest loader allocation helper. The debugger regression reaches that helper with TID 0 before the fix and with the real thread ID after it. Opt-in off/on, robust owner death and 64-cycle dynamic loading regressions pass on LoongArch ABI1. Supply the new runtime-gate variables in the standalone TB-flush test fixture so the complete KZT-enabled lat-pr-fast suite links and runs. Co-authored-by: sunguoyun <sunguoyun@loongson.cn> Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
…ries Provide an initially inactive libc boundary broker for errno, h_errno and locale names. Keep Guest thread destruction in the TLS runtime. Consumers explicitly initialize and activate the broker; enabling Guest TLS alone does not enable semantic propagation. Keep private libc pointers within their owning domain. Own locale projections per Guest context, document borrowed handles, and release each projection in its owning libc during context teardown. The two-thread regression fails with the old shared cache and passes with separate contexts, including mutation and release of an owned duplicate. Signed-off-by: Hanlu Li <heuleehanlu@gmail.com>
LaurenIsACoder
force-pushed
the
lauren/kzt-guest-tls
branch
from
September 13, 2026 08:55
e1262a7 to
e97cb17
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A native library can call back into x86-64 Guest code from a pthread that never ran the Guest pthread initialization path. This draft adds default-off Guest TLS attachment for those callbacks and a separately activated interface for selected libc state.
The branch stays as one five-commit series. The review fixes are folded into the existing Guest TLS commit; no follow-up fix commit was added.
Commit guide
edaa9425856182f1cba1dfe183e0fbb84exec.a1991d92a06e97cb175aafh_errno, and locale propagation boundaries.Review changes
dtv[0]. A separate loader generation is seeded from a DTV initialized by the Guest loader, then advanced once for eachr_brktransaction whose Guest-loader TLS inventory changes. This records consecutive load/unload transactions even when no attached callback runs between them. KZT-only external registrations do not advance this generation. An early loader callback prepares constructor TLS without committing the attached inventory; callbacks reached while the serialized loader operation is active use the same preparation-only path. The completed refresh publishes the tracked loader generation without calling_dl_allocate_tls_initagain or reinitializing live TLS values.The Guest TLS commit also includes the GLib declaration headers required to build the current upstream AOT tests with older GLib headers and warnings treated as errors.
Activation and ownership
LATX_KZT_GUEST_TLS=1and an effective KZT library group. The default remains off.Validation
The final source is rebased onto upstream
97429a33e82e0957baac261f1ec2ba343e599700and was built on LoongArch64 with 16 KiB pages, GCC 8.3, and host glibc 2.28:lat-pr-fast: 34 passed, 0 failed, 0 skipped.dlopenstress: 4/4 passed, including cold/warm AOT rounds.h_errno, and locale boundary: passed.12345rather than reverting to its initializer.A downstream composition using the dependent liblat branch and a separate JVM adapter also passed
lat-pr-fast34/34. MATLAB R2020b completed three consecutive desktop runs: JVM and native JVM/NBL mappings were observed, arithmetic completed, the desktop window matched the process, each run remained active for 90 seconds, and all three exited naturally with status 0. Ready times were 19.29 s, 18.28 s, and 19.30 s. The JVM adapter and NBL sources are not part of this PR.Remaining limits
fork()still produces a child failure on both the old and new branches. It is outside the four reviewed cases and remains open.Checklist
CONTRIBUTING.md.