Skip to content

Sync with upstream FEX - #2

Open
github-actions[bot] wants to merge 254 commits into
mainfrom
upstream-main
Open

github-actions[bot] wants to merge 254 commits into
mainfrom
upstream-main

Conversation

@github-actions

@github-actions github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

upstream-main has 254 commits that are not in main.

Newest upstream commit: 490bb02 Merge pull request #6147 from cjacek/avx32

Merge this PR with a merge commit (not squash or rebase) so that main keeps the upstream history.

javelina-pkwy and others added 30 commits October 6, 2026 12:16
Tests: Enable a handful of tests, and fix small bug in python test runner script
Peephole optimization for VPCMPEQD + VGATHERDPS
Scripts/InstallFEX: Add new ubuntu versions
NtDllRedirectionLUTSize is a uint32_t, but CheckCall loaded it with a
64-bit ldr. The upper half of the bound then comes from whatever follows
the variable in memory, and the :lo12: offset of a 64-bit ldr needs an
8-byte aligned symbol, so the link fails with "misaligned ldr/str offset"
when the variable ends up on a 4-byte boundary.

Load it with a 32-bit ldr, which zero-extends into x17 for the compare.
NtDllRedirectionLUT has NtDllRedirectionLUTSize entries, so valid
offsets are 0 to NtDllRedirectionLUTSize - 1. The bounds check used
b.hi, which let an offset equal to the size through and read one entry
past the end of the allocation.
This is fairly trivial to support.

Fixes #6028
ARM64EC: Fix the NtDllRedirectionLUT bounds check in CheckCall
Linux: Return EFAULT for stat() of a null path
Linux: Track main stack usage more accurately in VmData
Linux/SignalDelegator: Support SA_RESETHAND
Found this through introspection, only a real problem with -O0.
We were moving a fextl::vector in to a shared pointer so it can be long
living, this causes a change in ownership which was causing the
`BlobData` pointer to be stale. This was then passed to the work queue
to be consumed. In -O1 and above a std::move of a fextl::vector is a
proper move, but -O0 it turns in to a copy.

Easy fix is to just create the shared_ptr early and reference that, so
the pointer is long lived and no references become stale.
DiskCache: Fixes a race condition on the data blob
Tests: Reduce wall clock time spent in "ninja tests"
unittests/ASM: Test SAR sign extension for 8 and 16 bit
lioncash and others added 30 commits November 11, 2026 00:00
FEXInterpreter: select is banned
Wine now supports Windows-compatible context flags for storing YMM state
in the ARM64 context. That includes CONTEXT_ARM64_FLOATING_POINT_LOW/HIGH,
which can be used to address the FP registers representing SSE and AVX
registers separately. CONTEXT_ARM64_FLOATING_POINT is equivalent to
setting both of those flags, which is enough for how FEX currently uses
the context.

CONTEXT_ARM64_FEX_YMMSTATE has the same value as CONTEXT_ARM64_FLOATING_POINT_LOW,
which is not what it's meant to express, but it's harmless and redundant.
Just remove the flag to avoid confusion.
ARM64EC: Remove no longer needed CONTEXT_ARM64_FEX_YMMSTATE flag
This supplements the partial_decode_failure test with explicit
instructions that generate synchronous faults in FEX.

Today both of these tests pass in arm64ec and wow64, but wow64 currently
doesn't do fault-free synchronous faults. When tinkering with converting
wow64 over, it was picking up implementation failures.

Can't yet test these in CI directly but good to have.
FEXMingwTests: Adds a synchronous fault test
Turns out this is used in the wild by SecuROM. Helps get #6124 further,
but doesn't quite fix the game. Just has SecuROM error 8016 now.

Might be related to the DEP disablement stuff?
FEXCore: Ensure BSF/BSR works with repne prefix
When a process calls `NtTerminateProcess`, FEX gets in a state where
threads are ripped out from under itself. Due to how WINE implements
this syscall, what happens is that SIGQUIT is sent to all the threads.
These threads then die while holding various mutexes inside of FEX's
code. For the threads that were unlucky enough to be in a WINE syscall
handler and blocking the SIGQUIT signal, this means they continue trying
to do some work.

These remaining threads then call back in to FEX, hit some of these
mutexes that are now dead and hang forever. There's no way to recover
from this situation since those threads are completely gone already.

Luckily for us, FEX is allowed to do a bit of work before and after
`NtTerminateProcess`. So before the syscall actually fires, round up all
of our threads and suspend them using the Suspend Doorbell mechanism.
Once the threads are suspended we can then continue and let WINE SIGQUIT
them, since at that point we know they're no longer holding any locks
that could cause us to hang.

Technically this still isn't a 100% sure-fire approach since other
processes can call `NtTerminateProcess` on our process and WINE will
happily SIGQUIT the process without notifying us. There's also the case
that `NtTerminateThread` can do the same thing for a single thread. To
solve all these cases we actually need WINE itself to completely rewrite
how they do process shutdown in these instances and ensure to use the
doorbell itself in all cases.

The testcase for this was spinning on wine-mono's `delegate8.exe`
unittest which would quickly hang on process shutdown. I just started up
ten instances of this and let them spin for an hour to show they no
longer hang with these changes.

Fixes at least one spurious hang we've been having on process shutdown
which is nice.
WINE: Fixes race on TerminateProcess
ProfileStats on Win32 is actually fairly costly even when not enabled
because `QueryPerformanceCounter` actually requires going through Wine's
syscall disaptcher. We were always calling these even when they weren't
enabled as long as they were compiled in. Using the cycle counter is
almost already perfect for us since we're only caring about short
relative time events. We just need to convert the virtual cycle counter
from cycles to nanoseconds.

On real ARMv9.1 platforms with a 1Ghz cycle counters this'll turn in to
a multiply by 1 and divide by 1, which is fairly fast on modern CPUs.
Just need to calculate the scale factors early and reuse them.

Fixes #6133
Profiler: Use cycle counter register directly
If the flags were passed in to C/CXX flags, then skip these. Was causing
redundant flags to be set that were conflicting with each other.
CMake: Skip CPU/Arch tuning if already set
If memory space is getting reserved but not committed then we don't need
to track it ourselves. Removes some overhead down the line.
wow64/arm64ec: Stop tracking reserve only allocations
By detecting common SHA1 code patterns we can improve bulk throughput in SHA1 by about 2x, based on testing on Oryon-3.
This field now tells us what the granularity of LSE2 unaligned faults
occur for load, store, and RMW operations. Only show the value if it
differs from testing.

Oryon-3 today will show a difference today for this.
FEXGetConfig: Use new LSE2Size field to see unaligned granulrity
Maybe this changes are not needed and the execute bit is enough, but
i playing around and probably the PF from nonpresent page also a bit
useful.

Drop it if this test is useless :)
Supposedly these are supposed to only return NTSTATUS but I guess in
some cases it can return garbage in the upper-bits. In particular the
UnixCalls are a bit weird.

Fixes #6145
Wow64: Fixes incorrect zext on syscalls
Small improvements of partial decode test
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.