Skip to main content

Module linuxboot

Module linuxboot 

Source
Expand description

s9vm : guest-physical layout of a 64-bit boot-protocol guest.

Loading a 64-bit kernel is not only a parser problem: the boot loader must place several objects at addresses the kernel will find, keep them from overlapping, and hand over an identity mapping that covers exactly those objects. This module owns that decision:

ObjectGuest-physical addressWhy
boot parameter page0x1_0000fixed by the boot protocol
command line0x2_0000low memory, after the parameter page
guest page tables0x3_0000low memory, writable by the loader
boot stacktop of the low rangethe entry code needs a valid %rsp
kernel imagepref_address or 0x10_0000init_size window
initial ramdisk2 MiB aligned, above the imagemust not overlap it

The low range is the conventional first 640 KiB (0..=0x9_FFFF). Everything the loader writes below the first megabyte therefore lives in a range the guest kernel is told is usable memory, and the identity mapping given to the kernel covers it.

§Sub-architecture

The layout assumes the x86 PC sub-architecture (hardware_subarch = 0): the kernel image is loaded high, the real-mode setup block of the image is not executed (a 64-bit loader enters the image directly), and the boot parameter page carries the memory map built by the firmware layer (super::zeropage).

§Limits

The initial implementation keeps the kernel and the ramdisk below 4 GiB: the size of the guest is measured in 4 KiB pages and the second-level translation of this engine is compact below 4 GiB. Loading above 4 GiB is a layout extension, not an architectural limit of the boot protocol.

Testable on the host (L2 tests).

Re-exports§

use alloc::vec::Vec; 🔒
use super::guestpt::IdentityRange; 🔒
use super::guestpt::PtPerms; 🔒

Structs§

BootLayout
Where every boot object goes.
LayoutRequest
Inputs of the layout decision.

Enums§

LayoutError
Layout errors.

Constants§

BOOT_GDT_GPA
Guest-physical address of the descriptor table the entry contract requires.
BOOT_PARAMS_GPA
Guest-physical address of the boot parameter page (the “zero page”).
BOOT_PARAMS_SIZE
Size of the boot parameter page.
CMDLINE_GPA
Guest-physical address of the kernel command line.
CMDLINE_MAX
Maximum length of the kernel command line the loader accepts.
HIGH_LOAD_BASE
Default load address of the protected-mode kernel (1 MiB).
INITRD_ALIGN
Alignment of the initial ramdisk placement.
LOW_IDENTITY_END
End of the identity-mapped low range (page aligned, covers the EBDA hole).
LOW_MEMORY_END
End of the conventional low range (first 640 KiB usable).
MAX_GPA
Highest guest-physical address the layout may use (below 4 GiB).
PAGE_TABLES_GPA
Guest-physical address of the guest page tables.
STACK_GUARD_END
First address above the page tables the loader may use for the stack.
STACK_TOP
Top of the boot stack (%rsp at entry, stack grows down).

Functions§

align_up
Rounds value up to the next multiple of align.
kernel_base 🔒
Chooses the kernel load address.
page_table_budget
Number of 4 KiB frames to reserve for the guest page tables.
plan
Computes where every boot object goes.