The Skylake variants of the MDS software sequence save CR0 in %rax
(%eax on i386) and then reuse %eax for the clflushopt loop and the
stosb fill byte. The final test of CR0_TS always sees zero and CR0 is
never restored, so the return to user mode leaves TS clear even when
the thread does not own the FPU. The thread then takes no trap to load
its own FPU state, runs with whatever the registers hold, and its FPU
state is not saved on the next context switch. Only hw.mds_disable=2,
or 3 on a CPU without MD_CLEAR, selects these handlers.
Keep the saved CR0 in %rsi on amd64 and in %esi on i386, which the
handlers do not otherwise use.
Reported by: llm-postcr
Fixes: 7355a02bdd81 ("Mitigations for Microarchitectural Data...")
MFC after: 3 days
Sponsored by: Rubicon Communications, LLC ("Netgate")