From: "Kirill A. Shutemov" <k.shutemov@gmail.com>
To: Fabrice Bellard <fabrice@bellard.org>, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] Handle cpu_model in copy_cpu()
Date: Sat, 24 Nov 2007 23:30:28 +0200 [thread overview]
Message-ID: <20071124213028.GA3489@localhost.localdomain> (raw)
[-- Attachment #1: Type: text/plain, Size: 4538 bytes --]
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().
---
cpu-defs.h | 4 +++-
exec.c | 7 +------
target-arm/helper.c | 1 +
target-i386/helper2.c | 1 +
target-m68k/helper.c | 4 +++-
target-mips/translate.c | 1 +
target-ppc/helper.c | 1 +
target-sparc/translate.c | 1 +
8 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/cpu-defs.h b/cpu-defs.h
index 139dca2..9c96532 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; \
+ \
+ char cpu_model_str[32];
#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, ...)
CPUState *cpu_copy(CPUState *env)
{
-#if 0
- /* XXX: broken, must be handled by each CPU */
- CPUState *new_env = cpu_init();
+ CPUState *new_env = cpu_init(env->cpu_model_str);
/* preserve chaining and index */
CPUState *next_cpu = new_env->next_cpu;
int cpu_index = new_env->cpu_index;
@@ -1327,9 +1325,6 @@ CPUState *cpu_copy(CPUState *env)
new_env->next_cpu = next_cpu;
new_env->cpu_index = cpu_index;
return new_env;
-#else
- return NULL;
-#endif
}
#if !defined(CONFIG_USER_ONLY)
diff --git a/target-arm/helper.c b/target-arm/helper.c
index 038025d..ba0c503 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);
+ strcpy(env->cpu_model_str, cpu_model);
env->cp15.c0_cpuid = id;
cpu_reset(env);
return env;
diff --git a/target-i386/helper2.c b/target-i386/helper2.c
index 67658e2..0d4a046 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);
+ strcpy(env->cpu_model_str, cpu_model);
/* init various static tables */
if (!inited) {
diff --git a/target-m68k/helper.c b/target-m68k/helper.c
index f6b0cd6..316dae5 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);
+ strcpy(env->cpu_model_str, cpu_model);
+
if (cpu_m68k_set_model(env, cpu_model) < 0) {
cpu_m68k_close(env);
return NULL;
}
-
+
cpu_reset(env);
return env;
}
diff --git a/target-mips/translate.c b/target-mips/translate.c
index 55e6290..d8b70ff 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 = def;
cpu_exec_init(env);
+ strcpy(env->cpu_model_str, cpu_model);
cpu_reset(env);
return env;
}
diff --git a/target-ppc/helper.c b/target-ppc/helper.c
index cb9b778..8bfd97d 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);
+ strcpy(env->cpu_model_str, 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..891adf4 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);
+ strcpy(env->cpu_model_str, cpu_model);
env->version = def->iu_version;
env->fsr = def->fpu_version;
#if !defined(TARGET_SPARC64)
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ Velesys LLC, http://www.velesys.com/
+ ALT Linux Team, http://www.altlinux.com/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next reply other threads:[~2007-11-24 21:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-24 21:30 Kirill A. Shutemov [this message]
2007-11-25 13:04 ` [Qemu-devel] [PATCH] Handle cpu_model in copy_cpu() Dan Kenigsberg
2007-11-25 13:51 ` Kirill A. Shutemov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071124213028.GA3489@localhost.localdomain \
--to=k.shutemov@gmail.com \
--cc=fabrice@bellard.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).