/* * Use kernel_fpu_begin/end() if you intend to use FPU in kernel context. It * disables preemption and softirq processing, so be careful if you intend to * use it for long periods of time. Kernel-mode FPU cannot be used in all * contexts -- see irq_fpu_usable() for details.
*/
/* Kernel FPU states to initialize in kernel_fpu_begin_mask() */ #define KFPU_387 _BITUL(0) /* 387 state will be initialized */ #define KFPU_MXCSR _BITUL(1) /* MXCSR will be initialized */
/* Code that is unaware of kernel_fpu_begin_mask() can use this */ staticinlinevoid kernel_fpu_begin(void)
{ #ifdef CONFIG_X86_64 /* * Any 64-bit code that uses 387 instructions must explicitly request * KFPU_387.
*/
kernel_fpu_begin_mask(KFPU_MXCSR); #else /* * 32-bit kernel code may use 387 operations as well as SSE2, etc, * as long as it checks that the CPU has the required capability.
*/
kernel_fpu_begin_mask(KFPU_387 | KFPU_MXCSR); #endif
}
/* * Use fpregs_lock() while editing CPU's FPU registers or fpu->fpstate, or while * using the FPU in kernel mode. A context switch will (and softirq might) save * CPU's FPU registers to fpu->fpstate.regs and set TIF_NEED_FPU_LOAD leaving * CPU's FPU registers in a random state. * * local_bh_disable() protects against both preemption and soft interrupts * on !RT kernels. * * On RT kernels local_bh_disable() is not sufficient because it only * serializes soft interrupt related sections via a local lock, but stays * preemptible. Disabling preemption is the right choice here as bottom * half processing is always in thread context on RT kernels so it * implicitly prevents bottom half processing as well.
*/ staticinlinevoid fpregs_lock(void)
{ if (!IS_ENABLED(CONFIG_PREEMPT_RT))
local_bh_disable(); else
preempt_disable();
}
staticinlinevoid fpregs_unlock(void)
{ if (!IS_ENABLED(CONFIG_PREEMPT_RT))
local_bh_enable(); else
preempt_enable();
}
/* * FPU state gets lazily restored before returning to userspace. So when in the * kernel, the valid FPU state may be kept in the buffer. This function will force * restore all the fpu state to the registers early if needed, and lock them from * being automatically saved/restored. Then FPU state can be modified safely in the * registers, before unlocking with fpregs_unlock().
*/ void fpregs_lock_and_load(void);
/* * Load the task FPU state before returning to userspace.
*/ externvoid switch_fpu_return(void);
/* * Query the presence of one or more xfeatures. Works on any legacy CPU as well. * * If 'feature_name' is set then put a human-readable description of * the feature there as well - this can be used to print error (or success) * messages.
*/ externint cpu_has_xfeatures(u64 xfeatures_mask, constchar **feature_name);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.