aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorFenghua Yu <fenghua.yu@intel.com>2016-05-20 13:47:06 -0400
committerIngo Molnar <mingo@kernel.org>2016-06-18 04:10:18 -0400
commitbf15a8cf8d14879b785c548728415d36ccb6a33b (patch)
tree1628f72178bb023cc9342760fce962e5f9747bf0 /arch/x86/kernel
parenta1141e0b5ca6ee3e5e35d5f1a310a5ecb9c96ce5 (diff)
x86/fpu/xstate: Rename 'xstate_size' to 'fpu_kernel_xstate_size', to distinguish it from 'fpu_user_xstate_size'
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>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/fpu/core.c7
-rw-r--r--arch/x86/kernel/fpu/init.c20
-rw-r--r--arch/x86/kernel/fpu/signal.c2
-rw-r--r--arch/x86/kernel/fpu/xstate.c8
4 files changed, 20 insertions, 17 deletions
diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index 7d564742e499..c759bd01ec99 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -227,7 +227,7 @@ void fpstate_init(union fpregs_state *state)
227 return; 227 return;
228 } 228 }
229 229
230 memset(state, 0, xstate_size); 230 memset(state, 0, fpu_kernel_xstate_size);
231 231
232 if (static_cpu_has(X86_FEATURE_FXSR)) 232 if (static_cpu_has(X86_FEATURE_FXSR))
233 fpstate_init_fxstate(&state->fxsave); 233 fpstate_init_fxstate(&state->fxsave);
@@ -252,7 +252,7 @@ int fpu__copy(struct fpu *dst_fpu, struct fpu *src_fpu)
252 * leak into the child task: 252 * leak into the child task:
253 */ 253 */
254 if (use_eager_fpu()) 254 if (use_eager_fpu())
255 memset(&dst_fpu->state.xsave, 0, xstate_size); 255 memset(&dst_fpu->state.xsave, 0, fpu_kernel_xstate_size);
256 256
257 /* 257 /*
258 * Save current FPU registers directly into the child 258 * Save current FPU registers directly into the child
@@ -271,7 +271,8 @@ int fpu__copy(struct fpu *dst_fpu, struct fpu *src_fpu)
271 */ 271 */
272 preempt_disable(); 272 preempt_disable();
273 if (!copy_fpregs_to_fpstate(dst_fpu)) { 273 if (!copy_fpregs_to_fpstate(dst_fpu)) {
274 memcpy(&src_fpu->state, &dst_fpu->state, xstate_size); 274 memcpy(&src_fpu->state, &dst_fpu->state,
275 fpu_kernel_xstate_size);
275 276
276 if (use_eager_fpu()) 277 if (use_eager_fpu())
277 copy_kernel_to_fpregs(&src_fpu->state); 278 copy_kernel_to_fpregs(&src_fpu->state);
diff --git a/arch/x86/kernel/fpu/init.c b/arch/x86/kernel/fpu/init.c
index 5b1928c0aad4..60f3839c5bfa 100644
--- a/arch/x86/kernel/fpu/init.c
+++ b/arch/x86/kernel/fpu/init.c
@@ -145,8 +145,8 @@ static void __init fpu__init_system_generic(void)
145 * This is inherent to the XSAVE architecture which puts all state 145 * This is inherent to the XSAVE architecture which puts all state
146 * components into a single, continuous memory block: 146 * components into a single, continuous memory block:
147 */ 147 */
148unsigned int xstate_size; 148unsigned int fpu_kernel_xstate_size;
149EXPORT_SYMBOL_GPL(xstate_size); 149EXPORT_SYMBOL_GPL(fpu_kernel_xstate_size);
150 150
151/* Get alignment of the TYPE. */ 151/* Get alignment of the TYPE. */
152#define TYPE_ALIGN(TYPE) offsetof(struct { char x; TYPE test; }, test) 152#define TYPE_ALIGN(TYPE) offsetof(struct { char x; TYPE test; }, test)
@@ -178,7 +178,7 @@ static void __init fpu__init_task_struct_size(void)
178 * Add back the dynamically-calculated register state 178 * Add back the dynamically-calculated register state
179 * size. 179 * size.
180 */ 180 */
181 task_size += xstate_size; 181 task_size += fpu_kernel_xstate_size;
182 182
183 /* 183 /*
184 * We dynamically size 'struct fpu', so we require that 184 * We dynamically size 'struct fpu', so we require that
@@ -195,7 +195,7 @@ static void __init fpu__init_task_struct_size(void)
195} 195}
196 196
197/* 197/*
198 * Set up the user and kernel xstate_size based on the legacy FPU context size. 198 * Set up the user and kernel xstate sizes based on the legacy FPU context size.
199 * 199 *
200 * We set this up first, and later it will be overwritten by 200 * We set this up first, and later it will be overwritten by
201 * fpu__init_system_xstate() if the CPU knows about xstates. 201 * fpu__init_system_xstate() if the CPU knows about xstates.
@@ -208,7 +208,7 @@ static void __init fpu__init_system_xstate_size_legacy(void)
208 on_boot_cpu = 0; 208 on_boot_cpu = 0;
209 209
210 /* 210 /*
211 * Note that xstate_size might be overwriten later during 211 * Note that xstate sizes might be overwritten later during
212 * fpu__init_system_xstate(). 212 * fpu__init_system_xstate().
213 */ 213 */
214 214
@@ -219,15 +219,17 @@ static void __init fpu__init_system_xstate_size_legacy(void)
219 */ 219 */
220 setup_clear_cpu_cap(X86_FEATURE_XSAVE); 220 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
221 setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT); 221 setup_clear_cpu_cap(X86_FEATURE_XSAVEOPT);
222 xstate_size = sizeof(struct swregs_state); 222 fpu_kernel_xstate_size = sizeof(struct swregs_state);
223 } else { 223 } else {
224 if (boot_cpu_has(X86_FEATURE_FXSR)) 224 if (boot_cpu_has(X86_FEATURE_FXSR))
225 xstate_size = sizeof(struct fxregs_state); 225 fpu_kernel_xstate_size =
226 sizeof(struct fxregs_state);
226 else 227 else
227 xstate_size = sizeof(struct fregs_state); 228 fpu_kernel_xstate_size =
229 sizeof(struct fregs_state);
228 } 230 }
229 231
230 fpu_user_xstate_size = xstate_size; 232 fpu_user_xstate_size = fpu_kernel_xstate_size;
231 233
232 /* 234 /*
233 * Quirk: we don't yet handle the XSAVES* instructions 235 * Quirk: we don't yet handle the XSAVES* instructions
diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c
index 0d29d4de4209..06d80f62c03f 100644
--- a/arch/x86/kernel/fpu/signal.c
+++ b/arch/x86/kernel/fpu/signal.c
@@ -263,7 +263,7 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size)
263 int ia32_fxstate = (buf != buf_fx); 263 int ia32_fxstate = (buf != buf_fx);
264 struct task_struct *tsk = current; 264 struct task_struct *tsk = current;
265 struct fpu *fpu = &tsk->thread.fpu; 265 struct fpu *fpu = &tsk->thread.fpu;
266 int state_size = xstate_size; 266 int state_size = fpu_kernel_xstate_size;
267 u64 xfeatures = 0; 267 u64 xfeatures = 0;
268 int fx_only = 0; 268 int fx_only = 0;
269 269
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 9c4da358ebb9..46abfafe61c8 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -537,7 +537,7 @@ static void do_extra_xstate_size_checks(void)
537 */ 537 */
538 paranoid_xstate_size += xfeature_size(i); 538 paranoid_xstate_size += xfeature_size(i);
539 } 539 }
540 XSTATE_WARN_ON(paranoid_xstate_size != xstate_size); 540 XSTATE_WARN_ON(paranoid_xstate_size != fpu_kernel_xstate_size);
541} 541}
542 542
543 543
@@ -616,7 +616,7 @@ static int init_xstate_size(void)
616 * The size is OK, we are definitely going to use xsave, 616 * The size is OK, we are definitely going to use xsave,
617 * make it known to the world that we need more space. 617 * make it known to the world that we need more space.
618 */ 618 */
619 xstate_size = possible_xstate_size; 619 fpu_kernel_xstate_size = possible_xstate_size;
620 do_extra_xstate_size_checks(); 620 do_extra_xstate_size_checks();
621 621
622 /* 622 /*
@@ -679,14 +679,14 @@ void __init fpu__init_system_xstate(void)
679 return; 679 return;
680 } 680 }
681 681
682 update_regset_xstate_info(xstate_size, xfeatures_mask); 682 update_regset_xstate_info(fpu_kernel_xstate_size, xfeatures_mask);
683 fpu__init_prepare_fx_sw_frame(); 683 fpu__init_prepare_fx_sw_frame();
684 setup_init_fpu_buf(); 684 setup_init_fpu_buf();
685 setup_xstate_comp(); 685 setup_xstate_comp();
686 686
687 pr_info("x86/fpu: Enabled xstate features 0x%llx, context size is %d bytes, using '%s' format.\n", 687 pr_info("x86/fpu: Enabled xstate features 0x%llx, context size is %d bytes, using '%s' format.\n",
688 xfeatures_mask, 688 xfeatures_mask,
689 xstate_size, 689 fpu_kernel_xstate_size,
690 boot_cpu_has(X86_FEATURE_XSAVES) ? "compacted" : "standard"); 690 boot_cpu_has(X86_FEATURE_XSAVES) ? "compacted" : "standard");
691} 691}
692 692