Skip to content

FEX: Implement support for CPUID faulting - #6104

Merged
lioncash merged 5 commits into
FEX-Emu:mainfrom
Sonicadvance1:308
Nov 6, 2026
Merged

lioncash merged 5 commits into
FEX-Emu:mainfrom
Sonicadvance1:308

Conversation

@Sonicadvance1

Copy link
Copy Markdown
Member

This is a relatively new Linux feature from 2017. Supported on AMD CPUs since Zen 4 (2022) and Intel CPUs since Ivy Bridge (2012). So it's been a long time coming for AMD to catch up. I had been slowly working towards implementing this but finally pushed it over the edge. This will slow down our CPUID emulation slightly but having it supported is worth it.

Some test results from my AmpereOneA.
Before:

Test, Total Cycles, Iterations, Cycles Average, Iter Time Average, iterations/Second
cpuid, 555942960, 53355000, 10.42, 10.42, 95972075.98

Before with const-prop disabled:

Test, Total Cycles, Iterations, Cycles Average, Iter Time Average, iterations/Second
cpuid, 701291860, 23713500, 29.57, 29.57, 33814024.31

After:

Test, Total Cycles, Iterations, Cycles Average, Iter Time Average, iterations/Second
cpuid, 606550700, 23713500, 25.58, 25.58, 39095660.10

TR7995WX for fun:

Test, Total Cycles, Iterations, Cycles Average, Iter Time Average, iterations/Second
cpuid, 1713884925, 23713500, 72.27, 28.95, 34538389.08

As seen most of the performance hit comes from the const-prop removal, but we actually manage to claw back a bit of the performance. The implementation is still faster than the threadripper which is kind of fun. Tested this with Proton with its CPUID emulation to ensure its working properly there but the unittest does what WINE does plus more.

@Sonicadvance1

Copy link
Copy Markdown
Member Author

I'll finish this post-release.

Tests various instruction lengths to ensure it works robustly.
@Sonicadvance1
Sonicadvance1 marked this pull request as ready for review November 5, 2026 23:12
@Sonicadvance1

Copy link
Copy Markdown
Member Author

Alright, remaining bug actually wasn't anything spooky. I just forgot to say that the CPUID OpcodeDispatcher actually sets RIP.

@lioncash
lioncash merged commit c985199 into FEX-Emu:main Nov 6, 2026
13 checks passed
@Sonicadvance1
Sonicadvance1 deleted the 308 branch November 6, 2026 00:51
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