Skip to content

Instantly share code, notes, and snippets.

@sameo
Last active October 15, 2021 00:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sameo/746d8dacfa03f58ee565d8728a2a7dfe to your computer and use it in GitHub Desktop.
Save sameo/746d8dacfa03f58ee565d8728a2a7dfe to your computer and use it in GitHub Desktop.

Description

qboot is a simple x86 firmware that can boot Linux.

It is Paolo Bonzini's answer to the Clear Containers claim that QEMU takes too long to boot a Linux kernel.

qboot only works as a QEMU firmware as it's bound to QEMU's fw_cfg NVRAM firmware configuration device emulation mode.

QEMU and qboot interaction

qboot relies on QEMU's fw_cfg device that emulates an NVRAM block holding all firmware configuration information. The fw_cfg emulated commands and registers are documented here.

The qboot build process generates a bios.bin file that is passed to QEMU through the --bios command line option.

Before jumping into qboot's entry point, QEMU will initialize the selected machine type (--machine) and store the related machine firmware relevant pieces of information into the fw_cfg device. The QEMU machine type initilization code will generate and store in particular the following data:

  • ACPI tables
  • e820 maps
  • Kernel command line and size
  • Kernel data and size
  • Initrd data and size

QEMU stores that data at fixed offset into the emulated fw_cfg NVRAM space. qboot then reads and interacts with this emulated storage device.

qboot code flow

QEMU jumps to qboot's entry point and qboot then goes through the following steps:

  • Enable all PCI IRQs
  • Enable PCI PM
  • PIC setup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment