Re: [patch V2 01/52] x86/fpu: Make init_fpstate correct with optimized XSAVE

Borislav Petkov
2021-06-14T19:15:40Z

On Mon, Jun 14, 2021 at 05:44:09PM +0200, Thomas Gleixner wrote:
> @@ -466,10 +489,20 @@ static void __init setup_init_fpu_buf(vo
> copy_kernel_to_xregs_booting(&init_fpstate.xsave);
>
> /*
> - * Dump the init state again. This is to identify the init state
> - * of any feature which is not represented by all zero's.
> + * All components are now in init state. Read the state back so
> + * that init_fpstate contains all non-zero init state. This is only
> + * working with XSAVE,

"This only works with XSAVE, ... "

> but not with XSAVEOPT and XSAVES because
> + * those use the init optimization which skips writing data for
> + * components in init state.

<--- Add a newline in the comment here so that it is not as dense.

> So XSAVE could be used, but that would
> + * require to reshuffle the data when XSAVES is available because
> + * XSAVES uses xstate compaction. But doing so is a pointless
> + * exercise because most components have an all zeros init state
> + * except for the legacy ones (FP and SSE). Those can be saved with
> + * FXSAVE into the legacy area. Adding new features requires to
> + * ensure that init state is all zeroes or if not to add the
> + * necessary handling here.
> */
> - copy_xregs_to_kernel_booting(&init_fpstate.xsave);
> + fxsave_to_kernel(&init_fpstate.fxsave);

With those fixed:

Reviewed-by: Borislav Petkov <bp@suse.de>

--
Regards/Gruss,
Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg