LATX, fix: Restore LBT TOP state after longjmp - #424
Open
ganjue66da wants to merge 2 commits into
Open
Conversation
Some translator exits bypass the generated epilogue, and siglongjmp can restore a host context with LBT TOP mode still active. The next entry then loads physical x87 registers through the stale mapping and places values in the wrong slots for Minke.MI.Organ. After siglongjmp returns to cpu_exec(), check the saved FCSR TOP-mode bit. Clear both the saved bit and hardware mode only when it is set, and leave soft-float execution unchanged. Tests: - Run 20,000 x87 signal deliveries with no failures - Verify single, seven-thread, and nonzero-TOP signal restoration Signed-off-by: Wenqiang Wei <weiwenqiang@mail.ustc.edu.cn>
INT and syscall translators saved FCSR before register cleanup disabled LBT TOP mode. The longjmp exit therefore saw the saved mode as active and had to clear it again on every traditional syscall. Save FCSR after register cleanup on regular INT, traditional syscall tunnel, and x86-64 SYSCALL exits. This records the disabled mode, avoids the longjmp slow path, and removes an unused FCSR save from the optimized syscall tunnel. Tests: - Run 20,000 x87 signal deliveries with no failures - Run 2,000 Wine/.NET external-GC float round trips Signed-off-by: Wenqiang Wei <weiwenqiang@mail.ustc.edu.cn>
ganjue66da
force-pushed
the
codex/lbt-top-longjmp
branch
from
August 25, 2026 03:54
097cfe6 to
6932b21
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.
Motivation
Some translator exits use
siglongjmpand bypass the normal generated epilogue. If the saved host FCSR still records LBT TOP mode as active, the next x87 entry can reuse a stale physical-to-logical stack mapping.Changes
cpu_exec()throughsiglongjmp.Validation
ninja -C build32 latx-i386ninja -C build64 latx-x86_64LATX_SOFTFPU=2 LATX_SOFTFPU_FAST=0xc00000passes the signal-stack regression.Dependency note
The signal restoration regression also requires the separately submitted x87 signal-frame fix. This branch remains based directly on
masterso the two problems can be reviewed independently.