From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751389AbcFRIP2 (ORCPT ); Sat, 18 Jun 2016 04:15:28 -0400 Received: from terminus.zytor.com ([198.137.202.10]:56686 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751172AbcFRIPV (ORCPT ); Sat, 18 Jun 2016 04:15:21 -0400 Date: Sat, 18 Jun 2016 01:14:18 -0700 From: tip-bot for Yu-cheng Yu Message-ID: Cc: quentin.casasnovas@oracle.com, sai.praneeth.prakhya@intel.com, yu-cheng.yu@intel.com, fenghua.yu@intel.com, tglx@linutronix.de, hpa@zytor.com, dvlasenk@redhat.com, torvalds@linux-foundation.org, oleg@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, mingo@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org, dave.hansen@intel.com, luto@kernel.org, brgerst@gmail.com, ravi.v.shankar@intel.com Reply-To: ravi.v.shankar@intel.com, dave.hansen@linux.intel.com, mingo@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org, dave.hansen@intel.com, brgerst@gmail.com, luto@kernel.org, dvlasenk@redhat.com, hpa@zytor.com, torvalds@linux-foundation.org, oleg@redhat.com, bp@alien8.de, quentin.casasnovas@oracle.com, yu-cheng.yu@intel.com, sai.praneeth.prakhya@intel.com, fenghua.yu@intel.com, tglx@linutronix.de In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/fpu] x86/fpu/xstate: Copy xstate registers directly to the signal frame when compacted format is in use Git-Commit-ID: 99aa22d0d8f70d9317727ab40c85b2ead740a6ca 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: 99aa22d0d8f70d9317727ab40c85b2ead740a6ca Gitweb: http://git.kernel.org/tip/99aa22d0d8f70d9317727ab40c85b2ead740a6ca Author: Yu-cheng Yu AuthorDate: Fri, 20 May 2016 10:47:08 -0700 Committer: Ingo Molnar CommitDate: Sat, 18 Jun 2016 10:10:19 +0200 x86/fpu/xstate: Copy xstate registers directly to the signal frame when compacted format is in use XSAVES is a kernel instruction and uses a compacted format. When working with user space, the kernel should provide standard-format, non-supervisor state data. We cannot do __copy_to_user() from a compacted-format kernel xstate area to a signal frame. Dave Hansen proposes this method to simplify copy xstate directly to user. This patch is based on an earlier patch from Fenghua Yu Originally-from: Fenghua Yu Signed-off-by: Yu-cheng Yu Reviewed-by: Dave Hansen Cc: Andy Lutomirski Cc: Borislav Petkov Cc: Brian Gerst Cc: Dave Hansen Cc: Denys Vlasenko Cc: Fenghua Yu Cc: H. Peter Anvin Cc: Linus Torvalds Cc: Oleg Nesterov Cc: Peter Zijlstra Cc: Quentin Casasnovas Cc: Ravi V. Shankar Cc: Sai Praneeth Prakhya Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/c36f419d525517d04209a28dd8e1e5af9000036e.1463760376.git.yu-cheng.yu@intel.com Signed-off-by: Ingo Molnar --- arch/x86/include/asm/fpu/xstate.h | 1 + arch/x86/kernel/fpu/signal.c | 3 ++- arch/x86/kernel/fpu/xstate.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/fpu/xstate.h b/arch/x86/include/asm/fpu/xstate.h index 16df2c4..d812cf3 100644 --- a/arch/x86/include/asm/fpu/xstate.h +++ b/arch/x86/include/asm/fpu/xstate.h @@ -47,5 +47,6 @@ extern void update_regset_xstate_info(unsigned int size, u64 xstate_mask); void fpu__xstate_clear_all_cpu_caps(void); void *get_xsave_addr(struct xregs_state *xsave, int xstate); const void *get_xsave_field_ptr(int xstate_field); +int using_compacted_format(void); #endif diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c index 06d80f6..8aa96cb 100644 --- a/arch/x86/kernel/fpu/signal.c +++ b/arch/x86/kernel/fpu/signal.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -169,7 +170,7 @@ int copy_fpstate_to_sigframe(void __user *buf, void __user *buf_fx, int size) sizeof(struct user_i387_ia32_struct), NULL, (struct _fpstate_32 __user *) buf) ? -1 : 1; - if (fpregs_active()) { + if (fpregs_active() || using_compacted_format()) { /* Save the live register state to the user directly. */ if (copy_fpregs_to_sigframe(buf_fx)) return -1; diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index dbfef1b..0b01f00 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c @@ -420,7 +420,7 @@ static int xfeature_size(int xfeature_nr) * that it is obvious which aspect of 'XSAVES' is being handled * by the calling code. */ -static int using_compacted_format(void) +int using_compacted_format(void) { return boot_cpu_has(X86_FEATURE_XSAVES); }