NAME
fpu_kern — facility to use the FPU in the kernelSYNOPSIS
struct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int flags); void
fpu_kern_free_ctx(struct fpu_kern_ctx *ctx); void
fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags); int
fpu_kern_leave(struct thread *td, struct fpu_kern_ctx *ctx); int
fpu_kern_thread(u_int flags); int
is_fpu_kern_thread(u_int flags);
DESCRIPTION
The fpu_kern family of functions allows the use of FPU hardware in kernel code. Modern FPUs are not limited to providing hardware implementation for floating point arithmetic; they offer advanced accelerators for cryptography and other computational-intensive algorithms. These facilities share registers with the FPU hardware. Typical kernel code does not need access to the FPU. Saving a large register file on each entry to the kernel would waste time. When kernel code uses the FPU, the current FPU state must be saved to avoid corrupting the user-mode state, and vice versa. The management of the save and restore is automatic. The processor catches accesses to the FPU registers when the non-current context tries to access them. Explicit calls are required for the allocation of the save area and the notification of the start and end of the code using the FPU. The fpu_kern_alloc_ctx() function allocates the memory used by fpu_kern to track the use of the FPU hardware state and the related software state. The fpu_kern_alloc_ctx() function requires the flags argument, which currently accepts the following flags:FPU_KERN_NOWAIT
- Do not wait for the available memory if the request could not be satisfied without sleep.
- 0
- No special handling is required.
- td
- Currently must be curthread.
- ctx
- The context save area previously allocated by fpu_kern_alloc_ctx() and not currently in use by another call to fpu_kern_enter().
- flags
- This argument currently accepts the following flags:
NOTES
The fpu_kern is currently implemented only for the i386, amd64, and arm64 architectures. There is no way to handle floating point exceptions raised from kernel mode. The unused flags arguments to the fpu_kern functions are to be extended to allow specification of the set of the FPU hardware state used by the code region. This would allow optimizations of saving and restoring the state.AUTHORS
The fpu_kern facitily and this manual page were written by Konstantin Belousov <[email protected]>. The arm64 support was added byAndrew Turner <[email protected]>.
BUGS
fpu_kern_leave() should probably have type void (like fpu_kern_enter()).March 7, 2018 | Debian |