aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorFenghua Yu <fenghua.yu@intel.com>2014-05-30 17:59:24 -0400
committerH. Peter Anvin <hpa@linux.intel.com>2014-05-30 20:12:41 -0400
commit8ff925e10f2c72680918b95173ef4f8bb982d59e (patch)
treed8f4358a9962d4dbb9f5e5f9706e46678f46c690 /arch
parentc9e5a5a7034146493386d985ff432aed8059929a (diff)
x86/xsaves: Clean up code in xstate offsets computation in xsave area
This patch cleans up some code in xstate offsets computation in xsave area: 1. It changes xstate_comp_offsets as an array. This avoids possible NULL pointer caused by possible kmalloc() failure during boot time. 2. It changes the global variable xstate_comp_sizes to a local variable because it is used only in setup_xstate_comp(). 3. It adds missing offsets for FP and SSE in xsave area. Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> Link: http://lkml.kernel.org/r/1401387164-43416-17-git-send-email-fenghua.yu@intel.com Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kernel/xsave.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
index a6cb8233f628..940b142cc11f 100644
--- a/arch/x86/kernel/xsave.c
+++ b/arch/x86/kernel/xsave.c
@@ -26,7 +26,7 @@ struct xsave_struct *init_xstate_buf;
26 26
27static struct _fpx_sw_bytes fx_sw_reserved, fx_sw_reserved_ia32; 27static struct _fpx_sw_bytes fx_sw_reserved, fx_sw_reserved_ia32;
28static unsigned int *xstate_offsets, *xstate_sizes; 28static unsigned int *xstate_offsets, *xstate_sizes;
29static unsigned int *xstate_comp_offsets, *xstate_comp_sizes; 29static unsigned int xstate_comp_offsets[sizeof(pcntxt_mask)*8];
30static unsigned int xstate_features; 30static unsigned int xstate_features;
31 31
32/* 32/*
@@ -491,11 +491,16 @@ static void __init setup_xstate_features(void)
491 */ 491 */
492void setup_xstate_comp(void) 492void setup_xstate_comp(void)
493{ 493{
494 unsigned int xstate_comp_sizes[sizeof(pcntxt_mask)*8];
494 int i; 495 int i;
495 496
496 xstate_comp_offsets = kmalloc(xstate_features * sizeof(int), 497 /*
497 GFP_KERNEL); 498 * The FP xstates and SSE xstates are legacy states. They are always
498 xstate_comp_sizes = kmalloc(xstate_features * sizeof(int), GFP_KERNEL); 499 * in the fixed offsets in the xsave area in either compacted form
500 * or standard form.
501 */
502 xstate_comp_offsets[0] = 0;
503 xstate_comp_offsets[1] = offsetof(struct i387_fxsave_struct, xmm_space);
499 504
500 if (!cpu_has_xsaves) { 505 if (!cpu_has_xsaves) {
501 for (i = 2; i < xstate_features; i++) { 506 for (i = 2; i < xstate_features; i++) {