Re: [patch V2 02/52] x86/fpu: Fix copy_xstate_to_kernel() gap handling

From: Thomas Gleixner
Date: Wed Jun 16 2021 - 18:03:21 EST


On Mon, Jun 14 2021 at 17:44, Thomas Gleixner wrote:
> The gap handling in copy_xstate_to_kernel() is wrong in two aspects when
> XSAVES is in use.
>
> 1) Copying of xstate.i387.xmm_space is only copied when the SSE feature
> bit is set. This is not correct because YMM (AVX) shares the XMM space
> and that state must also be copied if only the YMM feature bit set
> like already done for MXCSR.

Thinking more about it. That'd be broken in hardware. When YMM is not in
init state then SSE cannot be in init state.

Of course you can use xsave, then clear the SSE bit and XRSTOR which
blows away the SSE state. Or clear the bit in the sigframe. So copying
it over is silly as XRSTOR will ignore it anyway. If so, user space can
keep the pieces. Let me take that out.

This stuff drives me nuts.

Thanks,

tglx