git: a77edeb0e54a - main - SYSINIT: add SI_SUB_KENV

Gleb Smirnoff <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a8363df.1d32e.23d22c24__26090.7155390427$1786995765$gmane$org@gitrepo.freebsd.org>
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=a77edeb0e54ad3e96e2a6c685d5c26eac4ba190a

commit a77edeb0e54ad3e96e2a6c685d5c26eac4ba190a
Author:     Gleb Smirnoff <[email protected]>
AuthorDate: 2026-08-17 19:40:49 +0000
Commit:     Gleb Smirnoff <[email protected]>
CommitDate: 2026-08-17 19:40:49 +0000

    SYSINIT: add SI_SUB_KENV
    
    Since the kernel environment has its own dependencies, lurking at the end
    of the SI_SUB_KMEM sequence appeared to be fragile.  Provide own subsystem
    for it.  The init_dynamic_kenv() goes SI_ORDER_FIRST, and two modules that
    depend on it go SI_ORDER_ANY.
    
    PR:                     297492
    Reviewed by:            imp, markj, emaste
    Differential Revision:  https://reviews.freebsd.org/D58836
---
 sys/geom/eli/g_eli.c        | 2 +-
 sys/kern/kern_environment.c | 2 +-
 sys/kern/subr_hints.c       | 2 +-
 sys/sys/kernel.h            | 1 +
 4 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/sys/geom/eli/g_eli.c b/sys/geom/eli/g_eli.c
index 622aa87d4e81..6430d4485395 100644
--- a/sys/geom/eli/g_eli.c
+++ b/sys/geom/eli/g_eli.c
@@ -165,7 +165,7 @@ fetch_loader_passphrase(void * dummy)
 		kern_unsetenv("kern.geom.eli.passphrase");
 	}
 }
-SYSINIT(geli_fetch_loader_passphrase, SI_SUB_KMEM, SI_ORDER_LAST,
+SYSINIT(geli_fetch_loader_passphrase, SI_SUB_KENV, SI_ORDER_ANY,
     fetch_loader_passphrase, NULL);
 
 static void
diff --git a/sys/kern/kern_environment.c b/sys/kern/kern_environment.c
index bf459a38107a..b348f318785e 100644
--- a/sys/kern/kern_environment.c
+++ b/sys/kern/kern_environment.c
@@ -511,7 +511,7 @@ init_dynamic_kenv(void *data __unused)
 	mtx_init(&kenv_lock, "kernel environment", NULL, MTX_DEF);
 	dynamic_kenv = true;
 }
-SYSINIT(kenv, SI_SUB_KMEM, SI_ORDER_LAST, init_dynamic_kenv, NULL);
+SYSINIT(kenv, SI_SUB_KENV, SI_ORDER_FIRST, init_dynamic_kenv, NULL);
 
 void
 freeenv(char *env)
diff --git a/sys/kern/subr_hints.c b/sys/kern/subr_hints.c
index e2577aa9a9b2..7f71ce55307f 100644
--- a/sys/kern/subr_hints.c
+++ b/sys/kern/subr_hints.c
@@ -88,7 +88,7 @@ static_hints_to_env(void *data __unused)
 }
 
 /* Any time after dynamic env is setup */
-SYSINIT(hintenv, SI_SUB_KMEM, SI_ORDER_LAST, static_hints_to_env, NULL);
+SYSINIT(hintenv, SI_SUB_KENV, SI_ORDER_ANY, static_hints_to_env, NULL);
 
 /*
  * Checks the environment to see if we even have any hints.  If it has no hints,
diff --git a/sys/sys/kernel.h b/sys/sys/kernel.h
index 01673ac3395e..c38b778f54e3 100644
--- a/sys/sys/kernel.h
+++ b/sys/sys/kernel.h
@@ -101,6 +101,7 @@ enum sysinit_sub_id {
 	SI_SUB_VM		= 0x1000000,	/* virtual memory system init */
 	SI_SUB_COUNTER		= 0x1100000,	/* counter(9) is initialized */
 	SI_SUB_KMEM		= 0x1800000,	/* kernel memory */
+	SI_SUB_KENV		= 0x1900000,	/* kernel environment */
 	SI_SUB_HYPERVISOR	= 0x1A40000,	/*
 						 * Hypervisor detection and
 						 * virtualization support
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.