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()
368 * that init_fpstate contains all non-zero init state. This only in setup_init_fpu_buf()
398 /* No unknown or supervisor features may be set */ in validate_user_xstate_header()
399 if (hdr->xfeatures & ~fpstate->user_xfeatures) in validate_user_xstate_header()
400 return -EINVAL; in validate_user_xstate_header()
403 if (hdr->xcomp_bv) in validate_user_xstate_header()
404 return -EINVAL; in validate_user_xstate_header()
410 BUILD_BUG_ON(sizeof(hdr->reserved) != 48); in validate_user_xstate_header()
413 if (memchr_inv(hdr->reserved, 0, sizeof(hdr->reserved))) in validate_user_xstate_header()
414 return -EINVAL; in validate_user_xstate_header()
456 * check_xtile_data_against_struct - Check tile data state size.
464 * Returns: 0 on success, -EINVAL on mismatch.
479 * Cross-check each tile size and find the maximum number of in check_xtile_data_against_struct()
499 return -EINVAL; in check_xtile_data_against_struct()
511 return -EINVAL; in check_xtile_data_against_struct()
554 unsigned int topmost = fls64(xfeatures) - 1; in xstate_calculate_size()
566 * This essentially double-checks what the cpu told us about
571 * covered by these checks. Only the size of the buffer for task->fpu
585 * Supervisor state components can be managed only by in paranoid_xstate_size_valid()
589 XSTATE_WARN_ON(1, "Got supervisor feature %d, but XSAVES not advertised\n", i); in paranoid_xstate_size_valid()
602 * Note the SDM's wording here. "sub-function 0" only enumerates
614 * - CPUID function 0DH, sub-function 1: in get_compacted_size()
622 * are no supervisor states, but XSAVEC still uses compacted in get_compacted_size()
630 * Get the total size of the enabled xstates without the independent supervisor
646 * This is the size required for the task->fpu buffer. in get_xsave_compacted_size()
650 /* Re-enable independent features so XSAVES will work on them again. */ in get_xsave_compacted_size()
660 * - CPUID function 0DH, sub-function 0: in get_xsave_size_user()
680 * XSAVES kernel size includes supervisor states and uses compacted in init_xstate_size()
682 * supervisor states. in init_xstate_size()
684 * XSAVE[OPT] do not support supervisor states so kernel and user in init_xstate_size()
696 return -EINVAL; in init_xstate_size()
730 fpstate_reset(¤t->thread.fpu); in fpu__init_disable_system_xstate()
762 * Find supervisor xstates supported by the processor. in fpu__init_system_xstate()
838 fpstate_reset(¤t->thread.fpu); in fpu__init_system_xstate()
841 * Update info used for ptrace frames; use standard-format size and no in fpu__init_system_xstate()
842 * supervisor xstates: in fpu__init_system_xstate()
912 wrmsrl(MSR_IA32_XFD, current->thread.fpu.fpstate->xfd); in fpu__resume_cpu()
922 u64 xcomp_bv = xsave->header.xcomp_bv; in __raw_xsave_addr()
979 if (!(xsave->header.xfeatures & BIT_ULL(xfeature_nr))) in get_xsave_addr()
988 * The xsave buffer should be in standard format, not compacted (e.g. user mode
1016 return -EINVAL; in arch_set_user_pkey_access()
1020 * values originating from in-kernel users. Complain in arch_set_user_pkey_access()
1024 return -EINVAL; in arch_set_user_pkey_access()
1054 * __copy_xstate_to_uabi_buf - Copy kernel saved xstate to a UABI buffer
1057 * @xfeatures: The mask of xfeatures to save (XSAVE mode only)
1059 * @copy_mode: The requested copy mode
1063 * to the requested @mode. UABI XSTATE is always uncompacted!
1073 struct xregs_state *xsave = &fpstate->regs.xsave; in __copy_xstate_to_uabi_buf()
1080 header.xfeatures = xsave->header.xfeatures; in __copy_xstate_to_uabi_buf()
1082 /* Mask out the feature bits depending on copy mode */ in __copy_xstate_to_uabi_buf()
1093 header.xfeatures &= fpstate->user_xfeatures & xfeatures; in __copy_xstate_to_uabi_buf()
1098 copy_feature(header.xfeatures & XFEATURE_MASK_FP, &to, &xsave->i387, in __copy_xstate_to_uabi_buf()
1099 &xinit->i387, off_mxcsr); in __copy_xstate_to_uabi_buf()
1103 &to, &xsave->i387.mxcsr, &xinit->i387.mxcsr, in __copy_xstate_to_uabi_buf()
1108 &to, &xsave->i387.st_space, &xinit->i387.st_space, in __copy_xstate_to_uabi_buf()
1109 sizeof(xsave->i387.st_space)); in __copy_xstate_to_uabi_buf()
1111 /* Copy the SSE state - shared with YMM, but independently managed */ in __copy_xstate_to_uabi_buf()
1113 &to, &xsave->i387.xmm_space, &xinit->i387.xmm_space, in __copy_xstate_to_uabi_buf()
1114 sizeof(xsave->i387.xmm_space)); in __copy_xstate_to_uabi_buf()
1120 membuf_zero(&to, sizeof(xsave->i387.padding)); in __copy_xstate_to_uabi_buf()
1122 /* Copy xsave->i387.sw_reserved */ in __copy_xstate_to_uabi_buf()
1123 membuf_write(&to, xstate_fx_sw_bytes, sizeof(xsave->i387.sw_reserved)); in __copy_xstate_to_uabi_buf()
1125 /* Copy the user space relevant state of @xsave->header */ in __copy_xstate_to_uabi_buf()
1135 * In non-compacted format, disabled features still occupy in __copy_xstate_to_uabi_buf()
1152 membuf_zero(&to, xstate_offsets[i] - zerofrom); in __copy_xstate_to_uabi_buf()
1168 * Keep track of the last copied state in the non-compacted in __copy_xstate_to_uabi_buf()
1180 * copy_xstate_to_uabi_buf - Copy kernel saved xstate to a UABI buffer
1183 * @copy_mode: The requested copy mode
1187 * to the requested @mode. UABI XSTATE is always uncompacted!
1194 __copy_xstate_to_uabi_buf(to, tsk->thread.fpu.fpstate, in copy_xstate_to_uabi_buf()
1195 tsk->thread.fpu.fpstate->user_xfeatures, in copy_xstate_to_uabi_buf()
1196 tsk->thread.pkru, copy_mode); in copy_xstate_to_uabi_buf()
1206 return -EFAULT; in copy_from_buffer()
1213 * copy_uabi_to_xstate - Copy a UABI format buffer to the kernel xstate
1243 struct xregs_state *xsave = &fpstate->regs.xsave; in copy_uabi_to_xstate()
1251 return -EFAULT; in copy_uabi_to_xstate()
1254 return -EINVAL; in copy_uabi_to_xstate()
1263 return -EFAULT; in copy_uabi_to_xstate()
1267 return -EINVAL; in copy_uabi_to_xstate()
1271 xsave->i387.mxcsr = mxcsr[0]; in copy_uabi_to_xstate()
1272 xsave->i387.mxcsr_mask = mxcsr[1]; in copy_uabi_to_xstate()
1286 return -EFAULT; in copy_uabi_to_xstate()
1294 *pkru = xpkru->pkru; in copy_uabi_to_xstate()
1305 * The state that came in from userspace was user-state only. in copy_uabi_to_xstate()
1308 xsave->header.xfeatures &= XFEATURE_MASK_SUPERVISOR_ALL; in copy_uabi_to_xstate()
1313 xsave->header.xfeatures |= hdr.xfeatures; in copy_uabi_to_xstate()
1319 * Convert from a ptrace standard-format kernel buffer to kernel XSAVE[S]
1328 * Convert from a sigreturn standard-format user-space buffer to kernel
1335 return copy_uabi_to_xstate(tsk->thread.fpu.fpstate, NULL, ubuf, &tsk->thread.pkru); in copy_sigframe_from_user_to_xstate()
1354 * xsaves - Save selected components to a kernel xstate buffer
1377 * xrstors - Restore selected components from a kernel xstate buffer
1403 void *addr = get_xsave_addr(&fps->regs.xsave, xfeature); in fpstate_clear_xstate_component()
1422 if (fpstate->xfd == xfd) in xstate_op_valid()
1426 * The XFD MSR does not match fpstate->xfd. That's invalid when in xstate_op_valid()
1429 if (fpstate->xfd == current->thread.fpu.fpstate->xfd) in xstate_op_valid()
1447 * the buffer area for XFD-disabled state components. in xstate_op_valid()
1455 mask &= ~fpstate->xfeatures; in xstate_op_valid()
1484 if (fpu->fpstate && fpu->fpstate != &fpu->__fpstate) in arch_initcall()
1485 vfree(fpu->fpstate); in arch_initcall()
1489 * fpstate_realloc - Reallocate struct fpstate for the requested new features
1497 * Note vs. vmalloc(): If the task with a vzalloc()-allocated buffer
1498 * terminates quickly, vfree()-induced IPIs may be a concern, but tasks
1501 * Returns: 0 on success, -ENOMEM on allocation error.
1506 struct fpu *fpu = ¤t->thread.fpu; in fpstate_realloc()
1515 return -ENOMEM; in fpstate_realloc()
1516 newfps->size = ksize; in fpstate_realloc()
1517 newfps->user_size = usize; in fpstate_realloc()
1518 newfps->is_valloc = true; in fpstate_realloc()
1521 * When a guest FPU is supplied, use @guest_fpu->fpstate in fpstate_realloc()
1524 curfps = guest_fpu ? guest_fpu->fpstate : fpu->fpstate; in fpstate_realloc()
1527 in_use = fpu->fpstate == curfps; in fpstate_realloc()
1530 newfps->is_guest = true; in fpstate_realloc()
1531 newfps->is_confidential = curfps->is_confidential; in fpstate_realloc()
1532 newfps->in_use = curfps->in_use; in fpstate_realloc()
1533 guest_fpu->xfeatures |= xfeatures; in fpstate_realloc()
1534 guest_fpu->uabi_size = usize; in fpstate_realloc()
1546 newfps->xfeatures = curfps->xfeatures | xfeatures; in fpstate_realloc()
1547 newfps->user_xfeatures = curfps->user_xfeatures | xfeatures; in fpstate_realloc()
1548 newfps->xfd = curfps->xfd & ~xfeatures; in fpstate_realloc()
1551 xstate_init_xcomp_bv(&newfps->regs.xsave, newfps->xfeatures); in fpstate_realloc()
1554 guest_fpu->fpstate = newfps; in fpstate_realloc()
1557 fpu->fpstate = newfps; in fpstate_realloc()
1559 fpu->fpstate = newfps; in fpstate_realloc()
1563 xfd_update_state(fpu->fpstate); in fpstate_realloc()
1567 if (curfps && curfps->is_valloc) in fpstate_realloc()
1575 struct task_struct *thread, *leader = current->group_leader; in validate_sigaltstack()
1578 lockdep_assert_held(¤t->sighand->siglock); in validate_sigaltstack()
1581 framesize -= fpu_user_cfg.max_size; in validate_sigaltstack()
1584 if (thread->sas_ss_size && thread->sas_ss_size < framesize) in validate_sigaltstack()
1585 return -ENOSPC; in validate_sigaltstack()
1599 struct fpu *fpu = ¤t->group_leader->thread.fpu; in __xstate_request_perm()
1611 /* Take supervisor states into account on the host */ in __xstate_request_perm()
1626 perm = guest ? &fpu->guest_perm : &fpu->perm; in __xstate_request_perm()
1628 WRITE_ONCE(perm->__state_perm, mask); in __xstate_request_perm()
1630 perm->__state_size = ksize; in __xstate_request_perm()
1631 perm->__user_state_size = usize; in __xstate_request_perm()
1648 return -EINVAL; in xstate_request_perm()
1657 return -EOPNOTSUPP; in xstate_request_perm()
1660 return -EOPNOTSUPP; in xstate_request_perm()
1668 spin_lock_irq(¤t->sighand->siglock); in xstate_request_perm()
1673 ret = -EBUSY; in xstate_request_perm()
1676 spin_unlock_irq(¤t->sighand->siglock); in xstate_request_perm()
1694 spin_lock_irq(¤t->sighand->siglock); in __xfd_enable_feature()
1698 spin_unlock_irq(¤t->sighand->siglock); in __xfd_enable_feature()
1699 return -EPERM; in __xfd_enable_feature()
1702 fpu = ¤t->group_leader->thread.fpu; in __xfd_enable_feature()
1703 perm = guest_fpu ? &fpu->guest_perm : &fpu->perm; in __xfd_enable_feature()
1704 ksize = perm->__state_size; in __xfd_enable_feature()
1705 usize = perm->__user_state_size; in __xfd_enable_feature()
1713 spin_unlock_irq(¤t->sighand->siglock); in __xfd_enable_feature()
1720 return -EFAULT; in __xfd_enable_feature()
1732 return -EPERM; in xstate_request_perm()
1743 * fpu_xstate_prctl - xstate permission operations
1791 return -EOPNOTSUPP; in fpu_xstate_prctl()
1796 return -EINVAL; in fpu_xstate_prctl()
1807 unsigned long timestamp = READ_ONCE(task->thread.fpu.avx512_timestamp); in avx512_status()
1812 * Report -1 if no AVX512 usage in avx512_status()
1814 delta = -1; in avx512_status()
1816 delta = (long)(jiffies - timestamp); in avx512_status()