1# Memory Layout 2 3## x86-64 guest physical memory map 4 5This is a survey of the existing memory layout for crosvm on x86-64 when booting a Linux kernel. Some of these values are different when booting a BIOS image; 6see the source. All addresses are in hexadecimal. 7 8| Name/source link | Address | End (exclusive) | Size | Notes | 9| ---------------------------- | ------------- | --------------- | --------- | ---------------------------------------------------------------------------------------- | 10| | `0000` | `A_0000` | 640 KiB | RAM (\<1M) | 11| [`MULTIBOOT_INFO_OFFSET`] | `6000` | `7000` | 4 KiB | Multiboot info structure | 12| [`ZERO_PAGE_OFFSET`] | `7000` | | | Linux boot_params structure | 13| [`BOOT_STACK_POINTER`] | `8000` | | | Boot SP value | 14| [`boot_pml4_addr`] | `9000` | `A000` | 4 KiB | Boot page table | 15| [`boot_pdpte_addr`] | `A000` | `B000` | 4 KiB | Boot page table | 16| [`boot_pde_addr`] | `B000` | `F000` | 16 KiB | Boot page tables | 17| [`CMDLINE_OFFSET`] | `2_0000` | `2_0800` | 2 KiB | Linux kernel command line | 18| [`SETUP_DATA_START`] | `2_0800` | `9_FC00` | 509 KiB | Linux kernel `setup_data` linked list | 19| [`MPTABLE_START`] | `9_FC00` | `A_0000` | 1 KiB | MultiProcessor Specification Configuration Table | 20| [`ACPI_HI_RSDP_WINDOW_BASE`] | `E_0000` | | | ACPI tables | 21| [`mem_1m_to_4g`] | `10_0000` | `D000_0000` | ~3.24 GiB | RAM (\<4G) | 22| [`KERNEL_START_OFFSET`] | `20_0000` | | | Linux kernel image load address | 23| [`initrd_start`] | after kernel | | | Initial RAM disk for Linux kernel (optional) | 24| [`PROTECTED_VM_FW_START`] | `7FC0_0000` | `8000_0000` | 4 MiB | pVM firmware (if running a protected VM) | 25| [`pci_mmio_before_32bit`] | `D000_0000` | `F400_0000` | 576 MiB | Low (\<4G) MMIO allocation area | 26| [`PCIE_CFG_MMIO_START`] | `F400_0000` | `F800_0000` | 64 MiB | PCIe enhanced config (ECAM) | 27| [`RESERVED_MEM_SIZE`] | `F800_0000` | `1_0000_0000` | 128 MiB | LAPIC/IOAPIC/HPET/… | 28| [`IDENTITY_MAP_ADDR`] | `FEFF_C000` | | | Identity map segment | 29| [`TSS_ADDR`] | `FEFF_D000` | | | Boot task state segment | 30| | `1_0000_0000` | | | RAM (>4G) | 31| | (end of RAM) | | | High (>4G) MMIO allocation area | 32 33[`multiboot_info_offset`]: https://crsrc.org/o/src/platform/crosvm/x86_64/src/lib.rs;l=381?q=MULITBOOT_INFO_OFFSET 34[`zero_page_offset`]: https://crsrc.org/o/src/platform/crosvm/x86_64/src/lib.rs;l=368?q=ZERO_PAGE_OFFSET 35[`boot_stack_pointer`]: https://crsrc.org/o/src/platform/crosvm/x86_64/src/lib.rs;l=350?q=BOOT_STACK_POINTER 36[`boot_pml4_addr`]: https://crsrc.org/o/src/platform/crosvm/x86_64/src/regs.rs;l=297?q=boot_pml4_addr 37[`boot_pdpte_addr`]: https://crsrc.org/o/src/platform/crosvm/x86_64/src/regs.rs;l=298?q=boot_pdpte_addr 38[`boot_pde_addr`]: https://crsrc.org/o/src/platform/crosvm/x86_64/src/regs.rs;l=299?q=boot_pde_addr 39[`cmdline_offset`]: https://crsrc.org/o/src/platform/crosvm/x86_64/src/lib.rs;l=373?q=CMDLINE_OFFSET 40[`setup_data_start`]: https://crsrc.org/o/src/platform/crosvm/x86_64/src/lib.rs;l=375?q=SETUP_DATA_START 41[`mptable_start`]: https://crsrc.org/o/src/platform/crosvm/x86_64/src/mptable.rs;l=72?q=MPTABLE_START 42[`acpi_hi_rsdp_window_base`]: https://crsrc.org/o/src/platform/crosvm/x86_64/src/lib.rs;l=388?q=ACPI_HI_RSDP_WINDOW_BASE 43[`kernel_start_offset`]: https://crsrc.org/o/src/platform/crosvm/x86_64/src/lib.rs;l=372?q=KERNEL_START_OFFSET 44[`initrd_start`]: https://crsrc.org/o/src/platform/crosvm/x86_64/src/lib.rs;l=1692?q=initrd_start 45[`protected_vm_fw_start`]: https://crsrc.org/o/src/platform/crosvm/x86_64/src/lib.rs;l=394?q=PROTECTED_VM_FW_START 46[`mem_1m_to_4g`]: https://crsrc.org/o/src/platform/crosvm/x86_64/src/lib.rs;l=737?q=mem_1m_to_4g 47[`pci_mmio_before_32bit`]: https://crsrc.org/o/src/platform/crosvm/x86_64/src/lib.rs;l=456?q=pci_mmio_before_32bit 48[`pcie_cfg_mmio_start`]: https://crsrc.org/o/src/platform/crosvm/x86_64/src/lib.rs;l=363?q=PCIE_CFG_MMIO_START 49[`reserved_mem_size`]: https://crsrc.org/o/src/platform/crosvm/x86_64/src/lib.rs;l=358?q=RESERVED_MEM_SIZE 50[`identity_map_addr`]: https://crsrc.org/o/src/platform/crosvm/x86_64/src/lib.rs;l=500?q=identity_map_addr_start 51[`tss_addr`]: https://crsrc.org/o/src/platform/crosvm/x86_64/src/lib.rs;l=505?q=tss_addr_start 52 53## aarch64 guest physical memory map 54 55All addresses are IPA in hexadecimal. 56 57### Common layout 58 59These apply for all boot modes. 60 61| Name/source link | Address | End (exclusive) | Size | Notes | 62| --------------------------------- | --------------- | --------------- | ---------- | ------------------------------------------------------------- | 63| [`SERIAL_ADDR[3]`][serial_addr] | `2e8` | `2f0` | 8 bytes | Serial port MMIO | 64| [`SERIAL_ADDR[1]`][serial_addr] | `2f8` | `300` | 8 bytes | Serial port MMIO | 65| [`SERIAL_ADDR[2]`][serial_addr] | `3e8` | `3f0` | 8 bytes | Serial port MMIO | 66| [`SERIAL_ADDR[0]`][serial_addr] | `3f8` | `400` | 8 bytes | Serial port MMIO | 67| [`AARCH64_RTC_ADDR`] | `2000` | `3000` | 4 KiB | Real-time clock | 68| [`AARCH64_VMWDT_ADDR`] | `3000` | `4000` | 4 KiB | Watchdog device | 69| [`AARCH64_PCI_CAM_BASE_DEFAULT`] | `1_0000` | `101_0000` | 16 MiB | PCI configuration (CAM) | 70| [`AARCH64_VIRTFREQ_BASE`] | `104_0000` | `105_0000` | 64 KiB | Virtual cpufreq device | 71| [`AARCH64_PVTIME_IPA_START`] | `1ff_0000` | `200_0000` | 64 KiB | Paravirtualized time | 72| [`AARCH64_PCI_MEM_BASE_DEFAULT`] | `200_0000` | `400_0000` | 32 MiB | Low MMIO allocation area | 73| [`AARCH64_GIC_CPUI_BASE`] | `3ffd_0000` | `3fff_0000` | 128 KiB | vGIC | 74| [`AARCH64_GIC_DIST_BASE`] | `3fff_0000` | `4000_0000` | 64 KiB | vGIC | 75| [`AARCH64_PROTECTED_VM_FW_START`] | `7fc0_0000` | `8000_0000` | 4 MiB | pVM firmware (if running a protected VM) | 76| [`AARCH64_PHYS_MEM_START`] | `8000_0000` | | --mem size | RAM (starts at IPA = 2 GiB) | 77| [`plat_mmio_base`] | after RAM | +0x800000 | 8 MiB | Platform device MMIO region | 78| [`high_mmio_base`] | after plat_mmio | max phys addr | | High MMIO allocation area | 79 80### RAM Layout 81 82The RAM layout depends on the `--fdt-position` setting, which defaults to 83`start` when load using `--bios` and to `end` when using `--kernel`. 84 85In `--kernel` mode, the initrd is always loaded immediately after the kernel, 86with a 16 MiB alignment. 87 88#### --fdt-position=start 89 90| Name/source link | Address | End (exclusive) | Size | Notes | 91| ------------------------- | ----------------- | --------------- | ----- | -------------------------------- | 92| [`fdt_address`] | `8000_0000` | `8020_0000` | 2 MiB | Flattened device tree in RAM | 93| [`payload_address`] | `8020_0000` | | | Kernel/BIOS load location in RAM | 94 95#### --fdt-position=after-payload 96 97| Name/source link | Address | End (exclusive) | Size | Notes | 98| ------------------------- | ----------------------------------- | --------------- | ----- | -------------------------------- | 99| [`payload_address`] | `8000_0000` | | | Kernel/BIOS load location in RAM | 100| [`fdt_address`] | after payload (2 MiB alignment) | | 2 MiB | Flattened device tree in RAM | 101 102#### --fdt-position=end 103 104| Name/source link | Address | End (exclusive) | Size | Notes | 105| ------------------------- | ----------------------------------- | --------------- | ----- | -------------------------------- | 106| [`payload_address`] | `8000_0000` | | | Kernel/BIOS load location in RAM | 107| [`fdt_address`] | before end of RAM (2 MiB alignment) | | 2 MiB | Flattened device tree in RAM | 108 109[serial_addr]: https://crsrc.org/o/src/platform/crosvm/arch/src/serial.rs;l=78?q=SERIAL_ADDR 110[`aarch64_rtc_addr`]: https://crsrc.org/o/src/platform/crosvm/aarch64/src/lib.rs;l=177?q=AARCH64_RTC_ADDR 111[`aarch64_vmwdt_addr`]: https://crsrc.org/o/src/platform/crosvm/aarch64/src/lib.rs;l=187?q=AARCH64_VMWDT_ADDR 112[`aarch64_virtfreq_base`]: https://crsrc.org/o/src/platform/crosvm/aarch64/src/lib.rs;l=207?q=AARCH64_VIRTFREQ_BASE 113[`aarch64_pci_cam_base_default`]: https://crsrc.org/o/src/platform/crosvm/aarch64/src/lib.rs;l=154?q=AARCH64_PCI_CAM_BASE_DEFAULT 114[`aarch64_pci_mem_base_default`]: https://crsrc.org/o/src/platform/crosvm/aarch64/src/lib.rs;l=154?q=AARCH64_PCI_MEM_BASE_DEFAULT 115[`aarch64_gic_cpui_base`]: https://crsrc.org/o/src/platform/crosvm/devices/src/irqchip/kvm/aarch64.rs;l=106?q=AARCH64_GIC_CPUI_BASE 116[`aarch64_gic_dist_base`]: https://crsrc.org/o/src/platform/crosvm/aarch64/src/lib.rs;l=105?q=AARCH64_GIC_DIST_BASE 117[`aarch64_pvtime_ipa_start`]: https://crsrc.org/o/src/platform/crosvm/aarch64/src/lib.rs;l=100?q=AARCH64_PVTIME_IPA_START 118[`aarch64_protected_vm_fw_start`]: https://crsrc.org/o/src/platform/crosvm/aarch64/src/lib.rs;l=96?q=AARCH64_PROTECTED_VM_FW_START 119[`aarch64_phys_mem_start`]: https://crsrc.org/o/src/platform/crosvm/aarch64/src/lib.rs;l=85?q=AARCH64_PHYS_MEM_START 120[`plat_mmio_base`]: https://crsrc.org/o/src/platform/crosvm/aarch64/src/lib.rs;l=835?q=plat_mmio_base 121[`high_mmio_base`]: https://crsrc.org/o/src/platform/crosvm/aarch64/src/lib.rs;l=838?q=high_mmio_base 122[`fdt_address`]: https://crsrc.org/o/src/platform/crosvm/aarch64/src/lib.rs;l=301?q=fdt_address 123[`payload_address`]: https://crsrc.org/o/src/platform/crosvm/aarch64/src/lib.rs;l=301?q=payload_address 124