Lines Matching +full:supervisor +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0
35 if (__copy_from_user(fx_sw, &fxbuf->sw_reserved[0], sizeof(*fx_sw))) in check_xstate_in_sigframe()
39 if (fx_sw->magic1 != FP_XSTATE_MAGIC1 || in check_xstate_in_sigframe()
40 fx_sw->xstate_size < min_xstate_size || in check_xstate_in_sigframe()
41 fx_sw->xstate_size > current->thread.fpu.fpstate->user_size || in check_xstate_in_sigframe()
42 fx_sw->xstate_size > fx_sw->extended_size) in check_xstate_in_sigframe()
51 if (__get_user(magic2, (__u32 __user *)(fpstate + fx_sw->xstate_size))) in check_xstate_in_sigframe()
57 trace_x86_fpu_xstate_check_failed(¤t->thread.fpu); in check_xstate_in_sigframe()
60 fx_sw->magic1 = 0; in check_xstate_in_sigframe()
61 fx_sw->xstate_size = sizeof(struct fxregs_state); in check_xstate_in_sigframe()
62 fx_sw->xfeatures = XFEATURE_MASK_FPSSE; in check_xstate_in_sigframe()
82 struct xregs_state *xsave = &tsk->thread.fpu.fpstate->regs.xsave; in save_fsave_header()
88 fxsave(&tsk->thread.fpu.fpstate->regs.fxsave); in save_fsave_header()
94 __put_user(xsave->i387.swd, &fp->status) || in save_fsave_header()
95 __put_user(X86_FXSR_MAGIC, &fp->magic)) in save_fsave_header()
101 if (__get_user(swd, &fp->swd) || __put_user(swd, &fp->status)) in save_fsave_header()
118 sw_bytes->magic1 = FP_XSTATE_MAGIC1; in save_sw_bytes()
119 sw_bytes->extended_size = fpstate->user_size + FP_XSTATE_MAGIC2_SIZE; in save_sw_bytes()
120 sw_bytes->xfeatures = fpstate->user_xfeatures; in save_sw_bytes()
121 sw_bytes->xstate_size = fpstate->user_size; in save_sw_bytes()
124 sw_bytes->extended_size += sizeof(struct fregs_state); in save_sw_bytes()
137 err = __copy_to_user(&x->i387.sw_reserved, &sw_bytes, sizeof(sw_bytes)); in save_xstate_epilog()
143 (__u32 __user *)(buf + fpstate->user_size)); in save_xstate_epilog()
149 err |= __get_user(xfeatures, (__u32 __user *)&x->header.xfeatures); in save_xstate_epilog()
164 err |= __put_user(xfeatures, (__u32 __user *)&x->header.xfeatures); in save_xstate_epilog()
189 * 'buf_fx' is the 64-byte aligned pointer at which the [f|fx|x]save
193 * buf == buf_fx for 64-bit frames and 32-bit fsave frame.
194 * buf != buf_fx for 32-bit frames with fxstate.
199 * If this is a 32-bit frame with fxstate, put a fsave header before
208 struct fpstate *fpstate = tsk->thread.fpu.fpstate; in copy_fpstate_to_sigframe()
233 if (__clear_user(&xbuf->header, sizeof(xbuf->header))) in copy_fpstate_to_sigframe()
253 if (!__clear_user(buf_fx, fpstate->user_size)) in copy_fpstate_to_sigframe()
258 /* Save the fsave header for the 32-bit frames. */ in copy_fpstate_to_sigframe()
296 struct fpu *fpu = ¤t->thread.fpu; in restore_fpregs_from_user()
300 xrestore &= fpu->fpstate->user_xfeatures; in restore_fpregs_from_user()
304 xfd_update_state(fpu->fpstate); in restore_fpregs_from_user()
306 ret = __restore_fpregs_from_user(buf, fpu->fpstate->user_xfeatures, in restore_fpregs_from_user()
330 if (!fault_in_readable(buf, fpu->fpstate->user_size)) in restore_fpregs_from_user()
336 * Restore supervisor states: previous context switch etc has done in restore_fpregs_from_user()
337 * XSAVES and saved the supervisor states in the kernel buffer from in restore_fpregs_from_user()
345 os_xrstor_supervisor(fpu->fpstate); in restore_fpregs_from_user()
356 struct fpu *fpu = &tsk->thread.fpu; in __fpu_restore_sig()
396 * If supervisor states are available then save the in __fpu_restore_sig()
398 * supervisor state is preserved. Save the full state for in __fpu_restore_sig()
400 * saving the supervisor states and then shuffle them to in __fpu_restore_sig()
401 * the right place in memory. It's ia32 mode. Shrug. in __fpu_restore_sig()
404 os_xsave(fpu->fpstate); in __fpu_restore_sig()
411 fpregs = &fpu->fpstate->regs; in __fpu_restore_sig()
416 if (__copy_from_user(&fpregs->fxsave, buf_fx, in __fpu_restore_sig()
417 sizeof(fpregs->fxsave))) in __fpu_restore_sig()
422 if (fpregs->fxsave.mxcsr & ~mxcsr_feature_mask) in __fpu_restore_sig()
426 fpregs->fxsave.mxcsr &= mxcsr_feature_mask; in __fpu_restore_sig()
431 fpregs->xsave.header.xfeatures |= XFEATURE_MASK_FPSSE; in __fpu_restore_sig()
435 convert_to_fxsr(&fpregs->fxsave, &env); in __fpu_restore_sig()
443 * fx_only mode as well because that has only FP and SSE in __fpu_restore_sig()
446 * Preserve supervisor states! in __fpu_restore_sig()
450 fpregs->xsave.header.xfeatures &= mask; in __fpu_restore_sig()
451 success = !os_xrstor_safe(fpu->fpstate, in __fpu_restore_sig()
454 success = !fxrstor_safe(&fpregs->fxsave); in __fpu_restore_sig()
466 unsigned int size = fpstate->user_size; in xstate_sigframe_size()
476 struct fpu *fpu = ¤t->thread.fpu; in fpu__restore_sig()
487 size = xstate_sigframe_size(fpu->fpstate); in fpu__restore_sig()
523 unsigned long frame_size = xstate_sigframe_size(current->thread.fpu.fpstate); in fpu__alloc_mathframe()
525 *buf_fx = sp = round_down(sp - frame_size, 64); in fpu__alloc_mathframe()
528 sp -= sizeof(struct fregs_state); in fpu__alloc_mathframe()
544 * This space is needed on (most) 32-bit kernels, or when a 32-bit in fpu__get_fpstate_size()
545 * app is running on a 64-bit kernel. To keep things simple, just in fpu__get_fpstate_size()
547 * even for 64-bit apps on 64-bit kernels. This wastes a bit of in fpu__get_fpstate_size()