Skip to main content

Module bootparams

Module bootparams 

Source
Expand description

s9vm : guest boot parameters (firmware hand-off block).

bootinfo is the compact s9vm-specific boot page. A real operating-system guest needs a richer hand-off: the physical memory map, the kernel command line, initrd/module ranges, console and device hints, and the RSDP pointer of the firmware tables built by acpi. This module defines that block.

The block has a fixed 1024-byte little-endian layout with a magic, a version, counts, a byte checksum (all the bytes of the block sum to zero modulo 256) and fixed-capacity arrays. Encoding and decoding are pure code and allocate nothing, so the kernel fills a stack buffer and copies it into guest memory, and a guest can validate the block with a single linear sum.

§Layout

OffsetSizeField
0x0008magic S9VMBP\0\0 (little-endian u64)
0x0084version (VERSION)
0x00C4block size (SIZE)
0x0104boot flags
0x0144memory entry count (<= 32)
0x0184module count (<= 4)
0x01C4command-line length (<= 256)
0x0208ACPI RSDP guest-physical address (0 = absent)
0x0288console MMIO base (virtio-mmio transport page)
0x0304console I/O APIC line
0x0341checksum
0x0353reserved, zero
0x038640memory map: 32 entries of 20 packed bytes
0x2B864modules: 4 entries of 16 packed bytes
0x2F8256command line, NUL padded
0x3F88reserved, zero

A memory entry is base: u64, len: u64, kind: u32; a module entry is base: u64, len: u64. Entries and the entry count are the only source of truth: unused trailing bytes are zero and must be ignored by readers.

The command line is not NUL-terminated: its length is authoritative and the remaining bytes of the 256-byte field are NUL padding, so a 256-byte command line uses the whole field with no terminator.

§Invariants

  • the magic, the version and the size match this module;
  • the checksum of the whole block is zero;
  • memory_count <= MAX_MEMORY_ENTRIES, module_count <= MAX_MODULE_ENTRIES and cmdline_len <= CMDLINE_MAX;
  • every memory entry uses one of the memory_kind values;
  • every flag set in BootParams::flags belongs to flags.

This module is pure core code and is host-tested by s9vm-tests.

Modules§

flags
Boot flags.
memory_kind
Kind of a memory map entry.

Structs§

BootParams
Guest boot parameters block.
MemoryEntry
One memory map entry.
ModuleEntry
One initrd/module entry.

Enums§

BootParamsError
Decoding and construction errors.

Constants§

CMDLINE_MAX
Maximum length of the inline kernel command line, in bytes.
CMDLINE_OFFSET
Offset of the inline command line.
MAGIC
Magic value: the ASCII bytes S9VMBP followed by two NUL bytes, read as a little-endian u64.
MAX_MEMORY_ENTRIES
Maximum number of memory map entries.
MAX_MODULE_ENTRIES
Maximum number of initrd/module entries.
MEMORY_ENTRY_SIZE
Wire size of one memory map entry: base: u64, len: u64, kind: u32.
MEMORY_OFFSET
Offset of the memory map, packed entries of MEMORY_ENTRY_SIZE bytes.
MODULE_ENTRY_SIZE
Wire size of one module entry: base: u64, len: u64.
MODULE_OFFSET
Offset of the module table, packed entries of MODULE_ENTRY_SIZE bytes.
OFF_CHECKSUM
Offset of the checksum byte.
OFF_CMDLINE_LEN
Offset of the command-line length field.
OFF_CONSOLE_IRQ
Offset of the console I/O APIC line field.
OFF_CONSOLE_MMIO
Offset of the console MMIO base field.
OFF_FLAGS
Offset of the boot flags field.
OFF_MAGIC
Offset of the magic field.
OFF_MEMORY_COUNT
Offset of the memory entry count field.
OFF_MODULE_COUNT
Offset of the module count field.
OFF_RSDP_GPA
Offset of the ACPI RSDP address field.
OFF_SIZE
Offset of the block size field.
OFF_VERSION
Offset of the version field.
SIZE
Total size of the block, in bytes.
VERSION
Layout version.

Functions§

checksum 🔒
Sums the bytes of bytes modulo 256.
get_u32 🔒
Reads a little-endian u32 at offset.
get_u64 🔒
Reads a little-endian u64 at offset.
put_u32 🔒
Writes a little-endian u32 at offset.
put_u64 🔒
Writes a little-endian u64 at offset.
seal 🔒
Writes the checksum byte so the whole block sums to zero.