[lkml]   [2015]   [May]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Subject[PATCH v3 Bugfix 0/6] xstate/fpu bug fixes
From: Fenghua Yu <>

This patchset is supposed to fix some xsave/xsaves/fpu related issues.

We may hit the issues on either existing platforms or upcoming platforms.
We had better to have the patches in upstream and backport them to stable
kernel and distros.

The patch 1/6 fixes an xstate offsets and sizes enumeration issue. During
enumerating offsets and sizes starting from 2 to the last enabled feature,
if one xstate's size is 0, current code thinks there is no other xstate
after this xstate and breaks from enumeration. This is not true because
architecturally it's possible to have a few xstates disabled between
xstate 2 and the last enabled xstate. The offsets and sizes of
the xstates that are not enumerated after the disabled xstate will be
consumed and cause issues in runtime.

The patch 2/6 introduces a new global variable "user_xstate_size". This
variable is used for standard formatted xsave area size in signal frame.
Current code incorrectly uses the smaller compacted formatted xsave area
size for signal frame and will cause issues in xstate access in signal

The patch 3/6 is not fixing a bug. But it renames "xstate_size" to
"kernel_xstate_size" to explicitly distinguish between xstate size in
kernel space and the one in user space. It just makes kernel code more

The patch 4/6 claims that the structure of xsave_struct is
non-architectural and fields/xstates in the structure is not defined
in compilation time. No new states should be added in xsave_struct.
The xsave area should be constructed during kernel booting time.

The patch 5/6 clears xstate_bv so that init optimization in hardware
can take action. Without the patch, some xstates are always not in
init status and this will impact badly on performance of context

The patch 6/6 introduces a correct check for user_has_fpu check.

Changes in v3:

1/6: In description, add that Ingo has a same patch in his xstate/fpu
overall clean up patchset.
2/6: Remove copy_to_user_xstate(). Now copy compact format xsave
area directly from processor to user buffer in 6/6.
Initialize user_xstate_size in init_thread_xstate().
3/6: Add Dave Hansen's credit in description.
5/6: Add this new patch for performance issue.
6/6: Add this new patch for a new user_has_fpu check to allow copy
compact format xsave area directly from processor to user buffer.

Fenghua Yu (6):
x86/xsave.c: Fix xstate offsets and sizes enumeration
x86/xsaves: Define and use user_xstate_size for xstate size in signal
x86/xsaves: Rename xstate_size to kernel_xstate_size to explicitly
distinguish xstate size in kernel from user space
x86/xsave: Don't add new states in xsave_struct
x86/xsaves: Keep xstate_bv in init_xstate_buf header as zero for init
x86/xsave.c: Introduce a new check that allows correct xstates copy
from kernel to user directly

arch/x86/include/asm/fpu-internal.h | 7 +--
arch/x86/include/asm/processor.h | 23 +++-----
arch/x86/include/asm/xsave.h | 1 -
arch/x86/kernel/i387.c | 21 ++++----
arch/x86/kernel/process.c | 2 +-
arch/x86/kernel/xsave.c | 105 ++++++++++++++++++++++++++----------
6 files changed, 102 insertions(+), 57 deletions(-)


 \ /
  Last update: 2015-05-09 00:01    [W:0.050 / U:12.368 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site