From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JweA6-0005WM-Cx for qemu-devel@nongnu.org; Thu, 15 May 2008 10:10:26 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JweA4-0005Uu-RB for qemu-devel@nongnu.org; Thu, 15 May 2008 10:10:25 -0400 Received: from [199.232.76.173] (port=37555 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JweA4-0005Uo-KL for qemu-devel@nongnu.org; Thu, 15 May 2008 10:10:24 -0400 Received: from mx1.redhat.com ([66.187.233.31]:35930) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JweA4-0003AY-1X for qemu-devel@nongnu.org; Thu, 15 May 2008 10:10:24 -0400 From: Glauber Costa Date: Thu, 15 May 2008 11:09:21 -0300 Message-Id: <12108605813076-git-send-email-gcosta@redhat.com> In-Reply-To: <12108605731805-git-send-email-gcosta@redhat.com> References: <12108605731805-git-send-email-gcosta@redhat.com> Subject: [Qemu-devel] [PATCH 01/13] [PATCH] make cpu_exec_init symmetric Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kvm-devel@lists.sourceforge.net 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