HomeFreeBSD

kern: Support duplicate variables in early kenv

Description

kern: Support duplicate variables in early kenv

Some virtual machines pass virtio MMIO device parameters via the kernel
command line as a series of virtio_mmio.device=<parameters> options.
These get translated into FreeBSD kernel environment variables; but
unfortunately they all use the same variable name, which resulted in
all but the first such parameter being ignored when the dynamic kernel
environment is set up from the initial environment buffers.

With this commit, duplicate environment settings will instead be stored
as ${name}_1, ${name}_2... ${name}_9999. In the unlikely event that
the same variable is set over 10000 times before the dynamic kernel
environment is set up, we panic.

Variable settings after the dynamic environment is initialized continue
to override the previously-set value; the change is limited to the very
early kernel boot (prior to SI_SUB_KMEM + 1) and changes behaviour from
"ignore" to "store with a different name" only.

Reviewed by: imp
Feedback from: kevans
Sponsored by: https://patreon.com/cperciva
Differential Revision: https://reviews.freebsd.org/D36187

Details

Provenance
cpercivaAuthored on Aug 13 2022, 12:14 AM
Reviewer
imp
Differential Revision
D36187: kern: Support duplicate variables in early kenv
Parents
rGd6eabdac2ef4: dpaa2: fix build without WITNESS
Branches
Unknown
Tags
Unknown