Skip to main content

load_module

Function load_module 

Source
pub fn load_module(
    world_id: u64,
    caps: &HwCaps,
    gpa: u64,
    bytes: &[u8],
) -> Result<(), VmError>
Expand description

Loads a guest module/initrd blob into a world’s guest memory.

This is the initrd/module companion of load_image: the bytes are not parsed, they are mapped read/write at gpa and copied verbatim. gpa must be 4 KiB aligned, the blob must be non-empty and at most MAX_MODULE_BYTES, and at most MAX_MODULES_PER_WORLD ranges can be recorded per world. The range is recorded for write_boot_params.

Loading is not atomic: if the module table is full, or if the copy cannot translate a page, the pages already mapped stay in place (the world memory layer has no unmap primitive) and the caller should destroy the world.