Skip to main content

Module guestcode

Module guestcode 

Source
Expand description

s9vm : machine-code payloads used by the host-side smoke tests.

The payloads live in a pure module so they can be decoded by the kernel’s own instruction decoder in a host test, not only executed on a machine that exposes hardware virtualization. A wrong payload encoding otherwise only shows up as a triple fault at boot: the guest walks into zero-filled memory and faults far away from the real problem, which is expensive to diagnose on hardware.

The guestos phase payload is deliberately not stored here: it is assembled at run time by crate::s9vm::guestprog::guestos, so every instruction is a typed encoding that the host tests re-decode. The arrays below remain hand-written for the phases that predate the assembler.

§Loader payload

LOADER_CODE is the guest program of the image-loader phase: publish the marker on the debug port, then halt.

BytesInstruction
B0 <marker>mov al, marker
E6 E9out 0xE9, al
F4hlt

The I/O instruction uses the immediate-port form on purpose: in 64-bit mode BA is MOV r32, imm32 (five bytes), not MOV DX, imm16; the register-port form would need a 66 operand-size prefix. A first version of this payload used BA E9 00 EE F4, which the processor decoded as mov edx, 0xF4EE00E9: the guest then ran into the zero-filled tail of its page and triple-faulted at the page boundary.

Constants§

ACPI_CODE
Guest program of the ACPI-discovery phase.
ACPI_FAIL_MARKER
Byte published by the ACPI-discovery guest when a check failed.
ACPI_FAIL_TAIL
Offset of the failure tail (failure marker + hlt) inside ACPI_CODE.
ACPI_MARKER
Byte published by the ACPI-discovery guest when every check passed.
ACPI_SUCCESS_TAIL
Offset of the success tail (marker + count + hlt) inside ACPI_CODE.
DEBUG_PORT
I/O port the loader-phase guest writes its marker to.
HLT
hlt opcode, the last instruction of every payload.
LOADER_CODE
Guest program of the image-loader phase (see the module documentation).
LOADER_MARKER
Byte published by the loader-phase guest on the debug port.
SMP_CODE_0
Guest program of the first vCPU of the SMP phase.
SMP_CODE_1
Guest program of the second vCPU of the SMP phase.
SMP_HLT_OFFSET
Offset of the final hlt inside SMP_CODE_0 and SMP_CODE_1.
SMP_MARKERS
Per-vCPU markers published by the SMP payloads ([vcpu0, vcpu1]).
SMP_OUT_INSTRUCTION_LEN
Length of the out instruction in the SMP payloads (out 0xE9, al).
SMP_SHARED_GPA
Guest-physical page shared by both vCPUs of the SMP phase.