Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1216498
| From | Dave Hansen <dave@sr71.net> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 07/15] x86, fpu: rework XSTATE_* macros to remove magic '2' |
| Date | 2015-09-01 00:40 +0200 |
| Message-ID | <q3FU6-4sb-39@gated-at.bofh.it> (permalink) |
| References | <q3FKq-4gF-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: Dave Hansen <dave.hansen@linux.intel.com>
The 'xstate.c' code has a bunch of references to '2'. This
is because we have a lot more work to do for the "extended"
xstates than the "legacy" ones and state component 2 is the
first "extended" state.
This patch replaces all of the instances of '2' with
FIRST_EXTENDED_XFEATURE, which clearly explains what is
going on.
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: x86@kernel.org
Cc: Borislav Petkov <bp@alien8.de>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
Cc: linux-kernel@vger.kernel.org
---
b/arch/x86/include/asm/fpu/types.h | 2 ++
b/arch/x86/kernel/fpu/xstate.c | 13 +++++++------
2 files changed, 9 insertions(+), 6 deletions(-)
diff -puN arch/x86/include/asm/fpu/types.h~remove-hard-coded-values arch/x86/include/asm/fpu/types.h
--- a/arch/x86/include/asm/fpu/types.h~remove-hard-coded-values 2015-08-31 15:17:34.150871163 -0700
+++ b/arch/x86/include/asm/fpu/types.h 2015-08-31 15:17:34.154871345 -0700
@@ -126,6 +126,8 @@ enum xfeature {
| XFEATURE_MASK_ZMM_Hi256 \
| XFEATURE_MASK_Hi16_ZMM)
+#define FIRST_EXTENDED_XFEATURE XFEATURE_YMM
+
/*
* There are 16x 256-bit AVX registers named YMM0-YMM15.
* The low 128 bits are aliased to the 16 SSE registers (XMM0-XMM15)
diff -puN arch/x86/kernel/fpu/xstate.c~remove-hard-coded-values arch/x86/kernel/fpu/xstate.c
--- a/arch/x86/kernel/fpu/xstate.c~remove-hard-coded-values 2015-08-31 15:17:34.151871208 -0700
+++ b/arch/x86/kernel/fpu/xstate.c 2015-08-31 15:17:34.155871391 -0700
@@ -200,7 +200,7 @@ static void __init setup_xstate_features
xfeatures_nr = fls64(xfeatures_mask);
- for (leaf = 2; leaf < xfeatures_nr; leaf++) {
+ for (leaf = FIRST_EXTENDED_XFEATURE; leaf < xfeatures_nr; leaf++) {
cpuid_count(XSTATE_CPUID, leaf, &eax, &ebx, &ecx, &edx);
xstate_offsets[leaf] = ebx;
@@ -252,7 +252,7 @@ static void __init setup_xstate_comp(voi
xstate_comp_offsets[1] = offsetof(struct fxregs_state, xmm_space);
if (!cpu_has_xsaves) {
- for (i = 2; i < xfeatures_nr; i++) {
+ for (i = FIRST_EXTENDED_XFEATURE; i < xfeatures_nr; i++) {
if (test_bit(i, (unsigned long *)&xfeatures_mask)) {
xstate_comp_offsets[i] = xstate_offsets[i];
xstate_comp_sizes[i] = xstate_sizes[i];
@@ -261,15 +261,16 @@ static void __init setup_xstate_comp(voi
return;
}
- xstate_comp_offsets[2] = FXSAVE_SIZE + XSAVE_HDR_SIZE;
+ xstate_comp_offsets[FIRST_EXTENDED_XFEATURE] =
+ FXSAVE_SIZE + XSAVE_HDR_SIZE;
- for (i = 2; i < xfeatures_nr; i++) {
+ for (i = FIRST_EXTENDED_XFEATURE; i < xfeatures_nr; i++) {
if (test_bit(i, (unsigned long *)&xfeatures_mask))
xstate_comp_sizes[i] = xstate_sizes[i];
else
xstate_comp_sizes[i] = 0;
- if (i > 2)
+ if (i > FIRST_EXTENDED_XFEATURE)
xstate_comp_offsets[i] = xstate_comp_offsets[i-1]
+ xstate_comp_sizes[i-1];
@@ -325,7 +326,7 @@ static unsigned int __init calculate_xst
}
calculated_xstate_size = FXSAVE_SIZE + XSAVE_HDR_SIZE;
- for (i = 2; i < 64; i++) {
+ for (i = FIRST_EXTENDED_XFEATURE; i < 64; i++) {
if (test_bit(i, (unsigned long *)&xfeatures_mask)) {
cpuid_count(XSTATE_CPUID, i, &eax, &ebx, &ecx, &edx);
calculated_xstate_size += eax;
_
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/15] [v3] x86, fpu: XSAVE cleanups and sanity checks Dave Hansen <dave@sr71.net> - 2015-09-01 00:30 +0200
[PATCH 10/15] x86, fpu: rework MPX 'xstate' types Dave Hansen <dave@sr71.net> - 2015-09-01 00:30 +0200
[PATCH 15/15] x86, fpu: check CPU-provided sizes against struct declarations Dave Hansen <dave@sr71.net> - 2015-09-01 00:30 +0200
[PATCH 02/15] x86, fpu: move XSAVE-disabling code to a helper Dave Hansen <dave@sr71.net> - 2015-09-01 00:40 +0200
[PATCH 13/15] x86, fpu: correct and check XSAVE xstate size calculations Dave Hansen <dave@sr71.net> - 2015-09-01 00:40 +0200
[PATCH 05/15] x86, fpu: XSAVE macro renames Dave Hansen <dave@sr71.net> - 2015-09-01 00:40 +0200
Re: [PATCH 05/15] x86, fpu: XSAVE macro renames Dave Hansen <dave@sr71.net> - 2015-09-01 01:50 +0200
[PATCH 11/15] x86, fpu: rework YMM definition Dave Hansen <dave@sr71.net> - 2015-09-01 00:40 +0200
[PATCH 06/15] x86, fpu: rename XFEATURES_NR_MAX Dave Hansen <dave@sr71.net> - 2015-09-01 00:40 +0200
[PATCH 04/15] x86, fpu: kill LWP support Dave Hansen <dave@sr71.net> - 2015-09-01 00:40 +0200
[PATCH 09/15] x86, fpu: add helper xfeature_enabled() instead of test_bit() Dave Hansen <dave@sr71.net> - 2015-09-01 00:40 +0200
[PATCH 07/15] x86, fpu: rework XSTATE_* macros to remove magic '2' Dave Hansen <dave@sr71.net> - 2015-09-01 00:40 +0200
[PATCH 12/15] x86, fpu: add C structures for AVX-512 state components Dave Hansen <dave@sr71.net> - 2015-09-01 00:40 +0200
[PATCH 03/15] x86, fpu: remove XSTATE_RESERVE Dave Hansen <dave@sr71.net> - 2015-09-01 00:40 +0200
[PATCH 08/15] x86, fpu: remove xfeature_nr Dave Hansen <dave@sr71.net> - 2015-09-01 00:40 +0200
csiph-web