Skip to content

Latest commit

 

History

History
146 lines (120 loc) · 7.56 KB

3.1-platform-control-device.md

File metadata and controls

146 lines (120 loc) · 7.56 KB

3.1 Platform Control Device

Architecture documentation > 3. Virtual Devices

Table 3.1 lists the three port-mapped I/O (PMIO) device functions that the platform uses.

Table 3.1. Platform-control device functions.

Port Function Architectural purpose
0xe9..0xeb Host/guest byte channel Early console data, restore metadata, generation identity, and host time samples
0x604 Shutdown Guest-requested process termination with a status byte
0x605 Snapshot request Guest-initiated capture and post-restore acknowledgement

PMIO callbacks perform only bounded state updates and notifications. They never pause virtual processors, drain devices, hash memory, or write files; lifecycle work is deferred to the VM controller and the state-unit graph.

3.1.1 Host/Guest Byte Channel

The byte channel is the simplest path between the guest and the host, and every microVM has one. It takes the place of the serial port, which the machine omits, and carries:

  • The guest's console. The kernel writes its boot messages to the channel from early in its initialization, before it probes any driver, and the channel is also the kernel console unless a boot console is configured. The channel takes no host input, so host input reaches the guest only through its consoles.
  • Failure reports from the guest agents, including failures of the control console.
  • The one-time restore packet, which gives a restored guest what it needs to repair its clocks, processors, and memory, the network settings of a network policy that the restore installed, and the fresh random bytes from which it refreshes its entropy.
  • Host time samples, which pair host UTC with the guest TSC and carry the host's clock correction, from which the guest sets and disciplines its wall clock.
  • The generation ID, a random identifier unique to each VM process. Every restored process receives a new one, even when several clones run from one snapshot, so the guest can detect that it has been restored and distinguish itself from other clones.

The channel deliberately does not depend on virtio discovery. The guest finds its virtio devices only after its kernel has parsed their discovery tokens and probed their drivers, and the consoles among them are optional. Through the byte channel, a guest that fails before or during discovery, or whose virtio devices fail, can still report the failure. The VMM also drains the channel before it reports a guest-requested exit, so the guest's final output is not silently lost; see Final Output and Exit Status.

The channel's protocol is also minimal: it needs no feature negotiation, queues in guest memory, or interrupt line. Each output byte is one port write, and the guest reads records and status with port reads. Every access to the channel's ports is a synchronous exit that the VMM completes before the guest continues, so a host time that the VMM records during an access lies between two guest TSC reads taken around it. The guest checks each time sample's pairing of host UTC with its TSC against them.

As Table 3.2 shows, the byte channel's three ports form one device: a data port, a status and record-selector port, and a time-sample window.

Table 3.2. Byte-channel ports.

Port Access Behavior
0xe9 Read and write Raw byte output. Without a selected record, a read returns zeros. With a record selected, a 1-, 2-, or 4-byte read returns that many bytes of the record, little-endian and zero-filled past its end.
0xea Read Status bits, listed in Table 3.3
0xea Write Record selector: 0xa5 selects the one-time restore packet, 0xa6 selects the 16-byte generation ID, and 0xa7 latches a fresh time sample without changing the 0xe9 selection
0xeb Read The next bytes of the latched time sample, zero-filled past its end or when no sample is latched

Table 3.3 lists the status bits.

Table 3.3. Byte-channel status bits.

Status bit Meaning
0 Zero: the channel takes no host input
1 A fresh restore packet is available
2 The restore carries a processor target
3 The restore carries a memory target
4 The memory target contains one or more expansion ranges
5 The generation-ID selector is available
6 The time-sample window exists; always set
7 Zero

The generation ID may be selected repeatedly and is stable for the lifetime of one VM process. After a restore, the guest agents require it to differ from the ID that they recorded before capture, or repair fails. A clone's guest agents also credit it, as part of the restore entropy, to the kernel's random-number generator and expose it to the workload runtime's post-restore hook, so that random-number state that clones would otherwise share is refreshed. Generations describes how a restored guest checks the ID, and Entropy Refresh how it obtains fresh random numbers.

The time-sample window is separate from the data port, so that the guest can latch and read a sample without changing the data port's record selection. Guest users of the selectors serialize their transactions. Every byte the guest reads is a port exit, so records are small and readable four bytes per exit.

The transmit buffer is bounded at 1 MiB. Overflow drops the newest bytes and emits a rate-limited warning. Output stays pending until the host endpoint accepts it: while no peer is connected, and after a write to the endpoint fails, whatever the error. Pending output is saved, so capture does not silently lose VMM-owned output, and the restored VM writes it to its endpoint. A restore refuses saved state that holds host input, as a snapshot of an earlier VMM can. The time-sample window is not saved state.

Since the channel takes no host input, gating host input for a snapshot boundary or post-restore repair leaves it unchanged: guest output, the generation ID, any restore packet, and the time-sample window remain available.

3.1.2 Shutdown

The first byte written to the shutdown port becomes the process status carried with the VM power-off request; reads return all ones. Shutdown initiates orderly VM teardown rather than emulating PC power management. Shutdown and Failure Semantics describes the final drain and status propagation.

3.1.3 Snapshot Request

A write to the snapshot port requests capture. A zero byte requests fresh scratch, and a nonzero first byte requests paired scratch; the scratch policy travels with the deferred boundary request. Reads return all ones, and the port reports no capture status.

A write with no configured snapshot destination completes normally, and the guest continues. With a destination, the device permits at most one pending transaction, coalesces repeated writes, and defers completion long enough for the controller to stop the virtual processor at the exact instruction boundary immediately after the output operation.

After a gated restore, a write to the same port acknowledges that processor, memory, time, entropy, and workload state have been repaired. Host input is released only after the VMM stops at that acknowledgement boundary.