From a16bcbdac02eb64a711cdc59385d1428654d13ef Mon Sep 17 00:00:00 2001 From: Yang Zhong Date: Sat, 3 Mar 2018 21:55:40 -0500 Subject: [PATCH] target/i386: add the tcg_enabled() in target/i386/ Add the tcg_enabled() where the x86 target needs to disable TCG-specific code. Backports commit 79c664f62d75cfba89a5bbe998622c8d5fdf833b from qemu --- qemu/target/i386/cpu.c | 4 +++- qemu/target/i386/cpu.h | 8 +++++++- qemu/target/i386/helper.c | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/qemu/target/i386/cpu.c b/qemu/target/i386/cpu.c index ac97854e..024a9222 100644 --- a/qemu/target/i386/cpu.c +++ b/qemu/target/i386/cpu.c @@ -3489,8 +3489,10 @@ static void x86_cpu_common_class_init(struct uc_struct *uc, ObjectClass *oc, voi cc->class_by_name = x86_cpu_class_by_name; cc->parse_features = x86_cpu_parse_featurestr; cc->has_work = x86_cpu_has_work; +#ifdef CONFIG_TCG cc->do_interrupt = x86_cpu_do_interrupt; cc->cpu_exec_interrupt = x86_cpu_exec_interrupt; +#endif cc->dump_state = x86_cpu_dump_state; cc->set_pc = x86_cpu_set_pc; cc->synchronize_from_tb = x86_cpu_synchronize_from_tb; @@ -3503,7 +3505,7 @@ static void x86_cpu_common_class_init(struct uc_struct *uc, ObjectClass *oc, voi cc->get_memory_mapping = x86_cpu_get_memory_mapping; cc->get_phys_page_debug = x86_cpu_get_phys_page_debug; #endif -#ifndef CONFIG_USER_ONLY +#if defined(CONFIG_TCG) && !defined(CONFIG_USER_ONLY) cc->debug_excp_handler = breakpoint_handler; #endif cc->cpu_exec_enter = x86_cpu_exec_enter; diff --git a/qemu/target/i386/cpu.h b/qemu/target/i386/cpu.h index adb5af72..9fdf0eb1 100644 --- a/qemu/target/i386/cpu.h +++ b/qemu/target/i386/cpu.h @@ -52,7 +52,9 @@ #include "exec/cpu-defs.h" +#ifdef CONFIG_TCG #include "fpu/softfloat.h" +#endif #define R_EAX 0 #define R_ECX 1 @@ -1570,7 +1572,11 @@ uint32_t cpu_cc_compute_all(CPUX86State *env1, int op); static inline uint32_t cpu_compute_eflags(CPUX86State *env) { - return (env->eflags0 & ~(CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C | DF_MASK)) | cpu_cc_compute_all(env, CC_OP) | (env->df & DF_MASK); + uint32_t eflags = env->eflags; + if (tcg_enabled(env->uc)) { + eflags |= cpu_cc_compute_all(env, CC_OP) | (env->df & DF_MASK); + } + return eflags; } /* NOTE: the translator must set DisasContext.cc_op to CC_OP_EFLAGS diff --git a/qemu/target/i386/helper.c b/qemu/target/i386/helper.c index 940cafdc..0bdc173b 100644 --- a/qemu/target/i386/helper.c +++ b/qemu/target/i386/helper.c @@ -1013,9 +1013,11 @@ void cpu_report_tpr_access(CPUX86State *env, TPRAccess access) X86CPU *cpu = x86_env_get_cpu(env); CPUState *cs = CPU(cpu); + if (tcg_enabled(env->uc)) { cpu_restore_state(cs, cs->mem_io_pc); apic_handle_tpr_access_report(cpu->apic_state, env->eip, access); + } } #endif /* !CONFIG_USER_ONLY */