From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yi0FT-0003hw-4B for qemu-devel@nongnu.org; Tue, 14 Apr 2015 08:47:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Yi0FP-00077y-2Q for qemu-devel@nongnu.org; Tue, 14 Apr 2015 08:47:27 -0400 Received: from cantor2.suse.de ([195.135.220.15]:54187 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Yi0FO-00077r-O3 for qemu-devel@nongnu.org; Tue, 14 Apr 2015 08:47:22 -0400 Message-ID: <552D0C58.4060601@suse.de> Date: Tue, 14 Apr 2015 14:47:20 +0200 From: =?windows-1252?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <3215703fb9a4b3cafb5f2b29b8f2349cc759c78a.1428653440.git.chen.fan.fnst@cn.fujitsu.com> <20150414144129.6ed55b5b@nial.brq.redhat.com> In-Reply-To: <20150414144129.6ed55b5b@nial.brq.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v3 1/2] apic: move apic mmio register to each apic realizefn List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chen Fan Cc: zhugh.fnst@cn.fujitsu.com, qemu-devel@nongnu.org, isimatu.yasuaki@jp.fujitsu.com, Paolo , guz.fnst@cn.fujitsu.com, Igor Mammedov Am 14.04.2015 um 14:41 schrieb Igor Mammedov: > On Fri, 10 Apr 2015 16:18:05 +0800 > Chen Fan wrote: >=20 >> Due to local apic address is in view of CPU's address space, >> so able to move apic mapping to each apic realizefn. >> >> Signed-off-by: Chen Fan >> --- >> hw/i386/pc.c | 7 ------- >> hw/intc/apic_common.c | 11 +++++------ >> 2 files changed, 5 insertions(+), 13 deletions(-) >> >> diff --git a/hw/i386/pc.c b/hw/i386/pc.c >> index a8e6be1..a5e2a27 100644 >> --- a/hw/i386/pc.c >> +++ b/hw/i386/pc.c >> @@ -1089,13 +1089,6 @@ void pc_cpus_init(const char *cpu_model, Device= State *icc_bridge) >> } >> } >> =20 >> - /* map APIC MMIO area if CPU has APIC */ >> - if (cpu && cpu->apic_state) { >> - /* XXX: what if the base changes? */ >> - sysbus_mmio_map_overlap(SYS_BUS_DEVICE(icc_bridge), 0, >> - APIC_DEFAULT_ADDRESS, 0x1000); >> - } >> - >> /* tell smbios about cpuid version and features */ >> smbios_set_cpuid(cpu->env.cpuid_version, cpu->env.features[FEAT_1= _EDX]); >> } >> diff --git a/hw/intc/apic_common.c b/hw/intc/apic_common.c >> index 042e960..004821a 100644 >> --- a/hw/intc/apic_common.c >> +++ b/hw/intc/apic_common.c >> @@ -306,7 +306,6 @@ static void apic_common_realize(DeviceState *dev, = Error **errp) >> APICCommonClass *info; >> static DeviceState *vapic; >> static int apic_no; >> - static bool mmio_registered; >> =20 >> if (apic_no >=3D MAX_APICS) { >> error_setg(errp, "%s initialization failed.", >> @@ -317,11 +316,11 @@ static void apic_common_realize(DeviceState *dev= , Error **errp) >> =20 >> info =3D APIC_COMMON_GET_CLASS(s); >> info->realize(dev, errp); >> - if (!mmio_registered) { >> - ICCBus *b =3D ICC_BUS(qdev_get_parent_bus(dev)); >> - memory_region_add_subregion(b->apic_address_space, 0, &s->io_= memory); >> - mmio_registered =3D true; >> - } >> + >> + memory_region_add_subregion_overlap(CPU(s->cpu)->as->root, > if you look at AddressSpace declaration, root field is marked as privat= e > so you can't access it. > Perhaps you need to add wrapper to get root, something like this: > address_space_root_memory_region() Also, by convention please use a local CPUState *cpu or *cs variable rather than calling CPU() inline. Regards, Andreas >> + APIC_DEFAULT_ADDRESS, > use s->apicbase here and set its default value from CPU using cpu_set_a= pic_base() > for example in: x86_cpu_apic_create() >=20 > PS: > we also probably need to teach kvm_apic_set_base()/apic_set_base() to > remap APIC in case base changes but it's out of scope of this series. >=20 >> + &s->io_memory, >> + 0x1000); >> =20 >> /* Note: We need at least 1M to map the VAPIC option ROM */ >> if (!vapic && s->vapic_control & VAPIC_ENABLE_MASK && --=20 SUSE Linux GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Felix Imend=F6rffer, Jane Smithard, Jennifer Guild, Dilip Upmanyu, Graham Norton; HRB 21284 (AG N=FCrnberg)