Start-of-day memory layout

group start_of_day_memory_layout

Start-of-day memory layout.

  1. The domain is started within contiguous virtual-memory region.
  2. The contiguous region ends on an aligned 4MB boundary.
  3. This the order of bootstrap elements in the initial virtual region: a. relocated kernel image b. initial ram disk [mod_start, mod_len] (may be omitted) c. list of allocated page frames [mfn_list, nr_pages] (unless relocated due to XEN_ELFNOTE_INIT_P2M) d. start_info_t structure [register rSI (x86)] in case of dom0 this page contains the console info, too e. unless dom0: xenstore ring page f. unless dom0: console ring page g. bootstrap page tables [pt_base and CR3 (x86)] h. bootstrap stack [register ESP (x86)]
  4. Bootstrap elements are packed together, but each is 4kB-aligned.
  5. The list of page frames forms a contiguous ‘pseudo-physical’ memory layout for the domain. In particular, the bootstrap virtual-memory region is a 1:1 mapping to the first section of the pseudo-physical map.
  6. All bootstrap elements are mapped read-writable for the guest OS. The only exception is the bootstrap page table, which is mapped read-only.
  7. There is guaranteed to be at least 512kB padding after the final bootstrap element. If necessary, the bootstrap virtual region is extended by an extra 4MB to ensure this.

Note: Prior to 25833:bb85bbccb1c9. (“x86/32-on-64 adjust Dom0 initial page table layout”) a bug caused the pt_base (3.g above) and cr3 to not point to the start of the guest page tables (it was offset by two pages). This only manifested itself on 32-on-64 dom0 kernels and not 32-on-64 domU or 64-bit kernels of any colour. The page tables for a 32-on-64 dom0 got allocated in the order: ‘first L1’,’first L2’, ‘first L3’, so the offset to the page table base is by two pages back. The initial domain if it is 32-bit and runs under a 64-bit hypervisor should NOT use two of the pages preceding pt_base and mark them as reserved/unused.


SIF_PRIVILEGED (1<<0) /* Is the domain privileged? */
SIF_INITDOMAIN (1<<1) /* Is this the initial control domain? */
SIF_MULTIBOOT_MOD (1<<2) /* Is mod_start a multiboot module? */
SIF_MOD_START_PFN (1<<3) /* Is mod_start a PFN? */
SIF_VIRT_P2M_4TOOLS (1<<4) /* Do Xen tools understand a virt. mapped */
SIF_PM_MASK (0xFF<<8) /* reserve 1 byte for xen-pm options */