target-i386: Pass X86CPU to do_cpu_{init,sipi}()

Allows to use cpu_reset() in place of cpu_state_reset().

Signed-off-by: Andreas Färber <afaerber@suse.de>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
This commit is contained in:
Andreas Färber 2012-05-05 01:14:41 +02:00
parent bf494367fa
commit 232fc23bed
4 changed files with 16 additions and 11 deletions

View File

@ -287,11 +287,11 @@ int cpu_exec(CPUArchState *env)
#if defined(TARGET_I386) #if defined(TARGET_I386)
if (interrupt_request & CPU_INTERRUPT_INIT) { if (interrupt_request & CPU_INTERRUPT_INIT) {
svm_check_intercept(env, SVM_EXIT_INIT); svm_check_intercept(env, SVM_EXIT_INIT);
do_cpu_init(env); do_cpu_init(x86_env_get_cpu(env));
env->exception_index = EXCP_HALTED; env->exception_index = EXCP_HALTED;
cpu_loop_exit(env); cpu_loop_exit(env);
} else if (interrupt_request & CPU_INTERRUPT_SIPI) { } else if (interrupt_request & CPU_INTERRUPT_SIPI) {
do_cpu_sipi(env); do_cpu_sipi(x86_env_get_cpu(env));
} else if (env->hflags2 & HF2_GIF_MASK) { } else if (env->hflags2 & HF2_GIF_MASK) {
if ((interrupt_request & CPU_INTERRUPT_SMI) && if ((interrupt_request & CPU_INTERRUPT_SMI) &&
!(env->hflags & HF_SMM_MASK)) { !(env->hflags & HF_SMM_MASK)) {

View File

@ -1053,8 +1053,8 @@ static inline void cpu_get_tb_cpu_state(CPUX86State *env, target_ulong *pc,
(env->eflags & (IOPL_MASK | TF_MASK | RF_MASK | VM_MASK)); (env->eflags & (IOPL_MASK | TF_MASK | RF_MASK | VM_MASK));
} }
void do_cpu_init(CPUX86State *env); void do_cpu_init(X86CPU *cpu);
void do_cpu_sipi(CPUX86State *env); void do_cpu_sipi(X86CPU *cpu);
#define MCE_INJECT_BROADCAST 1 #define MCE_INJECT_BROADCAST 1
#define MCE_INJECT_UNCOND_AO 2 #define MCE_INJECT_UNCOND_AO 2

View File

@ -1187,27 +1187,30 @@ CPUX86State *cpu_x86_init(const char *cpu_model)
} }
#if !defined(CONFIG_USER_ONLY) #if !defined(CONFIG_USER_ONLY)
void do_cpu_init(CPUX86State *env) void do_cpu_init(X86CPU *cpu)
{ {
CPUX86State *env = &cpu->env;
int sipi = env->interrupt_request & CPU_INTERRUPT_SIPI; int sipi = env->interrupt_request & CPU_INTERRUPT_SIPI;
uint64_t pat = env->pat; uint64_t pat = env->pat;
cpu_state_reset(env); cpu_reset(CPU(cpu));
env->interrupt_request = sipi; env->interrupt_request = sipi;
env->pat = pat; env->pat = pat;
apic_init_reset(env->apic_state); apic_init_reset(env->apic_state);
env->halted = !cpu_is_bsp(env); env->halted = !cpu_is_bsp(env);
} }
void do_cpu_sipi(CPUX86State *env) void do_cpu_sipi(X86CPU *cpu)
{ {
CPUX86State *env = &cpu->env;
apic_sipi(env->apic_state); apic_sipi(env->apic_state);
} }
#else #else
void do_cpu_init(CPUX86State *env) void do_cpu_init(X86CPU *cpu)
{ {
} }
void do_cpu_sipi(CPUX86State *env) void do_cpu_sipi(X86CPU *cpu)
{ {
} }
#endif #endif

View File

@ -1698,6 +1698,8 @@ void kvm_arch_post_run(CPUX86State *env, struct kvm_run *run)
int kvm_arch_process_async_events(CPUX86State *env) int kvm_arch_process_async_events(CPUX86State *env)
{ {
X86CPU *cpu = x86_env_get_cpu(env);
if (env->interrupt_request & CPU_INTERRUPT_MCE) { if (env->interrupt_request & CPU_INTERRUPT_MCE) {
/* We must not raise CPU_INTERRUPT_MCE if it's not supported. */ /* We must not raise CPU_INTERRUPT_MCE if it's not supported. */
assert(env->mcg_cap); assert(env->mcg_cap);
@ -1732,11 +1734,11 @@ int kvm_arch_process_async_events(CPUX86State *env)
} }
if (env->interrupt_request & CPU_INTERRUPT_INIT) { if (env->interrupt_request & CPU_INTERRUPT_INIT) {
kvm_cpu_synchronize_state(env); kvm_cpu_synchronize_state(env);
do_cpu_init(env); do_cpu_init(cpu);
} }
if (env->interrupt_request & CPU_INTERRUPT_SIPI) { if (env->interrupt_request & CPU_INTERRUPT_SIPI) {
kvm_cpu_synchronize_state(env); kvm_cpu_synchronize_state(env);
do_cpu_sipi(env); do_cpu_sipi(cpu);
} }
if (env->interrupt_request & CPU_INTERRUPT_TPR) { if (env->interrupt_request & CPU_INTERRUPT_TPR) {
env->interrupt_request &= ~CPU_INTERRUPT_TPR; env->interrupt_request &= ~CPU_INTERRUPT_TPR;