]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
x86/fpu: Use 'struct fpu' in fpstate_alloc_init()
authorIngo Molnar <mingo@kernel.org>
Fri, 24 Apr 2015 00:13:09 +0000 (02:13 +0200)
committerIngo Molnar <mingo@kernel.org>
Tue, 19 May 2015 13:47:29 +0000 (15:47 +0200)
Migrate this function to pure 'struct fpu' usage.

Reviewed-by: Borislav 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: Ingo Molnar <mingo@kernel.org>
arch/x86/include/asm/i387.h
arch/x86/kernel/fpu/core.c
arch/x86/kernel/fpu/xsave.c
arch/x86/kvm/x86.c
arch/x86/math-emu/fpu_entry.c

index e3b42c5379bcbbe110c3502b2f33ffd0bde2ad89..38376cdf297c58a1580d3f1b13cca15550d33ec5 100644 (file)
@@ -18,7 +18,7 @@
 struct pt_regs;
 struct user_i387_struct;
 
-extern int fpstate_alloc_init(struct task_struct *curr);
+extern int fpstate_alloc_init(struct fpu *fpu);
 extern void fpstate_init(struct fpu *fpu);
 extern void fpu__flush_thread(struct task_struct *tsk);
 
index a8435857523558ee80a036ec6bec5a1a3dff2487..183e69dfd4d082530c48cf84abc81fe96e347acf 100644 (file)
@@ -263,12 +263,11 @@ int fpu__copy(struct fpu *dst_fpu, struct fpu *src_fpu)
  *
  * Can fail.
  */
-int fpstate_alloc_init(struct task_struct *curr)
+int fpstate_alloc_init(struct fpu *fpu)
 {
-       struct fpu *fpu = &curr->thread.fpu;
        int ret;
 
-       if (WARN_ON_ONCE(curr != current))
+       if (WARN_ON_ONCE(fpu != &current->thread.fpu))
                return -EINVAL;
        if (WARN_ON_ONCE(fpu->fpstate_active))
                return -EINVAL;
@@ -276,11 +275,11 @@ int fpstate_alloc_init(struct task_struct *curr)
        /*
         * Memory allocation at the first usage of the FPU and other state.
         */
-       ret = fpstate_alloc(&curr->thread.fpu);
+       ret = fpstate_alloc(fpu);
        if (ret)
                return ret;
 
-       fpstate_init(&curr->thread.fpu);
+       fpstate_init(fpu);
 
        /* Safe to do for the current task: */
        fpu->fpstate_active = 1;
@@ -360,7 +359,7 @@ void fpu__restore(void)
                /*
                 * does a slab alloc which can sleep
                 */
-               if (fpstate_alloc_init(tsk)) {
+               if (fpstate_alloc_init(fpu)) {
                        /*
                         * ran out of memory!
                         */
@@ -396,7 +395,7 @@ void fpu__flush_thread(struct task_struct *tsk)
        } else {
                if (!fpu->fpstate_active) {
                        /* kthread execs. TODO: cleanup this horror. */
-               if (WARN_ON(fpstate_alloc_init(tsk)))
+               if (WARN_ON(fpstate_alloc_init(fpu)))
                                force_sig(SIGKILL, tsk);
                        user_fpu_begin();
                }
index 3953cbf8d7e7820bdca4dc956e3ca70e41630ee5..80b0c8fa50c50c091fc5a63ce72a863808ed5633 100644 (file)
@@ -350,7 +350,7 @@ int __restore_xstate_sig(void __user *buf, void __user *buf_fx, int size)
        if (!access_ok(VERIFY_READ, buf, size))
                return -EACCES;
 
-       if (!fpu->fpstate_active && fpstate_alloc_init(tsk))
+       if (!fpu->fpstate_active && fpstate_alloc_init(fpu))
                return -1;
 
        if (!static_cpu_has(X86_FEATURE_FPU))
index bab8afb61dc13c3a55d753ca61c9644bbe1ca977..479d4ce25081d8be9718aff7a657d43abfbe8dfb 100644 (file)
@@ -6601,7 +6601,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run)
        int r;
        sigset_t sigsaved;
 
-       if (!fpu->fpstate_active && fpstate_alloc_init(current))
+       if (!fpu->fpstate_active && fpstate_alloc_init(fpu))
                return -ENOMEM;
 
        if (vcpu->sigset_active)
index f1aac55d6a67930d0cde81286e822811fa3138cd..e394bcb4275dfac0946d383569729adbf34f6d53 100644 (file)
@@ -150,7 +150,7 @@ void math_emulate(struct math_emu_info *info)
        struct fpu *fpu = &current->thread.fpu;
 
        if (!fpu->fpstate_active) {
-               if (fpstate_alloc_init(current)) {
+               if (fpstate_alloc_init(fpu)) {
                        do_group_exit(SIGKILL);
                        return;
                }