]> git.baikalelectronics.ru Git - kernel.git/commit
x86/fpu/xstate: Fix XSAVES offsets in setup_xstate_comp()
authorYu-cheng Yu <yu-cheng.yu@intel.com>
Thu, 9 Jan 2020 21:14:51 +0000 (13:14 -0800)
committerBorislav Petkov <bp@suse.de>
Wed, 12 Feb 2020 14:43:31 +0000 (15:43 +0100)
commitc2a9cea7ead5ea72ce36ac6db4d96ed299bc7448
tree9f82f7448aed1693db3b23763dfa140912b8ae9c
parent13a3d772736379665ef295e224dd4a127df01fd1
x86/fpu/xstate: Fix XSAVES offsets in setup_xstate_comp()

In setup_xstate_comp(), each XSAVES component offset starts from the
end of its preceding component plus alignment. A disabled feature does
not take space and its offset should be set to the end of its preceding
one with no alignment. However, in this case, alignment is incorrectly
added to the offset, which can cause the next component to have a wrong
offset.

This problem has not been visible because currently there is no xfeature
requiring alignment.

Fix it by tracking the next starting offset only from enabled
xfeatures. To make it clear, also change the function name to
setup_xstate_comp_offsets().

 [ bp: Fix a typo in the comment above it, while at it. ]

Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Dave Hansen <dave.hansen@linux.intel.com>
Link: https://lkml.kernel.org/r/20200109211452.27369-3-yu-cheng.yu@intel.com
arch/x86/kernel/fpu/xstate.c