]> www.infradead.org Git - users/dwmw2/linux.git/commit
x86/fpu/xstate: Introduce xfeature order table and accessor macro
authorChang S. Bae <chang.seok.bae@intel.com>
Thu, 20 Mar 2025 23:42:53 +0000 (16:42 -0700)
committerIngo Molnar <mingo@kernel.org>
Mon, 14 Apr 2025 06:18:29 +0000 (08:18 +0200)
commit15d51a2f6f3f7057311d6e37d5190d58597a94a9
tree0f7e821ce1dd207638d8d6afe7d80f72a82aee84
parent031b33ef1a6a1129a1a02a16b89608ded2eff9be
x86/fpu/xstate: Introduce xfeature order table and accessor macro

The kernel has largely assumed that higher xstate component numbers
correspond to later offsets in the buffer. However, this assumption no
longer holds for the non-compacted format, where a newer state component
may have a lower offset.

When iterating over xstate components in offset order, using the feature
number as an index may be misleading. At the same time, the CPU exposes
each component’s size and offset based on its feature number, making it a
key for state information.

To provide flexibility in handling xstate ordering, introduce a mapping
table: feature order -> feature number.  The table is dynamically
populated based on the CPU-exposed features and is sorted in offset order
at boot time.

Additionally, add an accessor macro to facilitate sequential traversal of
xstate components based on their actual buffer positions, given a feature
bitmask. This accessor macro will be particularly useful for computing
custom non-compacted format sizes and iterating over xstate offsets in
non-compacted buffers.

Suggested-by: Dave Hansen <dave.hansen@linux.intel.com>
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Link: https://lore.kernel.org/r/20250320234301.8342-3-chang.seok.bae@intel.com
arch/x86/kernel/fpu/xstate.c