Memory Setup
HVM boot memory setup
For HVM domains, hvm_build_setup_mem()
is responsible for deriving the memory
layout of the new domain, allocating the required memory and populating for the
new domain. It must:
- Derive the
e820
memory layout of the system memory of the domain including memory holes depending on PCI passthrough and vGPU flags. - Load the BIOS/UEFI firmware images
- Store the final MMIO hole parameters in the Xenstore
- Call the
libxenguest
functionxc_dom_boot_mem_init()
(see below) - Call
construct_cpuid_policy()
to apply the CPUIDfeatureset
policy
It starts this by:
- Getting
struct xc_dom_image
,max_mem_mib
, andmax_start_mib
. - Calculating start and size of lower ranges of the domain’s memory maps
- taking memory holes for I/O into account, e.g.
mmio_size
andmmio_start
.
- taking memory holes for I/O into account, e.g.
- Calculating
lowmem_end
andhighmem_end
.
Calling into libxenguest for the bootmem setup
hvm_build_setup_mem()
then calls the libxenguest
function
xc_dom_boot_mem_init()
to set up the boot memory of domains.
xl
CLI also uses it to set up the boot memory of domains.
It constructs the memory layout of the domain and allocates and populates
the main system memory of the domain using calls to
xc_domain_populate_physmap().
For more details on the VM build step involving xenguest
and Xen side see
https://wiki.xenproject.org/wiki/Walkthrough:_VM_build_using_xenguest