18c2ecf20Sopenharmony_ciWhat: /sys/firmware/qemu_fw_cfg/ 28c2ecf20Sopenharmony_ciDate: August 2015 38c2ecf20Sopenharmony_ciContact: Gabriel Somlo <somlo@cmu.edu> 48c2ecf20Sopenharmony_ciDescription: 58c2ecf20Sopenharmony_ci Several different architectures supported by QEMU (x86, arm, 68c2ecf20Sopenharmony_ci sun4*, ppc/mac) are provisioned with a firmware configuration 78c2ecf20Sopenharmony_ci (fw_cfg) device, originally intended as a way for the host to 88c2ecf20Sopenharmony_ci provide configuration data to the guest firmware. Starting 98c2ecf20Sopenharmony_ci with QEMU v2.4, arbitrary fw_cfg file entries may be specified 108c2ecf20Sopenharmony_ci by the user on the command line, which makes fw_cfg additionally 118c2ecf20Sopenharmony_ci useful as an out-of-band, asynchronous mechanism for providing 128c2ecf20Sopenharmony_ci configuration data to the guest userspace. 138c2ecf20Sopenharmony_ci 148c2ecf20Sopenharmony_ci The authoritative guest-side hardware interface documentation 158c2ecf20Sopenharmony_ci to the fw_cfg device can be found in "docs/specs/fw_cfg.txt" 168c2ecf20Sopenharmony_ci in the QEMU source tree. 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci **SysFS fw_cfg Interface** 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci The fw_cfg sysfs interface described in this document is only 218c2ecf20Sopenharmony_ci intended to display discoverable blobs (i.e., those registered 228c2ecf20Sopenharmony_ci with the file directory), as there is no way to determine the 238c2ecf20Sopenharmony_ci presence or size of "legacy" blobs (with selector keys between 248c2ecf20Sopenharmony_ci 0x0002 and 0x0018) programmatically. 258c2ecf20Sopenharmony_ci 268c2ecf20Sopenharmony_ci All fw_cfg information is shown under: 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci /sys/firmware/qemu_fw_cfg/ 298c2ecf20Sopenharmony_ci 308c2ecf20Sopenharmony_ci The only legacy blob displayed is the fw_cfg device revision: 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci /sys/firmware/qemu_fw_cfg/rev 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci **Discoverable fw_cfg blobs by selector key** 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci All discoverable blobs listed in the fw_cfg file directory are 378c2ecf20Sopenharmony_ci displayed as entries named after their unique selector key 388c2ecf20Sopenharmony_ci value, e.g.: 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci /sys/firmware/qemu_fw_cfg/by_key/32 418c2ecf20Sopenharmony_ci /sys/firmware/qemu_fw_cfg/by_key/33 428c2ecf20Sopenharmony_ci /sys/firmware/qemu_fw_cfg/by_key/34 438c2ecf20Sopenharmony_ci ... 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci Each such fw_cfg sysfs entry has the following values exported 468c2ecf20Sopenharmony_ci as attributes: 478c2ecf20Sopenharmony_ci 488c2ecf20Sopenharmony_ci ==== ==================================================== 498c2ecf20Sopenharmony_ci name The 56-byte nul-terminated ASCII string used as the 508c2ecf20Sopenharmony_ci blob's 'file name' in the fw_cfg directory. 518c2ecf20Sopenharmony_ci size The length of the blob, as given in the fw_cfg 528c2ecf20Sopenharmony_ci directory. 538c2ecf20Sopenharmony_ci key The value of the blob's selector key as given in the 548c2ecf20Sopenharmony_ci fw_cfg directory. This value is the same as used in 558c2ecf20Sopenharmony_ci the parent directory name. 568c2ecf20Sopenharmony_ci raw The raw bytes of the blob, obtained by selecting the 578c2ecf20Sopenharmony_ci entry via the control register, and reading a number 588c2ecf20Sopenharmony_ci of bytes equal to the blob size from the data 598c2ecf20Sopenharmony_ci register. 608c2ecf20Sopenharmony_ci ==== ==================================================== 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci **Listing fw_cfg blobs by file name** 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci While the fw_cfg device does not impose any specific naming 658c2ecf20Sopenharmony_ci convention on the blobs registered in the file directory, 668c2ecf20Sopenharmony_ci QEMU developers have traditionally used path name semantics 678c2ecf20Sopenharmony_ci to give each blob a descriptive name. For example:: 688c2ecf20Sopenharmony_ci 698c2ecf20Sopenharmony_ci "bootorder" 708c2ecf20Sopenharmony_ci "genroms/kvmvapic.bin" 718c2ecf20Sopenharmony_ci "etc/e820" 728c2ecf20Sopenharmony_ci "etc/boot-fail-wait" 738c2ecf20Sopenharmony_ci "etc/system-states" 748c2ecf20Sopenharmony_ci "etc/table-loader" 758c2ecf20Sopenharmony_ci "etc/acpi/rsdp" 768c2ecf20Sopenharmony_ci "etc/acpi/tables" 778c2ecf20Sopenharmony_ci "etc/smbios/smbios-tables" 788c2ecf20Sopenharmony_ci "etc/smbios/smbios-anchor" 798c2ecf20Sopenharmony_ci ... 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci In addition to the listing by unique selector key described 828c2ecf20Sopenharmony_ci above, the fw_cfg sysfs driver also attempts to build a tree 838c2ecf20Sopenharmony_ci of directories matching the path name components of fw_cfg 848c2ecf20Sopenharmony_ci blob names, ending in symlinks to the by_key entry for each 858c2ecf20Sopenharmony_ci "basename", as illustrated below (assume current directory is 868c2ecf20Sopenharmony_ci /sys/firmware):: 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_ci qemu_fw_cfg/by_name/bootorder -> ../by_key/38 898c2ecf20Sopenharmony_ci qemu_fw_cfg/by_name/etc/e820 -> ../../by_key/35 908c2ecf20Sopenharmony_ci qemu_fw_cfg/by_name/etc/acpi/rsdp -> ../../../by_key/41 918c2ecf20Sopenharmony_ci ... 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci Construction of the directory tree and symlinks is done on a 948c2ecf20Sopenharmony_ci "best-effort" basis, as there is no guarantee that components 958c2ecf20Sopenharmony_ci of fw_cfg blob names are always "well behaved". I.e., there is 968c2ecf20Sopenharmony_ci the possibility that a symlink (basename) will conflict with 978c2ecf20Sopenharmony_ci a dirname component of another fw_cfg blob, in which case the 988c2ecf20Sopenharmony_ci creation of the offending /sys/firmware/qemu_fw_cfg/by_name 998c2ecf20Sopenharmony_ci entry will be skipped. 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci The authoritative list of entries will continue to be found 1028c2ecf20Sopenharmony_ci under the /sys/firmware/qemu_fw_cfg/by_key directory. 103