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


Groups > linux.kernel > #1392549

Re: [PATCH v4 04/10] x86/xsaves: Introduce a new check that allows correct xstates copy from kernel to user directly

From Yu-cheng Yu <yu-cheng.yu@intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH v4 04/10] x86/xsaves: Introduce a new check that allows correct xstates copy from kernel to user directly
Date 2016-05-03 00:30 +0200
Message-ID <ruuvL-3RN-3@gated-at.bofh.it> (permalink)
References (5 earlier) <rupPt-7D1-21@gated-at.bofh.it> <rupZ8-7Ji-17@gated-at.bofh.it> <rutzI-2GU-3@gated-at.bofh.it> <rutzI-2GU-15@gated-at.bofh.it> <rutJo-378-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, May 02, 2016 at 02:32:14PM -0700, Dave Hansen wrote:
> 
> I think we're off in the weeds here.
> 
> Please just send an updated patch for what you want to do here.

From 43134a773d23ae8bab9f158d143c5cfb76bc0e9c Mon Sep 17 00:00:00 2001
From: Yu-cheng Yu <yu-cheng.yu@intel.com>
Date: Sat, 14 Nov 2015 16:59:45 -0800
Subject: [PATCH] x86/xsaves: Introduce a new check that allows correct xstates
 copy from kernel to user directly

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.

Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Signed-off by: Yu-cheng Yu <yu-cheng.yu@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 0fbf60c..d7fdd8c 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>
 
@@ -167,7 +168,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 170c164..2b59bd7 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -415,7 +415,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 cpu_has_xsaves;
 }
-- 
1.9.1

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


Thread

Re: [PATCH v4 04/10] x86/xsaves: Introduce a new check that allows  correct xstates copy from kernel to user directly Dave Hansen <dave.hansen@linux.intel.com> - 2016-04-29 22:10 +0200
  Re: [PATCH v4 04/10] x86/xsaves: Introduce a new check that allows  correct xstates copy from kernel to user directly Yu-cheng Yu <yu-cheng.yu@intel.com> - 2016-04-30 00:50 +0200
    Re: [PATCH v4 04/10] x86/xsaves: Introduce a new check that allows  correct xstates copy from kernel to user directly Dave Hansen <dave.hansen@linux.intel.com> - 2016-04-30 02:40 +0200
      Re: [PATCH v4 04/10] x86/xsaves: Introduce a new check that allows  correct xstates copy from kernel to user directly Dave Hansen <dave.hansen@linux.intel.com> - 2016-05-02 18:10 +0200
        Re: [PATCH v4 04/10] x86/xsaves: Introduce a new check that allows  correct xstates copy from kernel to user directly Yu-cheng Yu <yu-cheng.yu@intel.com> - 2016-05-02 18:40 +0200
          Re: [PATCH v4 04/10] x86/xsaves: Introduce a new check that allows  correct xstates copy from kernel to user directly Dave Hansen <dave.hansen@linux.intel.com> - 2016-05-02 18:50 +0200
            Re: [PATCH v4 04/10] x86/xsaves: Introduce a new check that allows  correct xstates copy from kernel to user directly Yu-cheng Yu <yu-cheng.yu@intel.com> - 2016-05-02 19:30 +0200
              Re: [PATCH v4 04/10] x86/xsaves: Introduce a new check that allows  correct xstates copy from kernel to user directly Dave Hansen <dave.hansen@linux.intel.com> - 2016-05-02 19:40 +0200
                Re: [PATCH v4 04/10] x86/xsaves: Introduce a new check that allows  correct xstates copy from kernel to user directly Yu-cheng Yu <yu-cheng.yu@intel.com> - 2016-05-02 23:30 +0200
                Re: [PATCH v4 04/10] x86/xsaves: Introduce a new check that allows  correct xstates copy from kernel to user directly Yu-cheng Yu <yu-cheng.yu@intel.com> - 2016-05-02 23:30 +0200
                Re: [PATCH v4 04/10] x86/xsaves: Introduce a new check that allows  correct xstates copy from kernel to user directly Dave Hansen <dave.hansen@linux.intel.com> - 2016-05-02 23:40 +0200
                Re: [PATCH v4 04/10] x86/xsaves: Introduce a new check that allows  correct xstates copy from kernel to user directly Yu-cheng Yu <yu-cheng.yu@intel.com> - 2016-05-03 00:30 +0200
                Re: [PATCH v4 04/10] x86/xsaves: Introduce a new check that allows  correct xstates copy from kernel to user directly Dave Hansen <dave.hansen@linux.intel.com> - 2016-05-03 00:40 +0200
      Re: [PATCH v4 04/10] x86/xsaves: Introduce a new check that allows  correct xstates copy from kernel to user directly Yu-cheng Yu <yu-cheng.yu@intel.com> - 2016-05-02 18:10 +0200

csiph-web