Skip to contentSkip to conversation

hw/nvram/fw_cfg: Do not build device if not needed (Spring cleanup)

PATCH In review Philippe Mathieu-Daudé 5 participants 18 messages Apr 26, 2021 – Apr 28, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover hw/nvram/fw_cfg: Do not build device if not needed (Spring cleanup)

Hi,

Quite a trivial series around fw_cfg:
- enforce the FW_CFG Kconfig symbol,
- add missing Kconfig dependencies,
- explicit machines using the fw_cfg device,
- allow targets not using the device to build without it.

Please review,

Phil.

Philippe Mathieu-Daudé (7):
stubs: Restrict fw_cfg stubs to sysemu
hw/nvram: Rename FW_CFG_MIPS as generic FW_CFG Kconfig symbol hw/nvram: Declare FW_CFG_DMA Kconfig symbol in hw/nvram/ hw/acpi/vmgenid: Make ACPI_VMGENID depends on FW_CFG Kconfig
hw: Have machines Kconfig-select FW_CFG hw/{arm,hppa,riscv}: Add fw_cfg arch-specific stub hw/nvram: Do not build FW_CFG if not required

 hw/arm/fw_cfg.c      | 19 +++++++++++++++++
 hw/hppa/fw_cfg.c     | 19 +++++++++++++++++
 hw/riscv/fw_cfg.c    | 19 +++++++++++++++++
 stubs/fw_cfg.c       | 49 ++++++++++++++++++++++++++++++++++++++++++--
 MAINTAINERS          |  2 +-
 hw/acpi/Kconfig      |  1 +
 hw/arm/Kconfig       |  2 ++
 hw/arm/meson.build   |  1 +
 hw/display/Kconfig   |  3 ---
 hw/hppa/Kconfig      |  1 +
 hw/hppa/meson.build  |  1 +
 hw/i386/Kconfig      |  2 ++
 hw/mips/Kconfig      |  5 +----
 hw/mips/meson.build  |  2 +-
 hw/nvram/Kconfig     |  7 +++++++
 hw/nvram/meson.build |  2 +-
 hw/ppc/Kconfig       |  1 +
 hw/riscv/meson.build |  1 +
 hw/sparc/Kconfig     |  1 +
 hw/sparc64/Kconfig   |  1 +
 stubs/meson.build    |  2 +-
 21 files changed, 128 insertions(+), 13 deletions(-)
 create mode 100644 hw/arm/fw_cfg.c
 create mode 100644 hw/hppa/fw_cfg.c
 create mode 100644 hw/riscv/fw_cfg.c
Signature · 1 line
2.26.3
#1 lore raw

PATCH 1/7 stubs: Restrict fw_cfg stubs to sysemu

User emulation or tools don't use / require the fw_cfg device.

---
 stubs/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
stubs/meson.build +1 -1
index be6f6d609e5..4ff36401cf9 100644
@@ -12,7 +12,6 @@
 stub_ss.add(files('dump.c'))
 stub_ss.add(files('error-printf.c'))
 stub_ss.add(files('fdset.c'))
-stub_ss.add(files('fw_cfg.c'))
 stub_ss.add(files('gdbstub.c'))
 stub_ss.add(files('get-vm-name.c'))
 stub_ss.add(when: 'CONFIG_LINUX_IO_URING', if_true: files('io_uring.c'))
@@ -49,6 +48,7 @@
   stub_ss.add(files('replay-tools.c'))
 endif
 if have_system
+  stub_ss.add(files('fw_cfg.c'))
   stub_ss.add(files('semihost.c'))
   stub_ss.add(files('xen-hw-stub.c'))
 else
Signature · 1 line
2.26.3
Acked-by on v1 1/7
#2 lore raw

Re: [PATCH 1/7] stubs: Restrict fw_cfg stubs to sysemu

Quoted 21 lines · Philippe Mathieu-Daudé

User emulation or tools don't use / require the fw_cfg device.

---
 stubs/meson.build | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
stubs/meson.build +0 -1
index be6f6d609e5..4ff36401cf9 100644
@@ -12,7 +12,6 @@
 stub_ss.add(files('dump.c'))
 stub_ss.add(files('error-printf.c'))
 stub_ss.add(files('fdset.c'))
-stub_ss.add(files('fw_cfg.c'))
 stub_ss.add(files('gdbstub.c'))
 stub_ss.add(files('get-vm-name.c'))
 stub_ss.add(when: 'CONFIG_LINUX_IO_URING', if_true: files('io_uring.c'))

stubs/meson.build line 54

Quoted 7 lines
stubs/meson.build +1 -0
@@ -49,6 +48,7 @@
   stub_ss.add(files('replay-tools.c'))
 endif
 if have_system
+  stub_ss.add(files('fw_cfg.c'))
   stub_ss.add(files('semihost.c'))
   stub_ss.add(files('xen-hw-stub.c'))
 else

The intent is valid and the implementation looks plausible.

#3 lore raw

PATCH 2/7 hw/nvram: Rename FW_CFG_MIPS as generic FW_CFG Kconfig symbol

In reply to Philippe Mathieu-Daudé

Targets using the fw_cfg device might have architecture specific keys. If so, they define the fw_cfg_arch_key_name() function.

The use of FW_CFG_MIPS is not MIPS-specific, it is simply the architectural implementation. Rename it using the generic 'FW_CFG' and move the Kconfig declaration in hw/nvram/ where fw_cfg code is maintained.

---
 hw/mips/Kconfig     | 5 +----
 hw/mips/meson.build | 2 +-
 hw/nvram/Kconfig    | 3 +++
 3 files changed, 5 insertions(+), 5 deletions(-)
hw/mips/Kconfig +1 -4
index aadd436bf4e..bbc6b9c1d11 100644
@@ -42,7 +42,7 @@ config LOONGSON3V
     select PCI_DEVICES
     select PCI_EXPRESS_GENERIC_BRIDGE
     select MSI_NONBROKEN
-    select FW_CFG_MIPS
+    select FW_CFG
 
 config MIPS_CPS
     bool
@@ -50,6 +50,3 @@ config MIPS_CPS
 
 config MIPS_BOSTON
     bool
-
-config FW_CFG_MIPS
-    bool
hw/mips/meson.build +1 -1
index 1195716dc73..893e56f7453 100644
@@ -1,6 +1,6 @@
 mips_ss = ss.source_set()
 mips_ss.add(files('bootloader.c', 'mips_int.c'))
-mips_ss.add(when: 'CONFIG_FW_CFG_MIPS', if_true: files('fw_cfg.c'))
+mips_ss.add(when: 'CONFIG_FW_CFG', if_true: files('fw_cfg.c'))
 mips_ss.add(when: 'CONFIG_FULOONG', if_true: files('fuloong2e.c'))
 mips_ss.add(when: 'CONFIG_LOONGSON3V', if_true: files('loongson3_bootp.c', 'loongson3_virt.c'))
 mips_ss.add(when: 'CONFIG_JAZZ', if_true: files('jazz.c'))
