Revert "Merge remote-tracking branch 'lsk/v3.10/topic/arm64-fpsimd' into linux-linaro...
authorMark Brown <broonie@linaro.org>
Thu, 26 Jun 2014 09:49:57 +0000 (10:49 +0100)
committerMark Brown <broonie@linaro.org>
Thu, 26 Jun 2014 09:49:57 +0000 (10:49 +0100)
This reverts commit b621c22123dc6b6facafe115f6364cf80172d551, reversing
changes made to d7610b8eafd543c7f75568dcaeead439f31ffa53.

12 files changed:
arch/arm64/Kconfig
arch/arm64/include/asm/fpsimd.h
arch/arm64/include/asm/fpsimdmacros.h
arch/arm64/include/asm/neon.h [deleted file]
arch/arm64/include/asm/thread_info.h
arch/arm64/kernel/entry-fpsimd.S
arch/arm64/kernel/entry.S
arch/arm64/kernel/fpsimd.c
arch/arm64/kernel/process.c
arch/arm64/kernel/ptrace.c
arch/arm64/kernel/signal.c
arch/arm64/kernel/signal32.c

index 8b0c1829be894eb4c3cd5231c503c2dff0c8d91c..bb6571607c6ff278dce2072d8db720234eec41cf 100644 (file)
@@ -118,9 +118,6 @@ config IOMMU_HELPER
 config FIX_EARLYCON_MEM
        def_bool y
 
-config KERNEL_MODE_NEON
-       def_bool y
-
 source "init/Kconfig"
 
 source "kernel/Kconfig.freezer"
index 50f559f574fe53b4d25995bd465c7b90f0a4b8be..c43b4ac13008ffec8f0b39101e5cfd77e43fd3b5 100644 (file)
@@ -37,21 +37,8 @@ struct fpsimd_state {
                        u32 fpcr;
                };
        };
-       /* the id of the last cpu to have restored this state */
-       unsigned int cpu;
 };
 
-/*
- * Struct for stacking the bottom 'n' FP/SIMD registers.
- */
-struct fpsimd_partial_state {
-       u32             fpsr;
-       u32             fpcr;
-       u32             num_regs;
-       __uint128_t     vregs[32];
-};
-
-
 #if defined(__KERNEL__) && defined(CONFIG_COMPAT)
 /* Masks for extracting the FPSR and FPCR from the FPSCR */
 #define VFP_FPSCR_STAT_MASK    0xf800009f
@@ -71,16 +58,6 @@ extern void fpsimd_load_state(struct fpsimd_state *state);
 extern void fpsimd_thread_switch(struct task_struct *next);
 extern void fpsimd_flush_thread(void);
 
-extern void fpsimd_preserve_current_state(void);
-extern void fpsimd_restore_current_state(void);
-extern void fpsimd_update_current_state(struct fpsimd_state *state);
-
-extern void fpsimd_flush_task_state(struct task_struct *target);
-
-extern void fpsimd_save_partial_state(struct fpsimd_partial_state *state,
-                                     u32 num_regs);
-extern void fpsimd_load_partial_state(struct fpsimd_partial_state *state);
-
 #endif
 
 #endif
