Skip to content

x86/fpu: Move register state into a container struct (part 2)

Thomas Gleixner kvm lkml 1 version Applied

Status from this message: The following commit has been merged into the x86/fpu branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest21 patches 1 replyApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/21x86/fpu: Provide struct fpstatearch/x86/include/asm/fpu/types.h arch/x86/include/asm/processor.h arch/x86/kernel/fpu/core.c +2 more+39 -60 replies
2/21x86/fpu: Convert fpstate_init() to struct fpstatearch/x86/kernel/fpu/core.c arch/x86/kernel/fpu/internal.h arch/x86/kernel/fpu/signal.c +1 more+31 -310 replies
3/21x86/fpu: Convert restore_fpregs_from_fpstate() to struct fpstatearch/x86/include/asm/fpu/signal.h arch/x86/kernel/fpu/context.h arch/x86/kernel/fpu/core.c+8 -80 replies
4/21x86/fpu: Replace KVMs xstate component clearingarch/x86/include/asm/fpu/api.h arch/x86/include/asm/fpu/xstate.h arch/x86/kernel/fpu/xstate.c +2 more+19 -110 replies
5/21x86/KVM: Convert to fpstatearch/x86/kvm/x86.c+2 -21 reply
6/21x86/fpu: Convert tracing to fpstatearch/x86/include/asm/trace/fpu.h+2 -20 replies
7/21x86/fpu/regset: Convert to fpstatearch/x86/kernel/fpu/regset.c+14 -130 replies
8/21x86/fpu/signal: Convert to fpstatearch/x86/kernel/fpu/signal.c+16 -140 replies
9/21x86/fpu/core: Convert to fpstatearch/x86/include/asm/fpu/api.h arch/x86/kernel/fpu/core.c arch/x86/kernel/fpu/init.c +1 more+27 -250 replies
10/21x86/math-emu: Convert to fpstatearch/x86/math-emu/fpu_aux.c arch/x86/math-emu/fpu_entry.c arch/x86/math-emu/fpu_system.h+4 -40 replies
11/21x86/fpu: Remove fpu::statearch/x86/include/asm/fpu/types.h arch/x86/kernel/fpu/init.c+7 -150 replies
12/21x86/fpu: Do not leak fpstate pointer on forkarch/x86/kernel/process.c+2 -00 replies
13/21x86/process: Move arch_thread_struct_whitelist() out of linearch/x86/include/asm/processor.h arch/x86/kernel/fpu/core.c arch/x86/kernel/fpu/internal.h+15 -60 replies
14/21x86/fpu: Add size and mask information to fpstatearch/x86/include/asm/fpu/types.h arch/x86/kernel/fpu/core.c arch/x86/kernel/fpu/init.c +1 more+30 -00 replies
15/21x86/fpu: Use fpstate::sizearch/x86/kernel/fpu/core.c arch/x86/kernel/fpu/signal.c+9 -110 replies
16/21x86/fpu/xstate: Use fpstate for os_xsave()arch/x86/kernel/fpu/core.c arch/x86/kernel/fpu/signal.c arch/x86/kernel/fpu/xstate.h+6 -60 replies
17/21x86/fpu/xstate: Use fpstate for xsave_to_user_sigframe()arch/x86/kernel/fpu/xstate.h+1 -10 replies
18/21x86/fpu: Use fpstate in fpu_copy_kvm_uabi_to_fpstate()arch/x86/kernel/fpu/core.c+6 -60 replies
19/21x86/fpu: Use fpstate in __copy_xstate_to_uabi_buf()arch/x86/kernel/fpu/core.c arch/x86/kernel/fpu/xstate.c arch/x86/kernel/fpu/xstate.h+11 -100 replies
20/21x86/fpu/xstate: Use fpstate for copy_uabi_to_xstate()arch/x86/include/asm/fpu/xstate.h arch/x86/kernel/fpu/core.c arch/x86/kernel/fpu/regset.c +3 more+26 -250 replies
21/21x86/fpu/signal: Use fpstate for size and featuresarch/x86/kernel/fpu/signal.c+19 -121 reply

Reviews trailers per patch

1 of 21 patches has a Reviewed-by or Acked-by.

PatchPaolo Bonzini
1/21
2/21
3/21
4/21
5/21A-b
6/21
7/21
8/21
9/21
10/21
11/21
12/21
13/21
14/21
15/21
16/21
17/21
18/21
19/21
20/21
21/21

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [patch 00/21] x86/fpu: Move register state into a container struct (part 2)

This is the second part of the effort to support AMX. The first part can be found here:

     https://lore.kernel.org/r/[email protected]

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(-)