Lines Matching +full:supervisor +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0-only
51 "AVX-512 opmask",
52 "AVX-512 Hi256",
53 "AVX-512 ZMM_Hi256",
57 "Control-flow User registers",
58 "Control-flow Kernel registers (unused)",
86 { [ 0 ... XFEATURE_MAX - 1] = -1};
88 { [ 0 ... XFEATURE_MAX - 1] = -1};
110 * missing AVX feature - this is the most informative message in cpu_has_xfeatures()
118 xfeature_idx = fls64(xfeatures_print)-1; in cpu_has_xfeatures()
119 max_idx = ARRAY_SIZE(xfeature_names)-1; in cpu_has_xfeatures()
147 * Non-compacted format and legacy features use the cached fixed in xfeature_get_offset()
199 * MSR_IA32_XSS sets supervisor states managed by XSAVES. in fpu__init_cpu_xstate()
242 * If an xfeature is supervisor state, the offset in EBX is in setup_xstate_cache()
243 * invalid, leave it to -1. in setup_xstate_cache()
251 * In our xstate size checks, we assume that the highest-numbered in setup_xstate_cache()
380 * that init_fpstate contains all non-zero init state. This only in setup_init_fpu_buf()
410 /* No unknown or supervisor features may be set */ in validate_user_xstate_header()
411 if (hdr->xfeatures & ~fpstate->user_xfeatures) in validate_user_xstate_header()
412 return -EINVAL; in validate_user_xstate_header()
415 if (hdr->xcomp_bv) in validate_user_xstate_header()
416 return -EINVAL; in validate_user_xstate_header()
422 BUILD_BUG_ON(sizeof(hdr->reserved) != 48); in validate_user_xstate_header()
425 if (memchr_inv(hdr->reserved, 0, sizeof(hdr->reserved))) in validate_user_xstate_header()
426 return -EINVAL; in validate_user_xstate_header()
468 * check_xtile_data_against_struct - Check tile data state size.
476 * Returns: 0 on success, -EINVAL on mismatch.
491 * Cross-check each tile size and find the maximum number of in check_xtile_data_against_struct()
511 return -EINVAL; in check_xtile_data_against_struct()
523 return -EINVAL; in check_xtile_data_against_struct()
566 unsigned int topmost = fls64(xfeatures) - 1; in xstate_calculate_size()
578 * This essentially double-checks what the cpu told us about
583 * covered by these checks. Only the size of the buffer for task->fpu
597 * Supervisor state components can be managed only by in paranoid_xstate_size_valid()
601 XSTATE_WARN_ON(1, "Got supervisor feature %d, but XSAVES not advertised\n", i); in paranoid_xstate_size_valid()
614 * Note the SDM's wording here. "sub-function 0" only enumerates
626 * - CPUID function 0DH, sub-function 1: in get_compacted_size()
634 * are no supervisor states, but XSAVEC still uses compacted in get_compacted_size()
642 * Get the total size of the enabled xstates without the independent supervisor
658 * This is the size required for the task->fpu buffer. in get_xsave_compacted_size()
662 /* Re-enable independent features so XSAVES will work on them again. */ in get_xsave_compacted_size()
672 * - CPUID function 0DH, sub-function 0: in get_xsave_size_user()
692 * XSAVES kernel size includes supervisor states and uses compacted in init_xstate_size()
694 * supervisor states. in init_xstate_size()
696 * XSAVE[OPT] do not support supervisor states so kernel and user in init_xstate_size()
708 return -EINVAL; in init_xstate_size()
742 fpstate_reset(¤t->thread.fpu); in fpu__init_disable_system_xstate()
774 * Find supervisor xstates supported by the processor. in fpu__init_system_xstate()
850 fpstate_reset(¤t->thread.fpu); in fpu__init_system_xstate()
853 * Update info used for ptrace frames; use standard-format size and no in fpu__init_system_xstate()
854 * supervisor xstates: in fpu__init_system_xstate()
924 wrmsrl(MSR_IA32_XFD, current->thread.fpu.fpstate->xfd); in fpu__resume_cpu()
934 u64 xcomp_bv = xsave->header.xcomp_bv; in __raw_xsave_addr()
991 if (!(xsave->header.xfeatures & BIT_ULL(xfeature_nr))) in get_xsave_addr()
1000 * The xsave buffer should be in standard format, not compacted (e.g. user mode
1028 return -EINVAL; in arch_set_user_pkey_access()
1032 * values originating from in-kernel users. Complain in arch_set_user_pkey_access()
1036 return -EINVAL; in arch_set_user_pkey_access()
1066 * __copy_xstate_to_uabi_buf - Copy kernel saved xstate to a UABI buffer
1069 * @xfeatures: The mask of xfeatures to save (XSAVE mode only)
1071 * @copy_mode: The requested copy mode
1075 * to the requested @mode. UABI XSTATE is always uncompacted!
1085 struct xregs_state *xsave = &fpstate->regs.xsave; in __copy_xstate_to_uabi_buf()
1092 header.xfeatures = xsave->header.xfeatures; in __copy_xstate_to_uabi_buf()
1094 /* Mask out the feature bits depending on copy mode */ in __copy_xstate_to_uabi_buf()
1105 header.xfeatures &= fpstate->user_xfeatures & xfeatures; in __copy_xstate_to_uabi_buf()
1110 copy_feature(header.xfeatures & XFEATURE_MASK_FP, &to, &xsave->i387, in __copy_xstate_to_uabi_buf()
1111 &xinit->i387, off_mxcsr); in __copy_xstate_to_uabi_buf()
1115 &to, &xsave->i387.mxcsr, &xinit->i387.mxcsr, in __copy_xstate_to_uabi_buf()
1120 &to, &xsave->i387.st_space, &xinit->i387.st_space, in __copy_xstate_to_uabi_buf()
1121 sizeof(xsave->i387.st_space)); in __copy_xstate_to_uabi_buf()
1123 /* Copy the SSE state - shared with YMM, but independently managed */ in __copy_xstate_to_uabi_buf()
1125 &to, &xsave->i387.xmm_space, &xinit->i387.xmm_space, in __copy_xstate_to_uabi_buf()
1126 sizeof(xsave->i387.xmm_space)); in __copy_xstate_to_uabi_buf()
1132 membuf_zero(&to, sizeof(xsave->i387.padding)); in __copy_xstate_to_uabi_buf()
1134 /* Copy xsave->i387.sw_reserved */ in __copy_xstate_to_uabi_buf()
1135 membuf_write(&to, xstate_fx_sw_bytes, sizeof(xsave->i387.sw_reserved)); in __copy_xstate_to_uabi_buf()
1137 /* Copy the user space relevant state of @xsave->header */ in __copy_xstate_to_uabi_buf()
1147 * In non-compacted format, disabled features still occupy in __copy_xstate_to_uabi_buf()
1164 membuf_zero(&to, xstate_offsets[i] - zerofrom); in __copy_xstate_to_uabi_buf()
1180 * Keep track of the last copied state in the non-compacted in __copy_xstate_to_uabi_buf()
1192 * copy_xstate_to_uabi_buf - Copy kernel saved xstate to a UABI buffer
1195 * @copy_mode: The requested copy mode
1199 * to the requested @mode. UABI XSTATE is always uncompacted!
1206 __copy_xstate_to_uabi_buf(to, tsk->thread.fpu.fpstate, in copy_xstate_to_uabi_buf()
1207 tsk->thread.fpu.fpstate->user_xfeatures, in copy_xstate_to_uabi_buf()
1208 tsk->thread.pkru, copy_mode); in copy_xstate_to_uabi_buf()
1218 return -EFAULT; in copy_from_buffer()
1225 * copy_uabi_to_xstate - Copy a UABI format buffer to the kernel xstate
1255 struct xregs_state *xsave = &fpstate->regs.xsave; in copy_uabi_to_xstate()
1263 return -EFAULT; in copy_uabi_to_xstate()
1266 return -EINVAL; in copy_uabi_to_xstate()
1275 return -EFAULT; in copy_uabi_to_xstate()
1279 return -EINVAL; in copy_uabi_to_xstate()
1283 xsave->i387.mxcsr = mxcsr[0]; in copy_uabi_to_xstate()
1284 xsave->i387.mxcsr_mask = mxcsr[1]; in copy_uabi_to_xstate()
1298 return -EFAULT; in copy_uabi_to_xstate()
1306 *pkru = xpkru->pkru; in copy_uabi_to_xstate()
1317 * The state that came in from userspace was user-state only. in copy_uabi_to_xstate()
1320 xsave->header.xfeatures &= XFEATURE_MASK_SUPERVISOR_ALL; in copy_uabi_to_xstate()
1325 xsave->header.xfeatures |= hdr.xfeatures; in copy_uabi_to_xstate()
1331 * Convert from a ptrace standard-format kernel buffer to kernel XSAVE[S]
1340 * Convert from a sigreturn standard-format user-space buffer to kernel
1347 return copy_uabi_to_xstate(tsk->thread.fpu.fpstate, NULL, ubuf, &tsk->thread.pkru); in copy_sigframe_from_user_to_xstate()
1366 * xsaves - Save selected components to a kernel xstate buffer
1389 * xrstors - Restore selected components from a kernel xstate buffer
1415 void *addr = get_xsave_addr(&fps->regs.xsave, xfeature); in fpstate_clear_xstate_component()
1434 if (fpstate->xfd == xfd) in xstate_op_valid()
1438 * The XFD MSR does not match fpstate->xfd. That's invalid when in xstate_op_valid()
1441 if (fpstate->xfd == current->thread.fpu.fpstate->xfd) in xstate_op_valid()
1459 * the buffer area for XFD-disabled state components. in xstate_op_valid()
1467 mask &= ~fpstate->xfeatures; in xstate_op_valid()
1496 if (fpu->fpstate && fpu->fpstate != &fpu->__fpstate) in arch_initcall()
1497 vfree(fpu->fpstate); in arch_initcall()
1501 * fpstate_realloc - Reallocate struct fpstate for the requested new features
1509 * Note vs. vmalloc(): If the task with a vzalloc()-allocated buffer
1510 * terminates quickly, vfree()-induced IPIs may be a concern, but tasks
1513 * Returns: 0 on success, -ENOMEM on allocation error.
1518 struct fpu *fpu = ¤t->thread.fpu; in fpstate_realloc()
1527 return -ENOMEM; in fpstate_realloc()
1528 newfps->size = ksize; in fpstate_realloc()
1529 newfps->user_size = usize; in fpstate_realloc()
1530 newfps->is_valloc = true; in fpstate_realloc()
1533 * When a guest FPU is supplied, use @guest_fpu->fpstate in fpstate_realloc()
1536 curfps = guest_fpu ? guest_fpu->fpstate : fpu->fpstate; in fpstate_realloc()
1539 in_use = fpu->fpstate == curfps; in fpstate_realloc()
1542 newfps->is_guest = true; in fpstate_realloc()
1543 newfps->is_confidential = curfps->is_confidential; in fpstate_realloc()
1544 newfps->in_use = curfps->in_use; in fpstate_realloc()
1545 guest_fpu->xfeatures |= xfeatures; in fpstate_realloc()
1546 guest_fpu->uabi_size = usize; in fpstate_realloc()
1558 newfps->xfeatures = curfps->xfeatures | xfeatures; in fpstate_realloc()
1559 newfps->user_xfeatures = curfps->user_xfeatures | xfeatures; in fpstate_realloc()
1560 newfps->xfd = curfps->xfd & ~xfeatures; in fpstate_realloc()
1563 xstate_init_xcomp_bv(&newfps->regs.xsave, newfps->xfeatures); in fpstate_realloc()
1566 guest_fpu->fpstate = newfps; in fpstate_realloc()
1569 fpu->fpstate = newfps; in fpstate_realloc()
1571 fpu->fpstate = newfps; in fpstate_realloc()
1575 xfd_update_state(fpu->fpstate); in fpstate_realloc()
1579 if (curfps && curfps->is_valloc) in fpstate_realloc()
1587 struct task_struct *thread, *leader = current->group_leader; in validate_sigaltstack()
1590 lockdep_assert_held(¤t->sighand->siglock); in validate_sigaltstack()
1593 framesize -= fpu_user_cfg.max_size; in validate_sigaltstack()
1596 if (thread->sas_ss_size && thread->sas_ss_size < framesize) in validate_sigaltstack()
1597 return -ENOSPC; in validate_sigaltstack()
1611 struct fpu *fpu = ¤t->group_leader->thread.fpu; in __xstate_request_perm()
1623 /* Take supervisor states into account on the host */ in __xstate_request_perm()
1638 perm = guest ? &fpu->guest_perm : &fpu->perm; in __xstate_request_perm()
1640 WRITE_ONCE(perm->__state_perm, mask); in __xstate_request_perm()
1642 perm->__state_size = ksize; in __xstate_request_perm()
1643 perm->__user_state_size = usize; in __xstate_request_perm()
1660 return -EINVAL; in xstate_request_perm()
1669 return -EOPNOTSUPP; in xstate_request_perm()
1672 return -EOPNOTSUPP; in xstate_request_perm()
1680 spin_lock_irq(¤t->sighand->siglock); in xstate_request_perm()
1685 ret = -EBUSY; in xstate_request_perm()
1688 spin_unlock_irq(¤t->sighand->siglock); in xstate_request_perm()
1706 spin_lock_irq(¤t->sighand->siglock); in __xfd_enable_feature()
1710 spin_unlock_irq(¤t->sighand->siglock); in __xfd_enable_feature()
1711 return -EPERM; in __xfd_enable_feature()
1714 fpu = ¤t->group_leader->thread.fpu; in __xfd_enable_feature()
1715 perm = guest_fpu ? &fpu->guest_perm : &fpu->perm; in __xfd_enable_feature()
1716 ksize = perm->__state_size; in __xfd_enable_feature()
1717 usize = perm->__user_state_size; in __xfd_enable_feature()
1725 spin_unlock_irq(¤t->sighand->siglock); in __xfd_enable_feature()
1732 return -EFAULT; in __xfd_enable_feature()
1744 return -EPERM; in xstate_request_perm()
1755 * fpu_xstate_prctl - xstate permission operations
1803 return -EOPNOTSUPP; in fpu_xstate_prctl()
1808 return -EINVAL; in fpu_xstate_prctl()
1819 unsigned long timestamp = READ_ONCE(task->thread.fpu.avx512_timestamp); in avx512_status()
1824 * Report -1 if no AVX512 usage in avx512_status()
1826 delta = -1; in avx512_status()
1828 delta = (long)(jiffies - timestamp); in avx512_status()