This is the second part of the effort to support AMX. The first part can be found here: https://lore.kernel.org/r/20211011215813.558681373@xxxxxxxxxxxxx With AMX the FPU register state buffer which is part of task_struct::thread::fpu is not going to be extended unconditionally for all tasks on an AMX enabled system as that would waste minimum 8K per task. AMX provides a mechanism to trap on first use. That trap will be utilized to allocate a larger register state buffer when the task (process) has permissions to use it. The default buffer task_struct will only carry states up to AVX512. The original approach was to just allocate new register buffer, but that's not the right abstraction. The current series creates a container which carries information about the fpstate buffer, i.e. feature bits (user and kernel) and sizes (user and kernel). That allows all relevant code pathes to retrieve the required information from fpstate which avoids conditionals and lets the code just use this instead of reading it from the various global variables which provide this information today. The series is first introducing the new structure and then converting all usage sites over to it. After that it adds feature and size information and converts the affected code over to use that. This series is based on: git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git x86/fpu-1 and also available from git: git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git x86/fpu-2 The full series with part 3 and 4 on top is available here: git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git x86/fpu Thanks, tglx --- include/asm/fpu/api.h | 5 + include/asm/fpu/signal.h | 2 include/asm/fpu/types.h | 42 +++++++++++--- include/asm/fpu/xstate.h | 13 ---- include/asm/processor.h | 9 +-- include/asm/trace/fpu.h | 4 - kernel/fpu/context.h | 2 kernel/fpu/core.c | 140 +++++++++++++++++++++++++++-------------------- kernel/fpu/init.c | 16 ++++- kernel/fpu/internal.h | 7 +- kernel/fpu/regset.c | 28 ++++----- kernel/fpu/signal.c | 70 +++++++++++++---------- kernel/fpu/xstate.c | 56 ++++++++++++------ kernel/fpu/xstate.h | 24 ++++++-- kernel/process.c | 2 kvm/x86.c | 18 ++---- math-emu/fpu_aux.c | 2 math-emu/fpu_entry.c | 4 - math-emu/fpu_system.h | 2 19 files changed, 266 insertions(+), 180 deletions(-)