Message ID | 20230914032334.75212-9-weijiang.yang@intel.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | Introduce CET supervisor xstate support | expand |
diff --git a/arch/x86/kernel/fpu/xstate.h b/arch/x86/kernel/fpu/xstate.h index 9c6e3ca05c5c..c2b33a5db53d 100644 --- a/arch/x86/kernel/fpu/xstate.h +++ b/arch/x86/kernel/fpu/xstate.h @@ -186,6 +186,9 @@ static inline void os_xsave(struct fpstate *fpstate) WARN_ON_FPU(!alternatives_patched); xfd_validate_state(fpstate, mask, false); + WARN_ON_FPU(!fpstate->is_guest && + (mask & fpu_kernel_dynamic_xfeatures)); + XSTATE_XSAVE(&fpstate->regs.xsave, lmask, hmask, err); /* We should never fault when copying to a kernel buffer: */
fpu_kernel_dynamic_xfeatures now are __ONLY__ enabled by guest kernel and used for guest fpstate, i.e., none for normal fpstate. The bits are added when guest fpstate is allocated and fpstate->is_guest set to %true. For normal fpstate, the bits should have been removed when init system FPU settings, WARN_ONCE() if normal fpstate contains kernel dynamic xfeatures before xsaves is executed. Signed-off-by: Yang Weijiang <weijiang.yang@intel.com> --- arch/x86/kernel/fpu/xstate.h | 3 +++ 1 file changed, 3 insertions(+)