Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1404660

[PATCH 4/4] x86/fpu/xstate: Copy xstate registers directly to signal frame when compacted format is in use

From Yu-cheng Yu <yu-cheng.yu@intel.com>
Newsgroups linux.kernel
Subject [PATCH 4/4] x86/fpu/xstate: Copy xstate registers directly to signal frame when compacted format is in use
Date 2016-05-20 20:00 +0200
Message-ID <rAWSl-dY-9@gated-at.bofh.it> (permalink)
References <rAWSl-dY-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.
Based on an earlier patch from Fenghua Yu <fenghua.yu@intel.com>

Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
Reviewed-by: Dave Hansen <dave.hansen@intel.com>
---
 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 1454989..9ce2963 100644
--- a/arch/x86/kernel/fpu/signal.c
+++ b/arch/x86/kernel/fpu/signal.c
@@ -8,6 +8,7 @@
 #include <asm/fpu/internal.h>
 #include <asm/fpu/signal.h>
 #include <asm/fpu/regset.h>
+#include <asm/fpu/xstate.h>
 
 #include <asm/sigframe.h>
 
@@ -168,7 +169,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);
 }
-- 
1.9.1

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/4] x86/fpu/state: Fix XSAVES issues - Part 1 Yu-cheng Yu <yu-cheng.yu@intel.com> - 2016-05-20 20:00 +0200
  [PATCH 4/4] x86/fpu/xstate: Copy xstate registers directly to signal frame when compacted format is in use Yu-cheng Yu <yu-cheng.yu@intel.com> - 2016-05-20 20:00 +0200
  [PATCH 3/4] x86/fpu/xstate: Keep init_fpstate.xsave.header.xfeatures as zero for init optimization Yu-cheng Yu <yu-cheng.yu@intel.com> - 2016-05-20 20:00 +0200
  [PATCH 1/4] x86/fpu/xstate: Define and use fpu_user_xstate_size Yu-cheng Yu <yu-cheng.yu@intel.com> - 2016-05-20 20:00 +0200

csiph-web