diff options
author | Mark Johnston <markj@FreeBSD.org> | 2023-12-11 14:07:55 +0000 |
---|---|---|
committer | Mark Johnston <markj@FreeBSD.org> | 2023-12-11 14:07:55 +0000 |
commit | a6a481eaa2e0f02e24b874f1a08bb494a68972c0 (patch) | |
tree | 2e2daafcc0b9fdd4e129e5a338947740801cdf41 | |
parent | 96465c789a5ff2619c5d49305517b35db9754ffb (diff) | |
download | src-a6a481eaa2e0f02e24b874f1a08bb494a68972c0.tar.gz src-a6a481eaa2e0f02e24b874f1a08bb494a68972c0.zip |
arm: Add fpu_kern_alloc_ctx()
This enables the use of some out-of-tree crypto libraries on arm.
No functional change intended, there are no callers of this function in
the tree currently.
Reviewed by: andrew
MFC after: 1 week
Sponsored by: Klara, Inc.
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D42969
-rw-r--r-- | sys/arm/arm/vfp.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/sys/arm/arm/vfp.c b/sys/arm/arm/vfp.c index a4be235e1e01..f2979d4a2b27 100644 --- a/sys/arm/arm/vfp.c +++ b/sys/arm/arm/vfp.c @@ -30,10 +30,10 @@ #include <sys/param.h> #include <sys/systm.h> +#include <sys/kernel.h> #include <sys/limits.h> +#include <sys/malloc.h> #include <sys/proc.h> -#include <sys/imgact_elf.h> -#include <sys/kernel.h> #include <machine/armreg.h> #include <machine/elf.h> @@ -52,6 +52,9 @@ static struct undefined_handler vfp10_uh, vfp11_uh; /* If true the VFP unit has 32 double registers, otherwise it has 16 */ static int is_d32; +static MALLOC_DEFINE(M_FPUKERN_CTX, "fpukern_ctx", + "Kernel contexts for VFP state"); + struct fpu_kern_ctx { struct vfp_state *prev; #define FPU_KERN_CTX_DUMMY 0x01 /* avoided save for the kern thread */ @@ -407,6 +410,21 @@ vfp_save_state(struct thread *td, struct pcb *pcb) critical_exit(); } +struct fpu_kern_ctx * +fpu_kern_alloc_ctx(u_int flags) +{ + return (malloc(sizeof(struct fpu_kern_ctx), M_FPUKERN_CTX, + ((flags & FPU_KERN_NOWAIT) ? M_NOWAIT : M_WAITOK) | M_ZERO)); +} + +void +fpu_kern_free_ctx(struct fpu_kern_ctx *ctx) +{ + KASSERT((ctx->flags & FPU_KERN_CTX_INUSE) == 0, ("freeing in-use ctx")); + + free(ctx, M_FPUKERN_CTX); +} + void fpu_kern_enter(struct thread *td, struct fpu_kern_ctx *ctx, u_int flags) { |