x86/fpu/xstate: Rename 'xstate_size' to 'fpu_kernel_xstate_size', to distinguish...
authorFenghua Yu <fenghua.yu@intel.com>
Fri, 20 May 2016 17:47:06 +0000 (10:47 -0700)
committerIngo Molnar <mingo@kernel.org>
Sat, 18 Jun 2016 08:10:18 +0000 (10:10 +0200)
User space uses standard format xsave area. fpstate in signal frame
should have standard format size.

To explicitly distinguish between xstate size in kernel space and the
one in user space, we rename 'xstate_size' to 'fpu_kernel_xstate_size'.

Cleanup only, no change in functionality.

Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
[ Rebased the patch and cleaned up the naming. ]
Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
Reviewed-by: Dave Hansen <dave.hansen@intel.com>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Denys Vlasenko <dvlasenk@redhat.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: Quentin Casasnovas <quentin.casasnovas@oracle.com>
Cc: Ravi V. Shankar <ravi.v.shankar@intel.com>
Cc: Sai Praneeth Prakhya <sai.praneeth.prakhya@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/2ecbae347a5152d94be52adf7d0f3b7305d90d99.1463760376.git.yu-cheng.yu@intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
arch/x86/include/asm/processor.h
arch/x86/kernel/fpu/core.c
arch/x86/kernel/fpu/init.c
arch/x86/kernel/fpu/signal.c
arch/x86/kernel/fpu/xstate.c

index 0a16a16284f56142f7ccaa6f4f5da34d9393e6cd..965c5d212c31a652104420c0a6b9e1b1be89ce55 100644 (file)
@@ -367,7 +367,7 @@ DECLARE_PER_CPU(struct irq_stack *, hardirq_stack);
 DECLARE_PER_CPU(struct irq_stack *, softirq_stack);
 #endif /* X86_64 */
 
-extern unsigned int xstate_size;
+extern unsigned int fpu_kernel_xstate_size;
 extern unsigned int fpu_user_xstate_size;
 
 struct perf_event;
index 7d564742e499af79ebd2aa2d5bb11ac59b19448b..c759bd01ec99b3c6260106022b347d0069f965a4 100644 (file)
@@ -227,7 +227,7 @@ void fpstate_init(union fpregs_state *state)
                return;
        }
 
-       memset(state, 0, xstate_size);
+       memset(state, 0, fpu_kernel_xstate_size);
 
        if (static_cpu_has(X86_FEATURE_FXSR))
                fpstate_init_fxstate(&state->fxsave);
@@ -252,7 +252,7 @@ int fpu__copy(struct fpu *dst_fpu, struct fpu *src_fpu)
         * leak into the child task:
         */
        if (use_eager_fpu())
