1. 19 5月, 2015 9 次提交
    • I
      x86/fpu: Simplify the xsave_state*() methods · 3e261c14
      Ingo Molnar 提交于
      These functions (xsave_state() and xsave_state_booting()) have a 'mask'
      argument that is always -1.
      
      Propagate this into the functions instead and eliminate the extra argument.
      
      Does not change the generated code, because these were inlined functions.
      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>
      3e261c14
    • I
      x86/fpu: Fix header file dependencies of fpu-internal.h · f89e32e0
      Ingo Molnar 提交于
      Fix a minor header file dependency bug in asm/fpu-internal.h: it
      relies on i387.h but does not include it. All users of fpu-internal.h
      included it explicitly.
      
      Also remove unnecessary includes, to reduce compilation time.
      
      This also makes it easier to use it as a standalone header file
      for FPU internals, such as an upcoming C module in arch/x86/kernel/fpu/.
      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>
      f89e32e0
    • I
      x86/fpu: Move thread_info::fpu_counter into thread_info::fpu.counter · c0c2803d
      Ingo Molnar 提交于
      This field is kept separate from the main FPU state structure for
      no good reason.
      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>
      c0c2803d
    • I
      x86/fpu: Rename fpu_init() to fpu__cpu_init() · 3a9c4b0d
      Ingo Molnar 提交于
      fpu_init() is a bit of a misnomer in that it (falsely) creates the
      impression that it's related to the (old) fpu_finit() function,
      which initializes FPU ctx state.
      
      Rename it to fpu__cpu_init() to make its boot time initialization
      clear, and to move it to the fpu__*() namespace.
      
      Also fix and extend its comment block to point out that it's
      called not only on the boot CPU, but on secondary CPUs as well.
      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>
      3a9c4b0d
    • I
      x86/fpu: Rename fpu_free() to fpstate_free() · a7c2a833
      Ingo Molnar 提交于
      Use the fpu__*() namespace.
      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>
      a7c2a833
    • I
      x86/fpu: Rename fpu_alloc() to fpstate_alloc() · ed97b085
      Ingo Molnar 提交于
      Use the fpu__*() namespace for fpstate_alloc() as well.
      
      Also add a comment about FPU state alignment.
      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>
      ed97b085
    • I
      x86/fpu: Move fpu_alloc() out of line · 6fbe6712
      Ingo Molnar 提交于
      This is not a small function, and it's used in several places,
      one of them a popular module (KVM).
      
      Move the function out of line. This saves a bit of text,
      even with the symbol export overhead:
      
         text    data     bss     dec     hex filename
         12566052        1619504 1089536 15275092         e91454 vmlinux.before
         12566046        1619504 1089536 15275086         e9144e vmlinux.after
      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>
      6fbe6712
    • I
      x86/fpu: Remove fpu_allocated() · 37324422
      Ingo Molnar 提交于
      It's an unnecessary obfuscation of a very simple allocation pattern.
      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>
      37324422
    • I
      x86/fpu: Rename unlazy_fpu() to fpu__save() · 0a781551
      Ingo Molnar 提交于
      This function is a misnomer on two levels:
      
      1) it doesn't really manipulate TS on modern CPUs anymore, its
         primary purpose is to save FPU state, used:
      
            - when executing fork()/clone(): to copy current FPU state
              to the child's FPU state.
      
            - when handling math exceptions: to generate the math error
              si_code in the signal frame.
      
      2) even on legacy CPUs it doesn't actually 'unlazy', if then
         it lazies the FPU state: as a side effect of the old FNSAVE
         instruction which clears (destroys) FPU state it's necessary
         to set CR0::TS.
      
      So rename it to fpu__save() to better reflect its purpose.
      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>
      0a781551
  2. 23 3月, 2015 4 次提交
    • B
      x86/fpu: Rename drop_init_fpu() to fpu_reset_state() · b85e67d1
      Borislav Petkov 提交于
      Call it what it does and in accordance with the context where it is
      used: we reset the FPU state either because we were unable to restore it
      from the one saved in the task or because we simply want to reset it.
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Acked-by: NOleg Nesterov <oleg@redhat.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Rik van Riel <riel@redhat.com>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      b85e67d1
    • B
      x86/fpu: Fold __drop_fpu() into its sole user · d2d0ac9a
      Borislav Petkov 提交于
      Fold it into drop_fpu(). Phew, one less FPU function to pay attention
      to.
      
      No functionality change.
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Acked-by: NOleg Nesterov <oleg@redhat.com>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Pekka Riikonen <priikone@iki.fi>
      Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Suresh Siddha <sbsiddha@gmail.com>
      Signed-off-by: NIngo Molnar <mingo@kernel.org>
      d2d0ac9a
    • O
      x86/fpu: Introduce restore_init_xstate() · 8f4d8186
      Oleg Nesterov 提交于
      Extract the "use_eager_fpu()" code from drop_init_fpu() into a new,
      simple helper restore_init_xstate(). The next patch adds another user.
      
      - It is not clear why we do not check use_fxsr() like fpu_restore_checking()
        does. eager_fpu_init_bp() calls setup_init_fpu_buf() too, and we have the
        "eagerfpu=on" kernel option.
      
      - Ignoring the fact that init_xstate_buf is "struct xsave_struct *", not
        "union thread_xstate *", it is not clear why we can not simply use
        fpu_restore_checking() and avoid the code duplication.
      
      - It is not clear why we can't call setup_init_fpu_buf() unconditionally
        to always create init_xstate_buf(). Then do_device_not_available() path
        (at least) could use restore_init_xstate() too. It doesn't need to init
        fpu->state, its content doesn't matter until unlazy_fpu()/__switch_to()/etc
        which overwrites this memory anyway.
      Signed-off-by: NOleg Nesterov <oleg@redhat.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Pekka Riikonen <priikone@iki.fi>
      Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Suresh Siddha <sbsiddha@gmail.com>
      Link: http://lkml.kernel.org/r/20150311173429.GD5032@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      8f4d8186
    • O
      x86/fpu: Document user_fpu_begin() · fb14b4ea
      Oleg Nesterov 提交于
      Currently, user_fpu_begin() has a single caller and it is not clear why
      do we actually need it and why we should not worry about preemption
      right after preempt_enable().
      Signed-off-by: NOleg Nesterov <oleg@redhat.com>
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Cc: Andy Lutomirski <luto@amacapital.net>
      Cc: Dave Hansen <dave.hansen@intel.com>
      Cc: Fenghua Yu <fenghua.yu@intel.com>
      Cc: Linus Torvalds <torvalds@linux-foundation.org>
      Cc: Pekka Riikonen <priikone@iki.fi>
      Cc: Quentin Casasnovas <quentin.casasnovas@oracle.com>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Suresh Siddha <sbsiddha@gmail.com>
      Link: http://lkml.kernel.org/r/20150311173409.GC5032@redhat.comSigned-off-by: NIngo Molnar <mingo@kernel.org>
      fb14b4ea
  3. 13 3月, 2015 1 次提交
  4. 10 3月, 2015 1 次提交
  5. 19 2月, 2015 6 次提交
  6. 23 12月, 2014 1 次提交
  7. 03 9月, 2014 1 次提交
  8. 19 6月, 2014 1 次提交
  9. 30 5月, 2014 1 次提交
  10. 17 4月, 2014 1 次提交
  11. 12 1月, 2014 1 次提交
  12. 13 11月, 2013 1 次提交
  13. 21 6月, 2013 1 次提交
    • B
      x86, fpu: Use static_cpu_has_safe before alternatives · 5f8c4218
      Borislav Petkov 提交于
      The call stack below shows how this happens: basically eager_fpu_init()
      calls __thread_fpu_begin(current) which then does if (!use_eager_fpu()),
      which, in turn, uses static_cpu_has.
      
      And we're executing before alternatives so static_cpu_has doesn't work
      there yet.
      
      Use the safe variant in this path which becomes optimal after
      alternatives have run.
      
      WARNING: at arch/x86/kernel/cpu/common.c:1368 warn_pre_alternatives+0x1e/0x20()
      You're using static_cpu_has before alternatives have run!
      Modules linked in:
      Pid: 0, comm: swapper Not tainted 3.9.0-rc8+ #1
      Call Trace:
       warn_slowpath_common
       warn_slowpath_fmt
       ? fpu_finit
       warn_pre_alternatives
       eager_fpu_init
       fpu_init
       cpu_init
       trap_init
       start_kernel
       ? repair_env_string
       x86_64_start_reservations
       x86_64_start_kernel
      Signed-off-by: NBorislav Petkov <bp@suse.de>
      Link: http://lkml.kernel.org/r/1370772454-6106-6-git-send-email-bp@alien8.deSigned-off-by: NH. Peter Anvin <hpa@linux.intel.com>
      5f8c4218
  14. 07 6月, 2013 1 次提交
  15. 14 2月, 2013 1 次提交
  16. 01 12月, 2012 1 次提交
    • V
      x86, fpu: Avoid FPU lazy restore after suspend · 644c1541
      Vincent Palatin 提交于
      When a cpu enters S3 state, the FPU state is lost.
      After resuming for S3, if we try to lazy restore the FPU for a process running
      on the same CPU, this will result in a corrupted FPU context.
      
      Ensure that "fpu_owner_task" is properly invalided when (re-)initializing a CPU,
      so nobody will try to lazy restore a state which doesn't exist in the hardware.
      
      Tested with a 64-bit kernel on a 4-core Ivybridge CPU with eagerfpu=off,
      by doing thousands of suspend/resume cycles with 4 processes doing FPU
      operations running. Without the patch, a process is killed after a
      few hundreds cycles by a SIGFPE.
      
      Cc: Duncan Laurie <dlaurie@chromium.org>
      Cc: Olof Johansson <olofj@chromium.org>
      Cc: <stable@kernel.org> v3.4+ # for 3.4 need to replace this_cpu_write by percpu_write
      Signed-off-by: NVincent Palatin <vpalatin@chromium.org>
      Link: http://lkml.kernel.org/r/1354306532-1014-1-git-send-email-vpalatin@chromium.orgSigned-off-by: NH. Peter Anvin <hpa@linux.intel.com>
      644c1541
  17. 26 9月, 2012 1 次提交
  18. 22 9月, 2012 1 次提交
  19. 19 9月, 2012 6 次提交