1*4882a593SmuzhiyunWhat: /sys/firmware/qemu_fw_cfg/ 2*4882a593SmuzhiyunDate: August 2015 3*4882a593SmuzhiyunContact: Gabriel Somlo <somlo@cmu.edu> 4*4882a593SmuzhiyunDescription: 5*4882a593Smuzhiyun Several different architectures supported by QEMU (x86, arm, 6*4882a593Smuzhiyun sun4*, ppc/mac) are provisioned with a firmware configuration 7*4882a593Smuzhiyun (fw_cfg) device, originally intended as a way for the host to 8*4882a593Smuzhiyun provide configuration data to the guest firmware. Starting 9*4882a593Smuzhiyun with QEMU v2.4, arbitrary fw_cfg file entries may be specified 10*4882a593Smuzhiyun by the user on the command line, which makes fw_cfg additionally 11*4882a593Smuzhiyun useful as an out-of-band, asynchronous mechanism for providing 12*4882a593Smuzhiyun configuration data to the guest userspace. 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun The authoritative guest-side hardware interface documentation 15*4882a593Smuzhiyun to the fw_cfg device can be found in "docs/specs/fw_cfg.txt" 16*4882a593Smuzhiyun in the QEMU source tree. 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun **SysFS fw_cfg Interface** 19*4882a593Smuzhiyun 20*4882a593Smuzhiyun The fw_cfg sysfs interface described in this document is only 21*4882a593Smuzhiyun intended to display discoverable blobs (i.e., those registered 22*4882a593Smuzhiyun with the file directory), as there is no way to determine the 23*4882a593Smuzhiyun presence or size of "legacy" blobs (with selector keys between 24*4882a593Smuzhiyun 0x0002 and 0x0018) programmatically. 25*4882a593Smuzhiyun 26*4882a593Smuzhiyun All fw_cfg information is shown under: 27*4882a593Smuzhiyun 28*4882a593Smuzhiyun /sys/firmware/qemu_fw_cfg/ 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun The only legacy blob displayed is the fw_cfg device revision: 31*4882a593Smuzhiyun 32*4882a593Smuzhiyun /sys/firmware/qemu_fw_cfg/rev 33*4882a593Smuzhiyun 34*4882a593Smuzhiyun **Discoverable fw_cfg blobs by selector key** 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun All discoverable blobs listed in the fw_cfg file directory are 37*4882a593Smuzhiyun displayed as entries named after their unique selector key 38*4882a593Smuzhiyun value, e.g.: 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun /sys/firmware/qemu_fw_cfg/by_key/32 41*4882a593Smuzhiyun /sys/firmware/qemu_fw_cfg/by_key/33 42*4882a593Smuzhiyun /sys/firmware/qemu_fw_cfg/by_key/34 43*4882a593Smuzhiyun ... 44*4882a593Smuzhiyun 45*4882a593Smuzhiyun Each such fw_cfg sysfs entry has the following values exported 46*4882a593Smuzhiyun as attributes: 47*4882a593Smuzhiyun 48*4882a593Smuzhiyun ==== ==================================================== 49*4882a593Smuzhiyun name The 56-byte nul-terminated ASCII string used as the 50*4882a593Smuzhiyun blob's 'file name' in the fw_cfg directory. 51*4882a593Smuzhiyun size The length of the blob, as given in the fw_cfg 52*4882a593Smuzhiyun directory. 53*4882a593Smuzhiyun key The value of the blob's selector key as given in the 54*4882a593Smuzhiyun fw_cfg directory. This value is the same as used in 55*4882a593Smuzhiyun the parent directory name. 56*4882a593Smuzhiyun raw The raw bytes of the blob, obtained by selecting the 57*4882a593Smuzhiyun entry via the control register, and reading a number 58*4882a593Smuzhiyun of bytes equal to the blob size from the data 59*4882a593Smuzhiyun register. 60*4882a593Smuzhiyun ==== ==================================================== 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun **Listing fw_cfg blobs by file name** 63*4882a593Smuzhiyun 64*4882a593Smuzhiyun While the fw_cfg device does not impose any specific naming 65*4882a593Smuzhiyun convention on the blobs registered in the file directory, 66*4882a593Smuzhiyun QEMU developers have traditionally used path name semantics 67*4882a593Smuzhiyun to give each blob a descriptive name. For example:: 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun "bootorder" 70*4882a593Smuzhiyun "genroms/kvmvapic.bin" 71*4882a593Smuzhiyun "etc/e820" 72*4882a593Smuzhiyun "etc/boot-fail-wait" 73*4882a593Smuzhiyun "etc/system-states" 74*4882a593Smuzhiyun "etc/table-loader" 75*4882a593Smuzhiyun "etc/acpi/rsdp" 76*4882a593Smuzhiyun "etc/acpi/tables" 77*4882a593Smuzhiyun "etc/smbios/smbios-tables" 78*4882a593Smuzhiyun "etc/smbios/smbios-anchor" 79*4882a593Smuzhiyun ... 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun In addition to the listing by unique selector key described 82*4882a593Smuzhiyun above, the fw_cfg sysfs driver also attempts to build a tree 83*4882a593Smuzhiyun of directories matching the path name components of fw_cfg 84*4882a593Smuzhiyun blob names, ending in symlinks to the by_key entry for each 85*4882a593Smuzhiyun "basename", as illustrated below (assume current directory is 86*4882a593Smuzhiyun /sys/firmware):: 87*4882a593Smuzhiyun 88*4882a593Smuzhiyun qemu_fw_cfg/by_name/bootorder -> ../by_key/38 89*4882a593Smuzhiyun qemu_fw_cfg/by_name/etc/e820 -> ../../by_key/35 90*4882a593Smuzhiyun qemu_fw_cfg/by_name/etc/acpi/rsdp -> ../../../by_key/41 91*4882a593Smuzhiyun ... 92*4882a593Smuzhiyun 93*4882a593Smuzhiyun Construction of the directory tree and symlinks is done on a 94*4882a593Smuzhiyun "best-effort" basis, as there is no guarantee that components 95*4882a593Smuzhiyun of fw_cfg blob names are always "well behaved". I.e., there is 96*4882a593Smuzhiyun the possibility that a symlink (basename) will conflict with 97*4882a593Smuzhiyun a dirname component of another fw_cfg blob, in which case the 98*4882a593Smuzhiyun creation of the offending /sys/firmware/qemu_fw_cfg/by_name 99*4882a593Smuzhiyun entry will be skipped. 100*4882a593Smuzhiyun 101*4882a593Smuzhiyun The authoritative list of entries will continue to be found 102*4882a593Smuzhiyun under the /sys/firmware/qemu_fw_cfg/by_key directory. 103