aboutsummaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorConrad Meyer <cem@FreeBSD.org>2020-07-03 14:54:46 +0000
committerConrad Meyer <cem@FreeBSD.org>2020-07-03 14:54:46 +0000
commitc74a3041f019d6492ff0cd4d46d694fc0262e65f (patch)
treee1da4cc22dc04cc8e2f2f278f149dafa27f7518a /sys
parent58199a70529d2e1a1cbcd0d86dc5877b4e45f48e (diff)
Notes
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/amd64/fpu.c31
-rw-r--r--sys/amd64/include/fpu.h1
-rw-r--r--sys/crypto/aesni/aesni.c7
-rw-r--r--sys/crypto/blake2/blake2_cryptodev.c7
4 files changed, 36 insertions, 10 deletions
diff --git a/sys/amd64/amd64/fpu.c b/sys/amd64/amd64/fpu.c
index b554394a17bb1..53819131e5b04 100644
--- a/sys/amd64/amd64/fpu.c
+++ b/sys/amd64/amd64/fpu.c
@@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/bus.h>
+#include <sys/domainset.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
@@ -1030,17 +1031,31 @@ struct fpu_kern_ctx {
char hwstate1[];
};
+static inline size_t __pure2
+fpu_kern_alloc_sz(u_int max_est)
+{
+ return (sizeof(struct fpu_kern_ctx) + XSAVE_AREA_ALIGN + max_est);
+}
+
+static inline int __pure2
+fpu_kern_malloc_flags(u_int fpflags)
+{
+ return (((fpflags & FPU_KERN_NOWAIT) ? M_NOWAIT : M_WAITOK) | M_ZERO);
+}
+
struct fpu_kern_ctx *
-fpu_kern_alloc_ctx(u_int flags)
+fpu_kern_alloc_ctx_domain(int domain, u_int flags)
{
- struct fpu_kern_ctx *res;
- size_t sz;
+ return (malloc_domainset(fpu_kern_alloc_sz(cpu_max_ext_state_size),
+ M_FPUKERN_CTX, DOMAINSET_PREF(domain),
+ fpu_kern_malloc_flags(flags)));
+}
- sz = sizeof(struct fpu_kern_ctx) + XSAVE_AREA_ALIGN +
- cpu_max_ext_state_size;
- res = malloc(sz, M_FPUKERN_CTX, ((flags & FPU_KERN_NOWAIT) ?
- M_NOWAIT : M_WAITOK) | M_ZERO);
- return (res);
+struct fpu_kern_ctx *
+fpu_kern_alloc_ctx(u_int flags)
+{
+ return (malloc(fpu_kern_alloc_sz(cpu_max_ext_state_size),
+ M_FPUKERN_CTX, fpu_kern_malloc_flags(flags)));
}
void
diff --git a/sys/amd64/include/fpu.h b/sys/amd64/include/fpu.h
index 6b9782e7207ba..8f957eede39b4 100644
--- a/sys/amd64/include/fpu.h
+++ b/sys/amd64/include/fpu.h
@@ -71,6 +71,7 @@ int fputrap_sse(void);
int fputrap_x87(void);
void fpuuserinited(struct thread *td);
struct fpu_kern_ctx *fpu_kern_alloc_ctx(u_int flags);
+struct fpu_kern_ctx *fpu_kern_alloc_ctx_domain(int domain, 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);
diff --git a/sys/crypto/aesni/aesni.c b/sys/crypto/aesni/aesni.c
index 42973b50718ae..3a5a9e0fb1fea 100644
--- a/sys/crypto/aesni/aesni.c
+++ b/sys/crypto/aesni/aesni.c
@@ -180,7 +180,12 @@ aesni_attach(device_t dev)
M_WAITOK|M_ZERO);
CPU_FOREACH(i) {
- ctx_fpu[i] = fpu_kern_alloc_ctx(0);
+#ifdef __amd64__
+ ctx_fpu[i] = fpu_kern_alloc_ctx_domain(
+ pcpu_find(i)->pc_domain, FPU_KERN_NORMAL);
+#else
+ ctx_fpu[i] = fpu_kern_alloc_ctx(FPU_KERN_NORMAL);
+#endif
mtx_init(&ctx_mtx[i], "anifpumtx", NULL, MTX_DEF|MTX_NEW);
}
diff --git a/sys/crypto/blake2/blake2_cryptodev.c b/sys/crypto/blake2/blake2_cryptodev.c
index c374be28ea10e..fcb3ec56059d2 100644
--- a/sys/crypto/blake2/blake2_cryptodev.c
+++ b/sys/crypto/blake2/blake2_cryptodev.c
@@ -142,7 +142,12 @@ blake2_attach(device_t dev)
M_WAITOK | M_ZERO);
CPU_FOREACH(i) {
- ctx_fpu[i] = fpu_kern_alloc_ctx(0);
+#ifdef __amd64__
+ ctx_fpu[i] = fpu_kern_alloc_ctx_domain(
+ pcpu_find(i)->pc_domain, FPU_KERN_NORMAL);
+#else
+ ctx_fpu[i] = fpu_kern_alloc_ctx(FPU_KERN_NORMAL);
+#endif
mtx_init(&ctx_mtx[i], "bl2fpumtx", NULL, MTX_DEF | MTX_NEW);
}