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:
| Object | Guest-physical address | Why |
|---|---|---|
| boot parameter page | 0x1_0000 | fixed by the boot protocol |
| command line | 0x2_0000 | low memory, after the parameter page |
| guest page tables | 0x3_0000 | low memory, writable by the loader |
| boot stack | top of the low range | the entry code needs a valid %rsp |
| kernel image | pref_address or 0x10_0000 | init_size window |
| initial ramdisk | 2 MiB aligned, above the image | must 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§
- Boot
Layout - Where every boot object goes.
- Layout
Request - Inputs of the layout decision.
Enums§
- Layout
Error - 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 (
%rspat entry, stack grows down).
Functions§
- align_
up - Rounds
valueup to the next multiple ofalign. - 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.