Re: [PATCH 1/3] x86/fpu/xstate: Fix last_good_offset in setup_xstate_features()

From: Borislav Petkov
Date: Tue Feb 11 2020 - 13:56:46 EST


On Thu, Jan 09, 2020 at 01:14:50PM -0800, Yu-cheng Yu wrote:
> The function setup_xstate_features() uses CPUID to find each xfeature's
> standard-format offset and size. Since XSAVES always uses the compacted
> format, supervisor xstates are *NEVER* in the standard-format and their
> offsets are left as -1's. However, they are still being tracked as
> last_good_offset.
>
> Fix it by tracking only user xstate offsets.
>
> Signed-off-by: Yu-cheng Yu <yu-cheng.yu@xxxxxxxxx>
> Reviewed-by: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
> ---
> arch/x86/kernel/fpu/xstate.c | 24 ++++++++++++++----------
> 1 file changed, 14 insertions(+), 10 deletions(-)

How about cleaning it up some more, while at it?

---