1. 19 5月, 2015 40 次提交
    • I
      x86/fpu: Remove run-once init quirks · acd58a3a
      Ingo Molnar 提交于
      Remove various boot quirks that came from the old code.
      
      The new code is cleanly split up into per-system and per-cpu
      init sequences, and system init functions are only called once.
      
      Remove the run-once quirks.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      acd58a3a
    • I
      x86/fpu: Factor out fpu/regset.h from fpu/internal.h · 59a36d16
      Ingo Molnar 提交于
      Only a few places use the regset definitions, so factor them out.
      
      Also fix related header dependency assumptions.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      59a36d16
    • I
      x86/fpu: Split out fpu/signal.h from fpu/internal.h for signal frame handling functions · fcbc99c4
      Ingo Molnar 提交于
      Most of the FPU does not use them, so split it out and include
      them in signal.c and ia32_signal.c
      
      Also fix header file dependency assumption in fpu/core.c.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      fcbc99c4
    • I
      x86/fpu: Move is_ia32*frame() helpers out of fpu/internal.h · 05012c13
      Ingo Molnar 提交于
      Move them to their only user. This makes the code easier to read,
      the header is less cluttered, and it also speeds up the build a bit.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      05012c13
    • I
      x86/fpu: Merge fpu__reset() and fpu__clear() · fbce7782
      Ingo Molnar 提交于
      With recent cleanups and fixes the fpu__reset() and fpu__clear()
      functions have become almost identical in functionality: the only
      difference is that fpu__reset() assumed that the fpstate
      was already active in the eagerfpu case, while fpu__clear()
      activated it if it was inactive.
      
      This distinction almost never matters, the only case where such
      fpstate activation happens if if the init thread (PID 1) gets exec()-ed
      for the first time.
      
      So keep fpu__clear() and change all fpu__reset() uses to
      fpu__clear() to simpify the logic.
      
      ( In a later patch we'll further simplify fpu__clear() by making
        sure that all contexts it is called on are already active. )
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      fbce7782
    • I
      x86/fpu: Move the signal frame handling code closer to each other · 82c0e45e
      Ingo Molnar 提交于
      Consolidate more signal frame related functions:
      
         text      data    bss     dec       filename
         14108070  2575280 1634304 18317654  vmlinux.before
         14107944  2575344 1634304 18317592  vmlinux.after
      
      Also, while moving it, rename alloc_mathframe() to fpu__alloc_mathframe().
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      82c0e45e
    • I
      x86/fpu: Rename restore_xstate_sig() to fpu__restore_sig() · 9dfe99b7
      Ingo Molnar 提交于
      restore_xstate_sig() is a misnomer: it's not limited to 'xstate' at all,
      it is the high level 'restore FPU state from a signal frame' function
      that works with all legacy FPU formats as well.
      
      Rename it (and its helper) accordingly, and also move it to the
      fpu__*() namespace.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      9dfe99b7
    • I
      x86/fpu: Move fpu__clear() to 'struct fpu *' parameter passing · 04c8e01d
      Ingo Molnar 提交于
      Do it like all other high level FPU state handling functions: they
      only know about struct fpu, not about the task.
      
      (Also remove a dead prototype while at it.)
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      04c8e01d
    • I
      x86/fpu: Move all the fpu__*() high level methods closer to each other · 6ffc152e
      Ingo Molnar 提交于
      The fpu__*() methods are closely related, but they are defined
      in scattered places within the FPU code.
      
      Concentrate them, and also uninline fpu__save(), fpu__drop()
      and fpu__reset() to save about 5K of kernel text on 64-bit kernels:
      
         text            data    bss     dec        filename
         14113063        2575280 1634304 18322647   vmlinux.before
         14108070        2575280 1634304 18317654   vmlinux.after
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      6ffc152e
    • I
      x86/fpu: Rename restore_fpu_checking() to copy_fpstate_to_fpregs() · 0e75c54f
      Ingo Molnar 提交于
      fpu_restore_checking() is a helper function of restore_fpu_checking(),
      but this is not apparent from the naming.
      
      Both copy fpstate contents to fpregs, while the fuller variant does
      a full copy without leaking information.
      
      So rename them to:
      
          copy_fpstate_to_fpregs()
        __copy_fpstate_to_fpregs()
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      0e75c54f
    • I
      x86/fpu: Synchronize the naming of drop_fpu() and fpu_reset_state() · 50338615
      Ingo Molnar 提交于
      drop_fpu() and fpu_reset_state() are similar in functionality
      and in scope, yet this is not apparent from their names.
      
      drop_fpu() deactivates FPU contents (both the fpregs and the fpstate),
      but leaves register contents intact in the eager-FPU case, mostly as an
      optimization. It disables fpregs in the lazy FPU case. The drop_fpu()
      method can be used to destroy FPU state in an optimized way, when we
      know that a new state will be loaded before user-space might see
      any remains of the old FPU state:
      
           - such as in sys_exit()'s exit_thread() where we know this task
             won't execute any user-space instructions anymore and the
             next context switch cleans up the FPU. The old FPU state
             might still be around in the eagerfpu case but won't be
             saved.
      
           - in __restore_xstate_sig(), where we use drop_fpu() before
             copying a new state into the fpstate and activating that one.
             No user-pace instructions can execute between those steps.
      
           - in sys_execve()'s fpu__clear(): there we use drop_fpu() in
             the !eagerfpu case, where it's equivalent to a full reinit.
      
      fpu_reset_state() is a stronger version of drop_fpu(): both in
      the eagerfpu and the lazy-FPU case it guarantees that fpregs
      are reinitialized to init state. This method is used in cases
      where we need a full reset:
      
           - handle_signal() uses fpu_reset_state() to reset the FPU state
             to init before executing a user-space signal handler. While we
             have already saved the original FPU state at this point, and
             always restore the original state, the signal handling code
             still has to do this reinit, because signals may interrupt
             any user-space instruction, and the FPU might be in various
             intermediate states (such as an unbalanced x87 stack) that is
             not immediately usable for general C signal handler code.
      
           - __restore_xstate_sig() uses fpu_reset_state() when the signal
             frame has no FP context. Since the signal handler may have
             modified the FPU state, it gets reset back to init state.
      
           - in another branch __restore_xstate_sig() uses fpu_reset_state()
             to handle a restoration error: when restore_user_xstate() fails
             to restore FPU state and we might have inconsistent FPU data,
             fpu_reset_state() is used to reset it back to a known good
             state.
      
           - __kernel_fpu_end() uses fpu_reset_state() in an error branch.
             This is in a 'must not trigger' error branch, so on bug-free
             kernels this never triggers.
      
           - fpu__restore() uses fpu_reset_state() in an error path
             as well: if the fpstate was set up with invalid FPU state
             (via ptrace or via a signal handler), then it's reset back
             to init state.
      
           - likewise, the scheduler's switch_fpu_finish() uses it in a
             restoration error path too.
      
      Move both drop_fpu() and fpu_reset_state() to the fpu__*() namespace
      and harmonize their naming with their function:
      
          fpu__drop()
          fpu__reset()
      
      This clearly shows that both methods operate on the full state of the
      FPU, just like fpu__restore().
      
      Also add comments to explain what each function does.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      50338615
    • I
      x86/alternatives, x86/fpu: Add 'alternatives_patched' debug flag and use it in xsave_state() · 5e907bb0
      Ingo Molnar 提交于
      We'd like to use xsave_state() earlier, but its SYSTEM_BOOTING check
      is too imprecise.
      
      The real condition that xsave_state() would like to check is whether
      alternative XSAVE instructions were patched into the kernel image
      already.
      
      Add such a (read-mostly) debug flag and use it in xsave_state().
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      5e907bb0
    • I
      x86/fpu: Better document fpu__clear() state handling · 2e85591a
      Ingo Molnar 提交于
      So prior to this fix:
      
        c88d4748 ("x86/fpu: Always restore_xinit_state() when use_eager_cpu()")
      
      we leaked FPU state across execve() boundaries on eagerfpu systems:
      
      	$ /host/home/mingo/dump-xmm-regs-exec
      	# XMM state before execve():
      	XMM0 : 000000000000dede
      	XMM1 : 000000000000dedf
      	XMM2 : 000000000000dee0
      	XMM3 : 000000000000dee1
      	XMM4 : 000000000000dee2
      	XMM5 : 000000000000dee3
      	XMM6 : 000000000000dee4
      	XMM7 : 000000000000dee5
      	XMM8 : 000000000000dee6
      	XMM9 : 000000000000dee7
      	XMM10: 000000000000dee8
      	XMM11: 000000000000dee9
      	XMM12: 000000000000deea
      	XMM13: 000000000000deeb
      	XMM14: 000000000000deec
      	XMM15: 000000000000deed
      
      	# XMM state after execve(), in the new task context:
      	XMM0 : 0000000000000000
      	XMM1 : 2f2f2f2f2f2f2f2f
      	XMM2 : 0000000000000000
      	XMM3 : 0000000000000000
      	XMM4 : 00000000000000ff
      	XMM5 : 00000000ff000000
      	XMM6 : 000000000000dee4
      	XMM7 : 000000000000dee5
      	XMM8 : 0000000000000000
      	XMM9 : 0000000000000000
      	XMM10: 0000000000000000
      	XMM11: 0000000000000000
      	XMM12: 0000000000000000
      	XMM13: 000000000000deeb
      	XMM14: 000000000000deec
      	XMM15: 000000000000deed
      
      Better explain what this function is supposed to do and why.
      Reviewed-by: NBorislav Petkov <bp@alien8.de>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      2e85591a
    • I
      x86/fpu: Initialize fpregs in fpu__init_cpu_generic() · b1276c48
      Ingo Molnar 提交于
      FPU fpregs do not get initialized during bootup on secondary CPUs,
      on non-xsave capable CPUs.
      
      For example on one of my systems, the secondary CPU has this FPU
      state on bootup:
      
      	x86: Booting SMP configuration:
      	.... node  #0, CPUs:      #1
      	x86/fpu ######################
      	x86/fpu # FPU register dump on CPU#1:
      	x86/fpu # ... CWD: ffff0040
      	x86/fpu # ... SWD: ffff0000
      	x86/fpu # ... TWD: ffff555a
      	x86/fpu # ... FIP: 00000000
      	x86/fpu # ... FCS: 00000000
      	x86/fpu # ... FOO: 00000000
      	x86/fpu # ... FOS: ffff0000
      	x86/fpu # ... FP0: 02 57 00 00 00 00 00 00 ff ff
      	x86/fpu # ... FP1: 1b e2 00 00 00 00 00 00 ff ff
      	x86/fpu # ... FP2: 00 00 00 00 00 00 00 00 00 00
      	x86/fpu # ... FP3: 00 00 00 00 00 00 00 00 00 00
      	x86/fpu # ... FP4: 00 00 00 00 00 00 00 00 00 00
      	x86/fpu # ... FP5: 00 00 00 00 00 00 00 00 00 00
      	x86/fpu # ... FP6: 00 00 00 00 00 00 00 00 00 00
      	x86/fpu # ... FP7: 00 00 00 00 00 00 00 00 00 00
      	x86/fpu # ...  SW: dadadada
      	x86/fpu ######################
      
      Note how CWD and TWD are off their usual init state (0x037f and 0xffff),
      and how FP0 and FP1 has non-zero content.
      
      This is normally not a problem, because any user-space FPU state
      is initalized properly - but it can complicate the use of FPU
      instructions in kernel code via kernel_fpu_begin()/end(): if
      the FPU using code does not initialize registers itself, it
      might generate spurious exceptions depending on which CPU it
      executes on.
      
      Fix this by initializing the x87 state via the FNINIT instruction.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      b1276c48
    • I
      x86/fpu: Rename user_has_fpu() to fpregs_active() · 3c6dffa9
      Ingo Molnar 提交于
      Rename this function in line with the new FPU nomenclature.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      3c6dffa9
    • I
      x86/fpu: Clarify ancient comments in fpu__restore() · be7436d5
      Ingo Molnar 提交于
      So this function still had ancient language about 'saving current
      math information' - but we haven't been doing lazy FPU saves for
      quite some time, we are doing lazy FPU restores.
      
      Also remove IRQ13 related comment, which we don't support anymore
      either.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      be7436d5
    • I
      x86/fpu: Rename save_user_xstate() to copy_fpregs_to_sigframe() · 2a52af8b
      Ingo Molnar 提交于
      Move the naming in line with existing names, so that we now have:
      
        copy_fpregs_to_fpstate()
        copy_fpstate_to_sigframe()
        copy_fpregs_to_sigframe()
      
      ... where each function does what its name suggests.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      2a52af8b
    • I
      x86/fpu: Rename save_xstate_sig() to copy_fpstate_to_sigframe() · c8e14041
      Ingo Molnar 提交于
      Standardize the naming of save_xstate_sig() by renaming it to
      copy_fpstate_to_sigframe(): this tells us at a glance that
      the function copies an FPU fpstate to a signal frame.
      
      This naming also follows the naming of copy_fpregs_to_fpstate().
      
      Don't put 'xstate' into the name: since this is a generic name,
      it's expected that the function is able to handle xstate frames
      as well, beyond legacy frames.
      
      xstate used to be the odd case in the x86 FPU code - now it's the
      common case.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      c8e14041
    • I
      x86/fpu: Pass 'struct fpu' to fpstate_sanitize_xstate() · 36e49e7f
      Ingo Molnar 提交于
      Currently fpstate_sanitize_xstate() has a task_struct input parameter,
      but it only uses the fpu structure from it - so pass in a 'struct fpu'
      pointer only and update all call sites.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      36e49e7f
    • I
      x86/fpu: Simplify fpstate_sanitize_xstate() calls · 1ac91a76
      Ingo Molnar 提交于
      Remove the extra layer of __fpstate_sanitize_xstate():
      
      	if (!use_xsaveopt())
      		return;
      	__fpstate_sanitize_xstate(tsk);
      
      and move the check for use_xsaveopt() into fpstate_sanitize_xstate().
      
      In general we optimize for the presence of CPU features, not for
      the absence of them. Furthermore there's little point in this inlining,
      as the call sites are not super hot code paths.
      
      Doing this uninlining shrinks the code a bit:
      
         text    data     bss     dec     hex filename
         14108751        2573624 1634304 18316679        1177d87 vmlinux.before
         14108627        2573624 1634304 18316555        1177d0b vmlinux.after
      
      Also remove a pointless '!fx' check from fpstate_sanitize_xstate().
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      1ac91a76
    • I
      x86/fpu: Rename sanitize_i387_state() to fpstate_sanitize_xstate() · d0903193
      Ingo Molnar 提交于
      So the sanitize_i387_state() function has the following purpose:
      on CPUs that support optimized xstate saving instructions, an
      FPU fpstate might end up having partially uninitialized data.
      
      This function initializes that data.
      
      Note that the function name is a misnomer and confusing on two levels,
      not only is it not i387 specific at all, but it is the exact opposite:
      it only matters on xstate CPUs.
      
      So rename sanitize_i387_state() and __sanitize_i387_state() to
      fpstate_sanitize_xstate() and __fpstate_sanitize_xstate(),
      to clearly express the purpose and usage of the function.
      
      We'll further clean up this function in the next patch.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      d0903193
    • I
      x86/fpu: Move asm/xcr.h to asm/fpu/internal.h · befc61ad
      Ingo Molnar 提交于
      Now that all FPU internals using drivers are converted to public APIs,
      move xcr.h's definitions into fpu/internal.h and remove xcr.h.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      befc61ad
    • I
      x86/fpu, crypto x86/sha1_mb: Remove FPU internal headers from sha1_mb.c · 57dd083e
      Ingo Molnar 提交于
      This file only uses the public FPU APIs, so remove the xcr.h, fpu/xstate.h
      and fpu/internal.h headers and add the fpu/api.h include.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      57dd083e
    • I
      x86/fpu, crypto x86/serpent_avx2: Simplify the init() xfeature checks · 534ff06e
      Ingo Molnar 提交于
      Use the new 'cpu_has_xfeatures()' function to query AVX CPU support.
      
      This has the following advantages to the driver:
      
       - Decouples the driver from FPU internals: it's now only using <asm/fpu/api.h>.
      
       - Removes detection complexity from the driver, no more raw XGETBV instruction
      
       - Shrinks the code a bit.
      
       - Standardizes feature name error message printouts across drivers
      
      There are also advantages to the x86 FPU code: once all drivers
      are decoupled from internals we can move them out of common
      headers and we'll also be able to remove xcr.h.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      534ff06e
    • I
      x86/fpu, crypto x86/sha1_ssse3: Simplify the sha1_ssse3_mod_init() xfeature checks · d1e50966
      Ingo Molnar 提交于
      Use the new 'cpu_has_xfeatures()' function to query AVX CPU support.
      
      This has the following advantages to the driver:
      
       - Decouples the driver from FPU internals: it's now only using <asm/fpu/api.h>.
      
       - Removes detection complexity from the driver, no more raw XGETBV instruction
      
       - Shrinks the code a bit.
      
       - Standardizes feature name error message printouts across drivers
      
      There are also advantages to the x86 FPU code: once all drivers
      are decoupled from internals we can move them out of common
      headers and we'll also be able to remove xcr.h.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      d1e50966
    • I
      x86/fpu, crypto x86/cast6_avx: Simplify the cast6_init() xfeature checks · 1debf7db
      Ingo Molnar 提交于
      Use the new 'cpu_has_xfeatures()' function to query AVX CPU support.
      
      This has the following advantages to the driver:
      
       - Decouples the driver from FPU internals: it's now only using <asm/fpu/api.h>.
      
       - Removes detection complexity from the driver, no more raw XGETBV instruction
      
       - Shrinks the code a bit.
      
       - Standardizes feature name error message printouts across drivers
      
      There are also advantages to the x86 FPU code: once all drivers
      are decoupled from internals we can move them out of common
      headers and we'll also be able to remove xcr.h.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      1debf7db
    • I
      x86/fpu, crypto x86/sha512_ssse3: Simplify the sha512_ssse3_mod_init() xfeature checks · c93b8a39
      Ingo Molnar 提交于
      Use the new 'cpu_has_xfeatures()' function to query AVX CPU support.
      
      This has the following advantages to the driver:
      
       - Decouples the driver from FPU internals: it's now only using <asm/fpu/api.h>.
      
       - Removes detection complexity from the driver, no more raw XGETBV instruction
      
       - Shrinks the code a bit.
      
       - Standardizes feature name error message printouts across drivers
      
      There are also advantages to the x86 FPU code: once all drivers
      are decoupled from internals we can move them out of common
      headers and we'll also be able to remove xcr.h.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      c93b8a39
    • I
      x86/fpu, crypto x86/cast5_avx: Simplify the cast5_init() xfeature checks · d5d34d98
      Ingo Molnar 提交于
      Use the new 'cpu_has_xfeatures()' function to query AVX CPU support.
      
      This has the following advantages to the driver:
      
       - Decouples the driver from FPU internals: it's now only using <asm/fpu/api.h>.
      
       - Removes detection complexity from the driver, no more raw XGETBV instruction
      
       - Shrinks the code a bit.
      
       - Standardizes feature name error message printouts across drivers
      
      There are also advantages to the x86 FPU code: once all drivers
      are decoupled from internals we can move them out of common
      headers and we'll also be able to remove xcr.h.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      d5d34d98
    • I
      x86/fpu, crypto x86/serpent_avx: Simplify the serpent_init() xfeature checks · c1c23f7e
      Ingo Molnar 提交于
      Use the new 'cpu_has_xfeatures()' function to query AVX CPU support.
      
      This has the following advantages to the driver:
      
       - Decouples the driver from FPU internals: it's now only using <asm/fpu/api.h>.
      
       - Removes detection complexity from the driver, no more raw XGETBV instruction
      
       - Shrinks the code a bit.
      
       - Standardizes feature name error message printouts across drivers
      
      There are also advantages to the x86 FPU code: once all drivers
      are decoupled from internals we can move them out of common
      headers and we'll also be able to remove xcr.h.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      c1c23f7e
    • I
      x86/fpu, crypto x86/twofish_avx: Simplify the twofish_init() xfeature checks · 4eecd261
      Ingo Molnar 提交于
      Use the new 'cpu_has_xfeatures()' function to query AVX CPU support.
      
      This has the following advantages to the driver:
      
       - Decouples the driver from FPU internals: it's now only using <asm/fpu/api.h>.
      
       - Removes detection complexity from the driver, no more raw XGETBV instruction
      
       - Shrinks the code a bit.
      
       - Standardizes feature name error message printouts across drivers
      
      There are also advantages to the x86 FPU code: once all drivers
      are decoupled from internals we can move them out of common
      headers and we'll also be able to remove xcr.h.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      4eecd261
    • I
      x86/fpu, crypto x86/camellia_aesni_avx2: Simplify the camellia_aesni_init() xfeature checks · 7bc371fa
      Ingo Molnar 提交于
      Use the new 'cpu_has_xfeatures()' function to query AVX CPU support.
      
      This has the following advantages to the driver:
      
       - Decouples the driver from FPU internals: it's now only using <asm/fpu/api.h>.
      
       - Removes detection complexity from the driver, no more raw XGETBV instruction
      
       - Shrinks the code a bit.
      
       - Standardizes feature name error message printouts across drivers
      
      There are also advantages to the x86 FPU code: once all drivers
      are decoupled from internals we can move them out of common
      headers and we'll also be able to remove xcr.h.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      7bc371fa
    • I
      x86/fpu, crypto x86/sha256_ssse3: Simplify the sha256_ssse3_mod_init() xfeature checks · 70d51eb6
      Ingo Molnar 提交于
      Use the new 'cpu_has_xfeatures()' function to query AVX CPU support.
      
      This has the following advantages to the driver:
      
       - Decouples the driver from FPU internals: it's now only using <asm/fpu/api.h>.
      
       - Removes detection complexity from the driver, no more raw XGETBV instruction
      
       - Shrinks the code a bit.
      
       - Standardizes feature name error message printouts across drivers
      
      There are also advantages to the x86 FPU code: once all drivers
      are decoupled from internals we can move them out of common
      headers and we'll also be able to remove xcr.h.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      70d51eb6
    • I
      x86/fpu, crypto x86/camellia_aesni_avx: Simplify the camellia_aesni_init() xfeature checks · ce4f5f9b
      Ingo Molnar 提交于
      Use the new 'cpu_has_xfeatures()' function to query AVX CPU support.
      
      This has the following advantages to the driver:
      
       - Decouples the driver from FPU internals: it's now only using <asm/fpu/api.h>.
      
       - Removes detection complexity from the driver, no more raw XGETBV instruction
      
       - Shrinks the code a bit:
      
           text    data     bss     dec     hex filename
           2128    2896       0    5024    13a0 camellia_aesni_avx_glue.o.before
           2067    2896       0    4963    1363 camellia_aesni_avx_glue.o.after
      
       - Standardizes feature name error message printouts across drivers
      
      There are also advantages to the x86 FPU code: once all drivers
      are decoupled from internals we can move them out of common
      headers and we'll also be able to remove xcr.h.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      ce4f5f9b
    • I
      x86/fpu: Move xfeature type enumeration to fpu/types.h · 91969d69
      Ingo Molnar 提交于
      So xsave.h is an internal header that FPU using drivers commonly include,
      to get access to the xstate feature names, amongst other things.
      
      Move these type definitions to fpu/fpu.h to allow simplification
      of FPU using driver code.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      91969d69
    • I
      x86/fpu: Enumerate xfeature bits · 677b98bd
      Ingo Molnar 提交于
      Transform the xstate masks into an enumerated list of xfeature bits.
      
      This removes the hard coding of XFEATURES_NR_MAX.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      677b98bd
    • I
      x86/fpu: Simplify print_xstate_features() · 33588b52
      Ingo Molnar 提交于
      We do a boot time printout of xfeatures in print_xstate_features(),
      simplify this code to make use of the recently introduced cpu_has_xfeature()
      method.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      33588b52
    • I
      x86/fpu: Introduce cpu_has_xfeatures(xfeatures_mask, feature_name) · 5b073430
      Ingo Molnar 提交于
      A lot of FPU using driver code is querying complex CPU features to be
      able to figure out whether a given set of xstate features is supported
      by the CPU or not.
      
      Introduce a simplified API function that can be used on any CPU type
      to get this information. Also add an error string return pointer,
      so that the driver can print a meaningful error message with a
      standardized feature name.
      
      Also mark xfeatures_mask as __read_only.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      5b073430
    • I
      x86/fpu: Rename fpu/xsave.c to fpu/xstate.c · 62784854
      Ingo Molnar 提交于
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      62784854
    • I
      x86/fpu: Rename fpu/xsave.h to fpu/xstate.h · 669ebabb
      Ingo Molnar 提交于
      'xsave' is an x86 instruction name to most people - but xsave.h is
      about a lot more than just the XSAVE instruction: it includes
      definitions and support, both internal and external, related to
      xstate and xfeatures support.
      
      As a first step in cleaning up the various xstate uses rename this
      header to 'fpu/xstate.h' to better reflect what this header file
      is about.
      
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Borislav Petkov <bp@alien8.de>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      669ebabb
    • I
      x86/fpu: Optimize fpu_copy() some more on lazy switching systems · b1652900
      Ingo Molnar 提交于
      The current fpu_copy() code on lazy switching CPUs always saves
      into the current fpstate and then copies it over into the child
      context:
      
      		preempt_disable();
      		if (!copy_fpregs_to_fpstate(src_fpu))
      			fpregs_deactivate(src_fpu);
      		preempt_enable();
      		memcpy(&dst_fpu->state, &src_fpu->state, xstate_size);
      
      That memcpy() can be avoided on all lazy switching setups except
      really old FNSAVE-only systems: change fpu_copy() to directly save
      into the child context, for both the lazy and the eager context
      switching case.
      
      Note that we still have to do a memcpy() back into the parent
      context in the FNSAVE case, but this won't be executed on the
      majority of x86 systems that got built in the last 10 years or so.
      Reviewed-by: NBorislav Petkov <bp@alien8.de>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: H. Peter Anvin <hpa@zytor.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      b1652900