random: Make random_source definitions const

We can do so trivially, so make these tables read-only.  No functional
change intended.

Reviewed by:	cem, emaste
MFC after:	2 weeks
Sponsored by:	Stormshield
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D52003

(cherry picked from commit d5f55356a2fbf8222fb236fe509821e12f1ea456)
This commit is contained in:
Mark Johnston 2025-08-19 14:06:02 +00:00 committed by Franco Fichtner
parent 99461e26d8
commit b0ff0e437a
9 changed files with 12 additions and 12 deletions

View file

@ -79,7 +79,7 @@ static struct pciid {
{ 0x15df1022, "AMD CCP-5a" },
};
static struct random_source random_ccp = {
static const struct random_source random_ccp = {
.rs_ident = "AMD CCP TRNG",
.rs_source = RANDOM_PURE_CCP,
.rs_read = random_ccp_read,

View file

@ -64,7 +64,7 @@ static int qcom_rnd_detach(device_t);
static int qcom_rnd_harvest(struct qcom_rnd_softc *, void *, size_t *);
static unsigned qcom_rnd_read(void *, unsigned);
static struct random_source random_qcom_rnd = {
static const struct random_source random_qcom_rnd = {
.rs_ident = "Qualcomm Entropy Adapter",
.rs_source = RANDOM_PURE_QUALCOMM,
.rs_read = qcom_rnd_read,

View file

@ -44,7 +44,7 @@
static u_int random_rndr_read(void *, u_int);
static bool has_rndr;
static struct random_source random_armv8_rndr = {
static const struct random_source random_armv8_rndr = {
.rs_ident = "Armv8 rndr RNG",
.rs_source = RANDOM_PURE_ARMV8,
.rs_read = random_rndr_read,

View file

@ -57,7 +57,7 @@
static u_int random_darn_read(void *, u_int);
static struct random_source random_darn = {
static const struct random_source random_darn = {
.rs_ident = "PowerISA DARN random number generator",
.rs_source = RANDOM_PURE_DARN,
.rs_read = random_darn_read

View file

@ -52,7 +52,7 @@
static bool has_rdrand, has_rdseed;
static u_int random_ivy_read(void *, u_int);
static struct random_source random_ivy = {
static const struct random_source random_ivy = {
.rs_ident = "Intel Secure Key RNG",
.rs_source = RANDOM_PURE_RDRAND,
.rs_read = random_ivy_read

View file

@ -45,7 +45,7 @@
static u_int random_nehemiah_read(void *, u_int);
static struct random_source random_nehemiah = {
static const struct random_source random_nehemiah = {
.rs_ident = "VIA Nehemiah Padlock RNG",
.rs_source = RANDOM_PURE_NEHEMIAH,
.rs_read = random_nehemiah_read

View file

@ -109,7 +109,7 @@ __read_frequently u_int hc_source_mask;
struct random_sources {
CK_LIST_ENTRY(random_sources) rrs_entries;
struct random_source *rrs_source;
const struct random_source *rrs_source;
};
static CK_LIST_HEAD(sources_head, random_sources) source_list =
@ -629,7 +629,7 @@ random_harvest_deregister_source(enum random_entropy_source source)
}
void
random_source_register(struct random_source *rsource)
random_source_register(const struct random_source *rsource)
{
struct random_sources *rrs;
@ -648,7 +648,7 @@ random_source_register(struct random_source *rsource)
}
void
random_source_deregister(struct random_source *rsource)
random_source_deregister(const struct random_source *rsource)
{
struct random_sources *rrs = NULL;

View file

@ -103,8 +103,8 @@ struct random_source {
random_source_read_t *rs_read;
};
void random_source_register(struct random_source *);
void random_source_deregister(struct random_source *);
void random_source_register(const struct random_source *);
void random_source_deregister(const struct random_source *);
#endif /* _KERNEL */

View file

@ -78,7 +78,7 @@ static struct virtio_feature_desc vtrnd_feature_desc[] = {
{ 0, NULL }
};
static struct random_source random_vtrnd = {
static const struct random_source random_vtrnd = {
.rs_ident = "VirtIO Entropy Adapter",
.rs_source = RANDOM_PURE_VIRTIO,
.rs_read = vtrnd_read,