From: tip-bot for Fenghua Yu <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, hpa@zytor.com, mingo@kernel.org,
fenghua.yu@intel.com, tglx@linutronix.de, hpa@linux.intel.com
Subject: [tip:x86/xsave] x86/xsaves: Clean up code in xstate offsets computation in xsave area
Date: Fri, 30 May 2014 20:36:38 -0700 [thread overview]
Message-ID: <tip-8ff925e10f2c72680918b95173ef4f8bb982d59e@git.kernel.org> (raw)
In-Reply-To: <1401387164-43416-17-git-send-email-fenghua.yu@intel.com>
Commit-ID: 8ff925e10f2c72680918b95173ef4f8bb982d59e
Gitweb: http://git.kernel.org/tip/8ff925e10f2c72680918b95173ef4f8bb982d59e
Author: Fenghua Yu <fenghua.yu@intel.com>
AuthorDate: Fri, 30 May 2014 14:59:24 -0700
Committer: H. Peter Anvin <hpa@linux.intel.com>
CommitDate: Fri, 30 May 2014 17:12:41 -0700
x86/xsaves: Clean up code in xstate offsets computation in xsave area
This patch cleans up some code in xstate offsets computation in xsave
area:
1. It changes xstate_comp_offsets as an array. This avoids possible NULL pointer
caused by possible kmalloc() failure during boot time.
2. It changes the global variable xstate_comp_sizes to a local variable because
it is used only in setup_xstate_comp().
3. It adds missing offsets for FP and SSE in xsave area.
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Link: http://lkml.kernel.org/r/1401387164-43416-17-git-send-email-fenghua.yu@intel.com
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
---
arch/x86/kernel/xsave.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
index a6cb823..940b142 100644
--- a/arch/x86/kernel/xsave.c
+++ b/arch/x86/kernel/xsave.c
@@ -26,7 +26,7 @@ struct xsave_struct *init_xstate_buf;
static struct _fpx_sw_bytes fx_sw_reserved, fx_sw_reserved_ia32;
static unsigned int *xstate_offsets, *xstate_sizes;
-static unsigned int *xstate_comp_offsets, *xstate_comp_sizes;
+static unsigned int xstate_comp_offsets[sizeof(pcntxt_mask)*8];
static unsigned int xstate_features;
/*
@@ -491,11 +491,16 @@ static void __init setup_xstate_features(void)
*/
void setup_xstate_comp(void)
{
+ unsigned int xstate_comp_sizes[sizeof(pcntxt_mask)*8];
int i;
- xstate_comp_offsets = kmalloc(xstate_features * sizeof(int),
- GFP_KERNEL);
- xstate_comp_sizes = kmalloc(xstate_features * sizeof(int), GFP_KERNEL);
+ /*
+ * The FP xstates and SSE xstates are legacy states. They are always
+ * in the fixed offsets in the xsave area in either compacted form
+ * or standard form.
+ */
+ xstate_comp_offsets[0] = 0;
+ xstate_comp_offsets[1] = offsetof(struct i387_fxsave_struct, xmm_space);
if (!cpu_has_xsaves) {
for (i = 2; i < xstate_features; i++) {
prev parent reply other threads:[~2014-05-31 3:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1401387164-43416-17-git-send-email-fenghua.yu@intel.com>
2014-05-30 15:13 ` [tip:x86/xsave] Define kernel API to get address of each state " tip-bot for Fenghua Yu
2014-05-31 3:36 ` tip-bot for Fenghua Yu [this message]
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=tip-8ff925e10f2c72680918b95173ef4f8bb982d59e@git.kernel.org \
--to=tipbot@zytor.com \
--cc=fenghua.yu@intel.com \
--cc=hpa@linux.intel.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=tglx@linutronix.de \
/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