From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754990AbbINMXX (ORCPT ); Mon, 14 Sep 2015 08:23:23 -0400 Received: from terminus.zytor.com ([198.137.202.10]:35128 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751285AbbINMXV (ORCPT ); Mon, 14 Sep 2015 08:23:21 -0400 Date: Mon, 14 Sep 2015 05:22:12 -0700 From: tip-bot for Dave Hansen Message-ID: Cc: linux-kernel@vger.kernel.org, bp@alien8.de, torvalds@linux-foundation.org, luto@amacapital.net, fenghua.yu@intel.com, tglx@linutronix.de, brgerst@gmail.com, peterz@infradead.org, dvlasenk@redhat.com, mingo@kernel.org, hpa@zytor.com, tim.c.chen@linux.intel.com, dave.hansen@linux.intel.com Reply-To: dave.hansen@linux.intel.com, tim.c.chen@linux.intel.com, mingo@kernel.org, dvlasenk@redhat.com, hpa@zytor.com, peterz@infradead.org, fenghua.yu@intel.com, brgerst@gmail.com, tglx@linutronix.de, torvalds@linux-foundation.org, luto@amacapital.net, linux-kernel@vger.kernel.org, bp@alien8.de In-Reply-To: <20150902233128.3F30DF5A@viggo.jf.intel.com> References: <20150902233128.3F30DF5A@viggo.jf.intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/fpu] x86/fpu: Remove 'xfeature_nr' Git-Commit-ID: ee9ae257eb17d3426ee9ab91449a3aa443298b36 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: ee9ae257eb17d3426ee9ab91449a3aa443298b36 Gitweb: http://git.kernel.org/tip/ee9ae257eb17d3426ee9ab91449a3aa443298b36 Author: Dave Hansen AuthorDate: Wed, 2 Sep 2015 16:31:28 -0700 Committer: Ingo Molnar CommitDate: Mon, 14 Sep 2015 12:21:59 +0200 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 Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Denys Vlasenko Cc: Fenghua Yu Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Tim Chen 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 --- arch/x86/kernel/fpu/xstate.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index c1a0bf4..61ec60b 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] = static unsigned int xstate_sizes[XFEATURE_MAX] = { [ 0 ... XFEATURE_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; - /* * Clear all of the X86_FEATURE_* bits that are unavailable * when the CPU has no XSAVE support. @@ -190,23 +187,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; leaf < xfeatures_nr; leaf++) { - cpuid_count(XSTATE_CPUID, leaf, &eax, &ebx, &ecx, &edx); + for (i = FIRST_EXTENDED_XFEATURE; i < XFEATURE_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]: %4d, xstate_sizes[%d]: %4d\n", leaf, ebx, leaf, eax); + printk(KERN_INFO "x86/fpu: xstate_offset[%d]: %4d, xstate_sizes[%d]: %4d\n", i, ebx, i, eax); } } @@ -252,7 +244,7 @@ static void __init setup_xstate_comp(void) xstate_comp_offsets[1] = offsetof(struct fxregs_state, xmm_space); if (!cpu_has_xsaves) { - for (i = FIRST_EXTENDED_XFEATURE; i < xfeatures_nr; i++) { + for (i = FIRST_EXTENDED_XFEATURE; i < XFEATURE_MAX; i++) { if (test_bit(i, (unsigned long *)&xfeatures_mask)) { xstate_comp_offsets[i] = xstate_offsets[i]; xstate_comp_sizes[i] = xstate_sizes[i]; @@ -264,7 +256,7 @@ static void __init setup_xstate_comp(void) xstate_comp_offsets[FIRST_EXTENDED_XFEATURE] = FXSAVE_SIZE + XSAVE_HDR_SIZE; - for (i = FIRST_EXTENDED_XFEATURE; i < xfeatures_nr; i++) { + for (i = FIRST_EXTENDED_XFEATURE; i < XFEATURE_MAX; i++) { if (test_bit(i, (unsigned long *)&xfeatures_mask)) xstate_comp_sizes[i] = xstate_sizes[i]; else