On Fri, 13 Feb 2015 18:25:24 +0800 Zhu Guihua <zhugh.f...@cn.fujitsu.com> wrote:
> From: Chen Fan <chen.fan.f...@cn.fujitsu.com> > > ICC bus was invented only to provide hotplug capability to > CPU and APIC because at the time being hotplug was available only for > BUS attached devices. > > Now this patch is to drop ICC bus impl, and switch to bus-less > CPU+APIC hotplug, handling them in the same manner as pc-dimm. > > Signed-off-by: Chen Fan <chen.fan.f...@cn.fujitsu.com> > Signed-off-by: Zhu Guihua <zhugh.f...@cn.fujitsu.com> > --- > hw/i386/kvm/apic.c | 10 ++++++++-- > hw/i386/pc.c | 21 +++++---------------- > hw/i386/pc_piix.c | 9 +-------- > hw/i386/pc_q35.c | 9 +-------- > hw/intc/apic.c | 16 +++++++++++----- > hw/intc/apic_common.c | 14 +++++++++----- > include/hw/i386/apic_internal.h | 6 ++---- > include/hw/i386/pc.h | 3 ++- > target-i386/cpu.c | 19 +++---------------- > target-i386/cpu.h | 3 +-- > 10 files changed, 43 insertions(+), 67 deletions(-) > > diff --git a/hw/i386/kvm/apic.c b/hw/i386/kvm/apic.c > index 5b47056..4b7ce57 100644 > --- a/hw/i386/kvm/apic.c > +++ b/hw/i386/kvm/apic.c > @@ -10,6 +10,7 @@ > * See the COPYING file in the top-level directory. > */ > #include "hw/i386/apic_internal.h" > +#include "hw/i386/pc.h" > #include "hw/pci/msi.h" > #include "sysemu/kvm.h" > > @@ -180,9 +181,14 @@ static void kvm_apic_reset(APICCommonState *s) > static void kvm_apic_realize(DeviceState *dev, Error **errp) > { > APICCommonState *s = APIC_COMMON(dev); > + PCMachineState *pcms = PC_MACHINE(qdev_get_machine()); > + static bool mmio_registered; > > - memory_region_init_io(&s->io_memory, NULL, &kvm_apic_io_ops, s, > "kvm-apic-msi", > - APIC_SPACE_SIZE); > + if (!mmio_registered) { > + memory_region_init_io(&pcms->apic_mmio, NULL, &kvm_apic_io_ops, s, > + "kvm-apic-msi", APIC_SPACE_SIZE); APIC shouldn't access MachineState let alone modify it, so keep io_memory in APICCommonState and export method something like: apic_register_mmio(AddressSpace *as, hwaddr addr); and use it in pc_machine_device_plug_cb() but it would be better to use per CPU AddressSpace added by 09daed848c if it works with KVM. Then you could map APIC into it x86_cpu_realize().