supermachine 0.7.3

Run any OCI/Docker image as a hardware-isolated microVM on macOS HVF (Linux KVM and Windows WHP in progress). Single library API, zero flags for the common case, sub-100 ms cold-restore from snapshot.
// Guest physical address layout. Standard values for the Linux
// aarch64 boot protocol — these are dictated by what the kernel
// expects, not free parameters.

/// Start of guest RAM when loading a kernel image. Linux aarch64
/// boot protocol expects the kernel at offset 0x80000 from the
/// start of RAM.
pub const DRAM_MEM_START_KERNEL: u64 = 0x8000_0000; // 2 GB
pub const DRAM_MEM_END: u64 = 0x00FF_8000_0000;
pub const DRAM_MEM_MAX_SIZE: u64 = DRAM_MEM_END - DRAM_MEM_START_KERNEL;

/// Linux aarch64 boot protocol: kernel image at RAM_START + 0x80000.
pub const KERNEL_LOAD_OFFSET: u64 = 0x80000;

/// Cmdline + FDT layout constants.
pub const CMDLINE_MAX_SIZE: usize = 2048;
pub const FDT_MAX_SIZE: usize = 0x20_0000;

/// IRQ allocation. SPIs start at 32; we reserve up to 160.
pub const IRQ_BASE: u32 = 32;
pub const IRQ_MAX: u32 = 159;

/// vtimer SPI INTID is 11 (PPI base) + 16 (SPI offset) = 27.
pub const VTIMER_IRQ: u32 = 27;

/// MMIO region starts here. Below: GIC. Above: virtio devices.
pub const MAPPED_IO_START: u64 = 0x0a00_0000;

/// GIC v3: distributor + per-vCPU redistributor frames. The
/// redistributor area is `GICV3_REDIST_STRIDE * n_vcpus` bytes
/// at `GICV3_REDIST_BASE`. Stride = 0x20000 (RD_base 0x10000
/// + SGI_base 0x10000) per vCPU.
pub const GICV3_DIST_BASE: u64 = 0x0800_0000;
pub const GICV3_DIST_SIZE: u64 = 0x0001_0000;
pub const GICV3_REDIST_BASE: u64 = 0x0808_0000;
pub const GICV3_REDIST_STRIDE: u64 = 0x0002_0000;

/// First virtio-mmio device base; subsequent devices stride by 0x200.
pub const VIRTIO_MMIO_BASE: u64 = 0x0a00_0000;
pub const VIRTIO_MMIO_STRIDE: u64 = 0x200;

/// Serial console MMIO. Stub PL011 layout for boot-time logging.
pub const SERIAL_MMIO_BASE: u64 = 0x0900_0000;
pub const SERIAL_MMIO_SIZE: u64 = 0x1000;
pub const SERIAL_IRQ: u32 = 33;

/// virtio-fs DAX window. Lives well above the max plausible guest
/// RAM but BELOW the IPA ceiling HVF gives us with a default config
/// (~36-bit IPA = 64 GiB on Apple Silicon). 32 GiB base + 8 GiB
/// window = 40 GiB top; comfortably under the ceiling.
///
/// Costs nothing in host RAM at rest: the window is just guest
/// physical address space. Stage-2 page tables only materialize
/// when SETUPMAPPING actually maps a region into the window.
///
/// If we ever need to expand: `hv_vm_config_set_*` can negotiate
/// up to 48-bit IPA, but the cost is per-vCPU + per-mapping
/// overhead in the stage-2 walk. 64 GiB has plenty of headroom
/// for typical workloads — only bake-time `memoryMib` over ~30 GiB
/// would conflict with DAX_BASE here.
pub const VIRTIOFS_DAX_BASE: u64 = 0x8_0000_0000; // 32 GiB
pub const VIRTIOFS_DAX_LEN: u64 = 8 * 1024 * 1024 * 1024; // 8 GiB