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)
commit49a91d61aed1db01097b51a24c77137eb348a0bf
tree9f82f7448aed1693db3b23763dfa140912b8ae9c
parentc12e13dcd814023a903399ec5ac2e7082d664b8b
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