Skip to content

linux-user, fix: Preserve x87 state in signal frames - #423

Open
ganjue66da wants to merge 1 commit into
lat-opensource:masterfrom
ganjue66da:codex/x87-signal-frame
Open

linux-user, fix: Preserve x87 state in signal frames#423
ganjue66da wants to merge 1 commit into
lat-opensource:masterfrom
ganjue66da:codex/x87-signal-frame

Conversation

@ganjue66da

Copy link
Copy Markdown
Contributor

Motivation

An x87 value could be lost or restored into the wrong logical stack slot after a guest signal because the i386 signal frame did not preserve the complete x87 state used by LATX.

Changes

  • Preserve the missing x87 state when constructing and restoring i386 guest signal frames.
  • Keep the change limited to linux-user/i386/signal.c.

Validation

  • ninja -C build32 latx-i386
  • LATX_SOFTFPU=2 build32/latx-i386 latx-x87-signal-stack-test-one
  • Result: signals=1 failures=0.

Scope

This PR contains one correctness fix. LBT TOP cleanup is submitted separately.

The 32-bit signal path invoked destructive FSAVE before building the
FXSAVE or XSAVE image.  FSAVE initializes the x87 state, so sigreturn
restored an empty stack instead of the interrupted state for Minke.MI.
Organ CLR suspension.

Capture the extended state before filling the legacy FSAVE area.  This
preserves both signal-frame formats while leaving the initialized x87
state for the handler, matching Linux x86 signal semantics.

Tests:
- Verify that an x87 value survives SIGUSR1 delivery and sigreturn

Signed-off-by: Wenqiang Wei <weiwenqiang@mail.ustc.edu.cn>
@ganjue66da
ganjue66da force-pushed the codex/x87-signal-frame branch from 8e172d2 to 159c645 Compare August 25, 2026 03:54

@LaurenIsACoder LaurenIsACoder left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

确认一下x86_64路径有无问题

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants