LATX, fix: Avoid LL/SC lowering for locked i386 operations - #420
Draft
baibaidashixiong wants to merge 1 commit into
Draft
LATX, fix: Avoid LL/SC lowering for locked i386 operations#420baibaidashixiong wants to merge 1 commit into
baibaidashixiong wants to merge 1 commit into
Conversation
Steam's i386 runtime on LoongArch can receive EFAULT from a private FUTEX_WAIT while its guest futex word remains mapped. An unaligned i386 LOCK operand takes the LL/SC fallback through the instruction interpreter, which temporarily mremaps the guest host page and exposes that transient fault to a concurrent host futex wait. Select software-lock lowering for all locked i386 instruction translators. Use one process-local LATX lock instead of the 64-byte hash, since overlapping x86 operands can begin in adjacent hash stripes. Release the current CPU owner token on every nonlocal CPU-loop exit so a guest page fault cannot strand the lock. Signed-off-by: zqz <OrzZzznn@gmail.com>
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 / 变更说明
EFAULTfrom a privateFUTEX_WAITeven though the guest futex word remained mapped. The rootcause is not the futex syscall itself: an unaligned i386
LOCKoperand canenter the LL/SC interpreter fallback, which temporarily
mremaps the hostpage. A concurrent host futex wait can observe that short-lived unmapped
window.
including the previously separate
LOCK CMPXCHG8Bpath. i386 uses oneprocess-local lock rather than a 64-byte hash, because overlapping x86
operands can start in different hash stripes. x86-64 keeps its existing
lowering.
guest page fault cannot strand the lock. This is a root-cause repair: it
removes the temporary page migration instead of retrying a failed futex.
LOCK INC,LOCK CMPXCHG8B,private
FUTEX_WAITandFUTEX_WAIT_BITSET, a cross-stripe overlap check,and a
PROT_NONEfault-cleanup check. It runs the completeLATX_AOT=0/1 × LATX_KZT=0/1matrix with an isolated temporaryHOMEforAOT cache files.
MAP_SHAREDx86LOCKatomicity needs a separate shared-lock design.Validation / 验证
ninja -C build32 latx-i386: passed on LoongArch64.ninja -C build64 latx-x86_64: passed on LoongArch64.LATX_AOT=0/1 × LATX_KZT=0/1combinationspassed. The AOT=1 passes share the temporary cache directory after its
first creation.
straceof the focused test observed roughly 100,000 futex callsfor each KZT mode, with zero futex
EFAULTresults and zeromremapcalls.meson test -C build32-tests --suite latx-integration --print-errorlogs:passed on the PR branch (5/5) and again after integration (6/6).
git diff --check: passed. Independent review found no blocking issue;it verified the i386 LOCK paths,
CMPXCHG8B, cross-stripe overlap, andnonlocal-exit cleanup.
correctness path rather than a throughput optimization.
Checklist / 检查项
CONTRIBUTING.md. / 我已阅读CONTRIBUTING.md。git commit -s). /每个提交都包含 DCO 签署(
git commit -s)。are not applicable. /
我已提供相关构建或测试结果,或说明了不适用的原因。