remove icc bus/bridge
v7 cover remove icc bus/bridge
ICC Bus was used for providing a hotpluggable bus for APIC and CPU, but now we use HotplugHandler to make hotplug. So ICC Bus is unnecessary.
This code has passed the new pc-cpu-test.
And I have tested with kvm along with kernel_irqchip=on/off, it works fine.
This patch series is based on Eduardo's x86 tree.
https://github.com/ehabkost/qemu.git
v7:
-update to register reset handler for main_system_bus when created -register reset handler for apic after all devices are initialized
v6:
-reword commit message
-drop NULL check for APIC device
-use C cast instead of QOM cast
v5:
-convert DEVICE() casts to C casts
-use a local variable instead of doing the cast inline twice -drop to set cpu's parent bus
-rename patch 3's subject
-fix a bug about setting cpu's apic base
v4:
-add wrapper to get root memory region from address space -set cpu apic base's default value in x86_cpu_apic_create() -drop NULL check for cpu apic_state
-put drop of the unused files about icc_bus into a seprate patch -put DEVICE() casts into a seprate patch
v3:
-replace init apic by object_new()
-add reset apic at the time of CPU reset
Chen Fan (1):
cpu/apic: drop icc bus/bridge
Zhu Guihua (2):
sysbus: register reset handler for main_system_bus when created
icc_bus: drop the unused files
default-configs/i386-softmmu.mak | 1 - default-configs/x86_64-softmmu.mak | 1 - hw/core/sysbus.c | 4 ++ hw/cpu/Makefile.objs | 1 - hw/cpu/icc_bus.c | 118 ------------------------------------- hw/i386/pc.c | 19 ++---- hw/i386/pc_piix.c | 15 +++-- hw/i386/pc_q35.c | 15 +++-- hw/intc/apic_common.c | 5 +- include/hw/cpu/icc_bus.h | 82 -------------------------- include/hw/i386/apic_internal.h | 7 ++- include/hw/i386/pc.h | 2 +- target-i386/cpu.c | 24 +++++--- target-i386/cpu.h | 4 ++ vl.c | 3 - 15 files changed, 49 insertions(+), 252 deletions(-) delete mode 100644 hw/cpu/icc_bus.c delete mode 100644 include/hw/cpu/icc_bus.h
Signature · 1 line
1.9.3
PATCH v7 1/3 sysbus: register reset handler for main_system_bus when created
Since icc bus will be droped and apic reset should be after bus reset in x86, this patch moves reset handler for main_system_bus from vl.c to sysbus.c
--- hw/core/sysbus.c | 4 ++++ vl.c | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-)
hw/core/sysbus.c +4 -0
@@ -337,6 +337,10 @@ static void main_system_bus_create(void)object_property_add_child (container_get (qdev_get_machine (),"/unattached" ),"sysbus" ,OBJECT (main_system_bus),NULL ); + +/* TODO: once all bus devices are qdevified, this should be done +* when bus is created by qdev.c */ +qemu_register_reset (qbus_reset_all_fn, main_system_bus); }BusState *sysbus_get_default (void )
vl.c +0 -3
@@ -4339,9 +4339,6 @@ int main(int argc, char **argv, char **envp)exit (1 ); } -/* TODO: once all bus devices are qdevified, this should be done -* when bus is created by qdev.c */ -qemu_register_reset (qbus_reset_all_fn,sysbus_get_default ());qemu_run_machine_init_done_notifiers ();/* Done notifiers can load ROMs */
Signature · 1 line
1.9.3
Re: [Qemu-devel] [PATCH v7 1/3] sysbus: register reset handler for main_system_bus when created
Quoted 3 lines · Zhu Guihua
Since icc bus will be droped and apic reset should be after bus reset in x86, this patch moves reset handler for
main_system_busfromvl.ctosysbus.c
So, you are changing reset ordering for all machines because of a x86-specific requirement?
Other machines can have different ordering requirements and may break if you unconditionally change the reset order for all machines.
Like I said on v6: if x86 has specific CPU reset ordering requirements, we should be able to ensure the expected ordering in x86-specific code (in pc.c?), not hardcode reset ordering for all machines.
Maybe we can change the qemu_register_reset() API to accept an explicit ordering parameter, so ordering requirements are visibly encoded in the qemu_register_reset() calls instead of depending on non-obvious initialization code ordering.
While we don't have a better API, we can probably ensure the x86 reset ordering without affecting the other machines by calling qemu_register_reset() for the CPUs in a machine_init_done notifier registered by PC.
Signature · 1 line
Eduardo
Re: [Qemu-devel] [PATCH v7 1/3] sysbus: register reset handler for main_system_bus when created
Hi Eduardo,
Quoted 19 lines · Eduardo Habkost
Quoted 3 lines · Zhu Guihua
Since icc bus will be droped and apic reset should be after bus reset in x86, this patch moves reset handler for
main_system_busfromvl.ctosysbus.cSo, you are changing reset ordering for all machines because of a x86-specific requirement?
Other machines can have different ordering requirements and may break if you unconditionally change the reset order for all machines.
Like I said on v6: if x86 has specific CPU reset ordering requirements, we should be able to ensure the expected ordering in x86-specific code (in
pc.c?), not hardcode reset ordering for all machines.Maybe we can change the
qemu_register_reset()API to accept an explicit ordering parameter, so ordering requirements are visibly encoded in theqemu_register_reset()calls instead of depending on non-obvious initialization code ordering.
Quoted 4 lines
While we don't have a better API, we can probably ensure the x86 reset ordering without affecting the other machines by calling
qemu_register_reset()for the CPUs in amachine_init_donenotifier registered by PC.
I try to call qemu_register_reset() for the CPUs in pc_guest_info_machine_done (), the notifier is in hw/i386/pc.c. And I have tested this, it works well.
Thanks,
Zhu
Re: [Qemu-devel] [PATCH v7 1/3] sysbus: register reset handler for main_system_bus when created
Quoted 22 lines · Zhu Guihua
Hi Eduardo,
Quoted 19 lines · Eduardo Habkost
Quoted 3 lines · Zhu Guihua
Since icc bus will be droped and apic reset should be after bus reset in x86, this patch moves reset handler for
main_system_busfromvl.ctosysbus.cSo, you are changing reset ordering for all machines because of a x86-specific requirement?
Other machines can have different ordering requirements and may break if you unconditionally change the reset order for all machines.
Like I said on v6: if x86 has specific CPU reset ordering requirements, we should be able to ensure the expected ordering in x86-specific code (in
pc.c?), not hardcode reset ordering for all machines.Maybe we can change the
qemu_register_reset()API to accept an explicit ordering parameter, so ordering requirements are visibly encoded in theqemu_register_reset()calls instead of depending on non-obvious initialization code ordering.
Quoted 8 lines
Quoted 4 lines
While we don't have a better API, we can probably ensure the x86 reset ordering without affecting the other machines by calling
qemu_register_reset()for the CPUs in amachine_init_donenotifier registered by PC.I try to call
qemu_register_reset()for the CPUs inpc_guest_info_machine_done(),
the notifier is inhw/i386/pc.c. And I have tested this, it works well.
If you do that, please add a comment to pc_new_cpus() explaining why the reset handler needs to be registered later at machine_done. You also need to remove the reset handler registration from x86_cpu_realizefn() and register the reset handler at pc_hot_add_cpu() too.
(If we add a ordering parameter to qemu_register_reset(), we will be able to just register the reset handler at pc_new_cpu(), making everything simpler).
Signature · 1 line
Eduardo
PATCH v7 2/3 cpu/apic: drop icc bus/bridge
In reply to Zhu GuihuaFrom: Chen Fan <[email protected]>
After CPU hotplug has been converted to BUS-less hot-plug infrastructure, the only function ICC bus performs is to propagate reset to LAPICs. However LAPIC could be reset by registering its reset handler after all device are initialized.
Do so and drop ~200LOC of not needed anymore ICCBus related code.
--- hw/i386/pc.c | 19 ++++--------------- hw/i386/pc_piix.c | 15 +++++++-------- hw/i386/pc_q35.c | 15 +++++++-------- hw/intc/apic_common.c | 5 ++--- include/hw/i386/apic_internal.h | 7 ++++--- include/hw/i386/pc.h | 2 +- target-i386/cpu.c | 24 ++++++++++++++++-------- target-i386/cpu.h | 4 ++++ 8 files changed, 45 insertions(+), 46 deletions(-)
hw/i386/pc.c +4 -15
@@ -58,7 +58,6 @@#include "qemu/config-file.h" #include "hw/acpi/acpi.h" #include "hw/acpi/cpu_hotplug.h" -#include "hw/cpu/icc_bus.h" #include "hw/boards.h" #include "hw/pci/pci_host.h" #include "acpi-build.h"
@@ -990,23 +989,16 @@ void pc_acpi_smi_interrupt(void *opaque, int irq, int level) }static X86CPU *pc_new_cpu (const char *cpu_model,int64_t apic_id, -DeviceState *icc_bridge,Error **errp) +Error **errp) {X86CPU *cpu =NULL ;Error *local_err =NULL ; -if (icc_bridge ==NULL ) { -error_setg (&local_err,"Invalid icc-bridge value" ); - goto out; - } - cpu =cpu_x86_create (cpu_model, &local_err);if (local_err !=NULL ) { goto out; } -qdev_set_parent_bus (DEVICE (cpu),qdev_get_child_bus (icc_bridge,"icc" )); -object_property_set_int (OBJECT (cpu), apic_id,"apic-id" , &local_err);object_property_set_bool (OBJECT (cpu), true,"realized" , &local_err);
@@ -1023,7 +1015,6 @@ static const char *current_cpu_model;void pc_hot_add_cpu (const int64_t id,Error **errp) { -DeviceState *icc_bridge;X86CPU *cpu;int64_t apic_id =x86_cpu_apic_id_from_index (id);Error *local_err =NULL ;
@@ -1052,9 +1043,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)return ; } - icc_bridge =DEVICE (object_resolve_path_type ("icc-bridge" , -TYPE_ICC_BRIDGE ,NULL )); - cpu =pc_new_cpu (current_cpu_model, apic_id, icc_bridge, &local_err); + cpu =pc_new_cpu (current_cpu_model, apic_id, &local_err);if (local_err) {error_propagate (errp, local_err);return ;
@@ -1062,7 +1051,7 @@ void pc_hot_add_cpu(const int64_t id, Error **errp)object_unref (OBJECT (cpu)); } -void pc_cpus_init (const char *cpu_model,DeviceState *icc_bridge) +void pc_cpus_init (const char *cpu_model) {int i;X86CPU *cpu =NULL ;
@@ -1088,7 +1077,7 @@ void pc_cpus_init(const char *cpu_model, DeviceState *icc_bridge)for (i =0 ; i < smp_cpus; i++) { cpu =pc_new_cpu (cpu_model,x86_cpu_apic_id_from_index (i), - icc_bridge, &error); + &error);if (error) {error_report_err (error);exit (1 );
hw/i386/pc_piix.c +7 -8
@@ -39,7 +39,6 @@#include "hw/kvm/clock.h" #include "sysemu/sysemu.h" #include "hw/sysbus.h" -#include "hw/cpu/icc_bus.h" #include "sysemu/arch_init.h" #include "sysemu/block-backend.h" #include "hw/i2c/smbus.h"
@@ -98,7 +97,6 @@ static void pc_init1(MachineState *machine,MemoryRegion *ram_memory;MemoryRegion *pci_memory;MemoryRegion *rom_memory; -DeviceState *icc_bridge;FWCfgState *fw_cfg =NULL ;PcGuestInfo *guest_info;ram_addr_t lowmem;
@@ -143,11 +141,7 @@ static void pc_init1(MachineState *machine,exit (1 ); } - icc_bridge =qdev_create (NULL ,TYPE_ICC_BRIDGE ); -object_property_add_child (qdev_get_machine (),"icc-bridge" , -OBJECT (icc_bridge),NULL ); - -pc_cpus_init (machine->cpu_model, icc_bridge); +pc_cpus_init (machine->cpu_model);if (kvm_enabled () && kvmclock_enabled) {kvmclock_create ();
@@ -230,7 +224,6 @@ static void pc_init1(MachineState *machine,if (pci_enabled) {ioapic_init_gsi (gsi_state,"i440fx" ); } -qdev_init_nofail (icc_bridge);pc_register_ferr_irq (gsi[13 ]);
@@ -303,6 +296,12 @@ static void pc_init1(MachineState *machine,if (pci_enabled) {pc_pci_device_init (pci_bus); } + +/* since APIC is a bus-less device, propagate reset to it manually */ +CPUState *cpu; +CPU_FOREACH (cpu) { +qemu_register_reset (x86_cpu_apic_reset, cpu); + } }static void pc_init_pci (MachineState *machine)
hw/i386/pc_q35.c +7 -8
@@ -43,7 +43,6 @@#include "hw/ide/pci.h" #include "hw/ide/ahci.h" #include "hw/usb.h" -#include "hw/cpu/icc_bus.h" #include "qemu/error-report.h" /* ICH9 AHCI has 6 ports */
@@ -85,7 +84,6 @@ static void pc_q35_init(MachineState *machine)int i;ICH9LPCState *ich9_lpc;PCIDevice *ahci; -DeviceState *icc_bridge;PcGuestInfo *guest_info;ram_addr_t lowmem;DriveInfo *hd[MAX_SATA_PORTS ];
@@ -132,11 +130,7 @@ static void pc_q35_init(MachineState *machine)exit (1 ); } - icc_bridge =qdev_create (NULL ,TYPE_ICC_BRIDGE ); -object_property_add_child (qdev_get_machine (),"icc-bridge" , -OBJECT (icc_bridge),NULL ); - -pc_cpus_init (machine->cpu_model, icc_bridge); +pc_cpus_init (machine->cpu_model);pc_acpi_init ("q35-acpi-dsdt.aml" );kvmclock_create ();
@@ -240,7 +234,6 @@ static void pc_q35_init(MachineState *machine)if (pci_enabled) {ioapic_init_gsi (gsi_state,"q35" ); } -qdev_init_nofail (icc_bridge);pc_register_ferr_irq (gsi[13 ]);
@@ -287,6 +280,12 @@ static void pc_q35_init(MachineState *machine)if (pci_enabled) {pc_pci_device_init (host_bus); } + +/* since APIC is a bus-less device, propagate reset to it manually */ +CPUState *cpu; +CPU_FOREACH (cpu) { +qemu_register_reset (x86_cpu_apic_reset, cpu); + } }static void pc_compat_2_3 (MachineState *machine)
hw/intc/apic_common.c +2 -3
@@ -429,13 +429,12 @@ static Property apic_properties_common[] = {static void apic_common_class_init (ObjectClass *klass,void *data) { -ICCDeviceClass *idc =ICC_DEVICE_CLASS (klass);DeviceClass *dc =DEVICE_CLASS (klass); dc->vmsd = &vmstate_apic_common; dc->reset = apic_reset_common; dc->props = apic_properties_common; - idc->realize = apic_common_realize; + dc->realize = apic_common_realize;/* * Reason: APIC and CPU need to be wired up by * x86_cpu_apic_create()
@@ -445,7 +444,7 @@ static void apic_common_class_init(ObjectClass *klass, void *data)static const TypeInfo apic_common_type = { .name =TYPE_APIC_COMMON , - .parent =TYPE_ICC_DEVICE , + .parent =TYPE_DEVICE , .instance_size =sizeof (APICCommonState), .class_size =sizeof (APICCommonClass), .class_init = apic_common_class_init,
include/hw/i386/apic_internal.h +4 -3
@@ -21,7 +21,6 @@#define QEMU_APIC_INTERNAL_H #include "exec/memory.h" -#include "hw/cpu/icc_bus.h" #include "qemu/timer.h" /* APIC Local Vector Table */
@@ -78,7 +77,7 @@ typedef struct APICCommonState APICCommonState; typedef struct APICCommonClass { - ICCDeviceClass parent_class; + DeviceClass parent_class; DeviceRealize realize; void (*set_base)(APICCommonState *s, uint64_t val);
@@ -93,7 +92,9 @@ typedef struct APICCommonClass } APICCommonClass;struct APICCommonState { -ICCDevice busdev; +/*< private >*/ +DeviceState parent_obj; +/*< public >*/ MemoryRegion io_memory;X86CPU *cpu;
include/hw/i386/pc.h +1 -1
@@ -163,7 +163,7 @@ extern int fd_bootchk;void pc_register_ferr_irq (qemu_irq irq);void pc_acpi_smi_interrupt (void *opaque,int irq,int level); -void pc_cpus_init (const char *cpu_model,DeviceState *icc_bridge); +void pc_cpus_init (const char *cpu_model);void pc_hot_add_cpu (const int64_t id,Error **errp);void pc_acpi_init (const char *default_dsdt);
target-i386/cpu.c +16 -8
@@ -42,7 +42,6 @@#include "sysemu/sysemu.h" #include "hw/qdev-properties.h" -#include "hw/cpu/icc_bus.h" #ifndef CONFIG_USER_ONLY #include "hw/xen/xen.h" #include "hw/i386/apic_internal.h"
@@ -2718,7 +2717,6 @@ static void mce_init(X86CPU *cpu)#ifndef CONFIG_USER_ONLY static void x86_cpu_apic_create (X86CPU *cpu,Error **errp) { -DeviceState *dev =DEVICE (cpu);APICCommonState *apic;const char *apic_type ="apic" ;
@@ -2728,11 +2726,7 @@ static void x86_cpu_apic_create(X86CPU *cpu, Error **errp) apic_type ="xen-apic" ; } - cpu->apic_state =qdev_try_create (qdev_get_parent_bus (dev), apic_type); -if (cpu->apic_state ==NULL ) { -error_setg (errp,"APIC device '%s' could not be created" , apic_type); -return ; - } + cpu->apic_state =DEVICE (object_new (apic_type));object_property_add_child (OBJECT (cpu),"apic" ,OBJECT (cpu->apic_state),NULL );
@@ -2752,6 +2746,21 @@ static void x86_cpu_apic_realize(X86CPU *cpu, Error **errp)object_property_set_bool (OBJECT (cpu->apic_state), true,"realized" , errp); } + +void x86_cpu_apic_reset (void *opaque) +{ +CPUState *cs = opaque; +X86CPU *cpu =X86_CPU (cs); +DeviceClass *dc; + +if (cpu->apic_state) { + dc =DEVICE_GET_CLASS (cpu->apic_state); + +if (dc->reset !=NULL ) { + (*dc->reset)(cpu->apic_state); + } + } +}#else static void x86_cpu_apic_realize (X86CPU *cpu,Error **errp) {
@@ -3091,7 +3100,6 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data) xcc->parent_realize = dc->realize; dc->realize = x86_cpu_realizefn; - dc->bus_type =TYPE_ICC_BUS ; dc->props = x86_cpu_properties; xcc->parent_reset = cc->reset;
target-i386/cpu.h +4 -0
@@ -1105,6 +1105,10 @@ int x86_cpu_handle_mmu_fault(CPUState *cpu, vaddr addr, int is_write, int mmu_idx);void x86_cpu_set_a20 (X86CPU *cpu,int a20_state); +#ifndef CONFIG_USER_ONLY +void x86_cpu_apic_reset (void *opaque); +#endif +static inline bool hw_local_breakpoint_enabled (unsigned long dr7,int index) {return (dr7 >> (index *2 )) &1 ;
Signature · 1 line
1.9.3
PATCH v7 3/3 icc_bus: drop the unused files
In reply to Zhu GuihuaICC bus impl has been droped, so all icc related files are not useful any more; delete them.
--- default-configs/i386-softmmu.mak | 1 - default-configs/x86_64-softmmu.mak | 1 - hw/cpu/Makefile.objs | 1 - hw/cpu/icc_bus.c | 118 ------------------------------------- include/hw/cpu/icc_bus.h | 82 -------------------------- 5 files changed, 203 deletions(-) delete mode 100644 hw/cpu/icc_bus.c delete mode 100644 include/hw/cpu/icc_bus.h
default-configs/i386-softmmu.mak +0 -1
@@ -39,7 +39,6 @@ CONFIG_LPC_ICH9=y CONFIG_PCI_Q35=y CONFIG_APIC=y CONFIG_IOAPIC=y -CONFIG_ICC_BUS=y CONFIG_PVPANIC=y CONFIG_MEM_HOTPLUG=y CONFIG_XIO3130=y
default-configs/x86_64-softmmu.mak +0 -1
@@ -39,7 +39,6 @@ CONFIG_LPC_ICH9=y CONFIG_PCI_Q35=y CONFIG_APIC=y CONFIG_IOAPIC=y -CONFIG_ICC_BUS=y CONFIG_PVPANIC=y CONFIG_MEM_HOTPLUG=y CONFIG_XIO3130=y
hw/cpu/Makefile.objs +0 -1
@@ -2,5 +2,4 @@ obj-$(CONFIG_ARM11MPCORE) += arm11mpcore.o obj-$(CONFIG_REALVIEW) += realview_mpcore.o obj-$(CONFIG_A9MPCORE) += a9mpcore.o obj-$(CONFIG_A15MPCORE) += a15mpcore.o -obj-$(CONFIG_ICC_BUS) += icc_bus.o
hw/cpu/icc_bus.c deleted +0 -118
118 lines not on this page · raw message
include/hw/cpu/icc_bus.h deleted +0 -82
82 lines not on this page · raw message
Signature · 1 line
1.9.3
Quoted 10 lines · Zhu Guihua
ICC Bus was used for providing a hotpluggable bus for APIC and CPU, but now we use HotplugHandler to make hotplug. So ICC Bus is unnecessary.
This code has passed the new pc-cpu-test.
And I have tested with kvm along with kernel_irqchip=on/off, it works fine.This patch series is based on Eduardo's x86 tree.
https://github.com/ehabkost/qemu.git
I removed "apic: map APIC's MMIO region at each CPU's address space" from the x86 branch moments after you submitted this series. See Paolo's comments he sent as reply to my 2015-05-29 X86 pull request.
Signature · 1 line
Eduardo