Lines Matching +full:supervisor +full:- +full:mode

1 // SPDX-License-Identifier: GPL-2.0-only
47 "AVX-512 opmask",
48 "AVX-512 Hi256",
49 "AVX-512 ZMM_Hi256",
53 "Control-flow User registers",
54 "Control-flow Kernel registers (unused)",
82 { [ 0 ... XFEATURE_MAX - 1] = -1};
84 { [ 0 ... XFEATURE_MAX - 1] = -1};
106 * missing AVX feature - this is the most informative message in cpu_has_xfeatures()
114 xfeature_idx = fls64(xfeatures_print)-1; in cpu_has_xfeatures()
115 max_idx = ARRAY_SIZE(xfeature_names)-1; in cpu_has_xfeatures()
143 * Non-compacted format and legacy features use the cached fixed in xfeature_get_offset()
194 * MSR_IA32_XSS sets supervisor states managed by XSAVES. in fpu__init_cpu_xstate()
237 * If an xfeature is supervisor state, the offset in EBX is in setup_xstate_cache()
238 * invalid, leave it to -1. in setup_xstate_cache()
246 * In our xstate size checks, we assume that the highest-numbered in setup_xstate_cache()
375 * that init_fpstate contains all non-zero init state. This only in setup_init_fpu_buf()
405 /* No unknown or supervisor features may be set */ in validate_user_xstate_header()
406 if (hdr->xfeatures & ~fpstate->user_xfeatures) in validate_user_xstate_header()
407 return -EINVAL; in validate_user_xstate_header()
410 if (hdr->xcomp_bv) in validate_user_xstate_header()
411 return -EINVAL; in validate_user_xstate_header()
417 BUILD_BUG_ON(sizeof(hdr->reserved) != 48); in validate_user_xstate_header()
420 if (memchr_inv(hdr->reserved, 0, sizeof(hdr->reserved))) in validate_user_xstate_header()
421 return -EINVAL; in validate_user_xstate_header()
463 * check_xtile_data_against_struct - Check tile data state size.
471 * Returns: 0 on success, -EINVAL on mismatch.
486 * Cross-check each tile size and find the maximum number of in check_xtile_data_against_struct()
506 return -EINVAL; in check_xtile_data_against_struct()
518 return -EINVAL; in check_xtile_data_against_struct()
561 unsigned int topmost = fls64(xfeatures) - 1; in xstate_calculate_size()
573 * This essentially double-checks what the cpu told us about
578 * covered by these checks. Only the size of the buffer for task->fpu
592 * Supervisor state components can be managed only by in paranoid_xstate_size_valid()
596 XSTATE_WARN_ON(1, "Got supervisor feature %d, but XSAVES not advertised\n", i); in paranoid_xstate_size_valid()
609 * Note the SDM's wording here. "sub-function 0" only enumerates
621 * - CPUID function 0DH, sub-function 1: in get_compacted_size()
629 * are no supervisor states, but XSAVEC still uses compacted in get_compacted_size()
637 * Get the total size of the enabled xstates without the independent supervisor
653 * This is the size required for the task->fpu buffer. in get_xsave_compacted_size()
657 /* Re-enable independent features so XSAVES will work on them again. */ in get_xsave_compacted_size()
667 * - CPUID function 0DH, sub-function 0: in get_xsave_size_user()
687 * XSAVES kernel size includes supervisor states and uses compacted in init_xstate_size()
689 * supervisor states. in init_xstate_size()
691 * XSAVE[OPT] do not support supervisor states so kernel and user in init_xstate_size()
703 return -EINVAL; in init_xstate_size()
737 fpstate_reset(&current->thread.fpu); in fpu__init_disable_system_xstate()
774 * Find supervisor xstates supported by the processor. in fpu__init_system_xstate()
847 fpstate_reset(&current->thread.fpu); in fpu__init_system_xstate()
850 * Update info used for ptrace frames; use standard-format size and no in fpu__init_system_xstate()
851 * supervisor xstates: in fpu__init_system_xstate()
921 wrmsrl(MSR_IA32_XFD, current->thread.fpu.fpstate->xfd); in fpu__resume_cpu()
931 u64 xcomp_bv = xsave->header.xcomp_bv; in __raw_xsave_addr()
988 if (!(xsave->header.xfeatures & BIT_ULL(xfeature_nr))) in get_xsave_addr()
1011 return -EINVAL; in arch_set_user_pkey_access()
1015 * values originating from in-kernel users. Complain in arch_set_user_pkey_access()
1019 return -EINVAL; in arch_set_user_pkey_access()
1049 * __copy_xstate_to_uabi_buf - Copy kernel saved xstate to a UABI buffer
1052 * @xfeatures: The mask of xfeatures to save (XSAVE mode only)
1054 * @copy_mode: The requested copy mode
1058 * to the requested @mode. UABI XSTATE is always uncompacted!
1068 struct xregs_state *xsave = &fpstate->regs.xsave; in __copy_xstate_to_uabi_buf()
1075 header.xfeatures = xsave->header.xfeatures; in __copy_xstate_to_uabi_buf()
1077 /* Mask out the feature bits depending on copy mode */ in __copy_xstate_to_uabi_buf()
1088 header.xfeatures &= fpstate->user_xfeatures & xfeatures; in __copy_xstate_to_uabi_buf()
1093 copy_feature(header.xfeatures & XFEATURE_MASK_FP, &to, &xsave->i387, in __copy_xstate_to_uabi_buf()
1094 &xinit->i387, off_mxcsr); in __copy_xstate_to_uabi_buf()
1098 &to, &xsave->i387.mxcsr, &xinit->i387.mxcsr, in __copy_xstate_to_uabi_buf()
1103 &to, &xsave->i387.st_space, &xinit->i387.st_space, in __copy_xstate_to_uabi_buf()
1104 sizeof(xsave->i387.st_space)); in __copy_xstate_to_uabi_buf()
1106 /* Copy the SSE state - shared with YMM, but independently managed */ in __copy_xstate_to_uabi_buf()
1108 &to, &xsave->i387.xmm_space, &xinit->i387.xmm_space, in __copy_xstate_to_uabi_buf()
1109 sizeof(xsave->i387.xmm_space)); in __copy_xstate_to_uabi_buf()
1115 membuf_zero(&to, sizeof(xsave->i387.padding)); in __copy_xstate_to_uabi_buf()
1117 /* Copy xsave->i387.sw_reserved */ in __copy_xstate_to_uabi_buf()
1118 membuf_write(&to, xstate_fx_sw_bytes, sizeof(xsave->i387.sw_reserved)); in __copy_xstate_to_uabi_buf()
1120 /* Copy the user space relevant state of @xsave->header */ in __copy_xstate_to_uabi_buf()
1130 * In non-compacted format, disabled features still occupy in __copy_xstate_to_uabi_buf()
1147 membuf_zero(&to, xstate_offsets[i] - zerofrom); in __copy_xstate_to_uabi_buf()
1163 * Keep track of the last copied state in the non-compacted in __copy_xstate_to_uabi_buf()
1175 * copy_xstate_to_uabi_buf - Copy kernel saved xstate to a UABI buffer
1178 * @copy_mode: The requested copy mode
1182 * to the requested @mode. UABI XSTATE is always uncompacted!
1189 __copy_xstate_to_uabi_buf(to, tsk->thread.fpu.fpstate, in copy_xstate_to_uabi_buf()
1190 tsk->thread.fpu.fpstate->user_xfeatures, in copy_xstate_to_uabi_buf()
1191 tsk->thread.pkru, copy_mode); in copy_xstate_to_uabi_buf()
1201 return -EFAULT; in copy_from_buffer()
1208 * copy_uabi_to_xstate - Copy a UABI format buffer to the kernel xstate
1238 struct xregs_state *xsave = &fpstate->regs.xsave; in copy_uabi_to_xstate()
1246 return -EFAULT; in copy_uabi_to_xstate()
1249 return -EINVAL; in copy_uabi_to_xstate()
1258 return -EFAULT; in copy_uabi_to_xstate()
1262 return -EINVAL; in copy_uabi_to_xstate()
1266 xsave->i387.mxcsr = mxcsr[0]; in copy_uabi_to_xstate()
1267 xsave->i387.mxcsr_mask = mxcsr[1]; in copy_uabi_to_xstate()
1281 return -EFAULT; in copy_uabi_to_xstate()
1289 *pkru = xpkru->pkru; in copy_uabi_to_xstate()
1300 * The state that came in from userspace was user-state only. in copy_uabi_to_xstate()
1303 xsave->header.xfeatures &= XFEATURE_MASK_SUPERVISOR_ALL; in copy_uabi_to_xstate()
1308 xsave->header.xfeatures |= hdr.xfeatures; in copy_uabi_to_xstate()
1314 * Convert from a ptrace standard-format kernel buffer to kernel XSAVE[S]
1323 * Convert from a sigreturn standard-format user-space buffer to kernel
1330 return copy_uabi_to_xstate(tsk->thread.fpu.fpstate, NULL, ubuf, &tsk->thread.pkru); in copy_sigframe_from_user_to_xstate()
1349 * xsaves - Save selected components to a kernel xstate buffer
1372 * xrstors - Restore selected components from a kernel xstate buffer
1398 void *addr = get_xsave_addr(&fps->regs.xsave, xfeature); in fpstate_clear_xstate_component()
1417 if (fpstate->xfd == xfd) in xstate_op_valid()
1421 * The XFD MSR does not match fpstate->xfd. That's invalid when in xstate_op_valid()
1424 if (fpstate->xfd == current->thread.fpu.fpstate->xfd) in xstate_op_valid()
1442 * the buffer area for XFD-disabled state components. in xstate_op_valid()
1450 mask &= ~fpstate->xfeatures; in xstate_op_valid()
1479 if (fpu->fpstate && fpu->fpstate != &fpu->__fpstate) in arch_initcall()
1480 vfree(fpu->fpstate); in arch_initcall()
1484 * fpstate_realloc - Reallocate struct fpstate for the requested new features
1492 * Note vs. vmalloc(): If the task with a vzalloc()-allocated buffer
1493 * terminates quickly, vfree()-induced IPIs may be a concern, but tasks
1496 * Returns: 0 on success, -ENOMEM on allocation error.
1501 struct fpu *fpu = &current->thread.fpu; in fpstate_realloc()
1510 return -ENOMEM; in fpstate_realloc()
1511 newfps->size = ksize; in fpstate_realloc()
1512 newfps->user_size = usize; in fpstate_realloc()
1513 newfps->is_valloc = true; in fpstate_realloc()
1516 * When a guest FPU is supplied, use @guest_fpu->fpstate in fpstate_realloc()
1519 curfps = guest_fpu ? guest_fpu->fpstate : fpu->fpstate; in fpstate_realloc()
1522 in_use = fpu->fpstate == curfps; in fpstate_realloc()
1525 newfps->is_guest = true; in fpstate_realloc()
1526 newfps->is_confidential = curfps->is_confidential; in fpstate_realloc()
1527 newfps->in_use = curfps->in_use; in fpstate_realloc()
1528 guest_fpu->xfeatures |= xfeatures; in fpstate_realloc()
1529 guest_fpu->uabi_size = usize; in fpstate_realloc()
1541 newfps->xfeatures = curfps->xfeatures | xfeatures; in fpstate_realloc()
1542 newfps->user_xfeatures = curfps->user_xfeatures | xfeatures; in fpstate_realloc()
1543 newfps->xfd = curfps->xfd & ~xfeatures; in fpstate_realloc()
1546 xstate_init_xcomp_bv(&newfps->regs.xsave, newfps->xfeatures); in fpstate_realloc()
1549 guest_fpu->fpstate = newfps; in fpstate_realloc()
1552 fpu->fpstate = newfps; in fpstate_realloc()
1554 fpu->fpstate = newfps; in fpstate_realloc()
1558 xfd_update_state(fpu->fpstate); in fpstate_realloc()
1562 if (curfps && curfps->is_valloc) in fpstate_realloc()
1570 struct task_struct *thread, *leader = current->group_leader; in validate_sigaltstack()
1573 lockdep_assert_held(&current->sighand->siglock); in validate_sigaltstack()
1576 framesize -= fpu_user_cfg.max_size; in validate_sigaltstack()
1579 if (thread->sas_ss_size && thread->sas_ss_size < framesize) in validate_sigaltstack()
1580 return -ENOSPC; in validate_sigaltstack()
1594 struct fpu *fpu = &current->group_leader->thread.fpu; in __xstate_request_perm()
1606 /* Take supervisor states into account on the host */ in __xstate_request_perm()
1621 perm = guest ? &fpu->guest_perm : &fpu->perm; in __xstate_request_perm()
1623 WRITE_ONCE(perm->__state_perm, mask); in __xstate_request_perm()
1625 perm->__state_size = ksize; in __xstate_request_perm()
1626 perm->__user_state_size = usize; in __xstate_request_perm()
1643 return -EINVAL; in xstate_request_perm()
1652 return -EOPNOTSUPP; in xstate_request_perm()
1655 return -EOPNOTSUPP; in xstate_request_perm()
1663 spin_lock_irq(&current->sighand->siglock); in xstate_request_perm()
1668 ret = -EBUSY; in xstate_request_perm()
1671 spin_unlock_irq(&current->sighand->siglock); in xstate_request_perm()
1689 spin_lock_irq(&current->sighand->siglock); in __xfd_enable_feature()
1693 spin_unlock_irq(&current->sighand->siglock); in __xfd_enable_feature()
1694 return -EPERM; in __xfd_enable_feature()
1697 fpu = &current->group_leader->thread.fpu; in __xfd_enable_feature()
1698 perm = guest_fpu ? &fpu->guest_perm : &fpu->perm; in __xfd_enable_feature()
1699 ksize = perm->__state_size; in __xfd_enable_feature()
1700 usize = perm->__user_state_size; in __xfd_enable_feature()
1708 spin_unlock_irq(&current->sighand->siglock); in __xfd_enable_feature()
1715 return -EFAULT; in __xfd_enable_feature()
1727 return -EPERM; in xstate_request_perm()
1738 * fpu_xstate_prctl - xstate permission operations
1786 return -EOPNOTSUPP; in fpu_xstate_prctl()
1791 return -EINVAL; in fpu_xstate_prctl()
1802 unsigned long timestamp = READ_ONCE(task->thread.fpu.avx512_timestamp); in avx512_status()
1807 * Report -1 if no AVX512 usage in avx512_status()
1809 delta = -1; in avx512_status()
1811 delta = (long)(jiffies - timestamp); in avx512_status()