src/x86/layout.bend checks
raw source on the hub · import 0x79c2f5323029fcb91b9cbd02db6800f6/src/x86/layout.bend as Layout
3 imports
import Base import ../lib/u64.bend as U import ../vmm/layout.bend as L
Definitions
def X86.low_max source · line 23 · raw
0x79c2f5323029fcb91b9cbd02db6800f6/src/lib/u64.U64
3 GiB (0xC000_0000): low RAM ends here at most.
def X86.high_base source · line 27 · raw
0x79c2f5323029fcb91b9cbd02db6800f6/src/lib/u64.U64
4 GiB: RAM past low_max continues here.
def X86.low_size source · line 31 · raw
@+size:0x79c2f5323029fcb91b9cbd02db6800f6/src/lib/u64.U64 -> 0x79c2f5323029fcb91b9cbd02db6800f6/src/lib/u64.U64
Low RAM: [0, min(size, 3 GiB)).
def X86.high_size source · line 35 · raw
@+size:0x79c2f5323029fcb91b9cbd02db6800f6/src/lib/u64.U64 -> 0x79c2f5323029fcb91b9cbd02db6800f6/src/lib/u64.U64
RAM past 3 GiB, mapped at 4 GiB (0 when RAM fits below).
def X86.virtio_base source · line 38 · raw
0x79c2f5323029fcb91b9cbd02db6800f6/src/lib/u64.U64
def X86.virtio_slot source · line 42 · raw
@n:U32 -> 0x79c2f5323029fcb91b9cbd02db6800f6/src/lib/u64.U64
Base address of virtio slot n (512 bytes each).
def X86.ioapic_base source · line 45 · raw
U32
def X86.lapic_base source · line 48 · raw
U32
def X86.to_bus source · line 54 · raw
@+gpa:0x79c2f5323029fcb91b9cbd02db6800f6/src/lib/u64.U64 -> 0x79c2f5323029fcb91b9cbd02db6800f6/src/lib/u64.U64
A trapped guest address as the machine's bus sees it: the virtio slots move to L.Layout.virtio_base(); any other address goes to the machine's "no device" (0, which no bus device holds).
def X86.virtio_gsis source · line 62 · raw
List<&2, U32>
IOAPIC pins (GSIs) for the virtio slots: the ISA lines no legacy device here uses (0 timer, 1 keyboard, 2 cascade, 3 and 4 serial, 8 CMOS clock, 9 ACPI SCI are taken), then 16..23. 17 slots get a line; the others none.
def X86.uart_gsi source · line 66 · raw
U32
The COM1 16550's line.
def X86.no_gsi source · line 70 · raw
U32
255: no line.
def X86.slot_gsi source · line 74 · raw
@n:U32 -> U32
The GSI of virtio slot n, or no_gsi.
def X86.slots_with_lines source · line 78 · raw
U32
How many virtio slots have a line.
def X86.gsi_at source · line 85 · raw
@+intid:U32 -> U32
The machine's interrupt numbers (INTIDs) as IOAPIC pins: the table the host keeps (Hvf.x86_setup), indexed by INTID 0..79: L.Layout.uart_intid() is the 16550's line (X86.uart_gsi), virtio slot n's INTID is its GSI, everything else no_gsi.
def X86.gsi_table.go source · line 90 · raw
@n:Nat -> @+i:U32 -> List<&2, U32>
def X86.gsi_table source · line 97 · raw
List<&2, U32>
def X86.gdt source · line 105 · raw
U32
Boot structures in low RAM (decimal; hex in comments). GDT 1280 (0x500), the zero page (boot_params) 28672 (0x7000), the boot stack's top 36848 (0x8FF0), page tables: PML4 36864 (0x9000), PDPT 40960 (0xA000), PD 45056 (0xB000), the command line 131072 (0x2_0000), the ACPI tables 917504 (0xE_0000).
def X86.zero_page source · line 108 · raw
U32
def X86.stack_top source · line 111 · raw
U32
def X86.pml4 source · line 114 · raw
U32
def X86.pdpt source · line 117 · raw
U32
def X86.pd source · line 120 · raw
U32
def X86.cmdline source · line 123 · raw
U32
def X86.acpi source · line 126 · raw
U32
def X86.ebda source · line 131 · raw
U32
The legacy hole: [654336, 1048576) (0x9_FC00 .. 0x10_0000) is not RAM to the guest (the EBDA, the VGA window, the BIOS area with the ACPI tables).
def X86.mib1 source · line 134 · raw
U32
def X86.reset_vector source · line 138 · raw
U32
The real-mode reset vector, F000:FFF0: 1048560 (0xF_FFF0), in the hole.
def X86.kvm_words source · line 149 · raw
List<&2, U32>
KVM's own pieces of the machine, as the words Hvf.x86_setup takes: RAM's low end and high base (hi, lo each: X86.low_max, X86.high_base), where VMX's identity-map page (4278173696, 0xFEFF_C000) and its three TSS pages (4278177792, 0xFEFF_D000) go (in the hole below 4 GiB, clear of the IOAPIC and the local APICs), the local APIC's LINT0 delivery mode (7 ExtINT: the PIC's line, as a PC's firmware leaves it) and LINT1's (4 NMI), and the PIT's flags (1: KVM_PIT_SPEAKER_DUMMY, port 0x61 is KVM's).
def X86.cpu_plan source · line 163 · raw
List<&2, U32>
What an x86_64 snapshot keeps (Hvf.snap_plans), in the order a restore applies it. Per vCPU: the registers (1), the FPU and vector state (3, XSAVE), XCR0 (4), the segment and control registers (2: after the registers, before the MSRs that depend on EFER), the local APIC (6: after the APIC base in 2, before the MSRs: KVM drops a TSC deadline written while the APIC timer is not in TSC-deadline mode, and the restored timer would never fire), the MSRs KVM lists (5), the run state (7: an AP waiting for its SIPI stays waiting), pending events (8), the debug registers (9). For the VM: the PICs (20, 21), the IOAPIC (22), the PIT (23), KVM's clock (24: kvmclock goes on from where it was), the port machine (25, src/x86/pio.bend's Pio.saved).
def X86.vm_plan source · line 166 · raw
List<&2, U32>
def X86.pic_words source · line 175 · raw
List<&2, U32>
The PICs as a PC's firmware leaves them (Hvf.x86_setup): the master's vectors from 8 and the slave's from 112 (0x70), every line masked (255). Linux under hardware-reduced ACPI never programs them; left as KVM makes them (vectors from 0, unmasked), the PIT's ticks wait at the master, and a reboot that puts the local APIC back in virtual-wire mode (LINT0 as ExtINT) takes one as vector 0 mid-shutdown.