175f3e8e4SGabriel SomloWhat: /sys/firmware/qemu_fw_cfg/ 275f3e8e4SGabriel SomloDate: August 2015 375f3e8e4SGabriel SomloContact: Gabriel Somlo <somlo@cmu.edu> 475f3e8e4SGabriel SomloDescription: 575f3e8e4SGabriel Somlo Several different architectures supported by QEMU (x86, arm, 675f3e8e4SGabriel Somlo sun4*, ppc/mac) are provisioned with a firmware configuration 775f3e8e4SGabriel Somlo (fw_cfg) device, originally intended as a way for the host to 875f3e8e4SGabriel Somlo provide configuration data to the guest firmware. Starting 975f3e8e4SGabriel Somlo with QEMU v2.4, arbitrary fw_cfg file entries may be specified 1075f3e8e4SGabriel Somlo by the user on the command line, which makes fw_cfg additionally 1175f3e8e4SGabriel Somlo useful as an out-of-band, asynchronous mechanism for providing 1275f3e8e4SGabriel Somlo configuration data to the guest userspace. 1375f3e8e4SGabriel Somlo 1475f3e8e4SGabriel Somlo The authoritative guest-side hardware interface documentation 15*40b1aa59SJason A. Donenfeld to the fw_cfg device can be found in "docs/specs/fw_cfg.rst" 16*40b1aa59SJason A. Donenfeld in the QEMU source tree, or online at: 17*40b1aa59SJason A. Donenfeld https://qemu-project.gitlab.io/qemu/specs/fw_cfg.html 1875f3e8e4SGabriel Somlo 1954a19b4dSMauro Carvalho Chehab **SysFS fw_cfg Interface** 2075f3e8e4SGabriel Somlo 2175f3e8e4SGabriel Somlo The fw_cfg sysfs interface described in this document is only 2275f3e8e4SGabriel Somlo intended to display discoverable blobs (i.e., those registered 2375f3e8e4SGabriel Somlo with the file directory), as there is no way to determine the 2475f3e8e4SGabriel Somlo presence or size of "legacy" blobs (with selector keys between 2575f3e8e4SGabriel Somlo 0x0002 and 0x0018) programmatically. 2675f3e8e4SGabriel Somlo 2775f3e8e4SGabriel Somlo All fw_cfg information is shown under: 2875f3e8e4SGabriel Somlo 2975f3e8e4SGabriel Somlo /sys/firmware/qemu_fw_cfg/ 3075f3e8e4SGabriel Somlo 3175f3e8e4SGabriel Somlo The only legacy blob displayed is the fw_cfg device revision: 3275f3e8e4SGabriel Somlo 3375f3e8e4SGabriel Somlo /sys/firmware/qemu_fw_cfg/rev 3475f3e8e4SGabriel Somlo 3554a19b4dSMauro Carvalho Chehab **Discoverable fw_cfg blobs by selector key** 3675f3e8e4SGabriel Somlo 3775f3e8e4SGabriel Somlo All discoverable blobs listed in the fw_cfg file directory are 3875f3e8e4SGabriel Somlo displayed as entries named after their unique selector key 3975f3e8e4SGabriel Somlo value, e.g.: 4075f3e8e4SGabriel Somlo 4175f3e8e4SGabriel Somlo /sys/firmware/qemu_fw_cfg/by_key/32 4275f3e8e4SGabriel Somlo /sys/firmware/qemu_fw_cfg/by_key/33 4375f3e8e4SGabriel Somlo /sys/firmware/qemu_fw_cfg/by_key/34 4475f3e8e4SGabriel Somlo ... 4575f3e8e4SGabriel Somlo 4675f3e8e4SGabriel Somlo Each such fw_cfg sysfs entry has the following values exported 4775f3e8e4SGabriel Somlo as attributes: 4875f3e8e4SGabriel Somlo 4954a19b4dSMauro Carvalho Chehab ==== ==================================================== 5054a19b4dSMauro Carvalho Chehab name The 56-byte nul-terminated ASCII string used as the 5175f3e8e4SGabriel Somlo blob's 'file name' in the fw_cfg directory. 5254a19b4dSMauro Carvalho Chehab size The length of the blob, as given in the fw_cfg 5375f3e8e4SGabriel Somlo directory. 5454a19b4dSMauro Carvalho Chehab key The value of the blob's selector key as given in the 5575f3e8e4SGabriel Somlo fw_cfg directory. This value is the same as used in 5675f3e8e4SGabriel Somlo the parent directory name. 5754a19b4dSMauro Carvalho Chehab raw The raw bytes of the blob, obtained by selecting the 5875f3e8e4SGabriel Somlo entry via the control register, and reading a number 5975f3e8e4SGabriel Somlo of bytes equal to the blob size from the data 6075f3e8e4SGabriel Somlo register. 6154a19b4dSMauro Carvalho Chehab ==== ==================================================== 62246c46ebSGabriel Somlo 6354a19b4dSMauro Carvalho Chehab **Listing fw_cfg blobs by file name** 64246c46ebSGabriel Somlo 65246c46ebSGabriel Somlo While the fw_cfg device does not impose any specific naming 66246c46ebSGabriel Somlo convention on the blobs registered in the file directory, 67246c46ebSGabriel Somlo QEMU developers have traditionally used path name semantics 6854a19b4dSMauro Carvalho Chehab to give each blob a descriptive name. For example:: 69246c46ebSGabriel Somlo 70246c46ebSGabriel Somlo "bootorder" 71246c46ebSGabriel Somlo "genroms/kvmvapic.bin" 72246c46ebSGabriel Somlo "etc/e820" 73246c46ebSGabriel Somlo "etc/boot-fail-wait" 74246c46ebSGabriel Somlo "etc/system-states" 75246c46ebSGabriel Somlo "etc/table-loader" 76246c46ebSGabriel Somlo "etc/acpi/rsdp" 77246c46ebSGabriel Somlo "etc/acpi/tables" 78246c46ebSGabriel Somlo "etc/smbios/smbios-tables" 79246c46ebSGabriel Somlo "etc/smbios/smbios-anchor" 80246c46ebSGabriel Somlo ... 81246c46ebSGabriel Somlo 82246c46ebSGabriel Somlo In addition to the listing by unique selector key described 83246c46ebSGabriel Somlo above, the fw_cfg sysfs driver also attempts to build a tree 84246c46ebSGabriel Somlo of directories matching the path name components of fw_cfg 85246c46ebSGabriel Somlo blob names, ending in symlinks to the by_key entry for each 86246c46ebSGabriel Somlo "basename", as illustrated below (assume current directory is 8754a19b4dSMauro Carvalho Chehab /sys/firmware):: 88246c46ebSGabriel Somlo 89246c46ebSGabriel Somlo qemu_fw_cfg/by_name/bootorder -> ../by_key/38 90246c46ebSGabriel Somlo qemu_fw_cfg/by_name/etc/e820 -> ../../by_key/35 91246c46ebSGabriel Somlo qemu_fw_cfg/by_name/etc/acpi/rsdp -> ../../../by_key/41 92246c46ebSGabriel Somlo ... 93246c46ebSGabriel Somlo 94246c46ebSGabriel Somlo Construction of the directory tree and symlinks is done on a 95246c46ebSGabriel Somlo "best-effort" basis, as there is no guarantee that components 96246c46ebSGabriel Somlo of fw_cfg blob names are always "well behaved". I.e., there is 97246c46ebSGabriel Somlo the possibility that a symlink (basename) will conflict with 98246c46ebSGabriel Somlo a dirname component of another fw_cfg blob, in which case the 99246c46ebSGabriel Somlo creation of the offending /sys/firmware/qemu_fw_cfg/by_name 100246c46ebSGabriel Somlo entry will be skipped. 101246c46ebSGabriel Somlo 102246c46ebSGabriel Somlo The authoritative list of entries will continue to be found 103246c46ebSGabriel Somlo under the /sys/firmware/qemu_fw_cfg/by_key directory. 104