MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/5642
Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
JIRA: https://issues.redhat.com/browse/RHEL-65546
Omitted-fix: 0a13b6c3c546 ("docs/zh_CN: Add new translation of admin-guide/bootconfig.rst")
Add the bootconfig binary to the kernel-tools package. CONFIG_BOOT_CONFIG is already enabled in RHEL and this allows having a separate file with the kernel parameters and is described at https://docs.kernel.org/admin-guide/bootconfig.html. We intend to use this for automotive for testing purposes since some embedded platforms limit the kernel command line paramters to 511 bytes.
This also required bringing the bootconfig support up to the latest upstream at the time of this writing since the tools/bootconfig/ binary would not compile.
This series was tested in qemu with the following procedure. Create a `/etc/kernel/bootconfig` file with the following contents that contain a kernel command line parameter that's longer than 511 bytes:
```
kernel {
systemd.random-seed=EYDERk+qnhjx+WOS5zTfsSIbKGDeeZhaAXG5AaxkYr6lDgjIEZHmjjejC1INyArPQ7eNUWqzO9f/RtRaSXeLE7nac3kmVkOBlRmvMplPZS64O/vvMmQq/DZPx3pRKkuB6hGTL9LjK0eQtBFbSHI6YNhMnxSuZa/GWYpiw2rJZDU7EclaJT3xNcn3HFCL3EzPdh+fKm1s6SXF5YEqzGzSgdxj9CFGtrHuyNEoGU/bRCGRTQk11YvSrJJUPfR6zYSfBG26+oNyMwC7YJaguw/rKmXrGmCnrLMJRFuL8ytD6kHBhQJjxT2i2OIc+iSgHAYwZjCfsk3M/vbOTGxDoNiIEjljhGXPhCZofmLM8CgB0R5u/0vKNrwdxpmvKaVQzbFcVMpbGZAyt842yhXCbPDpBzfwQzqtD6bCYIxTzmz0JFE/H0McTNnMOur4u2kKbLcxoO0x8VxR6xYtGDPPJQmlxom9Zx7fIinUDcwA4Id1LCWXJuxrBtJKMK6ig7thwGtNN6qui7hUTMyjsLxgodg8eLaKIJJX393Hqid7wTZ90XQPG5ndO1M0FHfK1zBFF/R3BWlonwpKeh2avFCUcJidg+TzXsDmF+ru+//MVNA3MXRNw14qh+MYX4Xy/pWYuc4GngidF5AOzL0hIbC+PmGCHD+ae6yhj/o/5HPjqmHYNUjpvjsIhGTZaSJj9+1/9y1gCiQfypJP4zFUNPRAHBFoALMgTbQVI+Y1ZnuuIBNnRWQz/wpeRFl5YZjXwJNqxQCNMgPhKABaLd3GXi85yELrLnV5sOlPbuMvf7gR9YzDO5qeUtN23xDp+zDGLmxgCgrDdnLy4Gqbc8Pxos7RqEovBSUb+vtEpjLjub8nMGOzKsdM7ZzYzrLC2ydeh5SFHo6t3T23Kwoo5m+4VYVOsX7exbGFL8429PSnXXvUIosq0WtyBP4xVY7a274sOTnypJ4THia+dEBPaQ7mxO4qqI2+dGMpbCMOOMm4UqflvCrbypUFDrtfsCuolB8ddyV5kiwmzGjJri425QGxpoJQvvlgSAgOgZBVbP/YmPl3MQGDUtkGMxLyll1jFRGwsJQTYb35bP8oYLIpylD+9bdAM4Ev+sIDbISc0ao409aN8IOt61tpq1nzuCA9TPmDwzmP/PUDBFivVTFIuHjMJxXtu+rSp77sbSSwIJa/sXOic+m6ID6itX6lAO2cQ3gaBY+KGoF18QR50S3hU5wr5soooJv7KVmArNYMXtVOHpAWd1s0XxaQBYBF1SEhU4XgT/wZKdUeMkJQVvPk0Lzz2zF2WPkZnAdxPzfUieUo5vFWe1s7BVOMOb3CNrIKN5XfjS4JWUflEYxfDHkhhgQUJ2b+4tQUOQ==
}
```
Edit `/etc/kernel/cmdline` and add `bootconfig` to the list of kernel command line arguments. You may also need to edit `/boot/loader/entries/*` as well.
Run `sudo bootconfig -a /etc/kernel/bootconfig /boot/initramfs-5.14.0-*`
When the system boots you will see messages like the following in the log:
```
Nov 07 01:07:38 localhost kernel: Load bootconfig: 1409 bytes 4 nodes
...
Nov 07 01:07:38 localhost systemd[1]: Successfully credited entropy passed on kernel command line.
Nov 07 01:07:38 localhost systemd[1]: Note that the seed provided this way is accessible to unprivileged programs. This functionality should not be used outside of testing environments.
```
`/proc/cmdline` will contain the `systemd.random-seed` variable.
Signed-off-by: Brian Masney <bmasney@redhat.com>
Approved-by: Eric Chanudet <echanude@redhat.com>
Approved-by: Chris von Recklinghausen <crecklin@redhat.com>
Approved-by: Jan Stancek <jstancek@redhat.com>
Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com>
Merged-by: Rado Vrbovsky <rvrbovsk@redhat.com>