hw/nvram/Kconfig +3 -0
index e872fcb1941..cab1070375f 100644
@@ -1,3 +1,6 @@
+config FW_CFG
+    bool
+
 config DS1225Y
     bool
 
Signature · 1 line
2.26.3
#4 lore raw

PATCH 3/7 hw/nvram: Declare FW_CFG_DMA Kconfig symbol in hw/nvram/

In reply to Philippe Mathieu-Daudé

fw_cfg related files are maintained in hw/nvram/, so it makes sense to declare the FW_CFG_DMA Kconfig symbol there, along with the FW_CFG one.

---
 hw/display/Kconfig | 3 ---
 hw/nvram/Kconfig   | 4 ++++
 2 files changed, 4 insertions(+), 3 deletions(-)
hw/display/Kconfig +0 -3
index ca46b5830e7..0e4bb596c43 100644
@@ -6,9 +6,6 @@ config DDC
 config EDID
     bool
 
-config FW_CFG_DMA
-    bool
-
 config VGA_CIRRUS
     bool
     default y if PCI_DEVICES
hw/nvram/Kconfig +4 -0
index cab1070375f..59fac45c315 100644
@@ -1,6 +1,10 @@
 config FW_CFG
     bool
 
+config FW_CFG_DMA
+    bool
+    select FW_CFG
+
 config DS1225Y
     bool
 
Signature · 1 line
2.26.3
#5 lore raw

PATCH 4/7 hw/acpi/vmgenid: Make ACPI_VMGENID depends on FW_CFG Kconfig

In reply to Philippe Mathieu-Daudé

