[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] Fix CPU chaining in linux-user emulation
From: |
Gwenole Beauchesne |
Subject: |
[Qemu-devel] [PATCH] Fix CPU chaining in linux-user emulation |
Date: |
Tue, 20 Feb 2007 01:44:37 +0100 (CET) |
Hi,
This patch fixes chaining of CPU instances. It was simply trashed with the
memcpy() thus causing problems in threaded programs (N > 2): an infinite
loop in next cpu_init().
--- qemu-0.9.0/linux-user/syscall.c.cpuchain 2007-02-13 14:41:12.000000000
+0100
+++ qemu-0.9.0/linux-user/syscall.c 2007-02-20 01:36:10.000000000 +0100
@@ -1720,8 +1720,7 @@ int do_fork(CPUState *env, unsigned int
ts->next = first_task_state;
first_task_state = ts;
/* we create a new CPU instance. */
- new_env = cpu_init();
- memcpy(new_env, env, sizeof(CPUState));
+ new_env = cpu_copy(env);
#if defined(TARGET_I386)
if (!newsp)
newsp = env->regs[R_ESP];
--- qemu-0.9.0/exec.c.cpuchain 2007-02-20 01:31:45.000000000 +0100
+++ qemu-0.9.0/exec.c 2007-02-20 01:36:32.000000000 +0100
@@ -1222,6 +1222,18 @@ void cpu_abort(CPUState *env, const char
abort();
}
+CPUState *cpu_copy(CPUState *env)
+{
+ CPUState *new_env = cpu_init();
+ /* preserve chaining and index */
+ CPUState *next_cpu = new_env->next_cpu;
+ int cpu_index = new_env->cpu_index;
+ memcpy(new_env, env, sizeof(CPUState));
+ new_env->next_cpu = next_cpu;
+ new_env->cpu_index = cpu_index;
+ return new_env;
+}
+
#if !defined(CONFIG_USER_ONLY)
/* NOTE: if flush_global is true, also flush global entries (not
--- qemu-0.9.0/cpu-all.h.cpuchain 2007-02-18 14:40:33.000000000 +0100
+++ qemu-0.9.0/cpu-all.h 2007-02-20 01:34:53.000000000 +0100
@@ -760,6 +760,8 @@ void page_unprotect_range(target_ulong d
#endif /* SINGLE_CPU_DEFINES */
+CPUState *cpu_copy(CPUState *env);
+
void cpu_dump_state(CPUState *env, FILE *f,
int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
int flags);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-devel] [PATCH] Fix CPU chaining in linux-user emulation,
Gwenole Beauchesne <=