From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752461AbbCJKIq (ORCPT ); Tue, 10 Mar 2015 06:08:46 -0400 Received: from terminus.zytor.com ([198.137.202.10]:48123 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752061AbbCJKIf (ORCPT ); Tue, 10 Mar 2015 06:08:35 -0400 Date: Tue, 10 Mar 2015 03:08:03 -0700 From: tip-bot for Oleg Nesterov Message-ID: 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 Reply-To: hpa@zytor.com, bp@suse.de, oleg@redhat.com, riel@redhat.com, luto@amacapital.net, tglx@linutronix.de, torvalds@linux-foundation.org, bp@alien8.de, taviso@google.com, linux-kernel@vger.kernel.org, mingo@kernel.org In-Reply-To: <20150302183237.GB23085@redhat.com> References: <1425967585-4725-1-git-send-email-bp@alien8.de> <20150302183237.GB23085@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/fpu] x86/fpu: Change xstateregs_get()/set() to use -> xsave.i387 rather than ->fxsave Git-Commit-ID: e7f180dcd8ab48f18b20d7e8a7e9b39192bdf8e0 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: e7f180dcd8ab48f18b20d7e8a7e9b39192bdf8e0 Gitweb: http://git.kernel.org/tip/e7f180dcd8ab48f18b20d7e8a7e9b39192bdf8e0 Author: Oleg Nesterov AuthorDate: Tue, 10 Mar 2015 07:06:24 +0100 Committer: Ingo Molnar 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 Signed-off-by: Borislav Petkov Reviewed-by: Rik van Riel Cc: Andy Lutomirski Cc: Borislav Petkov Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Tavis Ormandy Cc: Thomas Gleixner 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 --- 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; }