aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2023-08-25 19:34:16 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2023-12-29 21:49:41 +0000
commit90ac116d5e466e631fc5b8ee8e9fd16bd10c8f07 (patch)
tree11bbffc6976019ac8265fd47b5a684b91c92a9d3
parent0609ca2f19d48d95005fc6b3b71422cce708c372 (diff)
downloadsrc-90ac116d5e466e631fc5b8ee8e9fd16bd10c8f07.tar.gz
src-90ac116d5e466e631fc5b8ee8e9fd16bd10c8f07.zip
nehemiah RNG: Switch to using FPU_KERN_NOCTX
Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D41583 (cherry picked from commit 7aec088cbce8381bd5bf730419b8fdcddf43b08d)
-rw-r--r--sys/dev/random/nehemiah.c24
1 files changed, 2 insertions, 22 deletions
diff --git a/sys/dev/random/nehemiah.c b/sys/dev/random/nehemiah.c
index 09c8c32c6d39..e01fdb952108 100644
--- a/sys/dev/random/nehemiah.c
+++ b/sys/dev/random/nehemiah.c
@@ -43,8 +43,6 @@
#include <dev/random/randomdev.h>
-static void random_nehemiah_init(void);
-static void random_nehemiah_deinit(void);
static u_int random_nehemiah_read(void *, u_int);
static struct random_source random_nehemiah = {
@@ -53,8 +51,6 @@ static struct random_source random_nehemiah = {
.rs_read = random_nehemiah_read
};
-static struct fpu_kern_ctx *fpu_ctx_save;
-
/* This H/W source never stores more than 8 bytes in one go */
/* ARGSUSED */
static __inline size_t
@@ -75,20 +71,6 @@ VIA_RNG_store(void *buf)
return (0);
}
-static void
-random_nehemiah_init(void)
-{
-
- fpu_ctx_save = fpu_kern_alloc_ctx(FPU_KERN_NORMAL);
-}
-
-static void
-random_nehemiah_deinit(void)
-{
-
- fpu_kern_free_ctx(fpu_ctx_save);
-}
-
/* It is specifically allowed that buf is a multiple of sizeof(long) */
static u_int
random_nehemiah_read(void *buf, u_int c)
@@ -97,14 +79,14 @@ random_nehemiah_read(void *buf, u_int c)
size_t count, ret;
uint64_t tmp;
- fpu_kern_enter(curthread, fpu_ctx_save, FPU_KERN_NORMAL);
+ fpu_kern_enter(curthread, NULL, FPU_KERN_NORMAL | FPU_KERN_NOCTX);
b = buf;
for (count = c; count > 0; count -= ret) {
ret = MIN(VIA_RNG_store(&tmp), count);
memcpy(b, &tmp, ret);
b += ret;
}
- fpu_kern_leave(curthread, fpu_ctx_save);
+ fpu_kern_leave(curthread, NULL);
return (c);
}
@@ -119,13 +101,11 @@ nehemiah_modevent(module_t mod, int type, void *unused)
if (via_feature_rng & VIA_HAS_RNG) {
random_source_register(&random_nehemiah);
printf("random: fast provider: \"%s\"\n", random_nehemiah.rs_ident);
- random_nehemiah_init();
}
break;
case MOD_UNLOAD:
if (via_feature_rng & VIA_HAS_RNG) {
- random_nehemiah_deinit();
random_source_deregister(&random_nehemiah);
}
break;