From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IwHrp-0001hC-Qm for qemu-devel@nongnu.org; Sun, 25 Nov 2007 08:49:49 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IwHro-0001fW-6P for qemu-devel@nongnu.org; Sun, 25 Nov 2007 08:49:49 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IwHrn-0001fE-LH for qemu-devel@nongnu.org; Sun, 25 Nov 2007 08:49:47 -0500 Received: from partizan.velesys.com ([213.184.230.195]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IwHrm-0001Te-Mg for qemu-devel@nongnu.org; Sun, 25 Nov 2007 08:49:47 -0500 Date: Sun, 25 Nov 2007 15:51:01 +0200 From: "Kirill A. Shutemov" Subject: Re: [Qemu-devel] [PATCH] Handle cpu_model in copy_cpu() Message-ID: <20071125135101.GA10761@localhost.localdomain> References: <20071124213028.GA3489@localhost.localdomain> <20071125130437.GA9275@karma.qumranet.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="EVF5PPMfhYS0aIcm" Content-Disposition: inline In-Reply-To: <20071125130437.GA9275@karma.qumranet.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Dan Kenigsberg Cc: qemu-devel@nongnu.org --EVF5PPMfhYS0aIcm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On [Sun, 25.11.2007 15:04], Dan Kenigsberg wrote: > On Sat, Nov 24, 2007 at 11:30:28PM +0200, Kirill A. Shutemov wrote: > > copy_cpu() has been broken since cpu_model added to parameters list of > > cpu_init(). This patch fix copy_cpu() by storing cpu_model string in > > CPUState structure on cpu_init and use this string in copy_cpu(). >=20 > Please excuse my layman's question: why does each cpu need its own copy > of the string, and not just point to the same const char *cpu_model? It's a good idea. Thanks. Updated patch: diff --git a/cpu-defs.h b/cpu-defs.h index 139dca2..5e0f046 100644 --- a/cpu-defs.h +++ b/cpu-defs.h @@ -146,6 +146,8 @@ typedef struct CPUTLBEntry { void *next_cpu; /* next CPU sharing TB cache */ \ int cpu_index; /* CPU index (informative) */ \ /* user data */ \ - void *opaque; + void *opaque; \ + \ + const char *cpu_model_str; =20 #endif diff --git a/exec.c b/exec.c index 046e967..3fe340a 100644 --- a/exec.c +++ b/exec.c @@ -1317,9 +1317,7 @@ void cpu_abort(CPUState *env, const char *fmt, ...) =20 CPUState *cpu_copy(CPUState *env) { -#if 0 - /* XXX: broken, must be handled by each CPU */ - CPUState *new_env =3D cpu_init(); + CPUState *new_env =3D cpu_init(env->cpu_model_str); /* preserve chaining and index */ CPUState *next_cpu =3D new_env->next_cpu; int cpu_index =3D new_env->cpu_index; @@ -1327,9 +1325,6 @@ CPUState *cpu_copy(CPUState *env) new_env->next_cpu =3D next_cpu; new_env->cpu_index =3D cpu_index; return new_env; -#else - return NULL; -#endif } =20 #if !defined(CONFIG_USER_ONLY) diff --git a/target-arm/helper.c b/target-arm/helper.c index 038025d..a27602d 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -182,6 +182,7 @@ CPUARMState *cpu_arm_init(const char *cpu_model) if (!env) return NULL; cpu_exec_init(env); + env->cpu_model_str =3D cpu_model; env->cp15.c0_cpuid =3D id; cpu_reset(env); return env; diff --git a/target-i386/helper2.c b/target-i386/helper2.c index 67658e2..968d9dd 100644 --- a/target-i386/helper2.c +++ b/target-i386/helper2.c @@ -99,6 +99,7 @@ CPUX86State *cpu_x86_init(const char *cpu_model) if (!env) return NULL; cpu_exec_init(env); + env->cpu_model_str =3D cpu_model; =20 /* init various static tables */ if (!inited) { diff --git a/target-m68k/helper.c b/target-m68k/helper.c index f6b0cd6..c639648 100644 --- a/target-m68k/helper.c +++ b/target-m68k/helper.c @@ -126,11 +126,13 @@ CPUM68KState *cpu_m68k_init(const char *cpu_model) return NULL; cpu_exec_init(env); =20 + env->cpu_model_str =3D cpu_model; + if (cpu_m68k_set_model(env, cpu_model) < 0) { cpu_m68k_close(env); return NULL; } - =20 + cpu_reset(env); return env; } diff --git a/target-mips/translate.c b/target-mips/translate.c index 55e6290..374eebd 100644 --- a/target-mips/translate.c +++ b/target-mips/translate.c @@ -6754,6 +6754,7 @@ CPUMIPSState *cpu_mips_init (const char *cpu_model) env->cpu_model =3D def; =20 cpu_exec_init(env); + env->cpu_model_str =3D cpu_model; cpu_reset(env); return env; } diff --git a/target-ppc/helper.c b/target-ppc/helper.c index cb9b778..dbbde12 100644 --- a/target-ppc/helper.c +++ b/target-ppc/helper.c @@ -2987,6 +2987,7 @@ CPUPPCState *cpu_ppc_init (const char *cpu_model) if (!env) return NULL; cpu_exec_init(env); + env->cpu_model_str =3D cpu_model; cpu_ppc_register_internal(env, def); cpu_ppc_reset(env); return env; diff --git a/target-sparc/translate.c b/target-sparc/translate.c index 1e373ce..a7e46fb 100644 --- a/target-sparc/translate.c +++ b/target-sparc/translate.c @@ -3506,6 +3506,7 @@ CPUSPARCState *cpu_sparc_init(const char *cpu_model) if (!env) return NULL; cpu_exec_init(env); + env->cpu_model_str =3D cpu_model; env->version =3D def->iu_version; env->fsr =3D def->fpu_version; #if !defined(TARGET_SPARC64) --=20 Regards, Kirill A. Shutemov + Belarus, Minsk + Velesys LLC, http://www.velesys.com/ + ALT Linux Team, http://www.altlinux.com/ --EVF5PPMfhYS0aIcm Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.7 (GNU/Linux) iD8DBQFHSX3FbWYnhzC5v6oRAiPSAJ4kx1fSpISla86Wyi1UoqvpqjIbpQCeJNpc 8nnT9KiWF/iWM8v0aa1NpEM= =W0wj -----END PGP SIGNATURE----- --EVF5PPMfhYS0aIcm--