From 130a03855098a4057c227bc658c0688f8665b71f Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Tue, 19 Jun 2012 14:46:29 +0200 Subject: [PATCH 1/4] target-i386: drop usage of prev_debug_excp_handler Chains of exception handlers are currently unused feature, drop it for now so as not to expose prev_debug_excp_handler at global scope when moving tcg initialization into target-i386/cpu.c Later we probably could re-invent better interface for this. Signed-off-by: Igor Mammedov --- target-i386/helper.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/target-i386/helper.c b/target-i386/helper.c index 2cc80977e8..b9384f6f1b 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -941,8 +941,6 @@ int check_hw_breakpoints(CPUX86State *env, int force_dr6_update) return hit_enabled; } -static CPUDebugExcpHandler *prev_debug_excp_handler; - static void breakpoint_handler(CPUX86State *env) { CPUBreakpoint *bp; @@ -965,8 +963,6 @@ static void breakpoint_handler(CPUX86State *env) break; } } - if (prev_debug_excp_handler) - prev_debug_excp_handler(env); } typedef struct MCEInjectionParams { @@ -1166,8 +1162,7 @@ X86CPU *cpu_x86_init(const char *cpu_model) inited = 1; optimize_flags_init(); #ifndef CONFIG_USER_ONLY - prev_debug_excp_handler = - cpu_set_debug_excp_handler(breakpoint_handler); + cpu_set_debug_excp_handler(breakpoint_handler); #endif } if (cpu_x86_register(cpu, cpu_model) < 0) { From eeec69dc06a0b87a578f4935bbd699d03bc4f359 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Thu, 21 Jun 2012 17:57:19 +0200 Subject: [PATCH 2/4] target-xtensa: drop usage of prev_debug_excp_handler Chains of exception handlers are currently unused feature. Dropping it to be consistent with target-i386 but it may simplify qom-ifying CPU in future like for target-i386. Signed-off-by: Igor Mammedov --- target-xtensa/helper.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/target-xtensa/helper.c b/target-xtensa/helper.c index 044ce18364..d5bb171fcd 100644 --- a/target-xtensa/helper.c +++ b/target-xtensa/helper.c @@ -54,8 +54,6 @@ static uint32_t check_hw_breakpoints(CPUXtensaState *env) return 0; } -static CPUDebugExcpHandler *prev_debug_excp_handler; - static void breakpoint_handler(CPUXtensaState *env) { if (env->watchpoint_hit) { @@ -70,9 +68,6 @@ static void breakpoint_handler(CPUXtensaState *env) cpu_resume_from_signal(env, NULL); } } - if (prev_debug_excp_handler) { - prev_debug_excp_handler(env); - } } XtensaCPU *cpu_xtensa_init(const char *cpu_model) @@ -105,8 +100,7 @@ XtensaCPU *cpu_xtensa_init(const char *cpu_model) if (!debug_handler_inited && tcg_enabled()) { debug_handler_inited = 1; - prev_debug_excp_handler = - cpu_set_debug_excp_handler(breakpoint_handler); + cpu_set_debug_excp_handler(breakpoint_handler); } xtensa_irq_init(env); From 84e3b6025930cd474d3ca9f1885801dbc100cecb Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Thu, 21 Jun 2012 18:29:38 +0200 Subject: [PATCH 3/4] cleanup cpu_set_debug_excp_handler There are no users left for previous exception handler returned from cpu_set_debug_excp_handler. It should simplify code a little. Signed-off-by: Igor Mammedov --- cpu-exec.c | 5 +---- exec-all.h | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index 624c409f7b..24607fbed5 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -156,12 +156,9 @@ static inline TranslationBlock *tb_find_fast(CPUArchState *env) static CPUDebugExcpHandler *debug_excp_handler; -CPUDebugExcpHandler *cpu_set_debug_excp_handler(CPUDebugExcpHandler *handler) +void cpu_set_debug_excp_handler(CPUDebugExcpHandler *handler) { - CPUDebugExcpHandler *old_handler = debug_excp_handler; - debug_excp_handler = handler; - return old_handler; } static void cpu_handle_debug_exception(CPUArchState *env) diff --git a/exec-all.h b/exec-all.h index 9bda7f7354..c5ec8e1158 100644 --- a/exec-all.h +++ b/exec-all.h @@ -357,7 +357,7 @@ tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr); typedef void (CPUDebugExcpHandler)(CPUArchState *env); -CPUDebugExcpHandler *cpu_set_debug_excp_handler(CPUDebugExcpHandler *handler); +void cpu_set_debug_excp_handler(CPUDebugExcpHandler *handler); /* vl.c */ extern int singlestep; From d65e9815b1ff90dff35e4e679bfb231c24e408f7 Mon Sep 17 00:00:00 2001 From: Igor Mammedov Date: Tue, 19 Jun 2012 15:39:46 +0200 Subject: [PATCH 4/4] target-i386: move tcg initialization into x86_cpu_initfn() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In order to make cpu object not depended on external ad-hoc initialization routines, move tcg initialization from cpu_x86_init inside cpu object "x86_cpu_initfn()". Signed-off-by: Igor Mammedov Reviewed-by: Andreas Färber --- target-i386/cpu.c | 10 ++++++++++ target-i386/cpu.h | 1 + target-i386/helper.c | 11 +---------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/target-i386/cpu.c b/target-i386/cpu.c index fdd95be8cf..445274c97d 100644 --- a/target-i386/cpu.c +++ b/target-i386/cpu.c @@ -1716,6 +1716,7 @@ static void x86_cpu_initfn(Object *obj) { X86CPU *cpu = X86_CPU(obj); CPUX86State *env = &cpu->env; + static int inited; cpu_exec_init(env); @@ -1745,6 +1746,15 @@ static void x86_cpu_initfn(Object *obj) x86_cpuid_set_tsc_freq, NULL, NULL, NULL); env->cpuid_apic_id = env->cpu_index; + + /* init various static tables used in TCG mode */ + if (tcg_enabled() && !inited) { + inited = 1; + optimize_flags_init(); +#ifndef CONFIG_USER_ONLY + cpu_set_debug_excp_handler(breakpoint_handler); +#endif + } } static void x86_cpu_common_class_init(ObjectClass *oc, void *data) diff --git a/target-i386/cpu.h b/target-i386/cpu.h index bcf663eeb5..80dcb49391 100644 --- a/target-i386/cpu.h +++ b/target-i386/cpu.h @@ -933,6 +933,7 @@ static inline int hw_breakpoint_len(unsigned long dr7, int index) void hw_breakpoint_insert(CPUX86State *env, int index); void hw_breakpoint_remove(CPUX86State *env, int index); int check_hw_breakpoints(CPUX86State *env, int force_dr6_update); +void breakpoint_handler(CPUX86State *env); /* will be suppressed */ void cpu_x86_update_cr0(CPUX86State *env, uint32_t new_cr0); diff --git a/target-i386/helper.c b/target-i386/helper.c index b9384f6f1b..c52ec130e5 100644 --- a/target-i386/helper.c +++ b/target-i386/helper.c @@ -941,7 +941,7 @@ int check_hw_breakpoints(CPUX86State *env, int force_dr6_update) return hit_enabled; } -static void breakpoint_handler(CPUX86State *env) +void breakpoint_handler(CPUX86State *env) { CPUBreakpoint *bp; @@ -1151,20 +1151,11 @@ X86CPU *cpu_x86_init(const char *cpu_model) { X86CPU *cpu; CPUX86State *env; - static int inited; cpu = X86_CPU(object_new(TYPE_X86_CPU)); env = &cpu->env; env->cpu_model_str = cpu_model; - /* init various static tables used in TCG mode */ - if (tcg_enabled() && !inited) { - inited = 1; - optimize_flags_init(); -#ifndef CONFIG_USER_ONLY - cpu_set_debug_excp_handler(breakpoint_handler); -#endif - } if (cpu_x86_register(cpu, cpu_model) < 0) { object_delete(OBJECT(cpu)); return NULL;