diff options
author | Suresh Siddha <suresh.b.siddha@intel.com> | 2010-07-19 19:05:48 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2010-07-19 20:51:17 -0400 |
commit | a1488f8bf4d72ad724700f6e982469a1240e4264 (patch) | |
tree | 44d88423b1e9ad3756f1b58ab6cc2768abc46777 | |
parent | 5734f62b6601d88fd8ec720cb56b93fd3a030557 (diff) |
x86, xsave: Track the offset, size of state in the xsave layout
Subleaves of the cpuid vector 0xd provides the offset and size of different
feature state that are managed by the xsave/xrstor. Track this for the upcoming
usage during signal handling.
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
LKML-Reference: <20100719230205.262987929@sbs-t61.sc.intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r-- | arch/x86/kernel/xsave.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c index 980149867a19..4993caa4181c 100644 --- a/arch/x86/kernel/xsave.c +++ b/arch/x86/kernel/xsave.c | |||
@@ -21,6 +21,8 @@ struct _fpx_sw_bytes fx_sw_reserved; | |||
21 | struct _fpx_sw_bytes fx_sw_reserved_ia32; | 21 | struct _fpx_sw_bytes fx_sw_reserved_ia32; |
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | static unsigned int *xstate_offsets, *xstate_sizes, xstate_features; | ||
25 | |||
24 | /* | 26 | /* |
25 | * Check for the presence of extended state information in the | 27 | * Check for the presence of extended state information in the |
26 | * user fpstate pointer in the sigcontext. | 28 | * user fpstate pointer in the sigcontext. |
@@ -302,12 +304,39 @@ void __cpuinit xsave_init(void) | |||
302 | } | 304 | } |
303 | 305 | ||
304 | /* | 306 | /* |
307 | * Record the offsets and sizes of different state managed by the xsave | ||
308 | * memory layout. | ||
309 | */ | ||
310 | static void setup_xstate_features(void) | ||
311 | { | ||
312 | int eax, ebx, ecx, edx, leaf = 0x2; | ||
313 | |||
314 | xstate_features = fls64(pcntxt_mask); | ||
315 | xstate_offsets = alloc_bootmem(xstate_features * sizeof(int)); | ||
316 | xstate_sizes = alloc_bootmem(xstate_features * sizeof(int)); | ||
317 | |||
318 | do { | ||
319 | cpuid_count(0xd, leaf, &eax, &ebx, &ecx, &edx); | ||
320 | |||
321 | if (eax == 0) | ||
322 | break; | ||
323 | |||
324 | xstate_offsets[leaf] = ebx; | ||
325 | xstate_sizes[leaf] = eax; | ||
326 | |||
327 | leaf++; | ||
328 | } while (1); | ||
329 | } | ||
330 | |||
331 | /* | ||
305 | * setup the xstate image representing the init state | 332 | * setup the xstate image representing the init state |
306 | */ | 333 | */ |
307 | static void __init setup_xstate_init(void) | 334 | static void __init setup_xstate_init(void) |
308 | { | 335 | { |
309 | init_xstate_buf = alloc_bootmem(xstate_size); | 336 | init_xstate_buf = alloc_bootmem(xstate_size); |
310 | init_xstate_buf->i387.mxcsr = MXCSR_DEFAULT; | 337 | init_xstate_buf->i387.mxcsr = MXCSR_DEFAULT; |
338 | |||
339 | setup_xstate_features(); | ||
311 | } | 340 | } |
312 | 341 | ||
313 | /* | 342 | /* |