x86/fpu: Introduce copy_supervisor_to_kernel()
authorYu-cheng Yu <yu-cheng.yu@intel.com>
Tue, 12 May 2020 14:54:42 +0000 (07:54 -0700)
committerBorislav Petkov <bp@suse.de>
Sat, 16 May 2020 09:24:14 +0000 (11:24 +0200)
commiteeedf1533687b8e81865fdbde79eddf7c4b76c9a
treed09915825c3f70bdae5d9b2e9b1f421801105f00
parentc95473e175dd1234b7440daa6eb2670ebf529653
x86/fpu: Introduce copy_supervisor_to_kernel()

The XSAVES instruction takes a mask and saves only the features specified
in that mask.  The kernel normally specifies that all features be saved.

XSAVES also unconditionally uses the "compacted format" which means that
all specified features are saved next to each other in memory.  If a
feature is removed from the mask, all the features after it will "move
up" into earlier locations in the buffer.

Introduce copy_supervisor_to_kernel(), which saves only supervisor states
and then moves those states into the standard location where they are
normally found.

Signed-off-by: Yu-cheng Yu <yu-cheng.yu@intel.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20200512145444.15483-9-yu-cheng.yu@intel.com
arch/x86/include/asm/fpu/xstate.h
arch/x86/kernel/fpu/xstate.c