qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH 01/13] [PATCH] make cpu_exec_init symmetric


From: Glauber Costa
Subject: [Qemu-devel] [PATCH 01/13] [PATCH] make cpu_exec_init symmetric
Date: Thu, 15 May 2008 11:09:21 -0300

we put all the code that needs to be executed only at cpu0
out of cpu_exec_init(), in exec_init(). It is executed
before machine_init(), and only once. With this change,
code cpu_exec_init() is completely symmetric.
---
 exec-all.h |    1 +
 exec.c     |   15 +++++++++------
 vl.c       |    1 +
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/exec-all.h b/exec-all.h
index d8c6c33..8c32858 100644
--- a/exec-all.h
+++ b/exec-all.h
@@ -82,6 +82,7 @@ int cpu_restore_state_copy(struct TranslationBlock *tb,
                            void *puc);
 void cpu_resume_from_signal(CPUState *env1, void *puc);
 void cpu_exec_init(CPUState *env);
+void exec_init(void);
 int page_unprotect(target_ulong address, unsigned long pc, void *puc);
 void tb_invalidate_phys_page_range(target_phys_addr_t start, 
target_phys_addr_t end,
                                    int is_cpu_write_access);
diff --git a/exec.c b/exec.c
index 2fd0078..5384460 100644
--- a/exec.c
+++ b/exec.c
@@ -327,17 +327,20 @@ static void tlb_unprotect_code_phys(CPUState *env, 
ram_addr_t ram_addr,
                                     target_ulong vaddr);
 #endif
 
+/* Must be called once before any of attempts to call cpu_init */
+void exec_init(void)
+{
+    cpu_gen_init();
+    code_gen_ptr = code_gen_buffer;
+    page_init();
+    io_mem_init();
+}
+
 void cpu_exec_init(CPUState *env)
 {
     CPUState **penv;
     int cpu_index;
 
-    if (!code_gen_ptr) {
-        cpu_gen_init();
-        code_gen_ptr = code_gen_buffer;
-        page_init();
-        io_mem_init();
-    }
     env->next_cpu = NULL;
     penv = &first_cpu;
     cpu_index = 0;
diff --git a/vl.c b/vl.c
index 67712f0..5999b37 100644
--- a/vl.c
+++ b/vl.c
@@ -8576,6 +8576,7 @@ int main(int argc, char **argv)
         }
     }
 
+    exec_init();
     machine->init(ram_size, vga_ram_size, boot_devices, ds,
                   kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
 
-- 
1.5.5





reply via email to

[Prev in Thread] Current Thread [Next in Thread]