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


Groups > linux.kernel > #1339834

[PATCH 07/10] x86/xsaves: Fix init_fpstate.header.xcomp_bv

From Yu-cheng Yu <yu-cheng.yu@intel.com>
Newsgroups linux.kernel
Subject [PATCH 07/10] x86/xsaves: Fix init_fpstate.header.xcomp_bv
Date 2016-02-22 20:10 +0100
Message-ID <r541Q-1YW-23@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


In setup_init_fpu_buf(), we use XRSTOR/XRSTORS with xfeatures (xstate_bv)
of 0x0 to effectively set all xstate components to init values. We then
execute XSAVE/XSAVES on the same buffer to save back init values.

This actually does not apply to XSAVES as XSAVES uses optimization. After
init, all components are in INIT and not MODIFIED state and will not be
saved. There is no need of setting xcomp_bv except for bit 63 to indicate
a compacted format.

Currently, init_fpstate is used in two ways:

(1) With copy_kernel_to_xregs(): because header.xfeatures is zero, the
    content is not actually read;

(2) With memcpy(): to sanitize a standard-format xsave area; the buffer is
    setup as expected.

Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
---
 arch/x86/kernel/fpu/xstate.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 13829e1..4087261 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -371,10 +371,10 @@ static void __init setup_init_fpu_buf(void)
 	print_xstate_features();
 
 	if (cpu_has_xsaves)
-		init_fpstate.xsave.header.xcomp_bv = (u64)1 << 63 | xfeatures_mask;
+		init_fpstate.xsave.header.xcomp_bv = (u64)1 << 63;
 
 	/*
-	 * Init all the features state with header_bv being 0x0
+	 * Init all the features state with header.xfeatures being 0x0
 	 */
 	copy_kernel_to_xregs_booting(&init_fpstate.xsave);
 
-- 
1.9.1

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


Thread

[PATCH 07/10] x86/xsaves: Fix init_fpstate.header.xcomp_bv Yu-cheng Yu <yu-cheng.yu@intel.com> - 2016-02-22 20:10 +0100
  Re: [PATCH 07/10] x86/xsaves: Fix init_fpstate.header.xcomp_bv Dave Hansen <dave.hansen@linux.intel.com> - 2016-02-22 21:00 +0100
    Re: [PATCH 07/10] x86/xsaves: Fix init_fpstate.header.xcomp_bv Yu-cheng Yu <yu-cheng.yu@intel.com> - 2016-02-22 21:50 +0100

csiph-web