From: Dave Hansen <dave@sr71.net>
To: dave@sr71.net
Cc: dave.hansen@linux.intel.com, mingo@redhat.com, x86@kernel.org,
bp@alien8.de, fenghua.yu@intel.com, tim.c.chen@linux.intel.com,
linux-kernel@vger.kernel.org
Subject: [PATCH 05/11] x86, fpu: add helper xfeature_nr_enabled() instead of test_bit()
Date: Thu, 27 Aug 2015 10:11:07 -0700 [thread overview]
Message-ID: <20150827171107.219DA1AA@viggo.jf.intel.com> (raw)
In-Reply-To: <20150827171102.1BDF27E5@viggo.jf.intel.com>
From: Dave Hansen <dave.hansen@linux.intel.com>
We currently use test_bit() in a few places to see if an xfeature
is enabled. It ends up being a bit ugly because 'xfeatures_mask'
is a u64 and test_bit wants an 'unsigned long' so it requires a
cast. The *_bit() functions are also techincally atomic, which
we have no need for here.
So, remove the test_bit()s and replace with the new
xfeature_nr_enabled() helper.
This also provides a central place to add a comment about the
future need to support 'system xstates'.
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 | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff -puN arch/x86/kernel/fpu/xstate.c~use-xfeature_enabled arch/x86/kernel/fpu/xstate.c
--- a/arch/x86/kernel/fpu/xstate.c~use-xfeature_enabled 2015-08-27 10:08:02.716686431 -0700
+++ b/arch/x86/kernel/fpu/xstate.c 2015-08-27 10:08:02.720686613 -0700
@@ -207,6 +207,16 @@ static void __init print_xstate_features
}
/*
+ * Note that in the future we will likely need a pair of
+ * functions here: one for user xstates and the other for
+ * system xstates. For now, they are the same.
+ */
+static int xfeature_nr_enabled(enum xfeature_nr xfeature_nr)
+{
+ return !!(xfeatures_mask & (1UL << xfeature_nr));
+}
+
+/*
* This function sets up offsets and sizes of all extended states in
* xsave area. This supports both standard format and compacted format
* of the xsave aread.
@@ -226,7 +236,7 @@ static void __init setup_xstate_comp(voi
if (!cpu_has_xsaves) {
for (i = FIRST_EXTENDED_XFEATURE_NR; i < XFEATURES_NR_MAX; i++) {
- if (test_bit(i, (unsigned long *)&xfeatures_mask)) {
+ if (xfeature_nr_enabled(i)) {
xstate_comp_offsets[i] = xstate_offsets[i];
xstate_comp_sizes[i] = xstate_sizes[i];
}
@@ -238,7 +248,7 @@ static void __init setup_xstate_comp(voi
FXSAVE_SIZE + XSAVE_HDR_SIZE;
for (i = FIRST_EXTENDED_XFEATURE_NR; i < XFEATURES_NR_MAX; i++) {
- if (test_bit(i, (unsigned long *)&xfeatures_mask))
+ if (xfeature_nr_enabled(i))
xstate_comp_sizes[i] = xstate_sizes[i];
else
xstate_comp_sizes[i] = 0;
@@ -299,7 +309,7 @@ static void __init init_xstate_size(void
xstate_size = FXSAVE_SIZE + XSAVE_HDR_SIZE;
for (i = FIRST_EXTENDED_XFEATURE_NR; i < 64; i++) {
- if (test_bit(i, (unsigned long *)&xfeatures_mask)) {
+ if (xfeature_nr_enabled(i)) {
cpuid_count(XSTATE_CPUID, i, &eax, &ebx, &ecx, &edx);
xstate_size += eax;
}
_
next prev parent reply other threads:[~2015-08-27 17:11 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-27 17:11 [PATCH 00/11] [v2] x86, fpu: XSAVE cleanups and sanity checks Dave Hansen
2015-08-27 17:11 ` [PATCH 01/11] x86, fpu: kill LWP support Dave Hansen
2015-08-28 4:50 ` Ingo Molnar
2015-08-27 17:11 ` [PATCH 03/11] x86, fpu: rework XSTATE_* macros to remove magic '2' Dave Hansen
2015-08-27 17:11 ` [PATCH 02/11] x86, fpu: rename xfeature_bit Dave Hansen
2015-08-28 5:16 ` Ingo Molnar
2015-08-27 17:11 ` [PATCH 04/11] x86, fpu: remove xfeature_nr Dave Hansen
2015-08-28 5:06 ` Ingo Molnar
2015-08-27 17:11 ` Dave Hansen [this message]
2015-08-28 5:04 ` [PATCH 05/11] x86, fpu: add helper xfeature_nr_enabled() instead of test_bit() Ingo Molnar
2015-08-27 17:11 ` [PATCH 06/11] x86, fpu: rework MPX 'xstate' types Dave Hansen
2015-08-27 17:11 ` [PATCH 07/11] x86, fpu: rework YMM definition Dave Hansen
2015-08-27 17:11 ` [PATCH 08/11] x86, fpu: add C structures for AVX-512 state components Dave Hansen
2015-08-28 5:00 ` Ingo Molnar
2015-08-27 17:11 ` [PATCH 09/11] x86, fpu: correct and check XSAVE xstate size calculations Dave Hansen
2015-08-28 4:54 ` Ingo Molnar
2015-08-28 14:31 ` Dave Hansen
2015-08-28 16:44 ` Andi Kleen
2015-08-27 17:11 ` [PATCH 10/11] x86, fpu: check to ensure increasing-offset xstate offsets Dave Hansen
2015-08-27 17:11 ` [PATCH 11/11] x86, fpu: check CPU-provided sizes against struct declarations Dave Hansen
2015-08-28 5:25 ` Ingo Molnar
2015-08-28 16:02 ` Dave Hansen
2015-08-28 5:18 ` [PATCH 00/11] [v2] x86, fpu: XSAVE cleanups and sanity checks Ingo Molnar
-- strict thread matches above, loose matches on Subject: below --
2015-08-25 20:12 [PATCH 00/11] " Dave Hansen
2015-08-25 20:12 ` [PATCH 05/11] x86, fpu: add helper xfeature_nr_enabled() instead of test_bit() Dave Hansen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150827171107.219DA1AA@viggo.jf.intel.com \
--to=dave@sr71.net \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=fenghua.yu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tim.c.chen@linux.intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome