Skip to content

Commit

Permalink
x86/Documentation: Update algo in init_size description of boot protocol
Browse files Browse the repository at this point in the history
The init_size description of boot protocol has an example of the runtime
start address for the compressed bzImage. For non-relocatable kernel
it relies on the pref_address value (if not 0), but for relocatable case
only pays respect to the load_addres and kernel_alignment, and it is
inaccurate for the latter. Boot loader must consider the pref_address
as the Linux kernel relocates to it before being decompressed as nicely
described in this commit message a year ago:

  43b1d3e ("kexec: Allocate kernel above bzImage's pref_address")

Due to this documentation inaccuracy some of the bootloaders (*) made a
mistake in the calculations and if kernel image is big enough, this may
lead to unbootable configurations.

*)
  In particular, kexec-tools missed that and resently got a couple of
  changes which will be part of v2.0.30 release. For the record,
  commit 43b1d3e only fixed the kernel kexec implementation and
  also missed to update the init_size description.

While at it, make an example C-like looking as it's done elsewhere in
the document and fix indentation as presribed by the reStructuredText
specifications, so the syntax highliting will work properly.

Fixes: 43b1d3e ("kexec: Allocate kernel above bzImage's pref_address")
Fixes: d297366 ("x86: document new bzImage fields")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Link: https://lore.kernel.org/r/20241125105005.1616154-1-andriy.shevchenko@linux.intel.com
  • Loading branch information
Andy Shevchenko authored and Ingo Molnar committed Nov 25, 2024
1 parent c809b0d commit be4ca6c
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Documentation/arch/x86/boot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -896,10 +896,19 @@ Offset/size: 0x260/4

The kernel runtime start address is determined by the following algorithm::

if (relocatable_kernel)
runtime_start = align_up(load_address, kernel_alignment)
else
runtime_start = pref_address
if (relocatable_kernel) {
if (load_address < pref_address)
load_address = pref_address;
runtime_start = align_up(load_address, kernel_alignment);
} else {
runtime_start = pref_address;
}

Hence the necessary memory window location and size can be estimated by
a boot loader as::

memory_window_start = runtime_start;
memory_window_size = init_size;

============ ===============
Field name: handover_offset
Expand Down

0 comments on commit be4ca6c

Please sign in to comment.