The TYPE_VMGENID device depends on fw_cfg:

  $ git grep \ fw_cfg hw/acpi/vmgenid.c
  hw/acpi/vmgenid.c:128:    fw_cfg_add_file(s, VMGENID_GUID_FW_CFG_FILE, guid->data,
  hw/acpi/vmgenid.c:131:    fw_cfg_add_file_callback(s, VMGENID_ADDR_FW_CFG_FILE, NULL, NULL, NULL,

Add the proper Kconfig dependency.

---
 hw/acpi/Kconfig | 1 +
 1 file changed, 1 insertion(+)
hw/acpi/Kconfig +1 -0
index 1932f66af8d..b9dc932d2a7 100644
@@ -40,5 +40,6 @@ config ACPI_VMGENID
     bool
     default y
     depends on PC
+    select FW_CFG
 
 config ACPI_HW_REDUCED
Signature · 1 line
2.26.3
Reviewed-by on v1 4/7
#6 lore raw

Re: [PATCH 4/7] hw/acpi/vmgenid: Make ACPI_VMGENID depends on FW_CFG Kconfig

Quoted 19 lines · Philippe Mathieu-Daudé

The TYPE_VMGENID device depends on fw_cfg:

  $ git grep \ fw_cfg hw/acpi/vmgenid.c
  hw/acpi/vmgenid.c:128:    fw_cfg_add_file(s, VMGENID_GUID_FW_CFG_FILE, guid->data,
  hw/acpi/vmgenid.c:131:    fw_cfg_add_file_callback(s, VMGENID_ADDR_FW_CFG_FILE, NULL, NULL, NULL,

Add the proper Kconfig dependency.

---
 hw/acpi/Kconfig | 1 +
 1 file changed, 1 insertion(+)
hw/acpi/Kconfig +0 -0
index 1932f66af8d..b9dc932d2a7 100644

hw/acpi/Kconfig config ACPI_VMGENID · line 45

Quoted 6 lines
hw/acpi/Kconfig +1 -0
@@ -40,5 +40,6 @@ config ACPI_VMGENID
     bool
     default y
     depends on PC
+    select FW_CFG
 
 config ACPI_HW_REDUCED

The intent is certainly correct and the implementation looks plausible.

#7 lore raw

PATCH 5/7 hw: Have machines Kconfig-select FW_CFG

In reply to Philippe Mathieu-Daudé

Beside the loongson3-virt machine (MIPS), the following machines also use the fw_cfg device:

- ARM: virt & sbsa-ref
- HPPA: generic machine
- X86: ACPI based (pc & microvm)
- PPC64: various
- SPARC: sun4m & sun4u

Add their FW_CFG Kconfig dependency.

---
 hw/arm/Kconfig     | 2 ++
 hw/hppa/Kconfig    | 1 +
 hw/i386/Kconfig    | 2 ++
 hw/ppc/Kconfig     | 1 +
 hw/sparc/Kconfig   | 1 +
 hw/sparc64/Kconfig | 1 +
 6 files changed, 8 insertions(+)
hw/arm/Kconfig +2 -0
index 8c37cf00da7..3b2641e39dc 100644
@@ -8,6 +8,7 @@ config ARM_VIRT
     imply TPM_TIS_SYSBUS
     select ARM_GIC
     select ACPI
+    select FW_CFG
     select ARM_SMMUV3
     select GPIO_KEY
     select FW_CFG_DMA
@@ -216,6 +217,7 @@ config SBSA_REF
     select PL061 # GPIO
     select USB_EHCI_SYSBUS
     select WDT_SBSA
+    select FW_CFG
 
 config SABRELITE
     bool
hw/hppa/Kconfig +1 -0
index 22948db0256..45f40e09224 100644
@@ -14,3 +14,4 @@ config DINO
     select LASIPS2
     select PARALLEL
     select ARTIST
+    select FW_CFG
hw/i386/Kconfig +2 -0
index 7f91f30877f..9e4039a2dce 100644
@@ -52,6 +52,7 @@ config PC_ACPI
     select SMBUS_EEPROM
     select PFLASH_CFI01
     depends on ACPI_SMBUS
+    select FW_CFG
 
 config I440FX
     bool
@@ -106,6 +107,7 @@ config MICROVM
     select ACPI_HW_REDUCED
     select PCI_EXPRESS_GENERIC_BRIDGE
     select USB_XHCI_SYSBUS
+    select FW_CFG
 
 config X86_IOMMU
     bool
hw/ppc/Kconfig +1 -0
index d11dc30509d..a7ba8283bf1 100644
@@ -131,6 +131,7 @@ config VIRTEX
 # Only used by 64-bit targets
 config FW_CFG_PPC
     bool
+    select FW_CFG
 
 config FDT_PPC
     bool
hw/sparc/Kconfig +1 -0
index 8dcb10086fd..267bf45fa21 100644
@@ -15,6 +15,7 @@ config SUN4M
     select STP2000
     select CHRP_NVRAM
     select OR_IRQ
+    select FW_CFG
 
 config LEON3
     bool
hw/sparc64/Kconfig +1 -0
index 980a201bb73..c17b34b9d5b 100644
@@ -13,6 +13,7 @@ config SUN4U
     select PCKBD
     select SIMBA
     select CHRP_NVRAM
+    select FW_CFG
 
 config NIAGARA
     bool
Signature · 1 line
2.26.3
#8 lore raw

Re: [PATCH 5/7] hw: Have machines Kconfig-select FW_CFG

Quoted 76 lines · Philippe Mathieu-Daudé

Beside the loongson3-virt machine (MIPS), the following machines also use the fw_cfg device:

- ARM: virt & sbsa-ref
- HPPA: generic machine
- X86: ACPI based (pc & microvm)
- PPC64: various
- SPARC: sun4m & sun4u

Add their FW_CFG Kconfig dependency.

---

hw/arm/Kconfig     | 2 ++
hw/hppa/Kconfig    | 1 +
hw/i386/Kconfig    | 2 ++
hw/ppc/Kconfig     | 1 +
hw/sparc/Kconfig   | 1 +
hw/sparc64/Kconfig | 1 +
6 files changed, 8 insertions(+)
hw/arm/Kconfig +2 -0
index 8c37cf00da7..3b2641e39dc 100644
@@ -8,6 +8,7 @@ config ARM_VIRT
    imply TPM_TIS_SYSBUS
    select ARM_GIC
    select ACPI
+    select FW_CFG
    select ARM_SMMUV3
    select GPIO_KEY
    select FW_CFG_DMA
@@ -216,6 +217,7 @@ config SBSA_REF
    select PL061 # GPIO
    select USB_EHCI_SYSBUS
    select WDT_SBSA
+    select FW_CFG
 

config SABRELITE
bool

hw/hppa/Kconfig +1 -0
index 22948db0256..45f40e09224 100644
@@ -14,3 +14,4 @@ config DINO
    select LASIPS2
    select PARALLEL
    select ARTIST
+    select FW_CFG
hw/i386/Kconfig +1 -0
index 7f91f30877f..9e4039a2dce 100644
@@ -52,6 +52,7 @@ config PC_ACPI
    select SMBUS_EEPROM
    select PFLASH_CFI01
    depends on ACPI_SMBUS
+    select FW_CFG
 

config I440FX
bool

hw/i386/Kconfig +1 -0
@@ -106,6 +107,7 @@ config MICROVM
    select ACPI_HW_REDUCED
    select PCI_EXPRESS_GENERIC_BRIDGE
    select USB_XHCI_SYSBUS
+    select FW_CFG
 

config X86_IOMMU
bool

hw/ppc/Kconfig +0 -0
index d11dc30509d..a7ba8283bf1 100644
@@ -131,6 +131,7 @@ config VIRTEX
 # Only used by 64-bit targets
Quoted 3 lines

config FW_CFG_PPC
bool
+ select FW_CFG

Why do we need a separate config option here if all it does is select FW_CFG and also in meson.build it only seems to add fw_cfg.c? (Unlike FW_CFG_DMA which seems to add other files so another option makes sense for that case). Could we just use FW_CFG directly and drop the PPC specific option like you did for MIPS?

Also the comment saying "Only used by 64-bit targets" seems to be wrong as it is also selected by MAC_OLDWORLD that's definitely a 32-bit machine (and MAC_NEWWORLD that can be both 32 or 64 bit) so maybe this option used to do something previously but now seems to be equivalent to just FW_CFG. So could it be dropped and use FW_CFG instead to simplify this or what's the reason to keep a PPC specific option for it?

Regards,
BALATON Zoltan

Quoted 28 lines

config FDT_PPC
bool

hw/sparc/Kconfig +1 -0
index 8dcb10086fd..267bf45fa21 100644
@@ -15,6 +15,7 @@ config SUN4M
    select STP2000
    select CHRP_NVRAM
    select OR_IRQ
+    select FW_CFG
 

config LEON3
bool

hw/sparc64/Kconfig +1 -0
index 980a201bb73..c17b34b9d5b 100644
@@ -13,6 +13,7 @@ config SUN4U
    select PCKBD
    select SIMBA
    select CHRP_NVRAM
+    select FW_CFG
 

config NIAGARA
bool

#9 lore raw

Re: [PATCH 5/7] hw: Have machines Kconfig-select FW_CFG

Quoted 87 lines · BALATON Zoltan
Quoted 76 lines · Philippe Mathieu-Daudé

Beside the loongson3-virt machine (MIPS), the following machines also use the fw_cfg device:

- ARM: virt & sbsa-ref
- HPPA: generic machine
- X86: ACPI based (pc & microvm)
- PPC64: various
- SPARC: sun4m & sun4u

Add their FW_CFG Kconfig dependency.

---

hw/arm/Kconfig     | 2 ++
hw/hppa/Kconfig    | 1 +
hw/i386/Kconfig    | 2 ++
hw/ppc/Kconfig     | 1 +
hw/sparc/Kconfig   | 1 +
hw/sparc64/Kconfig | 1 +
6 files changed, 8 insertions(+)
hw/arm/Kconfig +2 -0
index 8c37cf00da7..3b2641e39dc 100644
@@ -8,6 +8,7 @@ config ARM_VIRT
    imply TPM_TIS_SYSBUS
    select ARM_GIC
    select ACPI
+    select FW_CFG
    select ARM_SMMUV3
    select GPIO_KEY
    select FW_CFG_DMA
@@ -216,6 +217,7 @@ config SBSA_REF
    select PL061 # GPIO
    select USB_EHCI_SYSBUS
    select WDT_SBSA
+    select FW_CFG
 

config SABRELITE
bool

hw/hppa/Kconfig +1 -0
index 22948db0256..45f40e09224 100644
@@ -14,3 +14,4 @@ config DINO
    select LASIPS2
    select PARALLEL
    select ARTIST
+    select FW_CFG
hw/i386/Kconfig +1 -0
index 7f91f30877f..9e4039a2dce 100644
@@ -52,6 +52,7 @@ config PC_ACPI
    select SMBUS_EEPROM
    select PFLASH_CFI01
    depends on ACPI_SMBUS
+    select FW_CFG
 

config I440FX
bool

hw/i386/Kconfig +1 -0
@@ -106,6 +107,7 @@ config MICROVM
    select ACPI_HW_REDUCED
    select PCI_EXPRESS_GENERIC_BRIDGE
    select USB_XHCI_SYSBUS
+    select FW_CFG
 

config X86_IOMMU
bool

hw/ppc/Kconfig +0 -0
index d11dc30509d..a7ba8283bf1 100644
@@ -131,6 +131,7 @@ config VIRTEX
 # Only used by 64-bit targets
Quoted 3 lines

config FW_CFG_PPC
bool
+ select FW_CFG

Why do we need a separate config option here if all it does is select FW_CFG and also in meson.build it only seems to add fw_cfg.c? (Unlike FW_CFG_DMA which seems to add other files so another option makes sense for that case). Could we just use FW_CFG directly and drop the PPC specific option like you did for MIPS?

Quoted 6 lines

Also the comment saying "Only used by 64-bit targets" seems to be wrong as it is also selected by MAC_OLDWORLD that's definitely a 32-bit machine (and MAC_NEWWORLD that can be both 32 or 64 bit) so maybe this option used to do something previously but now seems to be equivalent to just FW_CFG. So could it be dropped and use FW_CFG instead to simplify this or what's the reason to keep a PPC specific option for it?

Actually... good point. I don't see any reason for this config option either.

Quoted 32 lines

Regards,
BALATON Zoltan

Quoted 28 lines

config FDT_PPC
bool

hw/sparc/Kconfig +1 -0
index 8dcb10086fd..267bf45fa21 100644
@@ -15,6 +15,7 @@ config SUN4M
    select STP2000
    select CHRP_NVRAM
    select OR_IRQ
+    select FW_CFG
 

config LEON3
bool

hw/sparc64/Kconfig +1 -0
index 980a201bb73..c17b34b9d5b 100644
@@ -13,6 +13,7 @@ config SUN4U
    select PCKBD
    select SIMBA
    select CHRP_NVRAM
+    select FW_CFG
 

config NIAGARA
bool

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
Acked-by on v1 5/7
#10 lore raw

Re: [PATCH 5/7] hw: Have machines Kconfig-select FW_CFG

In reply to Philippe Mathieu-Daudé
Quoted 9 lines · Philippe Mathieu-Daudé

Beside the loongson3-virt machine (MIPS), the following machines also use the fw_cfg device:

- ARM: virt & sbsa-ref
- HPPA: generic machine
- X86: ACPI based (pc & microvm)
- PPC64: various
- SPARC: sun4m & sun4u

Quoted 3 lines

Add their FW_CFG Kconfig dependency.

ppc parts

Quoted 94 lines
---
 hw/arm/Kconfig     | 2 ++
 hw/hppa/Kconfig    | 1 +
 hw/i386/Kconfig    | 2 ++
 hw/ppc/Kconfig     | 1 +
 hw/sparc/Kconfig   | 1 +
 hw/sparc64/Kconfig | 1 +
 6 files changed, 8 insertions(+)
hw/arm/Kconfig +2 -0
index 8c37cf00da7..3b2641e39dc 100644
@@ -8,6 +8,7 @@ config ARM_VIRT
     imply TPM_TIS_SYSBUS
     select ARM_GIC
     select ACPI
+    select FW_CFG
     select ARM_SMMUV3
     select GPIO_KEY
     select FW_CFG_DMA
@@ -216,6 +217,7 @@ config SBSA_REF
     select PL061 # GPIO
     select USB_EHCI_SYSBUS
     select WDT_SBSA
+    select FW_CFG
 
 config SABRELITE
     bool
hw/hppa/Kconfig +1 -0
index 22948db0256..45f40e09224 100644
@@ -14,3 +14,4 @@ config DINO
     select LASIPS2
     select PARALLEL
     select ARTIST
+    select FW_CFG
hw/i386/Kconfig +2 -0
index 7f91f30877f..9e4039a2dce 100644
@@ -52,6 +52,7 @@ config PC_ACPI
     select SMBUS_EEPROM
     select PFLASH_CFI01
     depends on ACPI_SMBUS
+    select FW_CFG
 
 config I440FX
     bool
@@ -106,6 +107,7 @@ config MICROVM
     select ACPI_HW_REDUCED
     select PCI_EXPRESS_GENERIC_BRIDGE
     select USB_XHCI_SYSBUS
+    select FW_CFG
 
 config X86_IOMMU
     bool
hw/ppc/Kconfig +1 -0
index d11dc30509d..a7ba8283bf1 100644
@@ -131,6 +131,7 @@ config VIRTEX
 # Only used by 64-bit targets
 config FW_CFG_PPC
     bool
+    select FW_CFG
 
 config FDT_PPC
     bool
hw/sparc/Kconfig +1 -0
index 8dcb10086fd..267bf45fa21 100644
@@ -15,6 +15,7 @@ config SUN4M
     select STP2000
     select CHRP_NVRAM
     select OR_IRQ
+    select FW_CFG
 
 config LEON3
     bool
hw/sparc64/Kconfig +1 -0
index 980a201bb73..c17b34b9d5b 100644
@@ -13,6 +13,7 @@ config SUN4U
     select PCKBD
     select SIMBA
     select CHRP_NVRAM
+    select FW_CFG
 
 config NIAGARA
     bool
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#11 lore raw

Re: [PATCH 5/7] hw: Have machines Kconfig-select FW_CFG

In reply to Philippe Mathieu-Daudé
Quoted 6 lines · Philippe Mathieu-Daudé

Beside the loongson3-virt machine (MIPS), the following machines also use the fw_cfg device:

- ARM: virt & sbsa-ref
- HPPA: generic machine
- X86: ACPI based (pc & microvm)

It's correct, but the way this is formulated is confusing, for me anyway. Can you please write "(pc (i440fx, q35) & microvm)"?

Because, we frequently use "pc" interchangeably with "i440fx", and so I was missing q35 from the list.

Thanks
Laszlo

Quoted 101 lines

- PPC64: various
- SPARC: sun4m & sun4u

Add their FW_CFG Kconfig dependency.

---
 hw/arm/Kconfig     | 2 ++
 hw/hppa/Kconfig    | 1 +
 hw/i386/Kconfig    | 2 ++
 hw/ppc/Kconfig     | 1 +
 hw/sparc/Kconfig   | 1 +
 hw/sparc64/Kconfig | 1 +
 6 files changed, 8 insertions(+)
hw/arm/Kconfig +2 -0
index 8c37cf00da7..3b2641e39dc 100644
@@ -8,6 +8,7 @@ config ARM_VIRT
     imply TPM_TIS_SYSBUS
     select ARM_GIC
     select ACPI
+    select FW_CFG
     select ARM_SMMUV3
     select GPIO_KEY
     select FW_CFG_DMA
@@ -216,6 +217,7 @@ config SBSA_REF
     select PL061 # GPIO
     select USB_EHCI_SYSBUS
     select WDT_SBSA
+    select FW_CFG
 
 config SABRELITE
     bool
hw/hppa/Kconfig +1 -0
index 22948db0256..45f40e09224 100644
@@ -14,3 +14,4 @@ config DINO
     select LASIPS2
     select PARALLEL
     select ARTIST
+    select FW_CFG
hw/i386/Kconfig +2 -0
index 7f91f30877f..9e4039a2dce 100644
@@ -52,6 +52,7 @@ config PC_ACPI
     select SMBUS_EEPROM
     select PFLASH_CFI01
     depends on ACPI_SMBUS
+    select FW_CFG
 
 config I440FX
     bool
@@ -106,6 +107,7 @@ config MICROVM
     select ACPI_HW_REDUCED
     select PCI_EXPRESS_GENERIC_BRIDGE
     select USB_XHCI_SYSBUS
+    select FW_CFG
 
 config X86_IOMMU
     bool
hw/ppc/Kconfig +1 -0
index d11dc30509d..a7ba8283bf1 100644
@@ -131,6 +131,7 @@ config VIRTEX
 # Only used by 64-bit targets
 config FW_CFG_PPC
     bool
+    select FW_CFG
 
 config FDT_PPC
     bool
hw/sparc/Kconfig +1 -0
index 8dcb10086fd..267bf45fa21 100644
@@ -15,6 +15,7 @@ config SUN4M
     select STP2000
     select CHRP_NVRAM
     select OR_IRQ
+    select FW_CFG
 
 config LEON3
     bool
hw/sparc64/Kconfig +1 -0
index 980a201bb73..c17b34b9d5b 100644
@@ -13,6 +13,7 @@ config SUN4U
     select PCKBD
     select SIMBA
     select CHRP_NVRAM
+    select FW_CFG
 
 config NIAGARA
     bool
Acked-by on v1 5/7
#12 lore raw

Re: [PATCH 5/7] hw: Have machines Kconfig-select FW_CFG

In reply to Philippe Mathieu-Daudé
Quoted 9 lines · Philippe Mathieu-Daudé

Beside the loongson3-virt machine (MIPS), the following machines also use the fw_cfg device:

- ARM: virt & sbsa-ref
- HPPA: generic machine
- X86: ACPI based (pc & microvm)
- PPC64: various
- SPARC: sun4m & sun4u

Quoted 3 lines

Add their FW_CFG Kconfig dependency.

Signature · 1 line
Eduardo
#13 lore raw

PATCH 6/7 hw/{arm,hppa,riscv}: Add fw_cfg arch-specific stub

In reply to Philippe Mathieu-Daudé

The ARM, HPPA and RISC-V architectures don't declare any fw_cfg specific key. To simplify the buildsys machinery and allow building QEMU without the fw_cfg device (in the next commit), first add a per-architecture empty stub defining the fw_cfg_arch_key_name().

Update the MAINTAINERS section to cover the various target-specific fw_cfg.c files.

---
 hw/arm/fw_cfg.c      | 19 +++++++++++++++++++
 hw/hppa/fw_cfg.c     | 19 +++++++++++++++++++
 hw/riscv/fw_cfg.c    | 19 +++++++++++++++++++
 MAINTAINERS          |  2 +-
 hw/arm/meson.build   |  1 +
 hw/hppa/meson.build  |  1 +
 hw/riscv/meson.build |  1 +
 7 files changed, 61 insertions(+), 1 deletion(-)
 create mode 100644 hw/arm/fw_cfg.c
 create mode 100644 hw/hppa/fw_cfg.c
 create mode 100644 hw/riscv/fw_cfg.c
hw/arm/fw_cfg.c new file +19 -0
new file mode 100644
index 00000000000..de2bca9c76c
@@ -0,0 +1,19 @@
+/*
+ * QEMU fw_cfg helpers (ARM specific)
+ *
+ * Copyright (c) 2021 Red Hat, Inc.
+ *
+ * Author:
+ *   Philippe Mathieu-Daudé <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/mips/fw_cfg.h"
+#include "hw/nvram/fw_cfg.h"
+
+const char *fw_cfg_arch_key_name(uint16_t key)
+{
+    return NULL;
+}
hw/hppa/fw_cfg.c new file +19 -0
new file mode 100644
index 00000000000..322b03068c7
@@ -0,0 +1,19 @@
+/*
+ * QEMU fw_cfg helpers (HPPA specific)
+ *
+ * Copyright (c) 2021 Red Hat, Inc.
+ *
+ * Author:
+ *   Philippe Mathieu-Daudé <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/mips/fw_cfg.h"
+#include "hw/nvram/fw_cfg.h"
+
+const char *fw_cfg_arch_key_name(uint16_t key)
+{
+    return NULL;
+}
hw/riscv/fw_cfg.c new file +19 -0
new file mode 100644
index 00000000000..8e3d2a8bdea
@@ -0,0 +1,19 @@
+/*
+ * QEMU fw_cfg helpers (RISC-V specific)
+ *
+ * Copyright (c) 2021 Red Hat, Inc.
+ *
+ * Author:
+ *   Philippe Mathieu-Daudé <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/mips/fw_cfg.h"
+#include "hw/nvram/fw_cfg.h"
+
+const char *fw_cfg_arch_key_name(uint16_t key)
+{
+    return NULL;
+}
MAINTAINERS +1 -1
index 36055f14c59..ab8f030d4c0 100644
@@ -2162,7 +2162,7 @@ R: Laszlo Ersek <[email protected]>
 R: Gerd Hoffmann <[email protected]>
 S: Supported
 F: docs/specs/fw_cfg.txt
-F: hw/nvram/fw_cfg*.c
+F: hw/*/fw_cfg*.c
 F: stubs/fw_cfg.c
 F: include/hw/nvram/fw_cfg.h
 F: include/standard-headers/linux/qemu_fw_cfg.h
hw/arm/meson.build +1 -0
index be39117b9b6..fd278de916f 100644
@@ -1,6 +1,7 @@
 arm_ss = ss.source_set()
 arm_ss.add(files('boot.c'), fdt)
 arm_ss.add(when: 'CONFIG_PLATFORM_BUS', if_true: files('sysbus-fdt.c'))
+arm_ss.add(when: 'CONFIG_FW_CFG', if_true: files('fw_cfg.c'))
 arm_ss.add(when: 'CONFIG_ARM_VIRT', if_true: files('virt.c'))
 arm_ss.add(when: 'CONFIG_ACPI', if_true: files('virt-acpi-build.c'))
 arm_ss.add(when: 'CONFIG_DIGIC', if_true: files('digic_boards.c'))
hw/hppa/meson.build +1 -0
index 1deae83aee8..10494cc24b7 100644
@@ -1,4 +1,5 @@
 hppa_ss = ss.source_set()
 hppa_ss.add(when: 'CONFIG_DINO', if_true: files('pci.c', 'machine.c', 'dino.c', 'lasi.c'))
+hppa_ss.add(when: 'CONFIG_FW_CFG', if_true: files('fw_cfg.c'))
 
 hw_arch += {'hppa': hppa_ss}
hw/riscv/meson.build +1 -0
index 275c0f7eb7c..ab4d3adb924 100644
@@ -8,5 +8,6 @@
 riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u.c'))
 riscv_ss.add(when: 'CONFIG_SPIKE', if_true: files('spike.c'))
 riscv_ss.add(when: 'CONFIG_MICROCHIP_PFSOC', if_true: files('microchip_pfsoc.c'))
+riscv_ss.add(when: 'CONFIG_FW_CFG', if_true: files('fw_cfg.c'))
 
 hw_arch += {'riscv': riscv_ss}
Signature · 1 line
2.26.3
#14 lore raw

Re: [PATCH 6/7] hw/{arm,hppa,riscv}: Add fw_cfg arch-specific stub

Quoted 9 lines · Philippe Mathieu-Daudé

The ARM, HPPA and RISC-V architectures don't declare any fw_cfg specific key. To simplify the buildsys machinery and allow building QEMU without the fw_cfg device (in the next commit), first add a per-architecture empty stub defining the fw_cfg_arch_key_name().

Update the MAINTAINERS section to cover the various target-specific fw_cfg.c files.

Quoted 12 lines
---
 hw/arm/fw_cfg.c      | 19 +++++++++++++++++++
 hw/hppa/fw_cfg.c     | 19 +++++++++++++++++++
 hw/riscv/fw_cfg.c    | 19 +++++++++++++++++++
 MAINTAINERS          |  2 +-
 hw/arm/meson.build   |  1 +
 hw/hppa/meson.build  |  1 +
 hw/riscv/meson.build |  1 +
 7 files changed, 61 insertions(+), 1 deletion(-)
 create mode 100644 hw/arm/fw_cfg.c
 create mode 100644 hw/hppa/fw_cfg.c
 create mode 100644 hw/riscv/fw_cfg.c

So, I haven't commented on the Kconfig symbol wrangling yet (my comment would be a blanket "Acked-by" anyway... sorry, not really my cup of tea), but at this point:

I don't understand why we need to add *more code* (stubs / boilerplate) if our goal is (apparently) to build QEMU with *fewer* devices.

Sorry for being dense. My total knowledge about stubs in QEMU is this:
for some QMP methods (and for some QGA methods, dependent on OS), we need stubs. When they are invoked, they report "sorry, not implemented". That's it: all I know about stubs.

So... the commit message here says "simplify the buildsys", and the next commit message says, paraphrased, "don't build fw_cfg unless we need it" -- but why does that require more C-language code? It seems like we have some function *calls* that shouldn't exist in an fw-cfg-less machine, in the first place.

Again, sorry, I'm totally dense on this.

Thanks
Laszlo

Quoted 123 lines
hw/arm/fw_cfg.c new file +19 -0
new file mode 100644
index 00000000000..de2bca9c76c
@@ -0,0 +1,19 @@
+/*
+ * QEMU fw_cfg helpers (ARM specific)
+ *
+ * Copyright (c) 2021 Red Hat, Inc.
+ *
+ * Author:
+ *   Philippe Mathieu-Daudé <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/mips/fw_cfg.h"
+#include "hw/nvram/fw_cfg.h"
+
+const char *fw_cfg_arch_key_name(uint16_t key)
+{
+    return NULL;
+}
hw/hppa/fw_cfg.c new file +19 -0
new file mode 100644
index 00000000000..322b03068c7
@@ -0,0 +1,19 @@
+/*
+ * QEMU fw_cfg helpers (HPPA specific)
+ *
+ * Copyright (c) 2021 Red Hat, Inc.
+ *
+ * Author:
+ *   Philippe Mathieu-Daudé <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/mips/fw_cfg.h"
+#include "hw/nvram/fw_cfg.h"
+
+const char *fw_cfg_arch_key_name(uint16_t key)
+{
+    return NULL;
+}
hw/riscv/fw_cfg.c new file +19 -0
new file mode 100644
index 00000000000..8e3d2a8bdea
@@ -0,0 +1,19 @@
+/*
+ * QEMU fw_cfg helpers (RISC-V specific)
+ *
+ * Copyright (c) 2021 Red Hat, Inc.
+ *
+ * Author:
+ *   Philippe Mathieu-Daudé <[email protected]>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#include "qemu/osdep.h"
+#include "hw/mips/fw_cfg.h"
+#include "hw/nvram/fw_cfg.h"
+
+const char *fw_cfg_arch_key_name(uint16_t key)
+{
+    return NULL;
+}
MAINTAINERS +1 -1
index 36055f14c59..ab8f030d4c0 100644
@@ -2162,7 +2162,7 @@ R: Laszlo Ersek <[email protected]>
 R: Gerd Hoffmann <[email protected]>
 S: Supported
 F: docs/specs/fw_cfg.txt
-F: hw/nvram/fw_cfg*.c
+F: hw/*/fw_cfg*.c
 F: stubs/fw_cfg.c
 F: include/hw/nvram/fw_cfg.h
 F: include/standard-headers/linux/qemu_fw_cfg.h
hw/arm/meson.build +1 -0
index be39117b9b6..fd278de916f 100644
@@ -1,6 +1,7 @@
 arm_ss = ss.source_set()
 arm_ss.add(files('boot.c'), fdt)
 arm_ss.add(when: 'CONFIG_PLATFORM_BUS', if_true: files('sysbus-fdt.c'))
+arm_ss.add(when: 'CONFIG_FW_CFG', if_true: files('fw_cfg.c'))
 arm_ss.add(when: 'CONFIG_ARM_VIRT', if_true: files('virt.c'))
 arm_ss.add(when: 'CONFIG_ACPI', if_true: files('virt-acpi-build.c'))
 arm_ss.add(when: 'CONFIG_DIGIC', if_true: files('digic_boards.c'))
hw/hppa/meson.build +1 -0
index 1deae83aee8..10494cc24b7 100644
@@ -1,4 +1,5 @@
 hppa_ss = ss.source_set()
 hppa_ss.add(when: 'CONFIG_DINO', if_true: files('pci.c', 'machine.c', 'dino.c', 'lasi.c'))
+hppa_ss.add(when: 'CONFIG_FW_CFG', if_true: files('fw_cfg.c'))
 
 hw_arch += {'hppa': hppa_ss}
hw/riscv/meson.build +1 -0
index 275c0f7eb7c..ab4d3adb924 100644
@@ -8,5 +8,6 @@
 riscv_ss.add(when: 'CONFIG_SIFIVE_U', if_true: files('sifive_u.c'))
 riscv_ss.add(when: 'CONFIG_SPIKE', if_true: files('spike.c'))
 riscv_ss.add(when: 'CONFIG_MICROCHIP_PFSOC', if_true: files('microchip_pfsoc.c'))
+riscv_ss.add(when: 'CONFIG_FW_CFG', if_true: files('fw_cfg.c'))
 
 hw_arch += {'riscv': riscv_ss}
#15 lore raw

Re: [PATCH 6/7] hw/{arm,hppa,riscv}: Add fw_cfg arch-specific stub

Quoted 35 lines · Laszlo Ersek
Quoted 9 lines · Philippe Mathieu-Daudé

The ARM, HPPA and RISC-V architectures don't declare any fw_cfg specific key. To simplify the buildsys machinery and allow building QEMU without the fw_cfg device (in the next commit), first add a per-architecture empty stub defining the fw_cfg_arch_key_name().

Update the MAINTAINERS section to cover the various target-specific fw_cfg.c files.

Quoted 12 lines
---
 hw/arm/fw_cfg.c      | 19 +++++++++++++++++++
 hw/hppa/fw_cfg.c     | 19 +++++++++++++++++++
 hw/riscv/fw_cfg.c    | 19 +++++++++++++++++++
 MAINTAINERS          |  2 +-
 hw/arm/meson.build   |  1 +
 hw/hppa/meson.build  |  1 +
 hw/riscv/meson.build |  1 +
 7 files changed, 61 insertions(+), 1 deletion(-)
 create mode 100644 hw/arm/fw_cfg.c
 create mode 100644 hw/hppa/fw_cfg.c
 create mode 100644 hw/riscv/fw_cfg.c

So, I haven't commented on the Kconfig symbol wrangling yet (my comment would be a blanket "Acked-by" anyway... sorry, not really my cup of tea), but at this point:

I don't understand why we need to add *more code* (stubs / boilerplate) if our goal is (apparently) to build QEMU with *fewer* devices.

Sorry for being dense. My total knowledge about stubs in QEMU is this:
for some QMP methods (and for some QGA methods, dependent on OS), we need stubs. When they are invoked, they report "sorry, not implemented". That's it: all I know about stubs.

Quoted 7 lines

So... the commit message here says "simplify the buildsys", and the next commit message says, paraphrased, "don't build fw_cfg unless we need it" -- but why does that require more C-language code? It seems like we have some function *calls* that shouldn't exist in an fw-cfg-less machine, in the first place.

Again, sorry, I'm totally dense on this.

Eh no problem, I don't like this neither.

If you don't mind I'll reply in the patch 7/7.

#16 lore raw

PATCH 7/7 hw/nvram: Do not build FW_CFG if not required

In reply to Philippe Mathieu-Daudé

If the Kconfig 'FW_CFG' symbol is not selected, it is pointless to build the fw_cfg device. Update the stubs.

---
 stubs/fw_cfg.c       | 49 ++++++++++++++++++++++++++++++++++++++++++--
 hw/nvram/meson.build |  2 +-
 2 files changed, 48 insertions(+), 3 deletions(-)
stubs/fw_cfg.c +47 -2
index bb1e3c8aa95..ac1e539c93f 100644
@@ -1,7 +1,7 @@
 /*
  * fw_cfg stubs
  *
- * Copyright (c) 2019 Red Hat, Inc.
+ * Copyright (c) 2019,2021 Red Hat, Inc.
  *
  * Author:
  *   Philippe Mathieu-Daudé <[email protected]>
@@ -13,9 +13,54 @@
  */
 
 #include "qemu/osdep.h"
+#include "qapi/error.h"
 #include "hw/nvram/fw_cfg.h"
 
-const char *fw_cfg_arch_key_name(uint16_t key)
+FWCfgState *fw_cfg_find(void)
 {
     return NULL;
 }
+
+bool fw_cfg_add_from_generator(FWCfgState *s, const char *filename,
+                               const char *gen_id, Error **errp)
+{
+    error_setg(errp, "fw-cfg device not built in");
+
+    return true;
+}
+
+void fw_cfg_add_file(FWCfgState *s,  const char *filename,
+                     void *data, size_t len)
+{
+    g_assert_not_reached();
+}
+
+void fw_cfg_add_file_callback(FWCfgState *s,  const char *filename,
+                              FWCfgCallback select_cb,
+                              FWCfgWriteCallback write_cb,
+                              void *callback_opaque,
+                              void *data, size_t len, bool read_only)
+{
+    g_assert_not_reached();
+}
+
+void *fw_cfg_modify_file(FWCfgState *s, const char *filename,
+                        void *data, size_t len)
+{
+    g_assert_not_reached();
+}
+
+void fw_cfg_set_order_override(FWCfgState *s, int order)
+{
+    g_assert_not_reached();
+}
+
+void fw_cfg_reset_order_override(FWCfgState *s)
+{
+    g_assert_not_reached();
+}
+
+bool fw_cfg_dma_enabled(void *opaque)
+{
+    g_assert_not_reached();
+}
hw/nvram/meson.build +1 -1
index fd2951a860f..99e12224483 100644
@@ -1,7 +1,7 @@
 # QOM interfaces must be available anytime QOM is used.
 qom_ss.add(files('fw_cfg-interface.c'))
 
-softmmu_ss.add(files('fw_cfg.c'))
+softmmu_ss.add(when: 'CONFIG_FW_CFG', if_true: files('fw_cfg.c'))
 softmmu_ss.add(when: 'CONFIG_CHRP_NVRAM', if_true: files('chrp_nvram.c'))
 softmmu_ss.add(when: 'CONFIG_DS1225Y', if_true: files('ds1225y.c'))
 softmmu_ss.add(when: 'CONFIG_NMC93XX_EEPROM', if_true: files('eeprom93xx.c'))
Signature · 1 line
2.26.3
#17 lore raw

Re: [PATCH 7/7] hw/nvram: Do not build FW_CFG if not required

Quoted 8 lines · Philippe Mathieu-Daudé

If the Kconfig 'FW_CFG' symbol is not selected, it is pointless to build the fw_cfg device. Update the stubs.

---
 stubs/fw_cfg.c       | 49 ++++++++++++++++++++++++++++++++++++++++++--
 hw/nvram/meson.build |  2 +-
 2 files changed, 48 insertions(+), 3 deletions(-)

Answering here to Laszlo's comment from:
https://lists.gnu.org/archive/html/qemu-devel/2021-04/msg05858.html

Quoted 2 lines · Laszlo Ersek

I don't understand why we need to add *more code* (stubs / boilerplate) if our goal is (apparently) to build QEMU with *fewer* devices.

The list of callers:

hw/acpi/bios-linker-loader.c:177: return fw_cfg &&
fw_cfg_dma_enabled(fw_cfg);
hw/acpi/core.c:640: fw_cfg_add_file(fw_cfg, "etc/system-states",
g_memdup(suspend, 6), 6);
hw/acpi/ghes.c:383: fw_cfg_add_file(s, ACPI_GHES_ERRORS_FW_CFG_FILE,
hardware_error->data,
hw/acpi/ghes.c:387: fw_cfg_add_file_callback(s,
ACPI_GHES_DATA_ADDR_FW_CFG_FILE, NULL, NULL,
hw/acpi/nvdimm.c:912: fw_cfg_add_file(fw_cfg, NVDIMM_DSM_MEM_FILE,
state->dsm_mem->data,
hw/acpi/vmgenid.c:128: fw_cfg_add_file(s, VMGENID_GUID_FW_CFG_FILE,
guid->data,
hw/acpi/vmgenid.c:131: fw_cfg_add_file_callback(s,
VMGENID_ADDR_FW_CFG_FILE, NULL, NULL, NULL,
hw/arm/virt-acpi-build.c:870: fw_cfg_add_file(vms->fw_cfg,
ACPI_BUILD_TPMLOG_FILE, tables.tcpalog->data,
hw/arm/virt.c:1531: fw_cfg_add_file(vms->fw_cfg,
"etc/smbios/smbios-tables",
hw/arm/virt.c:1533: fw_cfg_add_file(vms->fw_cfg,
"etc/smbios/smbios-anchor",
hw/core/loader.c:1017: fw_cfg_add_file(fw_cfg, fw_file_name,
data, rom->romsize);
hw/core/loader.c:1074: fw_cfg_add_file_callback(fw_cfg, fw_file_name,
hw/core/loader.c:1254: fw_cfg_set_order_override(fw_cfg, order);
hw/core/loader.c:1261: fw_cfg_reset_order_override(fw_cfg);
hw/core/loader.c:919: fw_cfg_modify_file(fw_cfg, id +
strlen("/rom@"), host, length);
hw/display/ramfb.c:131: fw_cfg_add_file_callback(fw_cfg, "etc/ramfb",
hw/hppa/machine.c:104: fw_cfg_add_file(fw_cfg,
"/etc/firmware-min-version",

hw/hppa/machine.c:108:    fw_cfg_add_file(fw_cfg, "/etc/cpu/tlb_entries",
hw/hppa/machine.c:112:    fw_cfg_add_file(fw_cfg, "/etc/cpu/btlb_entries",
hw/hppa/machine.c:116:    fw_cfg_add_file(fw_cfg, "/etc/power-button-addr",

hw/i386/acpi-build.c:2638: fw_cfg_add_file(x86ms->fw_cfg,
ACPI_BUILD_TPMLOG_FILE,
hw/i386/acpi-build.c:2648: fw_cfg_add_file(x86ms->fw_cfg,
"etc/tpm/config",
hw/i386/acpi-build.c:2667:
fw_cfg_add_file_callback(x86ms->fw_cfg, ACPI_BUILD_RSDP_FILE,
hw/i386/fw_cfg.c:130: fw_cfg_add_file(fw_cfg, "etc/e820", e820_table,
hw/i386/fw_cfg.c:181: fw_cfg_add_file(fw_cfg,
"etc/msr_feature_control", val, sizeof(*val));
hw/i386/fw_cfg.c:85: fw_cfg_add_file(fw_cfg,
"etc/smbios/smbios-tables",
hw/i386/fw_cfg.c:87: fw_cfg_add_file(fw_cfg,
"etc/smbios/smbios-anchor",
hw/i386/microvm.c:329: fw_cfg_add_file(fw_cfg, "etc/e820", e820_table,
hw/i386/pc.c:977: fw_cfg_add_file(fw_cfg,
"etc/reserved-memory-end", val, sizeof(*val));
hw/i386/x86.c:1078: if (linuxboot_dma_enabled &&
fw_cfg_dma_enabled(fw_cfg)) {
hw/isa/lpc_ich9.c:421: fw_cfg_add_file(fw_cfg,
"etc/smi/supported-features",
hw/isa/lpc_ich9.c:428: fw_cfg_add_file_callback(fw_cfg,
"etc/smi/requested-features",
hw/isa/lpc_ich9.c:433: fw_cfg_add_file_callback(fw_cfg,
"etc/smi/features-ok",
hw/misc/pvpanic-isa.c:60: fw_cfg_add_file(fw_cfg, "etc/pvpanic-port",
pvpanic_port,
hw/misc/vmcoreinfo.c:60: fw_cfg_add_file_callback(fw_cfg,
FW_CFG_VMCOREINFO_FILENAME,
hw/ppc/mac_newworld.c:526: fw_cfg_add_file(fw_cfg,
"ndrv/qemu_vga.ndrv", ndrv_file, ndrv_size);
hw/ppc/mac_oldworld.c:371: fw_cfg_add_file(fw_cfg,
"ndrv/qemu_vga.ndrv", ndrv_file, ndrv_size);
hw/vfio/igd.c:565: fw_cfg_add_file(fw_cfg_find(), "etc/igd-bdsm-size",
hw/vfio/pci-quirks.c:1201: fw_cfg_add_file(fw_cfg_find(),
"etc/igd-opregion",
softmmu/vl.c:1183: if (!fw_cfg_add_from_generator(fw_cfg, name,
gen_id, errp)) {
softmmu/vl.c:1196: fw_cfg_set_order_override(fw_cfg,
FW_CFG_ORDER_OVERRIDE_USER);
softmmu/vl.c:1197: fw_cfg_add_file(fw_cfg, name, buf, size);
softmmu/vl.c:1198: fw_cfg_reset_order_override(fw_cfg);

From this list,

I'd like to simplify hw/acpi/bios-linker-loader.c, but later.

The remaining core components are hw/core/loader.c and softmmu/vl.c:

hw/core/loader.c:1017: fw_cfg_add_file(fw_cfg, fw_file_name,
data, rom->romsize);
hw/core/loader.c:1074: fw_cfg_add_file_callback(fw_cfg, fw_file_name,
hw/core/loader.c:1254: fw_cfg_set_order_override(fw_cfg, order);
hw/core/loader.c:1261: fw_cfg_reset_order_override(fw_cfg);
hw/core/loader.c:919: fw_cfg_modify_file(fw_cfg, id +
strlen("/rom@"), host, length);

softmmu/vl.c:1183: if (!fw_cfg_add_from_generator(fw_cfg, name,
gen_id, errp)) {
softmmu/vl.c:1196: fw_cfg_set_order_override(fw_cfg,
FW_CFG_ORDER_OVERRIDE_USER);
softmmu/vl.c:1197: fw_cfg_add_file(fw_cfg, name, buf, size);
softmmu/vl.c:1198: fw_cfg_reset_order_override(fw_cfg);

Bah, I thought vl.c was generic code, but it is target-specific, so we could add '#include CONFIG_DEVICES' and add more #ifdef'ry on CONFIG_FW_CFG.

Less stubs VS more #ifdef'ry...

It is not clear to me how to modularize this from the core code.

TBC...

Thanks,

Phil.