Skip to content

Commit fbc6e1c

Browse files
mhiramatrostedt
authored andcommitted
docs: bootconfig: Update file format on initrd image
To align the total file size, add padding null character when appending the bootconfig to initrd image. Link: https://lkml.kernel.org/r/160576522916.320071.4145530996151028855.stgit@devnote2 Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent e1cef2d commit fbc6e1c

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

Documentation/admin-guide/bootconfig.rst

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,22 @@ Boot Kernel With a Boot Config
137137
==============================
138138

139139
Since the boot configuration file is loaded with initrd, it will be added
140-
to the end of the initrd (initramfs) image file with size, checksum and
141-
12-byte magic word as below.
140+
to the end of the initrd (initramfs) image file with padding, size,
141+
checksum and 12-byte magic word as below.
142142

143-
[initrd][bootconfig][size(u32)][checksum(u32)][#BOOTCONFIG\n]
143+
[initrd][bootconfig][padding][size(u32)][checksum(u32)][#BOOTCONFIG\n]
144+
145+
When the boot configuration is added to the initrd image, the total
146+
file size is aligned to 4 bytes. To fill the gap, null characters
147+
(``\0``) will be added. Thus the ``size`` is the length of the bootconfig
148+
file + padding bytes.
144149

145150
The Linux kernel decodes the last part of the initrd image in memory to
146151
get the boot configuration data.
147152
Because of this "piggyback" method, there is no need to change or
148-
update the boot loader and the kernel image itself.
153+
update the boot loader and the kernel image itself as long as the boot
154+
loader passes the correct initrd file size. If by any chance, the boot
155+
loader passes a longer size, the kernel feils to find the bootconfig data.
149156

150157
To do this operation, Linux kernel provides "bootconfig" command under
151158
tools/bootconfig, which allows admin to apply or delete the config file
@@ -176,7 +183,8 @@ up to 512 key-value pairs. If keys contains 3 words in average, it can
176183
contain 256 key-value pairs. In most cases, the number of config items
177184
will be under 100 entries and smaller than 8KB, so it would be enough.
178185
If the node number exceeds 1024, parser returns an error even if the file
179-
size is smaller than 32KB.
186+
size is smaller than 32KB. (Note that this maximum size is not including
187+
the padding null characters.)
180188
Anyway, since bootconfig command verifies it when appending a boot config
181189
to initrd image, user can notice it before boot.
182190

0 commit comments

Comments
 (0)