linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: tip-bot for Oleg Nesterov <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: luto@amacapital.net, riel@redhat.com, oleg@redhat.com,
	bp@suse.de, hpa@zytor.com, taviso@google.com,
	linux-kernel@vger.kernel.org, mingo@kernel.org, bp@alien8.de,
	torvalds@linux-foundation.org, tglx@linutronix.de
Subject: [tip:x86/fpu] x86/fpu: Change xstateregs_get()/set() to use -> xsave.i387 rather than ->fxsave
Date: Tue, 10 Mar 2015 03:08:03 -0700	[thread overview]
Message-ID: <tip-e7f180dcd8ab48f18b20d7e8a7e9b39192bdf8e0@git.kernel.org> (raw)
In-Reply-To: <20150302183237.GB23085@redhat.com>

Commit-ID:  e7f180dcd8ab48f18b20d7e8a7e9b39192bdf8e0
Gitweb:     http://git.kernel.org/tip/e7f180dcd8ab48f18b20d7e8a7e9b39192bdf8e0
Author:     Oleg Nesterov <oleg@redhat.com>
AuthorDate: Tue, 10 Mar 2015 07:06:24 +0100
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Tue, 10 Mar 2015 07:14:31 +0100

x86/fpu: Change xstateregs_get()/set() to use ->xsave.i387 rather than ->fxsave

This is a cosmetic change: xstateregs_get() and xstateregs_set()
abuse ->fxsave to access xsave->i387.sw_reserved.

This practice is correct, ->fxsave and xsave->i387 share the same memory,
but IMHO this looks confusing.

And we can make this code more readable if we add a
"struct xsave_struct *" local variable as well.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Rik van Riel <riel@redhat.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Tavis Ormandy <taviso@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/1425967585-4725-1-git-send-email-bp@alien8.de
Link: http://lkml.kernel.org/r/20150302183237.GB23085@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/i387.c | 25 +++++++++----------------
 1 file changed, 9 insertions(+), 16 deletions(-)

diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
index 8416b5f..03cc0ad 100644
--- a/arch/x86/kernel/i387.c
+++ b/arch/x86/kernel/i387.c
@@ -339,6 +339,7 @@ int xstateregs_get(struct task_struct *target, const struct user_regset *regset,
 		unsigned int pos, unsigned int count,
 		void *kbuf, void __user *ubuf)
 {
+	struct xsave_struct *xsave = &target->thread.fpu.state->xsave;
 	int ret;
 
 	if (!cpu_has_xsave)
@@ -353,14 +354,12 @@ int xstateregs_get(struct task_struct *target, const struct user_regset *regset,
 	 * memory layout in the thread struct, so that we can copy the entire
 	 * xstateregs to the user using one user_regset_copyout().
 	 */
-	memcpy(&target->thread.fpu.state->fxsave.sw_reserved,
-	       xstate_fx_sw_bytes, sizeof(xstate_fx_sw_bytes));
-
+	memcpy(&xsave->i387.sw_reserved,
+		xstate_fx_sw_bytes, sizeof(xstate_fx_sw_bytes));
 	/*
 	 * Copy the xstate memory layout.
 	 */
-	ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
-				  &target->thread.fpu.state->xsave, 0, -1);
+	ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, xsave, 0, -1);
 	return ret;
 }
 
@@ -368,8 +367,8 @@ int xstateregs_set(struct task_struct *target, const struct user_regset *regset,
 		  unsigned int pos, unsigned int count,
 		  const void *kbuf, const void __user *ubuf)
 {
+	struct xsave_struct *xsave = &target->thread.fpu.state->xsave;
 	int ret;
-	struct xsave_hdr_struct *xsave_hdr;
 
 	if (!cpu_has_xsave)
 		return -ENODEV;
@@ -378,22 +377,16 @@ int xstateregs_set(struct task_struct *target, const struct user_regset *regset,
 	if (ret)
 		return ret;
 
-	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
-				 &target->thread.fpu.state->xsave, 0, -1);
-
+	ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, xsave, 0, -1);
 	/*
 	 * mxcsr reserved bits must be masked to zero for security reasons.
 	 */
-	target->thread.fpu.state->fxsave.mxcsr &= mxcsr_feature_mask;
-
-	xsave_hdr = &target->thread.fpu.state->xsave.xsave_hdr;
-
-	xsave_hdr->xstate_bv &= pcntxt_mask;
+	xsave->i387.mxcsr &= mxcsr_feature_mask;
+	xsave->xsave_hdr.xstate_bv &= pcntxt_mask;
 	/*
 	 * These bits must be zero.
 	 */
-	memset(xsave_hdr->reserved, 0, 48);
-
+	memset(&xsave->xsave_hdr.reserved, 0, 48);
 	return ret;
 }
 

  parent reply	other threads:[~2015-03-10 10:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAJ_zFkJkHpU4Y8wrrZjO0VnhzUVqJfyrLmNfRsBRT29bgbDSHg@mail.gmail.com>
     [not found] ` <20150301184650.GA12758@redhat.com>
     [not found]   ` <20150301185943.GA14318@redhat.com>
     [not found]     ` <20150302174818.GA16886@redhat.com>
2015-03-02 18:32       ` [PATCH 0/2] x86/fpu: minor cleanups Oleg Nesterov
2015-03-02 18:32         ` [PATCH 1/2] x86/regsets: change xstateregs_get/set to use ->xsave.i387 rather than ->fxsave Oleg Nesterov
2015-03-03 19:23           ` Rik van Riel
2015-03-04 10:30           ` Borislav Petkov
2015-03-10 10:08           ` tip-bot for Oleg Nesterov [this message]
2015-03-02 18:32         ` [PATCH 2/2] x86/fpu: factor out memset(xstate, 0) in fpu_finit() paths Oleg Nesterov
2015-03-03 22:01           ` Rik van Riel
2015-03-04 11:38           ` Borislav Petkov
2015-03-10 10:08           ` [tip:x86/fpu] x86/fpu: Factor out memset(xstate, 0) in fpu_finit( ) paths tip-bot for Oleg Nesterov
2015-03-09 18:08 [GIT PULL] x86/fpu cleanups Borislav Petkov
2015-03-10  6:06 ` [PATCH 1/2] x86/fpu: Change xstateregs_get()/set() to use ->xsave.i387 rather than ->fxsave Borislav Petkov
2015-03-10  6:06   ` [PATCH 2/2] x86/fpu: factor out memset(xstate, 0) in fpu_finit() paths Borislav Petkov

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-e7f180dcd8ab48f18b20d7e8a7e9b39192bdf8e0@git.kernel.org \
    --to=tipbot@zytor.com \
    --cc=bp@alien8.de \
    --cc=bp@suse.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=riel@redhat.com \
    --cc=taviso@google.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).