tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

patch review: VirtIO early console support




In order to boot microvms with no legacy buses, early VirtIO console
support is needed to display kernel messages as soon as possible.
VirtIO implements an "emergency console"[1] with no need to setup
virtqueues, only using a 32 bits register to output data.
The use of this VirtIO console permits to avoid as many VMEXIT as
there are characters to be printed.

The following patch[2] implements this functionality to the virtio(4)
driver. The method to enumerate MMIO devices is abstracted through a
function pointer, enumerate_mmio_devices, which can be initialize to the
desired device listing method. For the x86 microvm, this is done by
reading kernel parameters.

This patch also includes required Taylor's kernel console patch support
for viocon(4).

Here's a typical QEMU command line for a fully MMIO-backed vm with
the KVM hypervisor:

qemu-system-x86_64 \
	-M microvm,rtc=off,acpi=off,pic=off,isa-serial=off,accel=kvm \
	-m 128 -cpu host,+invtsc -kernel ${KERNEL} \
	-append "root=ld0a console=viocon rw -v" \
	-display none -device virtio-blk-device,drive=hd0 \
	-drive file=${NBIMG},format=raw,id=hd0 \
	-device virtio-net-device,netdev=net0 \
	-netdev user,id=net0,ipv6=off,hostfwd=::2300-:22 \
	-chardev stdio,id=viocon0 -device virtio-serial-device \
	-device virtconsole,chardev=viocon0 \
	-global virtio-mmio.force-legacy=false

[1]: https://docs.oasis-open.org/virtio/virtio/v1.3/csd01/virtio-v1.3-csd01.html#x1-3240003
[2]: https://imil.net/NetBSD/viocon.patch

------------------------------------------------------------------------
Emile `iMil' Heitor <imil@{home.imil.net,NetBSD.org}> | https://imil.net



Home | Main Index | Thread Index | Old Index