Received: from eggs.gnu.org ([208.118.235.92]:48507) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UE3aU-0000CN-Q6 for qemu-devel@nongnu.org; Fri, 08 Mar 2013 15:08:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UE3a7-0000bP-SF for qemu-devel@nongnu.org; Fri, 08 Mar 2013 15:08:18 -0500 From: Alexander Graf Date: Fri, 8 Mar 2013 21:06:49 +0100 Message-Id: <1362773228-1747-48-git-send-email-agraf@suse.de> In-Reply-To: <1362773228-1747-1-git-send-email-agraf@suse.de> References: <1362773228-1747-1-git-send-email-agraf@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 47/66] target-ppc: Register all types for TARGET_PPCEMB List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel qemu-devel Cc: Blue Swirl , "qemu-ppc@nongnu.org list:PowerPC" , =?utf-8?q?Andreas=20F=C3=A4rber?= , =?utf-8?q?Aur=C3=A9lien=20Jarno?= From: Andreas F=C3=A4rber Don't attempt to suppress registration of CPU types, since the criteria is actually a property of the class and should thus become a field. Since we can't check a field set in a class_init function before registering the type that leads to execution of that function, guard the -cpu class lookup instead and suppress exposing these classes in -cpu ? and in QMP. In case someone tries to hot-add an incompatible CPU via device_add, error out in realize. Signed-off-by: Andreas F=C3=A4rber Signed-off-by: Alexander Graf --- target-ppc/translate_init.c | 43 ++++++++++++++++++++++++++++++++++---= ------ 1 files changed, 34 insertions(+), 9 deletions(-) diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index 06df161..ca56028 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -7876,14 +7876,6 @@ enum { /* PowerPC CPU definitions = */ #define POWERPC_DEF_PREFIX(pvr, svr, type) = \ glue(glue(glue(glue(pvr, _), svr), _), type) -#if defined(TARGET_PPCEMB) -#define POWERPC_DEF_CONDITION(type) = \ - if (glue(POWERPC_MMU_, type) !=3D POWERPC_MMU_BOOKE) { = \ - return; = \ - } -#else -#define POWERPC_DEF_CONDITION(type) -#endif #define POWERPC_DEF_SVR(_name, _pvr, _svr, _type) = \ static void = \ glue(POWERPC_DEF_PREFIX(_pvr, _svr, _type), _cpu_class_init) = \ @@ -7912,7 +7904,6 @@ enum { static void = \ glue(POWERPC_DEF_PREFIX(_pvr, _svr, _type), _cpu_register_types)(voi= d) \ { = \ - POWERPC_DEF_CONDITION(_type) = \ type_register_static( = \ &glue(POWERPC_DEF_PREFIX(_pvr, _svr, _type), _cpu_type_info)= ); \ } = \ @@ -10040,6 +10031,15 @@ static void ppc_cpu_realizefn(DeviceState *dev, = Error **errp) } } =20 +#if defined(TARGET_PPCEMB) + if (pcc->mmu_model !=3D POWERPC_MMU_BOOKE) { + error_setg(errp, "CPU does not possess a BookE MMU. " + "Please use qemu-system-ppc or qemu-system-ppc64 inst= ead " + "or choose another CPU model."); + return; + } +#endif + create_ppc_opcodes(cpu, &local_err); if (local_err !=3D NULL) { error_propagate(errp, local_err); @@ -10239,6 +10239,12 @@ static gint ppc_cpu_compare_class_pvr(gconstpoin= ter a, gconstpointer b) return -1; } =20 +#if defined(TARGET_PPCEMB) + if (pcc->mmu_model !=3D POWERPC_MMU_BOOKE) { + return -1; + } +#endif + return pcc->pvr =3D=3D pvr ? 0 : -1; } =20 @@ -10261,8 +10267,14 @@ static gint ppc_cpu_compare_class_name(gconstpoi= nter a, gconstpointer b) { ObjectClass *oc =3D (ObjectClass *)a; const char *name =3D b; +#if defined(TARGET_PPCEMB) + PowerPCCPUClass *pcc =3D POWERPC_CPU_CLASS(oc); +#endif =20 if (strncasecmp(name, object_class_get_name(oc), strlen(name)) =3D=3D= 0 && +#if defined(TARGET_PPCEMB) + pcc->mmu_model =3D=3D POWERPC_MMU_BOOKE && +#endif strcmp(object_class_get_name(oc) + strlen(name), "-" TYPE_POWERPC_CPU) =3D=3D 0) { return 0; @@ -10381,6 +10393,12 @@ static void ppc_cpu_list_entry(gpointer data, gp= ointer user_data) const char *typename =3D object_class_get_name(oc); char *name; =20 +#if defined(TARGET_PPCEMB) + if (pcc->mmu_model !=3D POWERPC_MMU_BOOKE) { + return; + } +#endif + name =3D g_strndup(typename, strlen(typename) - strlen("-" TYPE_POWERPC_CPU)); (*s->cpu_fprintf)(s->file, "PowerPC %-16s PVR %08x\n", @@ -10421,6 +10439,13 @@ static void ppc_cpu_defs_entry(gpointer data, gp= ointer user_data) const char *typename; CpuDefinitionInfoList *entry; CpuDefinitionInfo *info; +#if defined(TARGET_PPCEMB) + PowerPCCPUClass *pcc =3D POWERPC_CPU_CLASS(oc); + + if (pcc->mmu_model !=3D POWERPC_MMU_BOOKE) { + return; + } +#endif =20 typename =3D object_class_get_name(oc); info =3D g_malloc0(sizeof(*info)); --=20 1.6.0.2