On Wed Feb 7 15:27:09 2024 +0000, Paul Gofman wrote:
Here is my current full branch: https://gitlab.winehq.org/gofman/wine/-/commits/xstate_avx512/?ref_type=head... In the (current) final state the function minds generic feature mask to get the size which corresponds to it, and also xsave->CompactionMask:
unsigned int xstate_get_size( XSAVE_AREA_HEADER *xsave, UINT64 mask ) { UINT64 compaction_mask; unsigned int i; int off; if (xsave) compaction_mask = xsave->CompactionMask; else if (xstate_compaction_enabled) compaction_mask = ((UINT64)1 << 63) | mask; else compaction_mask = 0; mask >>= 2; off = sizeof(XSAVE_AREA_HEADER); i = 2; while (mask) { if (mask == 1) return off + xstate_feature_size[i]; off = next_xstate_offset( off, compaction_mask, i ); mask >>= 1; ++i; } return off; }
While looking at xsave->CompactionMask is not needed when dealing with Win context (which mask should always match system compaction to be valid), our "internal" xstate from signals always has CompactionMask of zero (Linux always copies xstate in uncompacted format for user signals). So I wanted xstate_get_size` / copy_xstate to deal with it transparently. Do you think I can leave the handle as is in attempt to reduce the amount of diff in the later patches, or should I introduce that only when really needed? Also, maybe if you have some general omments on the generic direction of those patches...
I'd suggest to pass the compaction mask explicitly, the xsave pointer shouldn't be necessary.