From nobody Tue Feb 15 02:09:28 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8B71319C3924; Tue, 15 Feb 2022 02:09:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JyPfd1Mgzz3vJR; Tue, 15 Feb 2022 02:09:29 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644890969; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GBR+wkf8N4/0RoJ5oA3KnFJjR34Un8rHyLxQcq8A5W4=; b=UZ+cjRvN2y0fdqaS+iZpolaeCwrlqkXxLKtjPlAdnIfLKx66V6NzkCqm8fE3EX7yO0g4m+ dYw0F+NRZebjHu0rjx+lA+E38Ad8IQ9AfCkfKXnPd10lNv2HTlu3nZmEHrx+tGA/UDHIzS pjfOu1Ap2m/KwA6UzYM0IfIGPt/uzOykyzaH7YbP3YfvkQRBZhXEuOyKHAMrztAGA4VRh9 rx/ixrHapFKx5goNgJwA0he5xWrdoD8HvuFCixm8/6065H7CAz1bAsOhw1EKWIo5oSQ895 1GF/UTXwnNvHHfxfPWNGrfqE+JGAkzzdpoY0ImSeGZXG8FjxM5TKP63zoJWqaw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EDF18196FC; Tue, 15 Feb 2022 02:09:28 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21F29SSt046661; Tue, 15 Feb 2022 02:09:28 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21F29SiX046660; Tue, 15 Feb 2022 02:09:28 GMT (envelope-from git) Date: Tue, 15 Feb 2022 02:09:28 GMT Message-Id: <202202150209.21F29SiX046660@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: "David E. O'Brien" Subject: git: e6e5f6a7dd80 - stable/12 - random(4): Reorder configuration of random source modules List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: obrien X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: e6e5f6a7dd807e1e703e2a3eee3983701bea283f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644890969; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=GBR+wkf8N4/0RoJ5oA3KnFJjR34Un8rHyLxQcq8A5W4=; b=bYSl94993roPGYtIGTOY1aYpO3mlFKNDT5o0c2uwA18YqoklMPZ+/ePZ3fnOj9OjNESX/J bmt+ruo1wdHV2BslCKdT9BsnD/bYoHiMdwa2mfde1jCorvHnkDms4P1HTx0+8MKWFokqzX ZzM/arzqyVQZR8ZUiZLVs8m7swuj3w/6yArGVvvuAq6YA3vec1F0E5zbVpuIZazr/G4F2d /6dWielt8whuxN5MQyoGTdKlZN4TUrwEg6cND0W2TzygxipGzAa8XykmuSOxhHvO75Nu++ n9WMi1I7VTLhpbG8TUjKYuxTNMu1oMXKrulmjG/r8rRWz1k5WW6dFZK8gF1ucA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644890969; a=rsa-sha256; cv=none; b=qSqaIZB2fqJgf0iZ2cDl28//tMeeHVi/MptumBWiUYOsng+hiHceuV12OIyZ3xFf696B9B L95QD1OSCilONFbHNtwTWIBi/IqxTpRUpuEhV/5h+MkLgl1who1rZR5yzQ14uG+vlO0i5b sm2aDKXUGm0RAxJq9OMSOOHC9wOpDdYFrALE9dd+gQUFMjztnTrnRcbsGRzunUUThm1z3P PXV75/k/G+7DPUEzalGm91g0o/EiQycbT1BXSiSwWiBKTGUnX6BRLk9sydZgQKWtZP/9RE LSQSxhavZx5WadvjzxqWXgoZ+wlKx9gTwKbBlreqgJ6FrLqrHzzvnc01GmBn4w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by obrien: URL: https://cgit.FreeBSD.org/src/commit/?id=e6e5f6a7dd807e1e703e2a3eee3983701bea283f commit e6e5f6a7dd807e1e703e2a3eee3983701bea283f Author: Conrad Meyer AuthorDate: 2019-08-18 16:04:01 +0000 Commit: David E. O'Brien CommitDate: 2022-02-15 02:09:08 +0000 random(4): Reorder configuration of random source modules Move fast entropy source registration to the earlier SI_SUB_RANDOM:SI_ORDER_FOURTH and move random_harvestq_prime after that. Relocate the registration routines out of the much later randomdev module and into random_harvestq. This is necessary for the fast random sources to actually register before we perform random_harvestq_prime() early in the kernel boot. No functional change. (cherry picked from commit 7384206a943be8d6b83e52bf5bfa5fca07e949f5) --- sys/dev/random/darn.c | 10 +++++-- sys/dev/random/ivy.c | 10 +++++-- sys/dev/random/nehemiah.c | 10 +++++-- sys/dev/random/random_harvestq.c | 58 +++++++++++++++++++++++++++++++++++++++- sys/dev/random/randomdev.c | 56 -------------------------------------- 5 files changed, 81 insertions(+), 63 deletions(-) diff --git a/sys/dev/random/darn.c b/sys/dev/random/darn.c index e42a4287a532..a9b0a84c7edd 100644 --- a/sys/dev/random/darn.c +++ b/sys/dev/random/darn.c @@ -137,6 +137,12 @@ darn_modevent(module_t mod, int type, void *unused) return (error); } -DEV_MODULE(darn, darn_modevent, NULL); +static moduledata_t darn_mod = { + "darn", + darn_modevent, + 0 +}; + +DECLARE_MODULE(darn, darn_mod, SI_SUB_RANDOM, SI_ORDER_FOURTH); MODULE_VERSION(darn, 1); -MODULE_DEPEND(darn, random_device, 1, 1, 1); +MODULE_DEPEND(darn, random_harvestq, 1, 1, 1); diff --git a/sys/dev/random/ivy.c b/sys/dev/random/ivy.c index 7ab2b0356094..7431f56f0f69 100644 --- a/sys/dev/random/ivy.c +++ b/sys/dev/random/ivy.c @@ -127,6 +127,12 @@ rdrand_modevent(module_t mod, int type, void *unused) return (error); } -DEV_MODULE(rdrand, rdrand_modevent, NULL); +static moduledata_t rdrand_mod = { + "rdrand", + rdrand_modevent, + 0 +}; + +DECLARE_MODULE(rdrand, rdrand_mod, SI_SUB_RANDOM, SI_ORDER_FOURTH); MODULE_VERSION(rdrand, 1); -MODULE_DEPEND(rdrand, random_device, 1, 1, 1); +MODULE_DEPEND(rdrand, random_harvestq, 1, 1, 1); diff --git a/sys/dev/random/nehemiah.c b/sys/dev/random/nehemiah.c index 6666eca2930e..3ad18005c935 100644 --- a/sys/dev/random/nehemiah.c +++ b/sys/dev/random/nehemiah.c @@ -146,6 +146,12 @@ nehemiah_modevent(module_t mod, int type, void *unused) return (error); } -DEV_MODULE(nehemiah, nehemiah_modevent, NULL); +static moduledata_t nehemiah_mod = { + "nehemiah", + nehemiah_modevent, + 0 +}; + +DECLARE_MODULE(nehemiah, nehemiah_mod, SI_SUB_RANDOM, SI_ORDER_FOURTH); MODULE_VERSION(nehemiah, 1); -MODULE_DEPEND(nehemiah, random_device, 1, 1, 1); +MODULE_DEPEND(nehemiah, random_harvestq, 1, 1, 1); diff --git a/sys/dev/random/random_harvestq.c b/sys/dev/random/random_harvestq.c index d681204832a5..598e2cfdc1f9 100644 --- a/sys/dev/random/random_harvestq.c +++ b/sys/dev/random/random_harvestq.c @@ -424,7 +424,7 @@ random_harvestq_prime(void *unused __unused) printf("random: no preloaded entropy cache\n"); } } -SYSINIT(random_device_prime, SI_SUB_RANDOM, SI_ORDER_FOURTH, random_harvestq_prime, NULL); +SYSINIT(random_device_prime, SI_SUB_RANDOM, SI_ORDER_MIDDLE, random_harvestq_prime, NULL); /* ARGSUSED */ static void @@ -533,4 +533,60 @@ random_harvest_deregister_source(enum random_entropy_source source) hc_source_mask &= ~(1 << source); } +void +random_source_register(struct random_source *rsource) +{ + struct random_sources *rrs; + + KASSERT(rsource != NULL, ("invalid input to %s", __func__)); + + rrs = malloc(sizeof(*rrs), M_ENTROPY, M_WAITOK); + rrs->rrs_source = rsource; + + random_harvest_register_source(rsource->rs_source); + + printf("random: registering fast source %s\n", rsource->rs_ident); + LIST_INSERT_HEAD(&source_list, rrs, rrs_entries); +} + +void +random_source_deregister(struct random_source *rsource) +{ + struct random_sources *rrs = NULL; + + KASSERT(rsource != NULL, ("invalid input to %s", __func__)); + + random_harvest_deregister_source(rsource->rs_source); + + LIST_FOREACH(rrs, &source_list, rrs_entries) + if (rrs->rrs_source == rsource) { + LIST_REMOVE(rrs, rrs_entries); + break; + } + if (rrs != NULL) + free(rrs, M_ENTROPY); +} + +static int +random_source_handler(SYSCTL_HANDLER_ARGS) +{ + struct random_sources *rrs; + struct sbuf sbuf; + int error, count; + + sbuf_new_for_sysctl(&sbuf, NULL, 64, req); + count = 0; + LIST_FOREACH(rrs, &source_list, rrs_entries) { + sbuf_cat(&sbuf, (count++ ? ",'" : "'")); + sbuf_cat(&sbuf, rrs->rrs_source->rs_ident); + sbuf_cat(&sbuf, "'"); + } + error = sbuf_finish(&sbuf); + sbuf_delete(&sbuf); + return (error); +} +SYSCTL_PROC(_kern_random, OID_AUTO, random_sources, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, + NULL, 0, random_source_handler, "A", + "List of active fast entropy sources."); + MODULE_VERSION(random_harvestq, 1); diff --git a/sys/dev/random/randomdev.c b/sys/dev/random/randomdev.c index 8af39deeb34b..f1ed80cc02f1 100644 --- a/sys/dev/random/randomdev.c +++ b/sys/dev/random/randomdev.c @@ -410,62 +410,6 @@ randomdev_ioctl(struct cdev *dev __unused, u_long cmd, caddr_t addr __unused, return (error); } -void -random_source_register(struct random_source *rsource) -{ - struct random_sources *rrs; - - KASSERT(rsource != NULL, ("invalid input to %s", __func__)); - - rrs = malloc(sizeof(*rrs), M_ENTROPY, M_WAITOK); - rrs->rrs_source = rsource; - - random_harvest_register_source(rsource->rs_source); - - printf("random: registering fast source %s\n", rsource->rs_ident); - LIST_INSERT_HEAD(&source_list, rrs, rrs_entries); -} - -void -random_source_deregister(struct random_source *rsource) -{ - struct random_sources *rrs = NULL; - - KASSERT(rsource != NULL, ("invalid input to %s", __func__)); - - random_harvest_deregister_source(rsource->rs_source); - - LIST_FOREACH(rrs, &source_list, rrs_entries) - if (rrs->rrs_source == rsource) { - LIST_REMOVE(rrs, rrs_entries); - break; - } - if (rrs != NULL) - free(rrs, M_ENTROPY); -} - -static int -random_source_handler(SYSCTL_HANDLER_ARGS) -{ - struct random_sources *rrs; - struct sbuf sbuf; - int error, count; - - sbuf_new_for_sysctl(&sbuf, NULL, 64, req); - count = 0; - LIST_FOREACH(rrs, &source_list, rrs_entries) { - sbuf_cat(&sbuf, (count++ ? ",'" : "'")); - sbuf_cat(&sbuf, rrs->rrs_source->rs_ident); - sbuf_cat(&sbuf, "'"); - } - error = sbuf_finish(&sbuf); - sbuf_delete(&sbuf); - return (error); -} -SYSCTL_PROC(_kern_random, OID_AUTO, random_sources, CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, - NULL, 0, random_source_handler, "A", - "List of active fast entropy sources."); - /* ARGSUSED */ static int randomdev_modevent(module_t mod __unused, int type, void *data __unused)