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


Groups > linux.kernel > #1565358

[PATCH] x86/fpu/xstate: Fix xcomp_bv in XSAVES header

From Yu-cheng Yu <yu-cheng.yu@intel.com>
Newsgroups linux.kernel
Subject [PATCH] x86/fpu/xstate: Fix xcomp_bv in XSAVES header
Date 2017-01-24 00:10 +0100
Message-ID <t2VUm-4rY-11@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


The compacted-format XSAVES area is determined at boot time and
never changed after.  The field xsave.header.xcomp_bv indicates
which components are in the fixed XSAVES format.

In fpstate_init() we did not set xcomp_bv to reflect the XSAVES
format since at the time there is no valid data.

However, after we do copy_init_fpstate_to_fpregs() in fpu__clear(),
as in commit: b22cbe404a9cc3c7949e380fa1861e31934c8978, and when
__fpu_restore_sig() does fpu__restore() for a COMPAT-mode app,
a #GP occurs.  This can be easily triggered by doing valgrind on
a COMPAT-mode "Hello World," as reported by Joakim Tjernlund and
others:

	https://bugzilla.kernel.org/show_bug.cgi?id=190061

Fix it by setting xcomp_bv correctly.

Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
Reported-by: Joakim Tjernlund <Joakim.Tjernlund@infinera.com>
---
 arch/x86/kernel/fpu/core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/fpu/core.c b/arch/x86/kernel/fpu/core.c
index c289e2f..e540dc1 100644
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -9,6 +9,7 @@
 #include <asm/fpu/regset.h>
 #include <asm/fpu/signal.h>
 #include <asm/fpu/types.h>
+#include <asm/fpu/xstate.h>
 #include <asm/traps.h>
 
 #include <linux/hardirq.h>
@@ -235,7 +236,8 @@ void fpstate_init(union fpregs_state *state)
 	 * it will #GP. Make sure it is replaced after the memset().
 	 */
 	if (static_cpu_has(X86_FEATURE_XSAVES))
-		state->xsave.header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT;
+		state->xsave.header.xcomp_bv = XCOMP_BV_COMPACTED_FORMAT |
+					       xfeatures_mask;
 
 	if (static_cpu_has(X86_FEATURE_FXSR))
 		fpstate_init_fxstate(&state->fxsave);
-- 
1.9.1

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


Thread

[PATCH] x86/fpu/xstate: Fix xcomp_bv in XSAVES header Yu-cheng Yu <yu-cheng.yu@intel.com> - 2017-01-24 00:10 +0100
  Re: [PATCH] x86/fpu/xstate: Fix xcomp_bv in XSAVES header Ingo Molnar <mingo@kernel.org> - 2017-01-24 09:20 +0100
  [tip:x86/urgent] x86/fpu/xstate: Fix xcomp_bv in XSAVES header tip-bot for Yu-cheng Yu <tipbot@zytor.com> - 2017-01-24 09:50 +0100

csiph-web