Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avx512 registers & fixes for getting & setting x64 context #290

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

mmozeiko
Copy link
Contributor

@mmozeiko mmozeiko commented Jul 20, 2024

This adds getting & setting thread context for avx-512 registers for 64-bit windows target.

It also fixes wrong code for getting xmm & ymm registers - the 128-bit halves were swapped. And GetXStateFeaturesMask was used incorrectly - it should be used after GetThreadContext, not before.

Theoretically 32-bit target also should support ymm & zmm registers, but I did not bother updating code for 32-bit codepaths.

I'm not completely sure about changes to codeview.h file - please check if that's fine. I'm not sure if it needs also zmm register enum values there in some form.

And I hope it's ok to change rdi_format.h file with new zmm register enums - they are 32 zmm's up from 16 ymm's.

Here's how the attached test program is running on avx-512 capable CPU:
a.c.txt
It is compiled with clang-cl.exe -Zi a.c

image

All the zmmN & kN registers are now visible in Registers view too. I would say it probably soon will require some improvements - there are too many of registers. It would be nice if they could be grouped in SSE, AVX, AVX-512 & similar categories. Ideally it also should not show the ones that are not supported on cpu in the target.

There is one disadvantage of doing SetThreadContext this way. It always sets all AVX and AVX-512 registers, even if user did not change any of them. That means context switches are now a bit more expensive, because OS needs to switch all the ymm and zmm registers. Usually OS does not do that, until first time you modify ymm or zmm register in a thread. Ideally debugger would store some mask in REGS_RegBlockX64 about which ymm/zmm register groups are modified and set only those.

@mmozeiko mmozeiko changed the base branch from master to dev July 20, 2024 03:56
@ryanfleury ryanfleury merged commit ce7c8d5 into EpicGamesExt:dev Jul 23, 2024
1 check passed
@mmozeiko mmozeiko deleted the avx512 branch October 15, 2024 01:29
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