diff options
author | Dave Hansen <dave.hansen@linux.intel.com> | 2015-09-02 19:31:28 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-09-14 06:21:59 -0400 |
commit | ee9ae257eb17d3426ee9ab91449a3aa443298b36 (patch) | |
tree | 44eebe10cdd9db74adbb5593f8291ebfd478d233 | |
parent | 8a93c9e0dca131a0bf330ea9d1e57c1bcf3824ad (diff) |
x86/fpu: Remove 'xfeature_nr'
xfeature_nr ended up being initialized too late for me to
use it in the "xsave size sanity check" patch which is
later in the series. I tried to move around its initialization
but realized that it was just as easy to get rid of it.
We only have 9 XFEATURES. Instead of dynamically calculating
and storing the last feature, just use the compile-time max:
XFEATURES_NR_MAX. Note that even with 'xfeatures_nr' we can
had "holes" in the xfeatures_mask that we had to deal with.
We also change a 'leaf' variable to be a plain 'i'. Although
it is used to grab a cpuid leaf in this one loop, all of the
other loops just use an 'i' and I find it much more obvious
to keep the naming consistent across all the similar loops.
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
Cc: dave@sr71.net
Cc: linux-kernel@vger.kernel.org
Link: http://lkml.kernel.org/r/20150902233128.3F30DF5A@viggo.jf.intel.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/kernel/fpu/xstate.c | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index c1a0bf4668de..61ec60bcbb63 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c | |||
@@ -35,9 +35,6 @@ static unsigned int xstate_offsets[XFEATURE_MAX] = { [ 0 ... XFEATURE_MAX - 1] = | |||
35 | static unsigned int xstate_sizes[XFEATURE_MAX] = { [ 0 ... XFEATURE_MAX - 1] = -1}; | 35 | static unsigned int xstate_sizes[XFEATURE_MAX] = { [ 0 ... XFEATURE_MAX - 1] = -1}; |
36 | static unsigned int xstate_comp_offsets[sizeof(xfeatures_mask)*8]; | 36 | static unsigned int xstate_comp_offsets[sizeof(xfeatures_mask)*8]; |
37 | 37 | ||
38 | /* The number of supported xfeatures in xfeatures_mask: */ | ||
39 | static unsigned int xfeatures_nr; | ||
40 | |||
41 | /* | 38 | /* |
42 | * Clear all of the X86_FEATURE_* bits that are unavailable | 39 | * Clear all of the X86_FEATURE_* bits that are unavailable |
43 | * when the CPU has no XSAVE support. | 40 | * when the CPU has no XSAVE support. |
@@ -190,23 +187,18 @@ void fpu__init_cpu_xstate(void) | |||
190 | /* | 187 | /* |
191 | * Record the offsets and sizes of various xstates contained | 188 | * Record the offsets and sizes of various xstates contained |
192 | * in the XSAVE state memory layout. | 189 | * in the XSAVE state memory layout. |
193 | * | ||
194 | * ( Note that certain features might be non-present, for them | ||
195 | * we'll have 0 offset and 0 size. ) | ||
196 | */ | 190 | */ |
197 | static void __init setup_xstate_features(void) | 191 | static void __init setup_xstate_features(void) |
198 | { | 192 | { |
199 | u32 eax, ebx, ecx, edx, leaf; | 193 | u32 eax, ebx, ecx, edx, i; |
200 | |||
201 | xfeatures_nr = fls64(xfeatures_mask); | ||
202 | 194 | ||
203 | for (leaf = FIRST_EXTENDED_XFEATURE; leaf < xfeatures_nr; leaf++) { | 195 | for (i = FIRST_EXTENDED_XFEATURE; i < XFEATURE_MAX; i++) { |
204 | cpuid_count(XSTATE_CPUID, leaf, &eax, &ebx, &ecx, &edx); | 196 | cpuid_count(XSTATE_CPUID, i, &eax, &ebx, &ecx, &edx); |
205 | 197 | ||
206 | xstate_offsets[leaf] = ebx; | 198 | xstate_offsets[i] = ebx; |
207 | xstate_sizes[leaf] = eax; | 199 | xstate_sizes[i] = eax; |
208 | 200 | ||
209 | printk(KERN_INFO "x86/fpu: xstate_offset[%d]: %4d, xstate_sizes[%d]: %4d\n", leaf, ebx, leaf, eax); | 201 | printk(KERN_INFO "x86/fpu: xstate_offset[%d]: %4d, xstate_sizes[%d]: %4d\n", i, ebx, i, eax); |
210 | } | 202 | } |
211 | } | 203 | } |
212 | 204 | ||
@@ -252,7 +244,7 @@ static void __init setup_xstate_comp(void) | |||
252 | xstate_comp_offsets[1] = offsetof(struct fxregs_state, xmm_space); | 244 | xstate_comp_offsets[1] = offsetof(struct fxregs_state, xmm_space); |
253 | 245 | ||
254 | if (!cpu_has_xsaves) { | 246 | if (!cpu_has_xsaves) { |
255 | for (i = FIRST_EXTENDED_XFEATURE; i < xfeatures_nr; i++) { | 247 | for (i = FIRST_EXTENDED_XFEATURE; i < XFEATURE_MAX; i++) { |
256 | if (test_bit(i, (unsigned long *)&xfeatures_mask)) { | 248 | if (test_bit(i, (unsigned long *)&xfeatures_mask)) { |
257 | xstate_comp_offsets[i] = xstate_offsets[i]; | 249 | xstate_comp_offsets[i] = xstate_offsets[i]; |
258 | xstate_comp_sizes[i] = xstate_sizes[i]; | 250 | xstate_comp_sizes[i] = xstate_sizes[i]; |
@@ -264,7 +256,7 @@ static void __init setup_xstate_comp(void) | |||
264 | xstate_comp_offsets[FIRST_EXTENDED_XFEATURE] = | 256 | xstate_comp_offsets[FIRST_EXTENDED_XFEATURE] = |
265 | FXSAVE_SIZE + XSAVE_HDR_SIZE; | 257 | FXSAVE_SIZE + XSAVE_HDR_SIZE; |
266 | 258 | ||
267 | for (i = FIRST_EXTENDED_XFEATURE; i < xfeatures_nr; i++) { | 259 | for (i = FIRST_EXTENDED_XFEATURE; i < XFEATURE_MAX; i++) { |
268 | if (test_bit(i, (unsigned long *)&xfeatures_mask)) | 260 | if (test_bit(i, (unsigned long *)&xfeatures_mask)) |
269 | xstate_comp_sizes[i] = xstate_sizes[i]; | 261 | xstate_comp_sizes[i] = xstate_sizes[i]; |
270 | else | 262 | else |