Lines Matching +full:supervisor +full:- +full:mode
1 // SPDX-License-Identifier: GPL-2.0-only
50 "AVX-512 opmask",
51 "AVX-512 Hi256",
52 "AVX-512 ZMM_Hi256",
56 "Control-flow User registers",
57 "Control-flow Kernel registers (unused)",
85 { [ 0 ... XFEATURE_MAX - 1] = -1};
87 { [ 0 ... XFEATURE_MAX - 1] = -1};
109 * missing AVX feature - this is the most informative message in cpu_has_xfeatures()
117 xfeature_idx = fls64(xfeatures_print)-1; in cpu_has_xfeatures()
118 max_idx = ARRAY_SIZE(xfeature_names)-1; in cpu_has_xfeatures()
146 * Non-compacted format and legacy features use the cached fixed in xfeature_get_offset()
198 * MSR_IA32_XSS sets supervisor states managed by XSAVES. in fpu__init_cpu_xstate()
241 * If an xfeature is supervisor state, the offset in EBX is in setup_xstate_cache()
242 * invalid, leave it to -1. in setup_xstate_cache()
250 * In our xstate size checks, we assume that the highest-numbered in setup_xstate_cache()
379 * that init_fpstate contains all non-zero init state. This only in setup_init_fpu_buf()
409 /* No unknown or supervisor features may be set */ in validate_user_xstate_header()
410 if (hdr->xfeatures & ~fpstate->user_xfeatures) in validate_user_xstate_header()
411 return -EINVAL; in validate_user_xstate_header()
414 if (hdr->xcomp_bv) in validate_user_xstate_header()
415 return -EINVAL; in validate_user_xstate_header()
421 BUILD_BUG_ON(sizeof(hdr->reserved) != 48); in validate_user_xstate_header()
424 if (memchr_inv(hdr->reserved, 0, sizeof(hdr->reserved))) in validate_user_xstate_header()
425 return -EINVAL; in validate_user_xstate_header()
467 * check_xtile_data_against_struct - Check tile data state size.
475 * Returns: 0 on success, -EINVAL on mismatch.
490 * Cross-check each tile size and find the maximum number of in check_xtile_data_against_struct()
510 return -EINVAL; in check_xtile_data_against_struct()
522 return -EINVAL; in check_xtile_data_against_struct()
565 unsigned int topmost = fls64(xfeatures) - 1; in xstate_calculate_size()
577 * This essentially double-checks what the cpu told us about
582 * covered by these checks. Only the size of the buffer for task->fpu
596 * Supervisor state components can be managed only by in paranoid_xstate_size_valid()
600 XSTATE_WARN_ON(1, "Got supervisor feature %d, but XSAVES not advertised\n", i); in paranoid_xstate_size_valid()
613 * Note the SDM's wording here. "sub-function 0" only enumerates
625 * - CPUID function 0DH, sub-function 1: in get_compacted_size()
633 * are no supervisor states, but XSAVEC still uses compacted in get_compacted_size()
641 * Get the total size of the enabled xstates without the independent supervisor
657 * This is the size required for the task->fpu buffer. in get_xsave_compacted_size()
661 /* Re-enable independent features so XSAVES will work on them again. */ in get_xsave_compacted_size()
671 * - CPUID function 0DH, sub-function 0: in get_xsave_size_user()
691 * XSAVES kernel size includes supervisor states and uses compacted in init_xstate_size()
693 * supervisor states. in init_xstate_size()
695 * XSAVE[OPT] do not support supervisor states so kernel and user in init_xstate_size()
707 return -EINVAL; in init_xstate_size()
741 fpstate_reset(¤t->thread.fpu); in fpu__init_disable_system_xstate()
778 * Find supervisor xstates supported by the processor. in fpu__init_system_xstate()
854 fpstate_reset(¤t->thread.fpu); in fpu__init_system_xstate()
857 * Update info used for ptrace frames; use standard-format size and no in fpu__init_system_xstate()
858 * supervisor xstates: in fpu__init_system_xstate()
928 wrmsrl(MSR_IA32_XFD, current->thread.fpu.fpstate->xfd); in fpu__resume_cpu()
938 u64 xcomp_bv = xsave->header.xcomp_bv; in __raw_xsave_addr()
995 if (!(xsave->header.xfeatures & BIT_ULL(xfeature_nr))) in get_xsave_addr()
1004 * The xsave buffer should be in standard format, not compacted (e.g. user mode
1032 return -EINVAL; in arch_set_user_pkey_access()
1036 * values originating from in-kernel users. Complain in arch_set_user_pkey_access()
1040 return -EINVAL; in arch_set_user_pkey_access()
1070 * __copy_xstate_to_uabi_buf - Copy kernel saved xstate to a UABI buffer
1073 * @xfeatures: The mask of xfeatures to save (XSAVE mode only)
1075 * @copy_mode: The requested copy mode
1079 * to the requested @mode. UABI XSTATE is always uncompacted!
1089 struct xregs_state *xsave = &fpstate->regs.xsave; in __copy_xstate_to_uabi_buf()
1096 header.xfeatures = xsave->header.xfeatures; in __copy_xstate_to_uabi_buf()
1098 /* Mask out the feature bits depending on copy mode */ in __copy_xstate_to_uabi_buf()
1109 header.xfeatures &= fpstate->user_xfeatures & xfeatures; in __copy_xstate_to_uabi_buf()
1114 copy_feature(header.xfeatures & XFEATURE_MASK_FP, &to, &xsave->i387, in __copy_xstate_to_uabi_buf()
1115 &xinit->i387, off_mxcsr); in __copy_xstate_to_uabi_buf()
1119 &to, &xsave->i387.mxcsr, &xinit->i387.mxcsr, in __copy_xstate_to_uabi_buf()
1124 &to, &xsave->i387.st_space, &xinit->i387.st_space, in __copy_xstate_to_uabi_buf()
1125 sizeof(xsave->i387.st_space)); in __copy_xstate_to_uabi_buf()
1127 /* Copy the SSE state - shared with YMM, but independently managed */ in __copy_xstate_to_uabi_buf()
1129 &to, &xsave->i387.xmm_space, &xinit->i387.xmm_space, in __copy_xstate_to_uabi_buf()
1130 sizeof(xsave->i387.xmm_space)); in __copy_xstate_to_uabi_buf()
1136 membuf_zero(&to, sizeof(xsave->i387.padding)); in __copy_xstate_to_uabi_buf()
1138 /* Copy xsave->i387.sw_reserved */ in __copy_xstate_to_uabi_buf()
1139 membuf_write(&to, xstate_fx_sw_bytes, sizeof(xsave->i387.sw_reserved)); in __copy_xstate_to_uabi_buf()
1141 /* Copy the user space relevant state of @xsave->header */ in __copy_xstate_to_uabi_buf()
1151 * In non-compacted format, disabled features still occupy in __copy_xstate_to_uabi_buf()
1168 membuf_zero(&to, xstate_offsets[i] - zerofrom); in __copy_xstate_to_uabi_buf()
1184 * Keep track of the last copied state in the non-compacted in __copy_xstate_to_uabi_buf()
1196 * copy_xstate_to_uabi_buf - Copy kernel saved xstate to a UABI buffer
1199 * @copy_mode: The requested copy mode
1203 * to the requested @mode. UABI XSTATE is always uncompacted!
1210 __copy_xstate_to_uabi_buf(to, tsk->thread.fpu.fpstate, in copy_xstate_to_uabi_buf()
1211 tsk->thread.fpu.fpstate->user_xfeatures, in copy_xstate_to_uabi_buf()
1212 tsk->thread.pkru, copy_mode); in copy_xstate_to_uabi_buf()
1222 return -EFAULT; in copy_from_buffer()
1229 * copy_uabi_to_xstate - Copy a UABI format buffer to the kernel xstate
1259 struct xregs_state *xsave = &fpstate->regs.xsave; in copy_uabi_to_xstate()
1267 return -EFAULT; in copy_uabi_to_xstate()
1270 return -EINVAL; in copy_uabi_to_xstate()
1279 return -EFAULT; in copy_uabi_to_xstate()
1283 return -EINVAL; in copy_uabi_to_xstate()
1287 xsave->i387.mxcsr = mxcsr[0]; in copy_uabi_to_xstate()
1288 xsave->i387.mxcsr_mask = mxcsr[1]; in copy_uabi_to_xstate()
1302 return -EFAULT; in copy_uabi_to_xstate()
1310 *pkru = xpkru->pkru; in copy_uabi_to_xstate()
1321 * The state that came in from userspace was user-state only. in copy_uabi_to_xstate()
1324 xsave->header.xfeatures &= XFEATURE_MASK_SUPERVISOR_ALL; in copy_uabi_to_xstate()
1329 xsave->header.xfeatures |= hdr.xfeatures; in copy_uabi_to_xstate()
1335 * Convert from a ptrace standard-format kernel buffer to kernel XSAVE[S]
1344 * Convert from a sigreturn standard-format user-space buffer to kernel
1351 return copy_uabi_to_xstate(tsk->thread.fpu.fpstate, NULL, ubuf, &tsk->thread.pkru); in copy_sigframe_from_user_to_xstate()
1370 * xsaves - Save selected components to a kernel xstate buffer
1393 * xrstors - Restore selected components from a kernel xstate buffer
1419 void *addr = get_xsave_addr(&fps->regs.xsave, xfeature); in fpstate_clear_xstate_component()
1438 if (fpstate->xfd == xfd) in xstate_op_valid()
1442 * The XFD MSR does not match fpstate->xfd. That's invalid when in xstate_op_valid()
1445 if (fpstate->xfd == current->thread.fpu.fpstate->xfd) in xstate_op_valid()
1463 * the buffer area for XFD-disabled state components. in xstate_op_valid()
1471 mask &= ~fpstate->xfeatures; in xstate_op_valid()
1500 if (fpu->fpstate && fpu->fpstate != &fpu->__fpstate) in arch_initcall()
1501 vfree(fpu->fpstate); in arch_initcall()
1505 * fpstate_realloc - Reallocate struct fpstate for the requested new features
1513 * Note vs. vmalloc(): If the task with a vzalloc()-allocated buffer
1514 * terminates quickly, vfree()-induced IPIs may be a concern, but tasks
1517 * Returns: 0 on success, -ENOMEM on allocation error.
1522 struct fpu *fpu = ¤t->thread.fpu; in fpstate_realloc()
1531 return -ENOMEM; in fpstate_realloc()
1532 newfps->size = ksize; in fpstate_realloc()
1533 newfps->user_size = usize; in fpstate_realloc()
1534 newfps->is_valloc = true; in fpstate_realloc()
1537 * When a guest FPU is supplied, use @guest_fpu->fpstate in fpstate_realloc()
1540 curfps = guest_fpu ? guest_fpu->fpstate : fpu->fpstate; in fpstate_realloc()
1543 in_use = fpu->fpstate == curfps; in fpstate_realloc()
1546 newfps->is_guest = true; in fpstate_realloc()
1547 newfps->is_confidential = curfps->is_confidential; in fpstate_realloc()
1548 newfps->in_use = curfps->in_use; in fpstate_realloc()
1549 guest_fpu->xfeatures |= xfeatures; in fpstate_realloc()
1550 guest_fpu->uabi_size = usize; in fpstate_realloc()
1562 newfps->xfeatures = curfps->xfeatures | xfeatures; in fpstate_realloc()
1563 newfps->user_xfeatures = curfps->user_xfeatures | xfeatures; in fpstate_realloc()
1564 newfps->xfd = curfps->xfd & ~xfeatures; in fpstate_realloc()
1567 xstate_init_xcomp_bv(&newfps->regs.xsave, newfps->xfeatures); in fpstate_realloc()
1570 guest_fpu->fpstate = newfps; in fpstate_realloc()
1573 fpu->fpstate = newfps; in fpstate_realloc()
1575 fpu->fpstate = newfps; in fpstate_realloc()
1579 xfd_update_state(fpu->fpstate); in fpstate_realloc()
1583 if (curfps && curfps->is_valloc) in fpstate_realloc()
1591 struct task_struct *thread, *leader = current->group_leader; in validate_sigaltstack()
1594 lockdep_assert_held(¤t->sighand->siglock); in validate_sigaltstack()
1597 framesize -= fpu_user_cfg.max_size; in validate_sigaltstack()
1600 if (thread->sas_ss_size && thread->sas_ss_size < framesize) in validate_sigaltstack()
1601 return -ENOSPC; in validate_sigaltstack()
1615 struct fpu *fpu = ¤t->group_leader->thread.fpu; in __xstate_request_perm()
1627 /* Take supervisor states into account on the host */ in __xstate_request_perm()
1642 perm = guest ? &fpu->guest_perm : &fpu->perm; in __xstate_request_perm()
1644 WRITE_ONCE(perm->__state_perm, mask); in __xstate_request_perm()
1646 perm->__state_size = ksize; in __xstate_request_perm()
1647 perm->__user_state_size = usize; in __xstate_request_perm()
1664 return -EINVAL; in xstate_request_perm()
1673 return -EOPNOTSUPP; in xstate_request_perm()
1676 return -EOPNOTSUPP; in xstate_request_perm()
1684 spin_lock_irq(¤t->sighand->siglock); in xstate_request_perm()
1689 ret = -EBUSY; in xstate_request_perm()
1692 spin_unlock_irq(¤t->sighand->siglock); in xstate_request_perm()
1710 spin_lock_irq(¤t->sighand->siglock); in __xfd_enable_feature()
1714 spin_unlock_irq(¤t->sighand->siglock); in __xfd_enable_feature()
1715 return -EPERM; in __xfd_enable_feature()
1718 fpu = ¤t->group_leader->thread.fpu; in __xfd_enable_feature()
1719 perm = guest_fpu ? &fpu->guest_perm : &fpu->perm; in __xfd_enable_feature()
1720 ksize = perm->__state_size; in __xfd_enable_feature()
1721 usize = perm->__user_state_size; in __xfd_enable_feature()
1729 spin_unlock_irq(¤t->sighand->siglock); in __xfd_enable_feature()
1736 return -EFAULT; in __xfd_enable_feature()
1748 return -EPERM; in xstate_request_perm()
1759 * fpu_xstate_prctl - xstate permission operations
1807 return -EOPNOTSUPP; in fpu_xstate_prctl()
1812 return -EINVAL; in fpu_xstate_prctl()
1823 unsigned long timestamp = READ_ONCE(task->thread.fpu.avx512_timestamp); in avx512_status()
1828 * Report -1 if no AVX512 usage in avx512_status()
1830 delta = -1; in avx512_status()
1832 delta = (long)(jiffies - timestamp); in avx512_status()