Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1214722

[PATCH 04/11] x86, fpu: remove xfeature_nr

From Dave Hansen <dave@sr71.net>
Newsgroups linux.kernel
Subject [PATCH 04/11] x86, fpu: remove xfeature_nr
Date 2015-08-27 19:20 +0200
Message-ID <q290e-2v7-23@gated-at.bofh.it> (permalink)
References <q290d-2v7-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Dave Hansen <dave.hansen@linux.intel.com>

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: 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/kernel/fpu/xstate.c |   24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)

diff -puN arch/x86/kernel/fpu/xstate.c~kill-xfeatures_nr arch/x86/kernel/fpu/xstate.c
--- a/arch/x86/kernel/fpu/xstate.c~kill-xfeatures_nr	2015-08-27 10:08:02.339669254 -0700
+++ b/arch/x86/kernel/fpu/xstate.c	2015-08-27 10:08:02.343669437 -0700
@@ -35,9 +35,6 @@ static unsigned int xstate_offsets[XFEAT
 static unsigned int xstate_sizes[XFEATURES_NR_MAX]   = { [ 0 ... XFEATURES_NR_MAX - 1] = -1};
 static unsigned int xstate_comp_offsets[sizeof(xfeatures_mask)*8];
 
-/* The number of supported xfeatures in xfeatures_mask: */
-static unsigned int xfeatures_nr;
-
 /*
  * Return whether the system supports a given xfeature.
  *
@@ -171,23 +168,18 @@ void fpu__init_cpu_xstate(void)
 /*
  * Record the offsets and sizes of various xstates contained
  * in the XSAVE state memory layout.
- *
- * ( Note that certain features might be non-present, for them
- *   we'll have 0 offset and 0 size. )
  */
 static void __init setup_xstate_features(void)
 {
-	u32 eax, ebx, ecx, edx, leaf;
-
-	xfeatures_nr = fls64(xfeatures_mask);
+	u32 eax, ebx, ecx, edx, i;
 
-	for (leaf = FIRST_EXTENDED_XFEATURE_NR; leaf < xfeatures_nr; leaf++) {
-		cpuid_count(XSTATE_CPUID, leaf, &eax, &ebx, &ecx, &edx);
+	for (i = FIRST_EXTENDED_XFEATURE_NR; i < XFEATURES_NR_MAX; i++) {
+		cpuid_count(XSTATE_CPUID, i, &eax, &ebx, &ecx, &edx);
 
-		xstate_offsets[leaf] = ebx;
-		xstate_sizes[leaf] = eax;
+		xstate_offsets[i] = ebx;
+		xstate_sizes[i] = eax;
 
-		printk(KERN_INFO "x86/fpu: xstate_offset[%d]: %04x, xstate_sizes[%d]: %04x\n", leaf, ebx, leaf, eax);
+		printk(KERN_INFO "x86/fpu: xstate_offset[%d]: %04x, xstate_sizes[%d]: %04x\n", i, ebx, i, eax);
 	}
 }
 
@@ -233,7 +225,7 @@ static void __init setup_xstate_comp(voi
 	xstate_comp_offsets[1] = offsetof(struct fxregs_state, xmm_space);
 
 	if (!cpu_has_xsaves) {
-		for (i = FIRST_EXTENDED_XFEATURE_NR; i < xfeatures_nr; i++) {
+		for (i = FIRST_EXTENDED_XFEATURE_NR; i < XFEATURES_NR_MAX; i++) {
 			if (test_bit(i, (unsigned long *)&xfeatures_mask)) {
 				xstate_comp_offsets[i] = xstate_offsets[i];
 				xstate_comp_sizes[i] = xstate_sizes[i];
@@ -245,7 +237,7 @@ static void __init setup_xstate_comp(voi
 	xstate_comp_offsets[FIRST_EXTENDED_XFEATURE_NR] =
 	  	FXSAVE_SIZE + XSAVE_HDR_SIZE;
 
-	for (i = FIRST_EXTENDED_XFEATURE_NR; i < xfeatures_nr; i++) {
+	for (i = FIRST_EXTENDED_XFEATURE_NR; i < XFEATURES_NR_MAX; i++) {
 		if (test_bit(i, (unsigned long *)&xfeatures_mask))
 			xstate_comp_sizes[i] = xstate_sizes[i];
 		else
_
--
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 | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 00/11] [v2] x86, fpu: XSAVE cleanups and sanity checks Dave Hansen <dave@sr71.net> - 2015-08-27 19:20 +0200
  [PATCH 06/11] x86, fpu: rework MPX 'xstate' types Dave Hansen <dave@sr71.net> - 2015-08-27 19:20 +0200
  [PATCH 04/11] x86, fpu: remove xfeature_nr Dave Hansen <dave@sr71.net> - 2015-08-27 19:20 +0200
    Re: [PATCH 04/11] x86, fpu: remove xfeature_nr Ingo Molnar <mingo@kernel.org> - 2015-08-28 07:10 +0200
  [PATCH 01/11] x86, fpu: kill LWP support Dave Hansen <dave@sr71.net> - 2015-08-27 19:20 +0200
    Re: [PATCH 01/11] x86, fpu: kill LWP support Ingo Molnar <mingo@kernel.org> - 2015-08-28 07:00 +0200
  [PATCH 07/11] x86, fpu: rework YMM definition Dave Hansen <dave@sr71.net> - 2015-08-27 19:20 +0200
  [PATCH 09/11] x86, fpu: correct and check XSAVE xstate size calculations Dave Hansen <dave@sr71.net> - 2015-08-27 19:20 +0200
    Re: [PATCH 09/11] x86, fpu: correct and check XSAVE xstate size  calculations Ingo Molnar <mingo@kernel.org> - 2015-08-28 07:00 +0200
      Re: [PATCH 09/11] x86, fpu: correct and check XSAVE xstate size calculations Dave Hansen <dave@sr71.net> - 2015-08-28 16:40 +0200
        Re: [PATCH 09/11] x86, fpu: correct and check XSAVE xstate size calculations Andi Kleen <andi@firstfloor.org> - 2015-08-28 18:50 +0200
  [PATCH 10/11] x86, fpu: check to ensure increasing-offset xstate offsets Dave Hansen <dave@sr71.net> - 2015-08-27 19:20 +0200
  [PATCH 08/11] x86, fpu: add C structures for AVX-512 state components Dave Hansen <dave@sr71.net> - 2015-08-27 19:20 +0200
    Re: [PATCH 08/11] x86, fpu: add C structures for AVX-512 state  components Ingo Molnar <mingo@kernel.org> - 2015-08-28 07:10 +0200
  [PATCH 11/11] x86, fpu: check CPU-provided sizes against struct declarations Dave Hansen <dave@sr71.net> - 2015-08-27 19:20 +0200
    Re: [PATCH 11/11] x86, fpu: check CPU-provided sizes against struct  declarations Ingo Molnar <mingo@kernel.org> - 2015-08-28 07:30 +0200
      Re: [PATCH 11/11] x86, fpu: check CPU-provided sizes against struct  declarations Dave Hansen <dave@sr71.net> - 2015-08-28 18:10 +0200
  [PATCH 05/11] x86, fpu: add helper xfeature_nr_enabled() instead of test_bit() Dave Hansen <dave@sr71.net> - 2015-08-27 19:20 +0200
    Re: [PATCH 05/11] x86, fpu: add helper xfeature_nr_enabled() instead  of test_bit() Ingo Molnar <mingo@kernel.org> - 2015-08-28 07:10 +0200
  Re: [PATCH 00/11] [v2] x86, fpu: XSAVE cleanups and sanity checks Ingo Molnar <mingo@kernel.org> - 2015-08-28 07:20 +0200

csiph-web