-               memset(&dst_fpu->state.xsave, 0, xstate_size);
+               memset(&dst_fpu->state.xsave, 0, fpu_kernel_xstate_size);
 
        /*
         * Save current FPU registers directly into the child
@@ -271,7 +271,8 @@ int fpu__copy(struct fpu *dst_fpu, struct fpu *src_fpu)
         */
        preempt_disable();
        if (!copy_fpregs_to_fpstate(dst_fpu)) {
-               memcpy(&src_fpu->state, &dst_fpu->state, xstate_size);
+               memcpy(&src_fpu->state, &dst_fpu->state,
+                      fpu_kernel_xstate_size);
 
                if (use_eager_fpu())
                        copy_kernel_to_fpregs(&src_fpu->state);
index 5b1928c0aad479f8438abcec772f08a3be2bfca1..60f3839c5bfaa5e6560cb245355b74b04d6f31e0 100644 (file)
@@ -145,8 +145,8 @@ static void __init fpu__init_system_generic(void)
  * This is inherent to the XSAVE architecture which puts all state
  * components into a single, continuous memory block:
  */
-unsigned int xstate_size;
-EXPORT_SYMBOL_GPL(xstate_size);
+unsigned int fpu_kernel_xstate_size;
+EXPORT_SYMBOL_GPL(fpu_kernel_xstate_size);
 
 /* Get alignment of the TYPE. */
 #define TYPE_ALIGN(TYPE) offsetof(struct { char x; TYPE test; }, test)
@@ -178,7 +178,7 @@ static void __init fpu__init_task_struct_size(void)
         * Add back the dynamically-calculated register state
         * size.
         */
-       task_size += xstate_size;
+       task_size += fpu_kernel_xstate_size;
 
        /*
         * We dynamically size 'struct fpu', so we require that
@@ -195,7 +195,7 @@ static void __init fpu__init_task_struct_size(void)
 }
 
 /*
- * Set up the user and kernel xstate_size based on the legacy FPU context size.
+ * Set up the user and kernel xstate sizes based on the legacy FPU context size.
  *
  * We set this up first, and later it will be overwritten by
  * fpu__init_system_xstate() if the CPU knows about xstates.
@@ -208,7 +208,7 @@ static void __init fpu__init_system_xstate_size_legacy(void)
        on_boot_cpu = 0;
 
        /*
-        * Note that xstate_size might be overwriten later during
+        * Note that xstate sizes might be overwritten later during
         * fpu__init_system_xstate().
         */
 
@@ -219,15 +219,17 @@ static void __init fpu__init_system_xstate_size_legacy(void)
                 */
                setup_clear_cpu_cap(X86_FEATURE_XSAVE);
                setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
-               xstate_size = sizeof(struct swregs_state);
+               fpu_kernel_xstate_size = sizeof(struct swregs_state);
        } else {
                if (boot_cpu_has(X86_FEATURE_FXSR))
-                       xstate_size = sizeof(struct fxregs_state);
+                       fpu_kernel_xstate_size =
+                               sizeof(struct fxregs_state);
                else
-                       xstate_size = sizeof(struct fregs_state);
+                       fpu_kernel_xstate_size =
+                               sizeof(struct fregs_state);
        }
 
-       fpu_user_xstate_size = xstate_size;
+       fpu_user_xstate_size = fpu_kernel_xstate_size;
 
        /*
         * Quirk: we don't yet handle the XSAVES* instructions
index 0d29d4de4209f07a8d2880157bcfd6af0c84d37e..06d80f62c03f96e37b5faac7a06e42bfda53eb6a 100644 (file)
@@ -263,7 +263,7 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size)
        int ia32_fxstate = (buf != buf_fx);
        struct task_struct *tsk = current;
        struct fpu *fpu = &tsk->thread.fpu;
-       int state_size = xstate_size;
+       int state_size = fpu_kernel_xstate_size;
        u64 xfeatures = 0;
        int fx_only = 0;
 
index 9c4da358ebb96abe0706f14d6c90fc35ca71ca73..46abfafe61c8cea71c2c0297cb4e05ac0a8b325f 100644 (file)
@@ -537,7 +537,7 @@ static void do_extra_xstate_size_checks(void)
                 */
                paranoid_xstate_size += xfeature_size(i);
        }
-       XSTATE_WARN_ON(paranoid_xstate_size != xstate_size);
+       XSTATE_WARN_ON(paranoid_xstate_size != fpu_kernel_xstate_size);
 }
 
 
@@ -616,7 +616,7 @@ static int init_xstate_size(void)
         * The size is OK, we are definitely going to use xsave,
         * make it known to the world that we need more space.
         */
-       xstate_size = possible_xstate_size;
+       fpu_kernel_xstate_size = possible_xstate_size;
        do_extra_xstate_size_checks();
 
        /*
@@ -679,14 +679,14 @@ void __init fpu__init_system_xstate(void)
                return;
        }
 
-       update_regset_xstate_info(xstate_size, xfeatures_mask);
+       update_regset_xstate_info(fpu_kernel_xstate_size, xfeatures_mask);
        fpu__init_prepare_fx_sw_frame();
        setup_init_fpu_buf();
        setup_xstate_comp();
 
        pr_info("x86/fpu: Enabled xstate features 0x%llx, context size is %d bytes, using '%s' format.\n",
                xfeatures_mask,
-               xstate_size,
+               fpu_kernel_xstate_size,
                boot_cpu_has(X86_FEATURE_XSAVES) ? "compacted" : "standard");
 }