FEX icon indicating copy to clipboard operation
FEX copied to clipboard

Wine: Properly Store and Restore TF, DF, and AF before clear

Open MelodicAlbuild opened this issue 1 year ago • 3 comments

In it's current implementation, FEX discards TF, DF, and AF when throwing guest exceptions. These bits are restored by Windows after an exception, and therefore needs to be saved by FEX before clear.

This PR is a Draft while I work on the Wine Patch and testing the implementation with Wine. This is not the final version of these changes as I plan on making it a bit cleaner and more performant

MelodicAlbuild avatar Jan 29 '25 08:01 MelodicAlbuild

TF is already handled here so that part can be dropped. Is the an application you have ran into depending on af/df being restored?

(You'd also wanna just move things into ReconstructThreadState where other flags are already handled)

bylaws avatar Jan 29 '25 09:01 bylaws

I.e. this patch should really only be a thrre line change, setting https://github.com/FEX-Emu/FEX/blob/fe8d9b046989965e398a1d269682bdcfeb6badf3/Source/Windows/ARM64EC/Module.cpp#L429 with a comment this is specific behaviour for a downstream wine patch and adding to https://github.com/FEX-Emu/FEX/blob/fe8d9b046989965e398a1d269682bdcfeb6badf3/Source/Windows/ARM64EC/Module.cpp#L532

bylaws avatar Jan 29 '25 10:01 bylaws

Didn't realize TF had already been handled, I saw the TODO and figured there hadn't been any implementation yet.

Currently running into the issue when running Photoshop on top of Wine, specifically when using long chain actions and an action fails. The AF flag specifically is used here Unsure why and is cleared when the action failed, then the application crashes after the fail is caught because it tries to resume, but AF is now 0, and it fails out.

MelodicAlbuild avatar Jan 30 '25 15:01 MelodicAlbuild

What's the way forward here? Is the 3 line change suggested by ByLaws worth integrating?

If it is, let's do it, otherwise let's not keep this PR lingering around without a clear path forward.

neobrain avatar Jul 10 '25 10:07 neobrain