hw/sparc64/sun4u: Use fw_cfg_init_io_nodma()
Subsystems (2)
v6 cover hw/sparc64/sun4u: Use fw_cfg_init_io_nodma()
Hi Zhao,
This is my answer to this comment of yours:
Quoted 6 lines
Although other callers of
fw_cfg_init_io_dma()besides x86 also pass DMA arguments to create DMA-enabled FwCfgIoState, the "dma_enabled" property of FwCfgIoState cannot yet be removed, because Sun4u and Sun4v still create DMA-disabled FwCfgIoState (bypassfw_cfg_init_io_dma()) insun4uv_init()(hw/sparc64/sun4u.c).
Quoted 7 lines
Maybe reusing
fw_cfg_init_io_dma()for them would be a better choice, or addingfw_cfg_init_io_nodma(). However, before that, first simplify the handling of FwCfgState in x86.Considering that FwCfgIoState in x86 enables DMA by default, remove the handling for DMA-disabled cases and replace DMA checks with assertions to ensure that the default DMA-enabled setting is not broken.
My series is to apply just after this patch of your series:
[PATCH v5 10/28] hw/mips/loongson3_virt: Prefer using fw_cfg_init_mem_nodma()
Regards,
Phil.
Based-on: <[email protected]>
Philippe Mathieu-Daudé (12):
hw/ppc/mac: Use fw_cfg_init_mem_nodma() hw/sparc/sun4m: Use fw_cfg_init_mem_nodma() hw/nvram/fw_cfg: Factor fw_cfg_init_mem_internal() out hw/nvram/fw_cfg: Rename fw_cfg_init_mem_wide() ->
fw_cfg_init_mem_dma()
hw/nvram/fw_cfg: Propagate I/O MemoryRegion to fw_cfg_init_io_dma() hw/nvram/fw_cfg: Factor fw_cfg_init_io_internal() out hw/nvram/fw_cfg: Add fw_cfg_init_io_nodma() helper hw/sparc64/sun4u: Use fw_cfg_init_io_nodma() hw/nvram/fw_cfg: Remove fw_cfg_io_properties::dma_enabled hw/i386/x86: Remove X86MachineClass::fwcfg_dma_enabled field hw/i386/pc: Remove multiboot.bin
hw/i386: Remove linuxboot.bin
Zhao Liu (1):
hw/i386: Assume fw_cfg DMA is always enabled
include/hw/i386/x86.h | 2 - include/hw/nvram/fw_cfg.h | 11 +- pc-bios/optionrom/optionrom.h | 4 - hw/arm/virt.c | 2 +- hw/i386/fw_cfg.c | 19 +-- hw/i386/microvm.c | 6 +- hw/i386/multiboot.c | 7 +- hw/i386/pc.c | 7 +- hw/i386/x86-common.c | 7 +- hw/i386/x86.c | 2 - hw/loongarch/fw_cfg.c | 4 +- hw/nvram/fw_cfg.c | 61 ++++---- hw/ppc/mac_newworld.c | 11 +- hw/ppc/mac_oldworld.c | 11 +- hw/riscv/virt.c | 4 +- hw/sparc/sun4m.c | 12 +- hw/sparc64/sun4u.c | 9 +- pc-bios/meson.build | 2 - pc-bios/multiboot.bin | Bin 1024 -> 0 bytes pc-bios/optionrom/Makefile | 2 +- pc-bios/optionrom/linuxboot.S | 195 ------------------------- pc-bios/optionrom/multiboot.S | 232 ----------------------------- pc-bios/optionrom/multiboot_dma.S | 234 +++++++++++++++++++++++++++++- 23 files changed, 302 insertions(+), 542 deletions(-) delete mode 100644 pc-bios/multiboot.bin delete mode 100644 pc-bios/optionrom/linuxboot.S delete mode 100644 pc-bios/optionrom/multiboot.S
Signature · 1 line
2.51.0
PATCH v6 1/13 hw/ppc/mac: Use fw_cfg_init_mem_nodma()
Use fw_cfg_init_mem_nodma() instead of open-coding it.
--- hw/ppc/mac_newworld.c | 11 +---------- hw/ppc/mac_oldworld.c | 11 +---------- 2 files changed, 2 insertions(+), 20 deletions(-)
hw/ppc/mac_newworld.c +1 -10
@@ -453,16 +453,7 @@ static void ppc_core99_init(MachineState *machine)pmac_format_nvram_partition (nvr,MACIO_NVRAM_SIZE );/* No PCI init: the BIOS will do it */ - dev =qdev_new (TYPE_FW_CFG_MEM ); - fw_cfg =FW_CFG (dev); -qdev_prop_set_uint32 (dev,"data_width" ,1 ); -qdev_prop_set_bit (dev,"dma_enabled" , false); -object_property_add_child (OBJECT (machine),TYPE_FW_CFG ,OBJECT (fw_cfg)); - s =SYS_BUS_DEVICE (dev); -sysbus_realize_and_unref (s, &error_fatal); -sysbus_mmio_map (s,0 ,CFG_ADDR ); -sysbus_mmio_map (s,1 ,CFG_ADDR +2 ); - + fw_cfg =fw_cfg_init_mem_nodma (CFG_ADDR ,CFG_ADDR +2 ,1 );fw_cfg_add_i16 (fw_cfg,FW_CFG_NB_CPUS , (uint16_t )machine->smp.cpus);fw_cfg_add_i16 (fw_cfg,FW_CFG_MAX_CPUS , (uint16_t )machine->smp.max_cpus);fw_cfg_add_i64 (fw_cfg,FW_CFG_RAM_SIZE , (uint64_t )machine->ram_size);
hw/ppc/mac_oldworld.c +1 -10
@@ -294,16 +294,7 @@ static void ppc_heathrow_init(MachineState *machine)/* No PCI init: the BIOS will do it */ - dev =qdev_new (TYPE_FW_CFG_MEM ); - fw_cfg =FW_CFG (dev); -qdev_prop_set_uint32 (dev,"data_width" ,1 ); -qdev_prop_set_bit (dev,"dma_enabled" , false); -object_property_add_child (OBJECT (machine),TYPE_FW_CFG ,OBJECT (fw_cfg)); - s =SYS_BUS_DEVICE (dev); -sysbus_realize_and_unref (s, &error_fatal); -sysbus_mmio_map (s,0 ,CFG_ADDR ); -sysbus_mmio_map (s,1 ,CFG_ADDR +2 ); - + fw_cfg =fw_cfg_init_mem_nodma (CFG_ADDR ,CFG_ADDR +2 ,1 );fw_cfg_add_i16 (fw_cfg,FW_CFG_NB_CPUS , (uint16_t )machine->smp.cpus);fw_cfg_add_i16 (fw_cfg,FW_CFG_MAX_CPUS , (uint16_t )machine->smp.max_cpus);fw_cfg_add_i64 (fw_cfg,FW_CFG_RAM_SIZE , (uint64_t )machine->ram_size);
Signature · 1 line
2.51.0
Re: [PATCH-for-11.0 v6 01/13] hw/ppc/mac: Use fw_cfg_init_mem_nodma()
Quoted 5 lines · Philippe Mathieu-Daudé
Date: Wed, 3 Dec 2025 07:09:29 +0100
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH-for-11.0 v6 01/13] hw/ppc/mac: Usefw_cfg_init_mem_nodma()
X-Mailer: git-send-email 2.51.0
Quoted 7 lines
Use
fw_cfg_init_mem_nodma()instead of open-coding it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/ppc/mac_newworld.c | 11 +---------- hw/ppc/mac_oldworld.c | 11 +---------- 2 files changed, 2 insertions(+), 20 deletions(-)
PATCH v6 2/13 hw/sparc/sun4m: Use fw_cfg_init_mem_nodma()
In reply to Philippe Mathieu-DaudéUse fw_cfg_init_mem_nodma() instead of open-coding it.
--- hw/sparc/sun4m.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
hw/sparc/sun4m.c +1 -11
@@ -1051,17 +1051,7 @@ static void sun4m_hw_init(MachineState *machine)ecc_init (hwdef->ecc_base, slavio_irq[28 ], hwdef->ecc_version); - dev =qdev_new (TYPE_FW_CFG_MEM ); - fw_cfg =FW_CFG (dev); -qdev_prop_set_uint32 (dev,"data_width" ,1 ); -qdev_prop_set_bit (dev,"dma_enabled" , false); -object_property_add_child (OBJECT (qdev_get_machine ()),TYPE_FW_CFG , -OBJECT (fw_cfg)); - s =SYS_BUS_DEVICE (dev); -sysbus_realize_and_unref (s, &error_fatal); -sysbus_mmio_map (s,0 ,CFG_ADDR ); -sysbus_mmio_map (s,1 ,CFG_ADDR +2 ); - + fw_cfg =fw_cfg_init_mem_nodma (CFG_ADDR ,CFG_ADDR +2 ,1 );fw_cfg_add_i16 (fw_cfg,FW_CFG_NB_CPUS , (uint16_t )smp_cpus);fw_cfg_add_i16 (fw_cfg,FW_CFG_MAX_CPUS , (uint16_t )max_cpus);fw_cfg_add_i64 (fw_cfg,FW_CFG_RAM_SIZE , (uint64_t )machine->ram_size);
Signature · 1 line
2.51.0
Re: [PATCH-for-11.0 v6 02/13] hw/sparc/sun4m: Use fw_cfg_init_mem_nodma()
Quoted 6 lines · Philippe Mathieu-Daudé
Date: Wed, 3 Dec 2025 07:09:30 +0100
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH-for-11.0 v6 02/13] hw/sparc/sun4m: Use
fw_cfg_init_mem_nodma()
X-Mailer: git-send-email 2.51.0
Quoted 6 lines
Use
fw_cfg_init_mem_nodma()instead of open-coding it.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/sparc/sun4m.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
PATCH v6 3/13 hw/nvram/fw_cfg: Factor fw_cfg_init_mem_internal() out
In reply to Philippe Mathieu-DaudéFactor fw_cfg_init_mem_internal() out of fw_cfg_init_mem_wide(). In fw_cfg_init_mem_wide(), assert DMA arguments are provided. Callers without DMA have to use the fw_cfg_init_mem() helper.
--- hw/nvram/fw_cfg.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
hw/nvram/fw_cfg.c +13 -4
@@ -1054,9 +1054,9 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase,return s; } -FWCfgState *fw_cfg_init_mem_wide (hwaddr ctl_addr, -hwaddr data_addr,uint32_t data_width, -hwaddr dma_addr,AddressSpace *dma_as) +static FWCfgState *fw_cfg_init_mem_internal (hwaddr ctl_addr, +hwaddr data_addr,uint32_t data_width, +hwaddr dma_addr,AddressSpace *dma_as) {DeviceState *dev;SysBusDevice *sbd;
@@ -1088,10 +1088,19 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr,return s; } +FWCfgState *fw_cfg_init_mem_wide (hwaddr ctl_addr, +hwaddr data_addr,uint32_t data_width, +hwaddr dma_addr,AddressSpace *dma_as) +{ +assert (dma_addr && dma_as); +return fw_cfg_init_mem_internal (ctl_addr, data_addr, data_width, + dma_addr, dma_as); +} +FWCfgState *fw_cfg_init_mem_nodma (hwaddr ctl_addr,hwaddr data_addr,unsigned data_width) { -return fw_cfg_init_mem_wide (ctl_addr, data_addr, data_width,0 ,NULL ); +return fw_cfg_init_mem_internal (ctl_addr, data_addr, data_width,0 ,NULL ); }
Signature · 1 line
2.51.0
PATCH v6 4/13 hw/nvram/fw_cfg: Rename fw_cfg_init_mem_wide() -> fw_cfg_init_mem_dma()
In reply to Philippe Mathieu-Daudé"wide" in fw_cfg_init_mem_wide() means "DMA support". Rename for clarity.
--- include/hw/nvram/fw_cfg.h | 6 +++--- hw/arm/virt.c | 2 +- hw/loongarch/fw_cfg.c | 4 ++-- hw/nvram/fw_cfg.c | 6 +++--- hw/riscv/virt.c | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-)
include/hw/nvram/fw_cfg.h +3 -3
@@ -309,9 +309,9 @@ FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase, AddressSpace *dma_as);FWCfgState *fw_cfg_init_mem_nodma (hwaddr ctl_addr,hwaddr data_addr,unsigned data_width); -FWCfgState *fw_cfg_init_mem_wide (hwaddr ctl_addr, -hwaddr data_addr,uint32_t data_width, -hwaddr dma_addr,AddressSpace *dma_as); +FWCfgState *fw_cfg_init_mem_dma (hwaddr ctl_addr, +hwaddr data_addr,uint32_t data_width, +hwaddr dma_addr,AddressSpace *dma_as);FWCfgState *fw_cfg_find (void );bool fw_cfg_dma_enabled (void *opaque);
hw/arm/virt.c +1 -1
@@ -1412,7 +1412,7 @@ static FWCfgState *create_fw_cfg(const VirtMachineState *vms, AddressSpace *as)FWCfgState *fw_cfg;char *nodename; - fw_cfg =fw_cfg_init_mem_wide (base +8 , base,8 , base +16 , as); + fw_cfg =fw_cfg_init_mem_dma (base +8 , base,8 , base +16 , as);fw_cfg_add_i16 (fw_cfg,FW_CFG_NB_CPUS , (uint16_t )ms->smp.cpus); nodename =g_strdup_printf ("/fw-cfg@%" PRIx64, base);
hw/loongarch/fw_cfg.c +2 -2
@@ -23,8 +23,8 @@ FWCfgState *virt_fw_cfg_init(ram_addr_t ram_size, MachineState *ms)int max_cpus = ms->smp.max_cpus;int smp_cpus = ms->smp.cpus; - fw_cfg =fw_cfg_init_mem_wide (VIRT_FWCFG_BASE +8 ,VIRT_FWCFG_BASE ,8 , -VIRT_FWCFG_BASE +16 , &address_space_memory); + fw_cfg =fw_cfg_init_mem_dma (VIRT_FWCFG_BASE +8 ,VIRT_FWCFG_BASE ,8 , +VIRT_FWCFG_BASE +16 , &address_space_memory);fw_cfg_add_i16 (fw_cfg,FW_CFG_MAX_CPUS , (uint16_t )max_cpus);fw_cfg_add_i64 (fw_cfg,FW_CFG_RAM_SIZE , (uint64_t )ram_size);fw_cfg_add_i16 (fw_cfg,FW_CFG_NB_CPUS , (uint16_t )smp_cpus);
hw/nvram/fw_cfg.c +3 -3
@@ -1088,9 +1088,9 @@ static FWCfgState *fw_cfg_init_mem_internal(hwaddr ctl_addr,return s; } -FWCfgState *fw_cfg_init_mem_wide (hwaddr ctl_addr, -hwaddr data_addr,uint32_t data_width, -hwaddr dma_addr,AddressSpace *dma_as) +FWCfgState *fw_cfg_init_mem_dma (hwaddr ctl_addr, +hwaddr data_addr,uint32_t data_width, +hwaddr dma_addr,AddressSpace *dma_as) {assert (dma_addr && dma_as); return fw_cfg_init_mem_internal(ctl_addr, data_addr, data_width,
hw/riscv/virt.c +2 -2
@@ -1274,8 +1274,8 @@ static FWCfgState *create_fw_cfg(const MachineState *ms, hwaddr base) {FWCfgState *fw_cfg; - fw_cfg =fw_cfg_init_mem_wide (base +8 , base,8 , base +16 , - &address_space_memory); + fw_cfg =fw_cfg_init_mem_dma (base +8 , base,8 , base +16 , + &address_space_memory);fw_cfg_add_i16 (fw_cfg,FW_CFG_NB_CPUS , (uint16_t )ms->smp.cpus);return fw_cfg;
Signature · 1 line
2.51.0
PATCH v6 5/13 hw/nvram/fw_cfg: Propagate I/O MemoryRegion to fw_cfg_init_io_dma()
In reply to Philippe Mathieu-DaudéTo allow callers to use I/O MemoryRegion different than the global get_system_io(), pass it as argument.
--- include/hw/nvram/fw_cfg.h | 4 ++-- hw/i386/fw_cfg.c | 3 ++- hw/i386/microvm.c | 3 ++- hw/i386/pc.c | 3 ++- hw/nvram/fw_cfg.c | 5 ++--- 5 files changed, 10 insertions(+), 8 deletions(-)
include/hw/nvram/fw_cfg.h +2 -2
@@ -305,8 +305,8 @@ bool fw_cfg_add_file_from_generator(FWCfgState *s, Object *parent, const char *part, const char *filename, Error **errp); -FWCfgState *fw_cfg_init_io_dma (uint32_t iobase,uint32_t dma_iobase, -AddressSpace *dma_as); +FWCfgState *fw_cfg_init_io_dma (MemoryRegion *io,uint32_t iobase, +uint32_t dma_iobase,AddressSpace *dma_as);FWCfgState *fw_cfg_init_mem_nodma (hwaddr ctl_addr,hwaddr data_addr,unsigned data_width); FWCfgState *fw_cfg_init_mem_dma(hwaddr ctl_addr,
hw/i386/fw_cfg.c +2 -1
@@ -127,7 +127,8 @@ FWCfgState *fw_cfg_arch_create(MachineState *ms,const CPUArchIdList *cpus = mc->possible_cpu_arch_ids (ms);int nb_numa_nodes = ms->numa_state->num_nodes; - fw_cfg =fw_cfg_init_io_dma (FW_CFG_IO_BASE ,FW_CFG_IO_BASE +4 , + fw_cfg =fw_cfg_init_io_dma (get_system_io (), +FW_CFG_IO_BASE ,FW_CFG_IO_BASE +4 , &address_space_memory);fw_cfg_add_i16 (fw_cfg,FW_CFG_NB_CPUS , boot_cpus);
hw/i386/microvm.c +2 -1
@@ -289,6 +289,7 @@ static void microvm_memory_init(MicrovmMachineState *mms)X86MachineState *x86ms =X86_MACHINE (mms);MemoryRegion *ram_below_4g, *ram_above_4g;MemoryRegion *system_memory =get_system_memory (); +MemoryRegion *io_memory =get_system_io ();FWCfgState *fw_cfg;ram_addr_t lowmem =0xc0000000 ;/* 3G */ int i;
@@ -319,7 +320,7 @@ static void microvm_memory_init(MicrovmMachineState *mms)e820_add_entry (0x100000000ULL , x86ms->above_4g_mem_size,E820_RAM ); } - fw_cfg =fw_cfg_init_io_dma (FW_CFG_IO_BASE ,FW_CFG_IO_BASE +4 , + fw_cfg =fw_cfg_init_io_dma (io_memory,FW_CFG_IO_BASE ,FW_CFG_IO_BASE +4 , &address_space_memory);fw_cfg_add_i16 (fw_cfg,FW_CFG_NB_CPUS , machine->smp.cpus);
hw/i386/pc.c +2 -1
@@ -659,7 +659,8 @@ void xen_load_linux(PCMachineState *pcms)assert (MACHINE (pcms)->kernel_filename !=NULL ); - fw_cfg =fw_cfg_init_io_dma (FW_CFG_IO_BASE ,FW_CFG_IO_BASE +4 , + fw_cfg =fw_cfg_init_io_dma (get_system_io (), +FW_CFG_IO_BASE ,FW_CFG_IO_BASE +4 , &address_space_memory);fw_cfg_add_i16 (fw_cfg,FW_CFG_NB_CPUS , x86ms->boot_cpus);rom_set_fw (fw_cfg);
hw/nvram/fw_cfg.c +2 -3
@@ -1019,14 +1019,13 @@ static void fw_cfg_common_realize(DeviceState *dev, Error **errp)qemu_add_machine_init_done_notifier (&s->machine_ready); } -FWCfgState *fw_cfg_init_io_dma (uint32_t iobase,uint32_t dma_iobase, -AddressSpace *dma_as) +FWCfgState *fw_cfg_init_io_dma (MemoryRegion *iomem,uint32_t iobase, +uint32_t dma_iobase,AddressSpace *dma_as) {DeviceState *dev;SysBusDevice *sbd;FWCfgIoState *ios;FWCfgState *s; -MemoryRegion *iomem =get_system_io ();bool dma_requested = dma_iobase && dma_as; dev =qdev_new (TYPE_FW_CFG_IO );
Signature · 1 line
2.51.0
Re: [PATCH-for-11.0 v6 05/13] hw/nvram/fw_cfg: Propagate I/O MemoryRegion to fw_cfg_init_io_dma()
Quoted 17 lines · Philippe Mathieu-Daudé
Date: Wed, 3 Dec 2025 07:09:33 +0100
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH-for-11.0 v6 05/13] hw/nvram/fw_cfg: Propagate I/O
MemoryRegion tofw_cfg_init_io_dma()
X-Mailer: git-send-email 2.51.0To allow callers to use I/O MemoryRegion different than the global
get_system_io(), pass it as argument.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/nvram/fw_cfg.h | 4 ++-- hw/i386/fw_cfg.c | 3 ++- hw/i386/microvm.c | 3 ++- hw/i386/pc.c | 3 ++- hw/nvram/fw_cfg.c | 5 ++--- 5 files changed, 10 insertions(+), 8 deletions(-)
...
Quoted 13 lines
hw/i386/microvm.c +1
-0@@ -289,6 +289,7 @@ static void microvm_memory_init(MicrovmMachineState *mms)X86MachineState *x86ms =X86_MACHINE (mms);MemoryRegion *ram_below_4g, *ram_above_4g;MemoryRegion *system_memory =get_system_memory (); +MemoryRegion *io_memory =get_system_io ();FWCfgState *fw_cfg;ram_addr_t lowmem =0xc0000000 ;/* 3G */ int i;
hw/i386/microvm.c static void microvm_memory_init(MicrovmMachineState *mms) · line 323
Quoted 5 lines
hw/i386/microvm.c +1
-1@@ -319,7 +320,7 @@ static void microvm_memory_init(MicrovmMachineState *mms)e820_add_entry (0x100000000ULL , x86ms->above_4g_mem_size,E820_RAM ); } - fw_cfg = fw_cfg_init_io_dma(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4, + fw_cfg = fw_cfg_init_io_dma(io_memory, FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4,
It seems here we can use get_system_io() directly :).
Otherwise,
Quoted 3 lines
hw/i386/microvm.c +0
-0&address_space_memory);fw_cfg_add_i16 (fw_cfg,FW_CFG_NB_CPUS , machine->smp.cpus);
Re: [PATCH-for-11.0 v6 05/13] hw/nvram/fw_cfg: Propagate I/O MemoryRegion to fw_cfg_init_io_dma()
Quoted 37 lines · Zhao Liu
Quoted 17 lines · Philippe Mathieu-Daudé
Date: Wed, 3 Dec 2025 07:09:33 +0100
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH-for-11.0 v6 05/13] hw/nvram/fw_cfg: Propagate I/O
MemoryRegion tofw_cfg_init_io_dma()
X-Mailer: git-send-email 2.51.0To allow callers to use I/O MemoryRegion different than the global
get_system_io(), pass it as argument.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/nvram/fw_cfg.h | 4 ++-- hw/i386/fw_cfg.c | 3 ++- hw/i386/microvm.c | 3 ++- hw/i386/pc.c | 3 ++- hw/nvram/fw_cfg.c | 5 ++--- 5 files changed, 10 insertions(+), 8 deletions(-)...
Quoted 16 lines
hw/i386/microvm.c +1
-0@@ -289,6 +289,7 @@ static void microvm_memory_init(MicrovmMachineState *mms)X86MachineState *x86ms =X86_MACHINE (mms);MemoryRegion *ram_below_4g, *ram_above_4g;MemoryRegion *system_memory =get_system_memory (); +MemoryRegion *io_memory =get_system_io ();FWCfgState *fw_cfg;ram_addr_t lowmem =0xc0000000 ;/* 3G */ int i;@@ -319,7 +320,7 @@ static void microvm_memory_init(MicrovmMachineState *mms)e820_add_entry (0x100000000ULL , x86ms->above_4g_mem_size,E820_RAM ); }
Quoted 4 lines
hw/i386/microvm.c static void microvm_memory_init(MicrovmMachineState *mms) · line 323
Quoted 2 lines
hw/i386/microvm.c +1
-1- fw_cfg = fw_cfg_init_io_dma(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4, + fw_cfg = fw_cfg_init_io_dma(io_memory, FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4,It seems here we can use
get_system_io()directly :).
I tried to follow the function style (see local system_memory declaration); I don't mind ;)
Quoted 4 lines
Otherwise,
Reviewed-by Zhao Liu <[email protected]>
Thanks!
Quoted 4 lines
Quoted 4 lines
hw/i386/microvm.c +0
-0&address_space_memory);fw_cfg_add_i16 (fw_cfg,FW_CFG_NB_CPUS , machine->smp.cpus);
PATCH v6 6/13 hw/nvram/fw_cfg: Factor fw_cfg_init_io_internal() out
In reply to Philippe Mathieu-DaudéFactor fw_cfg_init_io_internal() out of fw_cfg_init_io_dma(). In fw_cfg_init_io_dma(), assert DMA arguments are provided.
--- hw/nvram/fw_cfg.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
hw/nvram/fw_cfg.c +10 -2
@@ -1019,8 +1019,9 @@ static void fw_cfg_common_realize(DeviceState *dev, Error **errp)qemu_add_machine_init_done_notifier (&s->machine_ready); } -FWCfgState *fw_cfg_init_io_dma (MemoryRegion *iomem,uint32_t iobase, -uint32_t dma_iobase,AddressSpace *dma_as) +static FWCfgState *fw_cfg_init_io_internal (MemoryRegion *iomem, +uint32_t iobase,uint32_t dma_iobase, +AddressSpace *dma_as) {DeviceState *dev;SysBusDevice *sbd;
@@ -1053,6 +1054,13 @@ FWCfgState *fw_cfg_init_io_dma(MemoryRegion *iomem, uint32_t iobase,return s; } +FWCfgState *fw_cfg_init_io_dma (MemoryRegion *iomem,uint32_t iobase, +uint32_t dma_iobase,AddressSpace *dma_as) +{ +assert (dma_iobase); +return fw_cfg_init_io_internal (iomem, iobase, dma_iobase, dma_as); +} +static FWCfgState *fw_cfg_init_mem_internal (hwaddr ctl_addr,hwaddr data_addr,uint32_t data_width,hwaddr dma_addr,AddressSpace *dma_as)
Signature · 1 line
2.51.0
Re: [PATCH-for-11.0 v6 06/13] hw/nvram/fw_cfg: Factor fw_cfg_init_io_internal() out
Quoted 6 lines · Philippe Mathieu-Daudé
Date: Wed, 3 Dec 2025 07:09:34 +0100
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH-for-11.0 v6 06/13] hw/nvram/fw_cfg: Factor
fw_cfg_init_io_internal()out
X-Mailer: git-send-email 2.51.0
Quoted 7 lines
Factor
fw_cfg_init_io_internal()out offw_cfg_init_io_dma(). Infw_cfg_init_io_dma(), assert DMA arguments are provided.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/nvram/fw_cfg.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
PATCH v6 7/13 hw/nvram/fw_cfg: Add fw_cfg_init_io_nodma() helper
In reply to Philippe Mathieu-DaudéCalling fw_cfg_init_io_nodma(...) is more explicit than fw_cfg_init_io_dma(..., 0, NULL).
--- include/hw/nvram/fw_cfg.h | 1 + hw/nvram/fw_cfg.c | 5 +++++ 2 files changed, 6 insertions(+)
include/hw/nvram/fw_cfg.h +1 -0
@@ -305,6 +305,7 @@ bool fw_cfg_add_file_from_generator(FWCfgState *s, Object *parent, const char *part, const char *filename, Error **errp); +FWCfgState *fw_cfg_init_io_nodma (MemoryRegion *io,uint32_t iobase);FWCfgState *fw_cfg_init_io_dma (MemoryRegion *io,uint32_t iobase,uint32_t dma_iobase,AddressSpace *dma_as); FWCfgState *fw_cfg_init_mem_nodma(hwaddr ctl_addr, hwaddr data_addr,
hw/nvram/fw_cfg.c +5 -0
@@ -1054,6 +1054,11 @@ static FWCfgState *fw_cfg_init_io_internal(MemoryRegion *iomem,return s; } +FWCfgState *fw_cfg_init_io_nodma (MemoryRegion *iomem,uint32_t iobase) +{ +return fw_cfg_init_io_internal (iomem, iobase,0 ,NULL ); +} +FWCfgState *fw_cfg_init_io_dma (MemoryRegion *iomem,uint32_t iobase,uint32_t dma_iobase,AddressSpace *dma_as) {
Signature · 1 line
2.51.0
Re: [PATCH-for-11.0 v6 07/13] hw/nvram/fw_cfg: Add fw_cfg_init_io_nodma() helper
Quoted 6 lines · Philippe Mathieu-Daudé
Date: Wed, 3 Dec 2025 07:09:35 +0100
From: Philippe Mathieu-Daudé <[email protected]>
Subject: [PATCH-for-11.0 v6 07/13] hw/nvram/fw_cfg: Add
fw_cfg_init_io_nodma()helper
X-Mailer: git-send-email 2.51.0
Quoted 8 lines
Calling
fw_cfg_init_io_nodma(...)is more explicit thanfw_cfg_init_io_dma(..., 0, NULL).Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- include/hw/nvram/fw_cfg.h | 1 + hw/nvram/fw_cfg.c | 5 +++++ 2 files changed, 6 insertions(+)
PATCH v6 8/13 hw/sparc64/sun4u: Use fw_cfg_init_io_nodma()
In reply to Philippe Mathieu-DaudéUse fw_cfg_init_io_nodma() instead of open-coding it.
--- hw/sparc64/sun4u.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-)
hw/sparc64/sun4u.c +1 -8
@@ -683,14 +683,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem, graphic_width, graphic_height, graphic_depth, (uint8_t *)&macaddr); - dev =qdev_new (TYPE_FW_CFG_IO ); -qdev_prop_set_bit (dev,"dma_enabled" , false); -object_property_add_child (OBJECT (ebus),TYPE_FW_CFG ,OBJECT (dev)); -sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); -memory_region_add_subregion (pci_address_space_io (ebus),BIOS_CFG_IOPORT , - &FW_CFG_IO (dev)->comb_iomem); - - fw_cfg =FW_CFG (dev); + fw_cfg =fw_cfg_init_io_nodma (pci_address_space_io (ebus),BIOS_CFG_IOPORT );fw_cfg_add_i16 (fw_cfg,FW_CFG_NB_CPUS , (uint16_t )machine->smp.cpus);fw_cfg_add_i16 (fw_cfg,FW_CFG_MAX_CPUS , (uint16_t )machine->smp.max_cpus);fw_cfg_add_i64 (fw_cfg,FW_CFG_RAM_SIZE , (uint64_t )machine->ram_size);
Signature · 1 line
2.51.0
Hi Philippe,
hw/sparc64/sun4u.c static void sun4uv_init(MemoryRegion *address_space_mem, · line 688
Quoted 11 lines
hw/sparc64/sun4u.c +0
-3@@ -683,14 +683,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem, graphic_width, graphic_height, graphic_depth, (uint8_t *)&macaddr); - dev =qdev_new (TYPE_FW_CFG_IO ); -qdev_prop_set_bit (dev,"dma_enabled" , false); -object_property_add_child (OBJECT (ebus),TYPE_FW_CFG ,OBJECT (dev));
There's another difference: fw_cfg_init_io_nodma() uses machine as the parent and here sun4uv uses ebus.
I think maybe one reason to use ebus is because...
hw/sparc64/sun4u.c static void sun4uv_init(MemoryRegion *address_space_mem, · line 690
Quoted 2 lines
hw/sparc64/sun4u.c +0
-2-sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); - memory_region_add_subregion(pci_address_space_io(ebus), BIOS_CFG_IOPORT,
^^^^^^^^^^^^^^^^^^^^^^^^^^
... because the parent region is managed by ebus.
Perhaps we should add another argument: Object *parent?
hw/sparc64/sun4u.c static void sun4uv_init(MemoryRegion *address_space_mem, · line 692
Quoted 2 lines
hw/sparc64/sun4u.c +0
-2- &FW_CFG_IO(dev)->comb_iomem); -
Thanks,
Zhao
Quoted 10 lines · Zhao Liu
Hi Philippe,
Quoted 8 lines
hw/sparc64/sun4u.c +0
-0@@ -683,14 +683,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem, graphic_width, graphic_height, graphic_depth, (uint8_t *)&macaddr);
Quoted 6 lines
hw/sparc64/sun4u.c static void sun4uv_init(MemoryRegion *address_space_mem, · line 688
Quoted 3 lines
hw/sparc64/sun4u.c +0
-3- dev =qdev_new (TYPE_FW_CFG_IO ); -qdev_prop_set_bit (dev,"dma_enabled" , false); -object_property_add_child (OBJECT (ebus),TYPE_FW_CFG ,OBJECT (dev));There's another difference:
fw_cfg_init_io_nodma()usesmachineas the parent and here sun4uv usesebus.
Ah yeah I wanted to comment it but forgot :facepalm:
Quoted 9 lines
I think maybe one reason to use
ebusis because...hw/sparc64/sun4u.c static void sun4uv_init(MemoryRegion *address_space_mem, · line 690
Quoted 2 lines
hw/sparc64/sun4u.c +0
-2-sysbus_realize_and_unref (SYS_BUS_DEVICE (dev), &error_fatal); - memory_region_add_subregion(pci_address_space_io(ebus), BIOS_CFG_IOPORT,^^^^^^^^^^^^^^^^^^^^^^^^^^... because the parent region is managed by ebus.
Perhaps we should add another argument: Object *parent?
I thought about it but don't think so, all instances but this one use the machine container.
I'll improve the description.
Quoted 7 lines
hw/sparc64/sun4u.c static void sun4uv_init(MemoryRegion *address_space_mem, · line 692
Quoted 3 lines
hw/sparc64/sun4u.c +0
-2- &FW_CFG_IO(dev)->comb_iomem); -Thanks,
Zhao
Quoted 27 lines · Philippe Mathieu-Daudé
Quoted 15 lines · Zhao Liu
Hi Philippe,
hw/sparc64/sun4u.c static void sun4uv_init(MemoryRegion *address_space_mem, · line 687
Quoted 10 lines
hw/sparc64/sun4u.c +0
-3@@ -683,14 +683,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem, graphic_width, graphic_height, graphic_depth, (uint8_t *)&macaddr); - dev = qdev_new(TYPE_FW_CFG_IO); - qdev_prop_set_bit(dev, "dma_enabled", false); - object_property_add_child(OBJECT(ebus), TYPE_FW_CFG, OBJECT(dev));There's another difference:
fw_cfg_init_io_nodma()usesmachineas the parent and here sun4uv usesebus.Ah yeah I wanted to comment it but forgot :facepalm:
Quoted 8 lines
I think maybe one reason to use
ebusis because...hw/sparc64/sun4u.c static void sun4uv_init(MemoryRegion *address_space_mem, · line 690
Quoted 2 lines
hw/sparc64/sun4u.c +0
-2- sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - memory_region_add_subregion(pci_address_space_io(ebus), BIOS_CFG_IOPORT,^^^^^^^^^^^^^^^^^^^^^^^^^^ ... because the parent region is managed by ebus.
Quoted 6 lines
Quoted 1 line
Perhaps we should add another argument: Object *parent?
I thought about it but don't think so, all instances but this one use the machine container.
I'll improve the description.
The reason that the fw_cfg device lives under ebus on sun4u is because the ebus device is effectively a PCI-ISA bridge, and the fw_cfg port is mapped into I/O address space along with other ISA devices. I'm not sure that setting the parent to the machine is the right thing to do here.
ATB,
Mark.
Quoted 12 lines
Quoted 12 lines
Quoted 8 lines
I think maybe one reason to use
ebusis because...Quoted 2 lines
-
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - memory_region_add_subregion(pci_address_space_io(ebus),BIOS_CFG_IOPORT,^^^^^^^^^^^^^^^^^^^^^^^^^^ ... because the parent region is managed by ebus.
Perhaps we should add another argument: Object *parent?
I thought about it but don't think so, all instances but this one use the machine container.
Quoted 6 lines
Quoted 1 line
I'll improve the description.
The reason that the
fw_cfgdevice lives under ebus on sun4u is because the ebus device is effectively a PCI-ISA bridge, and thefw_cfgport is mapped into I/O address space along with other ISA devices. I'm not sure that setting the parent to the machine is the right thing to do here.
Thanks Philippe and Mark, IIUC, ebus doesn't have the hotplug use case, so it lives long enough like the sun4u/v machine, therefore replacing the parent object "ebus" with machine is safe.
And it might be better to explicitly set ebus as not supporting hotplug (via dc->hotpluggable = false).
Adding a "parent" argument to the generic interface fw_cfg_init_io_nodma() doesn't seem necessary at the moment, since using the default machine as parent seems enough to meet all current needs in QEMU.
What do you think?
Regards,
Zhao
Quoted 14 lines · Zhao Liu
Quoted 14 lines
Quoted 13 lines
Quoted 8 lines
I think maybe one reason to use
ebusis because...Quoted 2 lines
-
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - memory_region_add_subregion(pci_address_space_io(ebus),BIOS_CFG_IOPORT,^^^^^^^^^^^^^^^^^^^^^^^^^^
... because the parent region is managed by ebus.Perhaps we should add another argument: Object *parent?
I thought about it but don't think so, all instances but this one use the machine container.
I'll improve the description.
Quoted 8 lines
Quoted 4 lines
The reason that the
fw_cfgdevice lives under ebus on sun4u is because the ebus device is effectively a PCI-ISA bridge, and thefw_cfgport is mapped into I/O address space along with other ISA devices. I'm not sure that setting the parent to the machine is the right thing to do here.Thanks Philippe and Mark, IIUC, ebus doesn't have the hotplug use case, so it lives long enough like the sun4u/v machine, therefore replacing the parent object "ebus" with machine is safe.
It's safe, but it still doesn't make sense for sun4u/v because there is no machine-level I/O address space as per x86. It really does exist as a separate legacy bus under a PCI bridge.
Quoted 2 lines
And it might be better to explicitly set ebus as not supporting hotplug (via
dc->hotpluggable= false).
That's correct, ebus does not support hotplug.
Quoted 5 lines
Adding a "parent" argument to the generic interface
fw_cfg_init_io_nodma()doesn't seem necessary at the moment, since using the default machine as parent seems enough to meet all current needs in QEMU.What do you think?
My preference would be add to add the parent argument as it's easy to do, and doesn't attempt to enforce x86-type constraints on other architectures.
ATB,
Mark.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
The reason that the
fw_cfgdevice lives under ebus on sun4u is because the ebus device is effectively a PCI-ISA bridge, and thefw_cfgport is mapped into I/O address space along with other ISA devices. I'm not sure that setting the parent to the machine is the right thing to do here.
Quoted 7 lines
Quoted 3 lines
Thanks Philippe and Mark, IIUC, ebus doesn't have the hotplug use case, so it lives long enough like the sun4u/v machine, therefore replacing the parent object "ebus" with machine is safe.
It's safe, but it still doesn't make sense for sun4u/v because there is no machine-level I/O address space as per x86. It really does exist as a separate legacy bus under a PCI bridge.
I tend to agree with Philippe's perspective - since it's per-Guest, setting the parent as machine seems appropriate.
Quoted 10 lines
That's correct, ebus does not support hotplug.
Quoted 5 lines
Adding a "parent" argument to the generic interface
fw_cfg_init_io_nodma()doesn't seem necessary at the moment, since using the default machine as parent seems enough to meet all current needs in QEMU.What do you think?
My preference would be add to add the parent argument as it's easy to do, and doesn't attempt to enforce x86-type constraints on other architectures.
I think it's not a x86-specific issue. The parent parameter's role is lifecycle management - if we allowed custom parents, we'd have to account for various complications that could result from early parent destruction, so it's not much easy IMO.
Thanks,
Zhao
Quoted 23 lines · Zhao Liu
Quoted 12 lines
Quoted 12 lines
Quoted 8 lines
I think maybe one reason to use
ebusis because...Quoted 2 lines
-
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - memory_region_add_subregion(pci_address_space_io(ebus),BIOS_CFG_IOPORT,^^^^^^^^^^^^^^^^^^^^^^^^^^
... because the parent region is managed by ebus.Perhaps we should add another argument: Object *parent?
I thought about it but don't think so, all instances but this one use the machine container.
Quoted 6 lines
Quoted 1 line
I'll improve the description.
The reason that the
fw_cfgdevice lives under ebus on sun4u is because the ebus device is effectively a PCI-ISA bridge, and thefw_cfgport is mapped into I/O address space along with other ISA devices. I'm not sure that setting the parent to the machine is the right thing to do here.Thanks Philippe and Mark, IIUC, ebus doesn't have the hotplug use case, so it lives long enough like the sun4u/v machine, therefore replacing the parent object "ebus" with machine is safe.
Quoted 8 lines
And it might be better to explicitly set ebus as not supporting hotplug (via
dc->hotpluggable= false).Adding a "parent" argument to the generic interface
fw_cfg_init_io_nodma()doesn't seem necessary at the moment, since using the default machine as parent seems enough to meet all current needs in QEMU.What do you think?
fw_cfg is per guest, and there can only be once instance of it; so IMHO it makes sense to use the machine as parent. I should have posted a better commit description upfront, sorry.
Quoted 3 lines
fw_cfgis per guest, and there can only be once instance of it; so IMHO it makes sense to use the machine as parent. I should have posted a better commit description upfront, sorry.
You're welcome. It looks like most issues with the another series for removing v2.6 & 2.7 pc have been resolved, so I'm trying to help clarify this part to move things forward a bit.
Regards,
Zhao
Quoted 31 lines · Philippe Mathieu-Daudé
Quoted 30 lines · Zhao Liu
Quoted 12 lines
Quoted 12 lines
Quoted 8 lines
I think maybe one reason to use
ebusis because...Quoted 2 lines
-
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - memory_region_add_subregion(pci_address_space_io(ebus),BIOS_CFG_IOPORT,^^^^^^^^^^^^^^^^^^^^^^^^^^ ... because the parent region is managed by ebus.
Perhaps we should add another argument: Object *parent?
I thought about it but don't think so, all instances but this one use the machine container.
Quoted 6 lines
Quoted 1 line
I'll improve the description.
The reason that the
fw_cfgdevice lives under ebus on sun4u is because the ebus device is effectively a PCI-ISA bridge, and thefw_cfgport is mapped into I/O address space along with other ISA devices. I'm not sure that setting the parent to the machine is the right thing to do here.Thanks Philippe and Mark, IIUC, ebus doesn't have the hotplug use case, so it lives long enough like the sun4u/v machine, therefore replacing the parent object "ebus" with machine is safe.
And it might be better to explicitly set ebus as not supporting hotplug (via
dc->hotpluggable= false).Adding a "parent" argument to the generic interface
fw_cfg_init_io_nodma()doesn't seem necessary at the moment, since using the default machine as parent seems enough to meet all current needs in QEMU.
Quoted 5 lines
Quoted 1 line
What do you think?
fw_cfgis per guest, and there can only be once instance of it; so IMHO it makes sense to use the machine as parent. I should have posted a better commit description upfront, sorry.
That's true, but the I/O is mapped to the ISA bus and so if the ISA bus does not exist, it is impossible to access the device even if it exists on the machine.
Following on from this: at some point should we not be aiming for a qdev bus to have its devices as QOM children? Assigning fw_cfg directly to the machine would also be wrong in this scenario.
ATB,
Mark.
PATCH v6 9/13 hw/nvram/fw_cfg: Remove fw_cfg_io_properties::dma_enabled
In reply to Philippe Mathieu-DaudéNow than all calls to fw_cfg_init_io_dma() pass DMA arguments, the 'dma_enabled' of the TYPE_FW_CFG_IO type is not used anymore. Remove it, simplifying fw_cfg_init_io_dma() and fw_cfg_io_realize().
Note, we can not remove the equivalent in fw_cfg_mem_properties[] because it is still used in HPPA and MIPS Loongson3 machines:
$ git grep -w fw_cfg_init_mem_nodma hw/hppa/machine.c:204: fw_cfg = fw_cfg_init_mem_nodma(addr, addr + 4, 1); hw/mips/loongson3_virt.c:289: fw_cfg = fw_cfg_init_mem_nodma(cfg_addr, cfg_addr + 8, 8);
'linuxboot.bin' isn't used anymore, we'll remove it in the next commit.
--- hw/i386/fw_cfg.c | 15 +++++++-------- hw/nvram/fw_cfg.c | 26 ++++++++------------------ 2 files changed, 15 insertions(+), 26 deletions(-)
hw/i386/fw_cfg.c +7 -8
@@ -216,18 +216,17 @@ void fw_cfg_build_feature_control(MachineState *ms, FWCfgState *fw_cfg)#ifdef CONFIG_ACPI void fw_cfg_add_acpi_dsdt (Aml *scope,FWCfgState *fw_cfg) { +uint8_t io_size; +Aml *dev =aml_device ("FWCF" ); +Aml *crs =aml_resource_template (); +/* * when using port i/o, the 8-bit data register *always* overlaps * with half of the 16-bit control register. Hence, the total size -* of the i/o region used is FW_CFG_CTL_SIZE; when using DMA, the -* DMA control register is located at FW_CFG_DMA_IO_BASE + 4 +* of the i/o region used is FW_CFG_CTL_SIZE; And the DMA control +* register is located at FW_CFG_DMA_IO_BASE + 4 */ -Object *obj =OBJECT (fw_cfg); -uint8_t io_size =object_property_get_bool (obj,"dma_enabled" ,NULL ) ? -ROUND_UP (FW_CFG_CTL_SIZE ,4 ) +sizeof (dma_addr_t) : -FW_CFG_CTL_SIZE ; -Aml *dev =aml_device ("FWCF" ); -Aml *crs =aml_resource_template (); + io_size =ROUND_UP (FW_CFG_CTL_SIZE ,4 ) +sizeof (dma_addr_t);aml_append (dev,aml_name_decl ("_HID" ,aml_string ("QEMU0002" )));
hw/nvram/fw_cfg.c +8 -18
@@ -1027,12 +1027,9 @@ static FWCfgState *fw_cfg_init_io_internal(MemoryRegion *iomem,SysBusDevice *sbd;FWCfgIoState *ios;FWCfgState *s; -bool dma_requested = dma_iobase && dma_as; +assert (dma_iobase); dev =qdev_new (TYPE_FW_CFG_IO ); -if (!dma_requested) { -qdev_prop_set_bit (dev,"dma_enabled" , false); - }object_property_add_child (OBJECT (qdev_get_machine ()),TYPE_FW_CFG ,OBJECT (dev));
@@ -1043,13 +1040,10 @@ static FWCfgState *fw_cfg_init_io_internal(MemoryRegion *iomem,memory_region_add_subregion (iomem, iobase, &ios->comb_iomem); s =FW_CFG (dev); - -if (s->dma_enabled) { -/* 64 bits for the address field */ - s->dma_as = dma_as; - s->dma_addr =0 ; -memory_region_add_subregion (iomem, dma_iobase, &s->dma_iomem); - } +/* 64 bits for the address field */ + s->dma_as = dma_as; + s->dma_addr =0 ; +memory_region_add_subregion (iomem, dma_iobase, &s->dma_iomem);return s; }
@@ -1198,8 +1192,6 @@ static void fw_cfg_file_slots_allocate(FWCfgState *s, Error **errp) }static const Property fw_cfg_io_properties[] = { -DEFINE_PROP_BOOL ("dma_enabled" , FWCfgIoState, parent_obj.dma_enabled, - true),DEFINE_PROP_UINT16 ("x-file-slots" , FWCfgIoState, parent_obj.file_slots,FW_CFG_FILE_SLOTS_DFLT ), };
@@ -1220,11 +1212,9 @@ static void fw_cfg_io_realize(DeviceState *dev, Error **errp)memory_region_init_io (&s->comb_iomem,OBJECT (s), &fw_cfg_comb_mem_ops,FW_CFG (s),"fwcfg" ,FW_CFG_CTL_SIZE ); -if (FW_CFG (s)->dma_enabled) { -memory_region_init_io (&FW_CFG (s)->dma_iomem,OBJECT (s), - &fw_cfg_dma_mem_ops,FW_CFG (s),"fwcfg.dma" , -sizeof (dma_addr_t)); - } +memory_region_init_io (&FW_CFG (s)->dma_iomem,OBJECT (s), + &fw_cfg_dma_mem_ops,FW_CFG (s),"fwcfg.dma" , +sizeof (dma_addr_t));fw_cfg_common_realize (dev, errp); }
Signature · 1 line
2.51.0
PATCH v6 10/13 hw/i386/x86: Remove X86MachineClass::fwcfg_dma_enabled field
In reply to Philippe Mathieu-DaudéThe X86MachineClass::fwcfg_dma_enabled boolean was only used by the pc-q35-2.6 and pc-i440fx-2.6 machines, which got removed. Remove it and simplify.
'multiboot.bin' isn't used anymore, we'll remove it in the next commit.
--- include/hw/i386/x86.h | 2 -- hw/i386/microvm.c | 3 --- hw/i386/multiboot.c | 7 +------ hw/i386/x86-common.c | 3 +-- hw/i386/x86.c | 2 -- 5 files changed, 2 insertions(+), 15 deletions(-)
include/hw/i386/x86.h +0 -2
@@ -30,8 +30,6 @@struct X86MachineClass {MachineClass parent; -/* use DMA capable linuxboot option rom */ -bool fwcfg_dma_enabled;/* CPU and apic information: */ bool apic_xrupt_override; };
hw/i386/microvm.c +0 -3
@@ -641,7 +641,6 @@ GlobalProperty microvm_properties[] = {static void microvm_class_init (ObjectClass *oc,const void *data) { -X86MachineClass *x86mc =X86_MACHINE_CLASS (oc);MicrovmMachineClass *mmc =MICROVM_MACHINE_CLASS (oc);MachineClass *mc =MACHINE_CLASS (oc);HotplugHandlerClass *hc =HOTPLUG_HANDLER_CLASS (oc);
@@ -675,8 +674,6 @@ static void microvm_class_init(ObjectClass *oc, const void *data) hc->unplug_request = microvm_device_unplug_request_cb; hc->unplug = microvm_device_unplug_cb; - x86mc->fwcfg_dma_enabled = true; - object_class_property_add(oc, MICROVM_MACHINE_RTC, "OnOffAuto", microvm_machine_get_rtc, microvm_machine_set_rtc,
hw/i386/multiboot.c +1 -6
@@ -153,7 +153,6 @@ int load_multiboot(X86MachineState *x86ms,int kernel_file_size, uint8_t *header) { - bool multiboot_dma_enabled = X86_MACHINE_GET_CLASS(x86ms)->fwcfg_dma_enabled; int i, is_multiboot = 0;uint32_t flags =0 ;uint32_t mh_entry_addr;
@@ -402,11 +401,7 @@ int load_multiboot(X86MachineState *x86ms,fw_cfg_add_bytes (fw_cfg,FW_CFG_INITRD_DATA , mb_bootinfo_data,sizeof (bootinfo)); -if (multiboot_dma_enabled) { - option_rom[nb_option_roms].name ="multiboot_dma.bin" ; - }else { - option_rom[nb_option_roms].name ="multiboot.bin" ; - } + option_rom[nb_option_roms].name ="multiboot_dma.bin" ; option_rom[nb_option_roms].bootindex =0 ; nb_option_roms++;
hw/i386/x86-common.c +1 -2
@@ -645,7 +645,6 @@ void x86_load_linux(X86MachineState *x86ms,int acpi_data_size, bool pvh_enabled) { - bool linuxboot_dma_enabled = X86_MACHINE_GET_CLASS(x86ms)->fwcfg_dma_enabled; uint16_t protocol;int setup_size, kernel_size, cmdline_size;int dtb_size, setup_data_offset;
@@ -1004,7 +1003,7 @@ void x86_load_linux(X86MachineState *x86ms, option_rom[nb_option_roms].bootindex =0 ; option_rom[nb_option_roms].name ="linuxboot.bin" ; -if (linuxboot_dma_enabled &&fw_cfg_dma_enabled (fw_cfg)) { +if (fw_cfg_dma_enabled (fw_cfg)) { option_rom[nb_option_roms].name ="linuxboot_dma.bin" ; } nb_option_roms++;
hw/i386/x86.c +0 -2
@@ -375,14 +375,12 @@ static void x86_machine_initfn(Object *obj)static void x86_machine_class_init (ObjectClass *oc,const void *data) {MachineClass *mc =MACHINE_CLASS (oc); -X86MachineClass *x86mc =X86_MACHINE_CLASS (oc);NMIClass *nc =NMI_CLASS (oc); mc->cpu_index_to_instance_props = x86_cpu_index_to_props; mc->get_default_cpu_node_id = x86_get_default_cpu_node_id; mc->possible_cpu_arch_ids = x86_possible_cpu_arch_ids; mc->kvm_type = x86_kvm_type; - x86mc->fwcfg_dma_enabled = true; nc->nmi_monitor_handler = x86_nmi; object_class_property_add(oc, X86_MACHINE_SMM, "OnOffAuto",
Signature · 1 line
2.51.0
PATCH v6 11/13 hw/i386/pc: Remove multiboot.bin
In reply to Philippe Mathieu-DaudéAll PC machines now use the multiboot_dma.bin binary, we can remove the non-DMA version (multiboot.bin).
This doesn't change multiboot_dma binary file.
--- pc-bios/optionrom/optionrom.h | 4 - hw/i386/pc.c | 1 - pc-bios/meson.build | 1 - pc-bios/multiboot.bin | Bin 1024 -> 0 bytes pc-bios/optionrom/Makefile | 2 +- pc-bios/optionrom/multiboot.S | 232 ----------------------------- pc-bios/optionrom/multiboot_dma.S | 234 +++++++++++++++++++++++++++++- 7 files changed, 233 insertions(+), 241 deletions(-) delete mode 100644 pc-bios/multiboot.bin delete mode 100644 pc-bios/optionrom/multiboot.S
pc-bios/optionrom/optionrom.h +0 -4
@@ -117,16 +117,12 @@* * Clobbers: %eax, %edx, %es, %ecx, %edi and adresses %esp-20 to %esp */ -#ifdef USE_FW_CFG_DMA #define read_fw_blob_dma (var) \ read_fw var ## _SIZE; \ mov %eax, %ecx; \ read_fw var ## _ADDR; \ mov %eax, %edi ; \ read_fw_dma var ## _DATA, %ecx, %edi -#else -#define read_fw_blob_dma (var) read_fw_blob(var) -#endif #define read_fw_blob_pre (var) \ read_fw var ## _SIZE; \
hw/i386/pc.c +0 -1
@@ -670,7 +670,6 @@ void xen_load_linux(PCMachineState *pcms)assert (!strcmp (option_rom[i].name,"linuxboot.bin" ) || !strcmp (option_rom[i].name,"linuxboot_dma.bin" ) || !strcmp (option_rom[i].name,"pvh.bin" ) || - !strcmp (option_rom[i].name,"multiboot.bin" ) || !strcmp (option_rom[i].name,"multiboot_dma.bin" ));rom_add_option (option_rom[i].name, option_rom[i].bootindex); }
pc-bios/meson.build +0 -1
@@ -62,7 +62,6 @@ blobs = [ 'efi-e1000e.rom', 'efi-vmxnet3.rom', 'qemu-nsis.bmp', - 'multiboot.bin', 'multiboot_dma.bin', 'linuxboot.bin', 'linuxboot_dma.bin',
pc-bios/multiboot.bin deleted binary +0 -0
pc-bios/optionrom/Makefile +1 -1
@@ -2,7 +2,7 @@ include config.mak SRC_DIR := $(TOPSRC_DIR)/pc-bios/optionrom VPATH = $(SRC_DIR) -all: multiboot.bin multiboot_dma.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin +all: multiboot_dma.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin # Dummy command so that make thinks it has done something @true
pc-bios/optionrom/multiboot.S deleted +0 -232
232 lines not on this page · raw message
pc-bios/optionrom/multiboot_dma.S +232 -2
234 lines not on this page · raw message
Signature · 1 line
2.51.0
PATCH v6 12/13 hw/i386: Assume fw_cfg DMA is always enabled
In reply to Philippe Mathieu-DaudéFrom: Zhao Liu <[email protected]>
Now all calls of x86 machines to fw_cfg_init_io_dma() pass DMA arguments, so the FWCfgState (FWCfgIoState) created by x86 machines enables DMA by default.
Then 'linuxboot.bin' isn't used anymore, and it will be removed in the next commit.
--- hw/i386/fw_cfg.c | 1 + hw/i386/x86-common.c | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-)
hw/i386/fw_cfg.c +1 -0
@@ -226,6 +226,7 @@ void fw_cfg_add_acpi_dsdt(Aml *scope, FWCfgState *fw_cfg)* of the i/o region used is FW_CFG_CTL_SIZE; And the DMA control * register is located at FW_CFG_DMA_IO_BASE + 4 */ +assert (fw_cfg_dma_enabled (fw_cfg)); io_size =ROUND_UP (FW_CFG_CTL_SIZE ,4 ) +sizeof (dma_addr_t);aml_append (dev,aml_name_decl ("_HID" ,aml_string ("QEMU0002" )));
hw/i386/x86-common.c +2 -4
@@ -1002,10 +1002,8 @@ void x86_load_linux(X86MachineState *x86ms, } option_rom[nb_option_roms].bootindex =0 ; - option_rom[nb_option_roms].name ="linuxboot.bin" ; -if (fw_cfg_dma_enabled (fw_cfg)) { - option_rom[nb_option_roms].name ="linuxboot_dma.bin" ; - } +assert (fw_cfg_dma_enabled (fw_cfg)); + option_rom[nb_option_roms].name ="linuxboot_dma.bin" ; nb_option_roms++; }
Signature · 1 line
2.51.0
Re: [PATCH-for-11.0 v6 12/13] hw/i386: Assume fw_cfg DMA is always enabled
Quoted 10 lines · Philippe Mathieu-Daudé
From: Zhao Liu <[email protected]>
Now all calls of x86 machines to
fw_cfg_init_io_dma()pass DMA arguments, so the FWCfgState (FWCfgIoState) created by x86 machines enables DMA by default.Then 'linuxboot.bin' isn't used anymore, and it will be removed in the next commit.
Signed-off-by Zhao Liu <[email protected]>
Quoted 5 lines
Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- hw/i386/fw_cfg.c | 1 + hw/i386/x86-common.c | 6 ++---- 2 files changed, 3 insertions(+), 4 deletions(-)
PATCH v6 13/13 hw/i386: Remove linuxboot.bin
In reply to Philippe Mathieu-DaudéAll machines now use the linuxboot_dma.bin binary, so it's safe to remove the non-DMA version (linuxboot.bin).
--- hw/i386/pc.c | 3 +- pc-bios/meson.build | 1 - pc-bios/optionrom/Makefile | 2 +- pc-bios/optionrom/linuxboot.S | 195 ---------------------------------- 4 files changed, 2 insertions(+), 199 deletions(-) delete mode 100644 pc-bios/optionrom/linuxboot.S
hw/i386/pc.c +1 -2
@@ -667,8 +667,7 @@ void xen_load_linux(PCMachineState *pcms)x86_load_linux (x86ms, fw_cfg,PC_FW_DATA , pcmc->pvh_enabled);for (i =0 ; i < nb_option_roms; i++) { -assert (!strcmp (option_rom[i].name,"linuxboot.bin" ) || - !strcmp (option_rom[i].name,"linuxboot_dma.bin" ) || +assert (!strcmp (option_rom[i].name,"linuxboot_dma.bin" ) || !strcmp (option_rom[i].name,"pvh.bin" ) || !strcmp (option_rom[i].name,"multiboot_dma.bin" ));rom_add_option (option_rom[i].name, option_rom[i].bootindex);
pc-bios/meson.build +0 -1
@@ -63,7 +63,6 @@ blobs = [ 'efi-vmxnet3.rom', 'qemu-nsis.bmp', 'multiboot_dma.bin', - 'linuxboot.bin', 'linuxboot_dma.bin', 'kvmvapic.bin', 'pvh.bin',
pc-bios/optionrom/Makefile +1 -1
@@ -2,7 +2,7 @@ include config.mak SRC_DIR := $(TOPSRC_DIR)/pc-bios/optionrom VPATH = $(SRC_DIR) -all: multiboot_dma.bin linuxboot.bin linuxboot_dma.bin kvmvapic.bin pvh.bin +all: multiboot_dma.bin linuxboot_dma.bin kvmvapic.bin pvh.bin # Dummy command so that make thinks it has done something @true
pc-bios/optionrom/linuxboot.S deleted +0 -195
195 lines not on this page · raw message
Signature · 1 line
2.51.0
New (unreviewed) patches: 1, 2, 5-8
Quoted 42 lines · Philippe Mathieu-Daudé
Hi Zhao,
This is my answer to this comment of yours:
Quoted 6 lines
Although other callers of
fw_cfg_init_io_dma()besides x86 also pass DMA arguments to create DMA-enabled FwCfgIoState, the "dma_enabled" property of FwCfgIoState cannot yet be removed, because Sun4u and Sun4v still create DMA-disabled FwCfgIoState (bypassfw_cfg_init_io_dma()) insun4uv_init()(hw/sparc64/sun4u.c).Quoted 7 lines
Maybe reusing
fw_cfg_init_io_dma()for them would be a better choice, or addingfw_cfg_init_io_nodma(). However, before that, first simplify the handling of FwCfgState in x86.Considering that FwCfgIoState in x86 enables DMA by default, remove the handling for DMA-disabled cases and replace DMA checks with assertions to ensure that the default DMA-enabled setting is not broken.
My series is to apply just after this patch of your series:
[PATCH v5 10/28] hw/mips/loongson3_virt: Prefer using
fw_cfg_init_mem_nodma()Regards,
Phil.
Based-on: <[email protected]>
Philippe Mathieu-Daudé (12):
hw/ppc/mac: Usefw_cfg_init_mem_nodma()hw/sparc/sun4m: Usefw_cfg_init_mem_nodma()hw/nvram/fw_cfg: Factorfw_cfg_init_mem_internal()out hw/nvram/fw_cfg: Renamefw_cfg_init_mem_wide()->fw_cfg_init_mem_dma()hw/nvram/fw_cfg: Propagate I/O MemoryRegion to
fw_cfg_init_io_dma()hw/nvram/fw_cfg: Factorfw_cfg_init_io_internal()out hw/nvram/fw_cfg: Addfw_cfg_init_io_nodma()helper hw/sparc64/sun4u: Usefw_cfg_init_io_nodma()hw/nvram/fw_cfg: Removefw_cfg_io_properties::dma_enabledhw/i386/x86: RemoveX86MachineClass::fwcfg_dma_enabledfield hw/i386/pc: Remove multiboot.bin
hw/i386: Remove linuxboot.bin
Quoted 18 lines · Philippe Mathieu-Daudé
Hi Zhao,
This is my answer to this comment of yours:
Quoted 6 lines
Although other callers of
fw_cfg_init_io_dma()besides x86 also pass DMA arguments to create DMA-enabled FwCfgIoState, the "dma_enabled" property of FwCfgIoState cannot yet be removed, because Sun4u and Sun4v still create DMA-disabled FwCfgIoState (bypassfw_cfg_init_io_dma()) insun4uv_init()(hw/sparc64/sun4u.c).Quoted 7 lines
Maybe reusing
fw_cfg_init_io_dma()for them would be a better choice, or addingfw_cfg_init_io_nodma(). However, before that, first simplify the handling of FwCfgState in x86.Considering that FwCfgIoState in x86 enables DMA by default, remove the handling for DMA-disabled cases and replace DMA checks with assertions to ensure that the default DMA-enabled setting is not broken.
Quoted 7 lines
My series is to apply just after this patch of your series:
[PATCH v5 10/28] hw/mips/loongson3_virt: Prefer using
fw_cfg_init_mem_nodma()Regards,
Phil.
pc/fwcfg things:
Quoted 52 lines
Based-on: <[email protected]>
Philippe Mathieu-Daudé (12):
hw/ppc/mac: Usefw_cfg_init_mem_nodma()hw/sparc/sun4m: Usefw_cfg_init_mem_nodma()hw/nvram/fw_cfg: Factorfw_cfg_init_mem_internal()out hw/nvram/fw_cfg: Renamefw_cfg_init_mem_wide()->fw_cfg_init_mem_dma()hw/nvram/fw_cfg: Propagate I/O MemoryRegion to
fw_cfg_init_io_dma()hw/nvram/fw_cfg: Factorfw_cfg_init_io_internal()out hw/nvram/fw_cfg: Addfw_cfg_init_io_nodma()helper hw/sparc64/sun4u: Usefw_cfg_init_io_nodma()hw/nvram/fw_cfg: Removefw_cfg_io_properties::dma_enabledhw/i386/x86: RemoveX86MachineClass::fwcfg_dma_enabledfield hw/i386/pc: Remove multiboot.bin
hw/i386: Remove linuxboot.binZhao Liu (1):
hw/i386: Assumefw_cfgDMA is always enabledinclude/hw/i386/x86.h | 2 - include/hw/nvram/fw_cfg.h | 11 +- pc-bios/optionrom/optionrom.h | 4 - hw/arm/virt.c | 2 +- hw/i386/fw_cfg.c | 19 +-- hw/i386/microvm.c | 6 +- hw/i386/multiboot.c | 7 +- hw/i386/pc.c | 7 +- hw/i386/x86-common.c | 7 +- hw/i386/x86.c | 2 - hw/loongarch/fw_cfg.c | 4 +- hw/nvram/fw_cfg.c | 61 ++++---- hw/ppc/mac_newworld.c | 11 +- hw/ppc/mac_oldworld.c | 11 +- hw/riscv/virt.c | 4 +- hw/sparc/sun4m.c | 12 +- hw/sparc64/sun4u.c | 9 +- pc-bios/meson.build | 2 - pc-bios/multiboot.bin | Bin 1024 -> 0 bytes pc-bios/optionrom/Makefile | 2 +- pc-bios/optionrom/linuxboot.S | 195 ------------------------- pc-bios/optionrom/multiboot.S | 232 ----------------------------- pc-bios/optionrom/multiboot_dma.S | 234 +++++++++++++++++++++++++++++- 23 files changed, 302 insertions(+), 542 deletions(-) delete mode 100644 pc-bios/multiboot.bin delete mode 100644 pc-bios/optionrom/linuxboot.S delete mode 100644 pc-bios/optionrom/multiboot.SSignature · 1 line
2.51.0