Re: [PATCH v2 8/8] x86/fpu/xstate: Restore supervisor xstates for __fpu__restore_sig()

From: Yu-cheng Yu
Date: Fri Feb 28 2020 - 16:23:48 EST


On Fri, 2020-02-28 at 19:31 +0100, Borislav Petkov wrote:
> On Fri, Feb 28, 2020 at 10:11:44AM -0800, Yu-cheng Yu wrote:
> > CET has 16 bytes for ring-3 setting, 24 bytes for ring-0.
> > Saving supervisor states somewhere else and copying back is not better
> > either.
>
> Well, if you're going to save a lot bigger user states area which is
> going to be absolutely wasted cycles in that case, you better save those
> couple of bytes in another buffer and then copy them into the final state
> buffer which gets restored.

The code is for sigreturn only. Because of lazy-restore,
copy_xregs_to_kernel() does not happen all the time. It is attractive in
terms of simplicity.

XSAVES buffer has fixed 576-byte overhead (512-byte legacy + 64-byte
header) and not suitable for partial saving. To save only supervisor
states, we need to read out each MSR separately and store them in a struct.

>
> > We save supervisor states only when xfeatures_mask_supervisor() is not
> > zero.
>
> And on which systems is it not zero? On systems which have supervisor
> features or on systems which have *and* *are* *using* supervisor
> features?

On systems using supervisor features.

Yu-cheng