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 1575f3e8e4SGabriel Somlo to the fw_cfg device can be found in "docs/specs/fw_cfg.txt" 1675f3e8e4SGabriel Somlo in the QEMU source tree. 1775f3e8e4SGabriel Somlo 18*54a19b4dSMauro Carvalho Chehab **SysFS fw_cfg Interface** 1975f3e8e4SGabriel Somlo 2075f3e8e4SGabriel Somlo The fw_cfg sysfs interface described in this document is only 2175f3e8e4SGabriel Somlo intended to display discoverable blobs (i.e., those registered 2275f3e8e4SGabriel Somlo with the file directory), as there is no way to determine the 2375f3e8e4SGabriel Somlo presence or size of "legacy" blobs (with selector keys between 2475f3e8e4SGabriel Somlo 0x0002 and 0x0018) programmatically. 2575f3e8e4SGabriel Somlo 2675f3e8e4SGabriel Somlo All fw_cfg information is shown under: 2775f3e8e4SGabriel Somlo 2875f3e8e4SGabriel Somlo /sys/firmware/qemu_fw_cfg/ 2975f3e8e4SGabriel Somlo 3075f3e8e4SGabriel Somlo The only legacy blob displayed is the fw_cfg device revision: 3175f3e8e4SGabriel Somlo 3275f3e8e4SGabriel Somlo /sys/firmware/qemu_fw_cfg/rev 3375f3e8e4SGabriel Somlo 34*54a19b4dSMauro Carvalho Chehab **Discoverable fw_cfg blobs by selector key** 3575f3e8e4SGabriel Somlo 3675f3e8e4SGabriel Somlo All discoverable blobs listed in the fw_cfg file directory are 3775f3e8e4SGabriel Somlo displayed as entries named after their unique selector key 3875f3e8e4SGabriel Somlo value, e.g.: 3975f3e8e4SGabriel Somlo 4075f3e8e4SGabriel Somlo /sys/firmware/qemu_fw_cfg/by_key/32 4175f3e8e4SGabriel Somlo /sys/firmware/qemu_fw_cfg/by_key/33 4275f3e8e4SGabriel Somlo /sys/firmware/qemu_fw_cfg/by_key/34 4375f3e8e4SGabriel Somlo ... 4475f3e8e4SGabriel Somlo 4575f3e8e4SGabriel Somlo Each such fw_cfg sysfs entry has the following values exported 4675f3e8e4SGabriel Somlo as attributes: 4775f3e8e4SGabriel Somlo 48*54a19b4dSMauro Carvalho Chehab ==== ==================================================== 49*54a19b4dSMauro Carvalho Chehab name The 56-byte nul-terminated ASCII string used as the 5075f3e8e4SGabriel Somlo blob's 'file name' in the fw_cfg directory. 51*54a19b4dSMauro Carvalho Chehab size The length of the blob, as given in the fw_cfg 5275f3e8e4SGabriel Somlo directory. 53*54a19b4dSMauro Carvalho Chehab key The value of the blob's selector key as given in the 5475f3e8e4SGabriel Somlo fw_cfg directory. This value is the same as used in 5575f3e8e4SGabriel Somlo the parent directory name. 56*54a19b4dSMauro Carvalho Chehab raw The raw bytes of the blob, obtained by selecting the 5775f3e8e4SGabriel Somlo entry via the control register, and reading a number 5875f3e8e4SGabriel Somlo of bytes equal to the blob size from the data 5975f3e8e4SGabriel Somlo register. 60*54a19b4dSMauro Carvalho Chehab ==== ==================================================== 61246c46ebSGabriel Somlo 62*54a19b4dSMauro Carvalho Chehab **Listing fw_cfg blobs by file name** 63246c46ebSGabriel Somlo 64246c46ebSGabriel Somlo While the fw_cfg device does not impose any specific naming 65246c46ebSGabriel Somlo convention on the blobs registered in the file directory, 66246c46ebSGabriel Somlo QEMU developers have traditionally used path name semantics 67*54a19b4dSMauro Carvalho Chehab to give each blob a descriptive name. For example:: 68246c46ebSGabriel Somlo 69246c46ebSGabriel Somlo "bootorder" 70246c46ebSGabriel Somlo "genroms/kvmvapic.bin" 71246c46ebSGabriel Somlo "etc/e820" 72246c46ebSGabriel Somlo "etc/boot-fail-wait" 73246c46ebSGabriel Somlo "etc/system-states" 74246c46ebSGabriel Somlo "etc/table-loader" 75246c46ebSGabriel Somlo "etc/acpi/rsdp" 76246c46ebSGabriel Somlo "etc/acpi/tables" 77246c46ebSGabriel Somlo "etc/smbios/smbios-tables" 78246c46ebSGabriel Somlo "etc/smbios/smbios-anchor" 79246c46ebSGabriel Somlo ... 80246c46ebSGabriel Somlo 81246c46ebSGabriel Somlo In addition to the listing by unique selector key described 82246c46ebSGabriel Somlo above, the fw_cfg sysfs driver also attempts to build a tree 83246c46ebSGabriel Somlo of directories matching the path name components of fw_cfg 84246c46ebSGabriel Somlo blob names, ending in symlinks to the by_key entry for each 85246c46ebSGabriel Somlo "basename", as illustrated below (assume current directory is 86*54a19b4dSMauro Carvalho Chehab /sys/firmware):: 87246c46ebSGabriel Somlo 88246c46ebSGabriel Somlo qemu_fw_cfg/by_name/bootorder -> ../by_key/38 89246c46ebSGabriel Somlo qemu_fw_cfg/by_name/etc/e820 -> ../../by_key/35 90246c46ebSGabriel Somlo qemu_fw_cfg/by_name/etc/acpi/rsdp -> ../../../by_key/41 91246c46ebSGabriel Somlo ... 92246c46ebSGabriel Somlo 93246c46ebSGabriel Somlo Construction of the directory tree and symlinks is done on a 94246c46ebSGabriel Somlo "best-effort" basis, as there is no guarantee that components 95246c46ebSGabriel Somlo of fw_cfg blob names are always "well behaved". I.e., there is 96246c46ebSGabriel Somlo the possibility that a symlink (basename) will conflict with 97246c46ebSGabriel Somlo a dirname component of another fw_cfg blob, in which case the 98246c46ebSGabriel Somlo creation of the offending /sys/firmware/qemu_fw_cfg/by_name 99246c46ebSGabriel Somlo entry will be skipped. 100246c46ebSGabriel Somlo 101246c46ebSGabriel Somlo The authoritative list of entries will continue to be found 102246c46ebSGabriel Somlo under the /sys/firmware/qemu_fw_cfg/by_key directory. 103