index 768414d55e642f461788c0a031e1749c83cfac86..bbec599c96bd61df88740e7e1295d81540189edc 100644 (file)
        ldr     w\tmpnr, [\state, #16 * 2 + 4]
        msr     fpcr, x\tmpnr
 .endm
-
-.altmacro
-.macro fpsimd_save_partial state, numnr, tmpnr1, tmpnr2
-       mrs     x\tmpnr1, fpsr
-       str     w\numnr, [\state, #8]
-       mrs     x\tmpnr2, fpcr
-       stp     w\tmpnr1, w\tmpnr2, [\state]
-       adr     x\tmpnr1, 0f
-       add     \state, \state, x\numnr, lsl #4
-       sub     x\tmpnr1, x\tmpnr1, x\numnr, lsl #1
-       br      x\tmpnr1
-       .irp    qa, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0
-       .irp    qb, %(qa + 1)
-       stp     q\qa, q\qb, [\state, # -16 * \qa - 16]
-       .endr
-       .endr
-0:
-.endm
-
-.macro fpsimd_restore_partial state, tmpnr1, tmpnr2
-       ldp     w\tmpnr1, w\tmpnr2, [\state]
-       msr     fpsr, x\tmpnr1
-       msr     fpcr, x\tmpnr2
-       adr     x\tmpnr1, 0f
-       ldr     w\tmpnr2, [\state, #8]
-       add     \state, \state, x\tmpnr2, lsl #4
-       sub     x\tmpnr1, x\tmpnr1, x\tmpnr2, lsl #1
-       br      x\tmpnr1
-       .irp    qa, 30, 28, 26, 24, 22, 20, 18, 16, 14, 12, 10, 8, 6, 4, 2, 0
-       .irp    qb, %(qa + 1)
-       ldp     q\qa, q\qb, [\state, # -16 * \qa - 16]
-       .endr
-       .endr
-0:
-.endm
diff --git a/arch/arm64/include/asm/neon.h b/arch/arm64/include/asm/neon.h
deleted file mode 100644 (file)
index 13ce4cc..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * linux/arch/arm64/include/asm/neon.h
- *
- * Copyright (C) 2013 Linaro Ltd <ard.biesheuvel@linaro.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include <linux/types.h>
-
-#define cpu_has_neon()         (1)
-
-#define kernel_neon_begin()    kernel_neon_begin_partial(32)
-
-void kernel_neon_begin_partial(u32 num_regs);
-void kernel_neon_end(void);
index c09cbf6ce34ac607cbc83994a493dc5f4e084d3f..59f151f8241d599724d0317dad48fc3437c76080 100644 (file)
@@ -109,7 +109,6 @@ static inline struct thread_info *current_thread_info(void)
 #define TIF_SIGPENDING         0
 #define TIF_NEED_RESCHED       1
 #define TIF_NOTIFY_RESUME      2       /* callback before returning to user */
-#define TIF_FOREIGN_FPSTATE    3       /* CPU's FP state is not current's */
 #define TIF_SYSCALL_TRACE      8
 #define TIF_SYSCALL_AUDIT      9
 #define TIF_SYSCALL_TRACEPOINT 10
@@ -125,7 +124,6 @@ static inline struct thread_info *current_thread_info(void)
 #define _TIF_SIGPENDING                (1 << TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED      (1 << TIF_NEED_RESCHED)
 #define _TIF_NOTIFY_RESUME     (1 << TIF_NOTIFY_RESUME)
-#define _TIF_FOREIGN_FPSTATE   (1 << TIF_FOREIGN_FPSTATE)
 #define _TIF_SYSCALL_TRACE     (1 << TIF_SYSCALL_TRACE)
 #define _TIF_SYSCALL_AUDIT     (1 << TIF_SYSCALL_AUDIT)
 #define _TIF_SYSCALL_TRACEPOINT        (1 << TIF_SYSCALL_TRACEPOINT)
@@ -133,7 +131,7 @@ static inline struct thread_info *current_thread_info(void)
 #define _TIF_32BIT             (1 << TIF_32BIT)
 
 #define _TIF_WORK_MASK         (_TIF_NEED_RESCHED | _TIF_SIGPENDING | \
-                                _TIF_NOTIFY_RESUME | _TIF_FOREIGN_FPSTATE)
+                                _TIF_NOTIFY_RESUME)
 
 #define _TIF_SYSCALL_WORK      (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
                                 _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
index d358ccacfc00275bd8ef8462e8839ac9f12161f8..6a27cd6dbfa6dd81be8a6042e5366262a8146801 100644 (file)
@@ -41,27 +41,3 @@ ENTRY(fpsimd_load_state)
        fpsimd_restore x0, 8
        ret
 ENDPROC(fpsimd_load_state)
-
-#ifdef CONFIG_KERNEL_MODE_NEON
-
-/*
- * Save the bottom n FP registers.
- *
- * x0 - pointer to struct fpsimd_partial_state
- */
-ENTRY(fpsimd_save_partial_state)
-       fpsimd_save_partial x0, 1, 8, 9
-       ret
-ENDPROC(fpsimd_load_partial_state)
-
-/*
- * Load the bottom n FP registers.
- *
- * x0 - pointer to struct fpsimd_partial_state
- */
-ENTRY(fpsimd_load_partial_state)
-       fpsimd_restore_partial x0, 8, 9
-       ret
-ENDPROC(fpsimd_load_partial_state)
-
-#endif
index 1fe70fa6160cfd1dd70f49d5e0933edc4bdceb91..fa789169f98b1a63b2134c4609d51821b3c36c1f 100644 (file)
@@ -591,7 +591,7 @@ fast_work_pending:
        str     x0, [sp, #S_X0]                 // returned x0
 work_pending:
        tbnz    x1, #TIF_NEED_RESCHED, work_resched
-       /* TIF_SIGPENDING, TIF_NOTIFY_RESUME or TIF_FOREIGN_FPSTATE case */
+       /* TIF_SIGPENDING or TIF_NOTIFY_RESUME case */
        ldr     x2, [sp, #S_PSTATE]
        mov     x0, sp                          // 'regs'
        tst     x2, #PSR_MODE_MASK              // user mode regs?
index ad8aebb1cdef7d289d609015bc22d51498cddc08..522df9c7f3a4288cf5c8e5bb07f564304bd6ab15 100644 (file)
@@ -22,7 +22,6 @@
 #include <linux/init.h>
 #include <linux/sched.h>
 #include <linux/signal.h>
-#include <linux/hardirq.h>
 
 #include <asm/fpsimd.h>
 #include <asm/cputype.h>
 #define FPEXC_IXF      (1 << 4)
 #define FPEXC_IDF      (1 << 7)
 
-/*
- * In order to reduce the number of times the FPSIMD state is needlessly saved
- * and restored, we need to keep track of two things:
- * (a) for each task, we need to remember which CPU was the last one to have
- *     the task's FPSIMD state loaded into its FPSIMD registers;
- * (b) for each CPU, we need to remember which task's userland FPSIMD state has
- *     been loaded into its FPSIMD registers most recently, or whether it has
- *     been used to perform kernel mode NEON in the meantime.
- *
- * For (a), we add a 'cpu' field to struct fpsimd_state, which gets updated to
- * the id of the current CPU everytime the state is loaded onto a CPU. For (b),
- * we add the per-cpu variable 'fpsimd_last_state' (below), which contains the
- * address of the userland FPSIMD state of the task that was loaded onto the CPU
- * the most recently, or NULL if kernel mode NEON has been performed after that.
- *
- * With this in place, we no longer have to restore the next FPSIMD state right
- * when switching between tasks. Instead, we can defer this check to userland
- * resume, at which time we verify whether the CPU's fpsimd_last_state and the
- * task's fpsimd_state.cpu are still mutually in sync. If this is the case, we
- * can omit the FPSIMD restore.
- *
- * As an optimization, we use the thread_info flag TIF_FOREIGN_FPSTATE to
- * indicate whether or not the userland FPSIMD state of the current task is
- * present in the registers. The flag is set unless the FPSIMD registers of this
- * CPU currently contain the most recent userland FPSIMD state of the current
- * task.
- *
- * For a certain task, the sequence may look something like this:
- * - the task gets scheduled in; if both the task's fpsimd_state.cpu field
- *   contains the id of the current CPU, and the CPU's fpsimd_last_state per-cpu
- *   variable points to the task's fpsimd_state, the TIF_FOREIGN_FPSTATE flag is
- *   cleared, otherwise it is set;
- *
- * - the task returns to userland; if TIF_FOREIGN_FPSTATE is set, the task's
- *   userland FPSIMD state is copied from memory to the registers, the task's
- *   fpsimd_state.cpu field is set to the id of the current CPU, the current
- *   CPU's fpsimd_last_state pointer is set to this task's fpsimd_state and the
- *   TIF_FOREIGN_FPSTATE flag is cleared;
- *
- * - the task executes an ordinary syscall; upon return to userland, the
- *   TIF_FOREIGN_FPSTATE flag will still be cleared, so no FPSIMD state is
- *   restored;
- *
- * - the task executes a syscall which executes some NEON instructions; this is
- *   preceded by a call to kernel_neon_begin(), which copies the task's FPSIMD
- *   register contents to memory, clears the fpsimd_last_state per-cpu variable
- *   and sets the TIF_FOREIGN_FPSTATE flag;
- *
- * - the task gets preempted after kernel_neon_end() is called; as we have not
- *   returned from the 2nd syscall yet, TIF_FOREIGN_FPSTATE is still set so
- *   whatever is in the FPSIMD registers is not saved to memory, but discarded.
- */
-static DEFINE_PER_CPU(struct fpsimd_state *, fpsimd_last_state);
-
 /*
  * Trapped FP/ASIMD access.
  */
@@ -126,137 +71,43 @@ void do_fpsimd_exc(unsigned int esr, struct pt_regs *regs)
 
 void fpsimd_thread_switch(struct task_struct *next)
 {
-       /*
-        * Save the current FPSIMD state to memory, but only if whatever is in
-        * the registers is in fact the most recent userland FPSIMD state of
-        * 'current'.
-        */
-       if (current->mm && !test_thread_flag(TIF_FOREIGN_FPSTATE))
+       /* check if not kernel threads */
+       if (current->mm)
                fpsimd_save_state(&current->thread.fpsimd_state);
-
-       if (next->mm) {
-               /*
-                * If we are switching to a task whose most recent userland
-                * FPSIMD state is already in the registers of *this* cpu,
-                * we can skip loading the state from memory. Otherwise, set
-                * the TIF_FOREIGN_FPSTATE flag so the state will be loaded
-                * upon the next return to userland.
-                */
-               struct fpsimd_state *st = &next->thread.fpsimd_state;
-
-               if (__this_cpu_read(fpsimd_last_state) == st
-                   && st->cpu == smp_processor_id())
-                       clear_ti_thread_flag(task_thread_info(next),
-                                            TIF_FOREIGN_FPSTATE);
-               else
-                       set_ti_thread_flag(task_thread_info(next),
-                                          TIF_FOREIGN_FPSTATE);
-       }
+       if (next->mm)
+               fpsimd_load_state(&next->thread.fpsimd_state);
 }
 
 void fpsimd_flush_thread(void)
-{
-       memset(&current->thread.fpsimd_state, 0, sizeof(struct fpsimd_state));
-       set_thread_flag(TIF_FOREIGN_FPSTATE);
-}
-
-/*
- * Save the userland FPSIMD state of 'current' to memory, but only if the state
- * currently held in the registers does in fact belong to 'current'
- */
-void fpsimd_preserve_current_state(void)
-{
-       preempt_disable();
-       if (!test_thread_flag(TIF_FOREIGN_FPSTATE))
-               fpsimd_save_state(&current->thread.fpsimd_state);
-       preempt_enable();
-}
-
-/*
- * Load the userland FPSIMD state of 'current' from memory, but only if the
- * FPSIMD state already held in the registers is /not/ the most recent FPSIMD
- * state of 'current'
- */
-void fpsimd_restore_current_state(void)
-{
-       preempt_disable();
-       if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE)) {
-               struct fpsimd_state *st = &current->thread.fpsimd_state;
-
-               fpsimd_load_state(st);
-               this_cpu_write(fpsimd_last_state, st);
-               st->cpu = smp_processor_id();
-       }
-       preempt_enable();
-}
-
-/*
- * Load an updated userland FPSIMD state for 'current' from memory and set the
- * flag that indicates that the FPSIMD register contents are the most recent
- * FPSIMD state of 'current'
- */
-void fpsimd_update_current_state(struct fpsimd_state *state)
 {
        preempt_disable();
-       fpsimd_load_state(state);
-       if (test_and_clear_thread_flag(TIF_FOREIGN_FPSTATE)) {
-               struct fpsimd_state *st = &current->thread.fpsimd_state;
-
-               this_cpu_write(fpsimd_last_state, st);
-               st->cpu = smp_processor_id();
-       }
+       memset(&current->thread.fpsimd_state, 0, sizeof(struct fpsimd_state));
+       fpsimd_load_state(&current->thread.fpsimd_state);
        preempt_enable();
 }
 
-/*
- * Invalidate live CPU copies of task t's FPSIMD state
- */
-void fpsimd_flush_task_state(struct task_struct *t)
-{
-       t->thread.fpsimd_state.cpu = NR_CPUS;
-}
-
 #ifdef CONFIG_KERNEL_MODE_NEON
 
-static DEFINE_PER_CPU(struct fpsimd_partial_state, hardirq_fpsimdstate);
-static DEFINE_PER_CPU(struct fpsimd_partial_state, softirq_fpsimdstate);
-
 /*
  * Kernel-side NEON support functions
  */
-void kernel_neon_begin_partial(u32 num_regs)
+void kernel_neon_begin(void)
 {
-       if (in_interrupt()) {
-               struct fpsimd_partial_state *s = this_cpu_ptr(
-                       in_irq() ? &hardirq_fpsimdstate : &softirq_fpsimdstate);
+       /* Avoid using the NEON in interrupt context */
+       BUG_ON(in_interrupt());
+       preempt_disable();
 
-               BUG_ON(num_regs > 32);
-               fpsimd_save_partial_state(s, roundup(num_regs, 2));
-       } else {
-               /*
-                * Save the userland FPSIMD state if we have one and if we
-                * haven't done so already. Clear fpsimd_last_state to indicate
-                * that there is no longer userland FPSIMD state in the
-                * registers.
-                */
-               preempt_disable();
-               if (current->mm &&
-                   !test_and_set_thread_flag(TIF_FOREIGN_FPSTATE))
-                       fpsimd_save_state(&current->thread.fpsimd_state);
-               this_cpu_write(fpsimd_last_state, NULL);
-       }
+       if (current->mm)
+               fpsimd_save_state(&current->thread.fpsimd_state);
 }
-EXPORT_SYMBOL(kernel_neon_begin_partial);
+EXPORT_SYMBOL(kernel_neon_begin);
 
 void kernel_neon_end(void)
 {
-       if (in_interrupt()) {
-               struct fpsimd_partial_state *s = this_cpu_ptr(
-                       in_irq() ? &hardirq_fpsimdstate : &softirq_fpsimdstate);
-               fpsimd_load_partial_state(s);
-       } else {
-               preempt_enable();
-       }
+       if (current->mm)
+               fpsimd_load_state(&current->thread.fpsimd_state);
+
+       preempt_enable();
 }
 EXPORT_SYMBOL(kernel_neon_end);
 
@@ -268,12 +119,12 @@ static int fpsimd_cpu_pm_notifier(struct notifier_block *self,
 {
        switch (cmd) {
        case CPU_PM_ENTER:
-               if (current->mm && !test_thread_flag(TIF_FOREIGN_FPSTATE))
+               if (current->mm)
                        fpsimd_save_state(&current->thread.fpsimd_state);
                break;
        case CPU_PM_EXIT:
                if (current->mm)
-                       set_thread_flag(TIF_FOREIGN_FPSTATE);
+                       fpsimd_load_state(&current->thread.fpsimd_state);
                break;
        case CPU_PM_ENTER_FAILED:
        default:
index 15c91e25d045b858d18cd2870db2d0b6631e0647..3193bf35dbc893beb073b260e5d2dc14286cf540 100644 (file)
@@ -215,7 +215,7 @@ void release_thread(struct task_struct *dead_task)
 
 int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
 {
-       fpsimd_preserve_current_state();
+       fpsimd_save_state(&current->thread.fpsimd_state);
        *dst = *src;
        return 0;
 }
index 3e926b9c0641a7718f800d11156a87d9554bcb3c..0bf195533088ad0db219799861e8193dd287509d 100644 (file)
@@ -521,7 +521,6 @@ static int fpr_set(struct task_struct *target, const struct user_regset *regset,
                return ret;
 
        target->thread.fpsimd_state.user_fpsimd = newstate;
-       fpsimd_flush_task_state(target);
        return ret;
 }
 
@@ -769,7 +768,6 @@ static int compat_vfp_set(struct task_struct *target,
                uregs->fpcr = fpscr & VFP_FPSCR_CTRL_MASK;
        }
 
-       fpsimd_flush_task_state(target);
        return ret;
 }
 
index bbc1aad21ce6be3d190967b6690bc9323c3a7dd5..e3cf09626245aea9440aafbbbe5d84ad2d0ea5a6 100644 (file)
@@ -51,7 +51,7 @@ static int preserve_fpsimd_context(struct fpsimd_context __user *ctx)
        int err;
 
        /* dump the hardware registers to the fpsimd_state structure */
-       fpsimd_preserve_current_state();
+       fpsimd_save_state(fpsimd);
 
        /* copy the FP and status/control registers */
        err = __copy_to_user(ctx->vregs, fpsimd->vregs, sizeof(fpsimd->vregs));
@@ -86,8 +86,11 @@ static int restore_fpsimd_context(struct fpsimd_context __user *ctx)
        __get_user_error(fpsimd.fpcr, &ctx->fpcr, err);
 
        /* load the hardware registers from the fpsimd_state structure */
-       if (!err)
-               fpsimd_update_current_state(&fpsimd);
+       if (!err) {
+               preempt_disable();
+               fpsimd_load_state(&fpsimd);
+               preempt_enable();
+       }
 
        return err ? -EFAULT : 0;
 }
@@ -420,8 +423,4 @@ asmlinkage void do_notify_resume(struct pt_regs *regs,
                clear_thread_flag(TIF_NOTIFY_RESUME);
                tracehook_notify_resume(regs);
        }
-
-       if (thread_flags & _TIF_FOREIGN_FPSTATE)
-               fpsimd_restore_current_state();
-
 }
index 02de43260332b93166f823da472e53f5c6913c16..e51bbe79f5b5b9c850207a577e42018caf5fa846 100644 (file)
@@ -219,7 +219,7 @@ static int compat_preserve_vfp_context(struct compat_vfp_sigframe __user *frame)
         * Note that this also saves V16-31, which aren't visible
         * in AArch32.
         */
-       fpsimd_preserve_current_state();
+       fpsimd_save_state(fpsimd);
 
        /* Place structure header on the stack */
        __put_user_error(magic, &frame->magic, err);
@@ -282,8 +282,11 @@ static int compat_restore_vfp_context(struct compat_vfp_sigframe __user *frame)
         * We don't need to touch the exception register, so
         * reload the hardware state.
         */
-       if (!err)
-               fpsimd_update_current_state(&fpsimd);
+       if (!err) {
+               preempt_disable();
+               fpsimd_load_state(&fpsimd);
+               preempt_enable();
+       }
 
        return err ? -EFAULT : 0;
 }