On 8/27/2021 11:21 AM, Borislav Petkov wrote:
On Fri, Aug 27, 2021 at 11:10:31AM -0700, Yu, Yu-cheng wrote:
quoted
Because on context switches the whole xstates are switched together,
we need to make sure all are in registers.
There's context switch code which does that already.
Why would shstk_setup() be responsible for switching the whole extended
states buffer instead of only the shadow stack stuff only?
Right now, the kernel does lazy restore, and it waits until right before a task goes back to ring-3 to restore xstates. If a task needs to write to any xstate registers before that (e.g. for signals), it restores the whole xstates first and clears TIF_NEED_FPU_LOAD, which will prevent xstates being restored again later.