-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Update the CPUID and XSAVE logics for APX #104637
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
Changes from all commits
9f8f67c
a68865c
6dfb92b
b998cdf
3446e28
9bc008a
44163d7
600abd0
81b47c6
d516feb
42f1729
d90bf49
79b23c8
8e1ba4a
ea8949f
597e797
117c401
8cc7e8e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1374,12 +1374,14 @@ typedef struct _KNONVOLATILE_CONTEXT_POINTERS { | |
| #define XSTATE_AVX512_KMASK (5) | ||
| #define XSTATE_AVX512_ZMM_H (6) | ||
| #define XSTATE_AVX512_ZMM (7) | ||
| #define XSTATE_APX (19) | ||
|
|
||
| #define XSTATE_MASK_GSSE (UI64(1) << (XSTATE_GSSE)) | ||
| #define XSTATE_MASK_AVX (XSTATE_MASK_GSSE) | ||
| #define XSTATE_MASK_AVX512 ((UI64(1) << (XSTATE_AVX512_KMASK)) | \ | ||
| (UI64(1) << (XSTATE_AVX512_ZMM_H)) | \ | ||
| (UI64(1) << (XSTATE_AVX512_ZMM))) | ||
| #define XSTATE_MASK_APX (UI64(1) << (XSTATE_APX)) | ||
|
|
||
| typedef struct DECLSPEC_ALIGN(16) _M128A { | ||
| ULONGLONG Low; | ||
|
|
@@ -1616,6 +1618,27 @@ typedef struct DECLSPEC_ALIGN(16) _CONTEXT { | |
| M512 Zmm30; | ||
| M512 Zmm31; | ||
| }; | ||
|
|
||
| struct | ||
| { | ||
| DWORD64 Egpr16; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these in this location because it mimics the layout of XSAVE? Or is it arbitrary? Why are these named "Egpr16" instead of just "R16"? |
||
| DWORD64 Egpr17; | ||
| DWORD64 Egpr18; | ||
| DWORD64 Egpr19; | ||
| DWORD64 Egpr20; | ||
| DWORD64 Egpr21; | ||
| DWORD64 Egpr22; | ||
| DWORD64 Egpr23; | ||
| DWORD64 Egpr24; | ||
| DWORD64 Egpr25; | ||
| DWORD64 Egpr26; | ||
| DWORD64 Egpr27; | ||
| DWORD64 Egpr28; | ||
| DWORD64 Egpr29; | ||
| DWORD64 Egpr30; | ||
| DWORD64 Egpr31; | ||
| }; | ||
|
|
||
| } CONTEXT, *PCONTEXT, *LPCONTEXT; | ||
|
|
||
| // | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -183,6 +183,46 @@ LOCAL_LABEL(Done_Restore_CONTEXT_FLOATING_POINT): | |
| kmovq k6, qword ptr [rdi + (CONTEXT_KMask0 + 6 * 8)] | ||
| kmovq k7, qword ptr [rdi + (CONTEXT_KMask0 + 7 * 8)] | ||
|
|
||
| test BYTE PTR [rdi + CONTEXT_XStateFeaturesMask], XSTATE_MASK_APX | ||
| je LOCAL_LABEL(Done_Restore_CONTEXT_XSTATE) | ||
|
|
||
| // TODO-XArch-APX: | ||
| // we are using raw hex code here to emit EGPRs-related changes, | ||
| // we will need to come back and re-write this part when assembler supports EGPRs. | ||
|
Comment on lines
+189
to
+191
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there some way to do an
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not aware of, do we have sth like LLVM version identifier defined in our code base? I think this chunk is meant to be converted to @tannergooding, could you share some thoughts on this?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think its fine as is, I don't think its worth supporting code that we can't reliably test and maintain in CI at this point in time. Rather, lets just have the one path and update when the toolchain can finally be updated to LLVM 19/20 or later
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree with this too.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Ruihan-Yin The dotnet/runtime Linux compilers now use LLVM 20. Does this assembler support the eGPR? (So this could be updated) |
||
|
|
||
| // mov r16, qword ptr [rdi + CONTEXT_Egpr + 0 * 8] | ||
| .byte 0xd5, 0x48, 0x8b, 0x87, 0x20, 0x0c, 0x00, 0x00 | ||
| // mov r17, qword ptr [rdi + CONTEXT_Egpr + 1 * 8] | ||
| .byte 0xd5, 0x48, 0x8b, 0x8f, 0x28, 0x0c, 0x00, 0x00 | ||
| // mov r18, qword ptr [rdi + CONTEXT_Egpr + 2 * 8] | ||
| .byte 0xd5, 0x48, 0x8b, 0x97, 0x30, 0x0c, 0x00, 0x00 | ||
| // mov r19, qword ptr [rdi + CONTEXT_Egpr + 3 * 8] | ||
| .byte 0xd5, 0x48, 0x8b, 0x9f, 0x38, 0x0c, 0x00, 0x00 | ||
| // mov r20, qword ptr [rdi + CONTEXT_Egpr + 4 * 8] | ||
| .byte 0xd5, 0x48, 0x8b, 0xa7, 0x40, 0x0c, 0x00, 0x00 | ||
| // mov r21, qword ptr [rdi + CONTEXT_Egpr + 5 * 8] | ||
| .byte 0xd5, 0x48, 0x8b, 0xaf, 0x48, 0x0c, 0x00, 0x00 | ||
| // mov r22, qword ptr [rdi + CONTEXT_Egpr + 6 * 8] | ||
| .byte 0xd5, 0x48, 0x8b, 0xb7, 0x50, 0x0c, 0x00, 0x00 | ||
| // mov r23, qword ptr [rdi + CONTEXT_Egpr + 7 * 8] | ||
| .byte 0xd5, 0x48, 0x8b, 0xbf, 0x58, 0x0c, 0x00, 0x00 | ||
| // mov r24, qword ptr [rdi + CONTEXT_Egpr + 8 * 8] | ||
| .byte 0xd5, 0x4c, 0x8b, 0x87, 0x60, 0x0c, 0x00, 0x00 | ||
| // mov r25, qword ptr [rdi + CONTEXT_Egpr + 9 * 8] | ||
| .byte 0xd5, 0x4c, 0x8b, 0x8f, 0x68, 0x0c, 0x00, 0x00 | ||
| // mov r26, qword ptr [rdi + CONTEXT_Egpr + 10 * 8] | ||
| .byte 0xd5, 0x4c, 0x8b, 0x97, 0x70, 0x0c, 0x00, 0x00 | ||
| // mov r27, qword ptr [rdi + CONTEXT_Egpr + 11 * 8] | ||
| .byte 0xd5, 0x4c, 0x8b, 0x9f, 0x78, 0x0c, 0x00, 0x00 | ||
| // mov r28, qword ptr [rdi + CONTEXT_Egpr + 12 * 8] | ||
| .byte 0xd5, 0x4c, 0x8b, 0xa7, 0x80, 0x0c, 0x00, 0x00 | ||
| // mov r29, qword ptr [rdi + CONTEXT_Egpr + 13 * 8] | ||
| .byte 0xd5, 0x4c, 0x8b, 0xaf, 0x88, 0x0c, 0x00, 0x00 | ||
| // mov r30, qword ptr [rdi + CONTEXT_Egpr + 14 * 8] | ||
| .byte 0xd5, 0x4c, 0x8b, 0xb7, 0x90, 0x0c, 0x00, 0x00 | ||
| // mov r31, qword ptr [rdi + CONTEXT_Egpr + 15 * 8] | ||
| .byte 0xd5, 0x4c, 0x8b, 0xbf, 0x98, 0x0c, 0x00, 0x00 | ||
|
|
||
| LOCAL_LABEL(Done_Restore_CONTEXT_XSTATE): | ||
|
|
||
| test BYTE PTR [rdi + CONTEXT_ContextFlags], CONTEXT_CONTROL | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.