From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:43878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UV3r7-0002jD-Vu for qemu-devel@nongnu.org; Wed, 24 Apr 2013 13:51:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UV3r2-0006Df-VJ for qemu-devel@nongnu.org; Wed, 24 Apr 2013 13:51:45 -0400 Received: from cantor2.suse.de ([195.135.220.15]:53982 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UV3r2-0006Bh-LK for qemu-devel@nongnu.org; Wed, 24 Apr 2013 13:51:40 -0400 Message-ID: <51781BA7.5090601@suse.de> Date: Wed, 24 Apr 2013 19:51:35 +0200 From: =?ISO-8859-15?Q?Andreas_F=E4rber?= MIME-Version: 1.0 References: <1366705795-24732-1-git-send-email-imammedo@redhat.com> <1366705795-24732-8-git-send-email-imammedo@redhat.com> In-Reply-To: <1366705795-24732-8-git-send-email-imammedo@redhat.com> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 07/21] cpu: introduce get_arch_id() method and override it for target-i386 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov Cc: kwolf@redhat.com, peter.maydell@linaro.org, aliguori@us.ibm.com, ehabkost@redhat.com, gleb@redhat.com, mst@redhat.com, jan.kiszka@siemens.com, quintela@redhat.com, claudio.fontana@huawei.com, qemu-devel@nongnu.org, aderumier@odiso.com, lcapitulino@redhat.com, blauwirbel@gmail.com, anthony.perard@citrix.com, alex.williamson@redhat.com, kraxel@redhat.com, yang.z.zhang@intel.com, pbonzini@redhat.com, stefano.stabellini@eu.citrix.com, armbru@redhat.com, rth@twiddle.net Am 23.04.2013 10:29, schrieb Igor Mammedov: > get_arch_id() adds possibility for generic code to get guest visible > CPU ID without accessing CPUArchState. If target doesn't override it, > it will return cpu_index. >=20 > Override it on target-i386 to return APIC ID. >=20 > Signed-off-by: Igor Mammedov > Reviewed-by: Eduardo Habkost > Reviewed-by: liguang > Acked-by: Michael S. Tsirkin > --- > * it will be used later by new cpu_exists() generic function and > acpi_piix. > * s/cpu_firmware_id/cpu_arch_id/ > --- > include/qom/cpu.h | 2 ++ > qom/cpu.c | 6 ++++++ > target-i386/cpu.c | 10 ++++++++++ > 3 files changed, 18 insertions(+), 0 deletions(-) Thanks, applied to qom-cpu (with two minor changes below and rewording wrt target vs. QOM class): https://github.com/afaerber/qemu-cpu/commits/qom-cpu >=20 > diff --git a/include/qom/cpu.h b/include/qom/cpu.h > index d6a0e80..639b436 100644 > --- a/include/qom/cpu.h > +++ b/include/qom/cpu.h > @@ -45,6 +45,7 @@ typedef struct CPUState CPUState; > * instantiatable CPU type. > * @reset: Callback to reset the #CPUState to its initial state. > * @do_interrupt: Callback for interrupt handling. > + * @get_arch_id: Callback for getting architecture depended CPU ID "dependent" > * @vmsd: State description for migration. > * > * Represents a CPU family or model. [...] > diff --git a/target-i386/cpu.c b/target-i386/cpu.c > index e2302d8..a415fa3 100644 > --- a/target-i386/cpu.c > +++ b/target-i386/cpu.c > @@ -2272,6 +2272,14 @@ static void x86_cpu_initfn(Object *obj) > } > } > =20 > +static int64_t x86_cpu_get_arch_id(CPUState *cpu) > +{ > + X86CPU *x86cpu =3D X86_CPU(cpu); > + CPUX86State *env =3D &x86cpu->env; > + > + return env->cpuid_apic_id; > +} > + > static void x86_cpu_common_class_init(ObjectClass *oc, void *data) > { > X86CPUClass *xcc =3D X86_CPU_CLASS(oc); [snip] To stay consistent in our X86CPU naming conventions: diff --git a/target-i386/cpu.c b/target-i386/cpu.c index a415fa3..f34ba23 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -2272,10 +2272,10 @@ static void x86_cpu_initfn(Object *obj) } } -static int64_t x86_cpu_get_arch_id(CPUState *cpu) +static int64_t x86_cpu_get_arch_id(CPUState *cs) { - X86CPU *x86cpu =3D X86_CPU(cpu); - CPUX86State *env =3D &x86cpu->env; + X86CPU *cpu =3D X86_CPU(cs); + CPUX86State *env =3D &cpu->env; return env->cpuid_apic_id; } Andreas --=20 SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N=FCrnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imend=F6rffer; HRB 16746 AG N=FCrnbe= rg