@@ -706,7 +706,7 @@ static void ppce500_cpu_reset_sec(void *opaque)
/* Secondary CPU starts in halted state for now. Needs to change when
implementing non-kernel boot. */
- cs->halted = 1;
+ cpu_halted_set(cs, 1);
cs->exception_index = EXCP_HLT;
}
@@ -720,7 +720,7 @@ static void ppce500_cpu_reset(void *opaque)
cpu_reset(cs);
/* Set initial guest state. */
- cs->halted = 0;
+ cpu_halted_set(cs, 0);
env->gpr[1] = (16 * MiB) - 8;
env->gpr[3] = bi->dt_base;
env->gpr[4] = 0;
@@ -149,7 +149,7 @@ static void ppc6xx_set_irq(void *opaque, int pin, int level)
/* XXX: Note that the only way to restart the CPU is to reset it */
if (level) {
LOG_IRQ("%s: stop the CPU\n", __func__);
- cs->halted = 1;
+ cpu_halted_set(cs, 1);
}
break;
case PPC6xx_INPUT_HRESET:
@@ -228,10 +228,10 @@ static void ppc970_set_irq(void *opaque, int pin, int level)
/* XXX: TODO: relay the signal to CKSTP_OUT pin */
if (level) {
LOG_IRQ("%s: stop the CPU\n", __func__);
- cs->halted = 1;
+ cpu_halted_set(cs, 1);
} else {
LOG_IRQ("%s: restart the CPU\n", __func__);
- cs->halted = 0;
+ cpu_halted_set(cs, 0);
qemu_cpu_kick(cs);
}
break;
@@ -445,10 +445,10 @@ static void ppc40x_set_irq(void *opaque, int pin, int level)
/* Level sensitive - active low */
if (level) {
LOG_IRQ("%s: stop the CPU\n", __func__);
- cs->halted = 1;
+ cpu_halted_set(cs, 1);
} else {
LOG_IRQ("%s: restart the CPU\n", __func__);
- cs->halted = 0;
+ cpu_halted_set(cs, 0);
qemu_cpu_kick(cs);
}
break;
@@ -107,9 +107,11 @@ static void spin_kick(CPUState *cs, run_on_cpu_data data)
map_start = ldq_p(&curspin->addr) & ~(map_size - 1);
mmubooke_create_initial_mapping(env, 0, map_start, map_size);
- cs->halted = 0;
- cs->exception_index = -1;
+ cpu_mutex_lock(cs);
+ cpu_halted_set(cs, 0);
cs->stopped = false;
+ cpu_mutex_unlock(cs);
+ cs->exception_index = -1;
qemu_cpu_kick(cs);
}
@@ -39,7 +39,7 @@ static void spapr_reset_vcpu(PowerPCCPU *cpu)
/* All CPUs start halted. CPU0 is unhalted from the machine level
* reset code and the rest are explicitly started up by the guest
* using an RTAS call */
- cs->halted = 1;
+ cpu_halted_set(cs, 1);
env->spr[SPR_HIOR] = 0;
@@ -88,7 +88,7 @@ void spapr_cpu_set_entry_state(PowerPCCPU *cpu, target_ulong nip,
env->gpr[3] = r3;
env->gpr[4] = r4;
kvmppc_set_reg_ppc_online(cpu, 1);
- CPU(cpu)->halted = 0;
+ cpu_halted_set(CPU(cpu), 0);
/* Enable Power-saving mode Exit Cause exceptions */
ppc_store_lpcr(cpu, env->spr[SPR_LPCR] | pcc->lpcr_pm);
}
@@ -1058,17 +1058,19 @@ static target_ulong h_cede(PowerPCCPU *cpu, SpaprMachineState *spapr,
env->msr |= (1ULL << MSR_EE);
hreg_compute_hflags(env);
+ cpu_mutex_lock(cs);
if (spapr_cpu->prod) {
spapr_cpu->prod = false;
+ cpu_mutex_unlock(cs);
return H_SUCCESS;
}
if (!cpu_has_work(cs)) {
- cs->halted = 1;
+ cpu_halted_set(cs, 1);
cs->exception_index = EXCP_HLT;
cs->exit_request = 1;
}
-
+ cpu_mutex_unlock(cs);
return H_SUCCESS;
}
@@ -1085,7 +1087,7 @@ static target_ulong h_confer_self(PowerPCCPU *cpu)
spapr_cpu->prod = false;
return H_SUCCESS;
}
- cs->halted = 1;
+ cpu_halted_set(cs, 1);
cs->exception_index = EXCP_HALTED;
cs->exit_request = 1;
@@ -1116,7 +1118,7 @@ static target_ulong h_join(PowerPCCPU *cpu, SpaprMachineState *spapr,
}
/* Don't have a way to indicate joined, so use halted && MSR[EE]=0 */
- if (!cs->halted || (e->msr & (1ULL << MSR_EE))) {
+ if (!cpu_halted(cs) || (e->msr & (1ULL << MSR_EE))) {
last_unjoined = false;
break;
}
@@ -1199,7 +1201,7 @@ static target_ulong h_prod(PowerPCCPU *cpu, SpaprMachineState *spapr,
spapr_cpu = spapr_cpu_state(tcpu);
spapr_cpu->prod = true;
- cs->halted = 0;
+ cpu_halted_set(cs, 0);
qemu_cpu_kick(cs);
return H_SUCCESS;
@@ -1685,7 +1687,7 @@ target_ulong do_client_architecture_support(PowerPCCPU *cpu,
if (cs == CPU(cpu)) {
continue;
}
- if (!cs->halted) {
+ if (!cpu_halted(cs)) {
warn_report("guest has multiple active vCPUs at CAS, which is not allowed");
return H_MULTI_THREADS_ACTIVE;
}
@@ -111,7 +111,7 @@ static void rtas_query_cpu_stopped_state(PowerPCCPU *cpu_,
id = rtas_ld(args, 0);
cpu = spapr_find_cpu(id);
if (cpu != NULL) {
- if (CPU(cpu)->halted) {
+ if (cpu_halted(CPU(cpu))) {
rtas_st(rets, 1, 0);
} else {
rtas_st(rets, 1, 2);
@@ -155,7 +155,7 @@ static void rtas_start_cpu(PowerPCCPU *callcpu, SpaprMachineState *spapr,
env = &newcpu->env;
pcc = POWERPC_CPU_GET_CLASS(newcpu);
- if (!CPU(newcpu)->halted) {
+ if (!cpu_halted(CPU(newcpu))) {
rtas_st(rets, 0, RTAS_OUT_HW_ERROR);
return;
}
@@ -213,7 +213,7 @@ static void rtas_stop_self(PowerPCCPU *cpu, SpaprMachineState *spapr,
*/
ppc_store_lpcr(cpu, env->spr[SPR_LPCR] & ~pcc->lpcr_pm);
env->spr[SPR_PSSCR] |= PSSCR_EC;
- cs->halted = 1;
+ cpu_halted_set(cs, 1);
kvmppc_set_reg_ppc_online(cpu, 0);
qemu_cpu_kick(cs);
}
@@ -238,7 +238,7 @@ static void rtas_ibm_suspend_me(PowerPCCPU *cpu, SpaprMachineState *spapr,
}
/* See h_join */
- if (!cs->halted || (e->msr & (1ULL << MSR_EE))) {
+ if (!cpu_halted(cs) || (e->msr & (1ULL << MSR_EE))) {
rtas_st(rets, 0, H_MULTI_THREADS_ACTIVE);
return;
}
@@ -293,7 +293,7 @@ static inline void powerpc_excp(PowerPCCPU *cpu, int excp_model, int excp)
qemu_log("Machine check while not allowed. "
"Entering checkstop state\n");
}
- cs->halted = 1;
+ cpu_halted_set(cs, 1);
cpu_interrupt_exittb(cs);
}
if (env->msr_mask & MSR_HVB) {
@@ -1095,7 +1095,7 @@ void helper_pminsn(CPUPPCState *env, powerpc_pm_insn_t insn)
CPUState *cs;
cs = env_cpu(env);
- cs->halted = 1;
+ cpu_halted_set(cs, 1);
/*
* The architecture specifies that HDEC interrupts are discarded
@@ -168,7 +168,7 @@ static inline int hreg_store_msr(CPUPPCState *env, target_ulong value,
#if !defined(CONFIG_USER_ONLY)
if (unlikely(msr_pow == 1)) {
if (!env->pending_interrupts && (*env->check_pow)(env)) {
- cs->halted = 1;
+ cpu_halted_set(cs, 1);
excp = EXCP_HALTED;
}
}
@@ -1342,7 +1342,7 @@ MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run)
int kvm_arch_process_async_events(CPUState *cs)
{
- return cs->halted;
+ return cpu_halted(cs);
}
static int kvmppc_handle_halt(PowerPCCPU *cpu)
@@ -1351,7 +1351,7 @@ static int kvmppc_handle_halt(PowerPCCPU *cpu)
CPUPPCState *env = &cpu->env;
if (!(cs->interrupt_request & CPU_INTERRUPT_HARD) && (msr_ee)) {
- cs->halted = 1;
+ cpu_halted_set(cs, 1);
cs->exception_index = EXCP_HLT;
}
@@ -8539,7 +8539,7 @@ static bool cpu_has_work_POWER7(CPUState *cs)
PowerPCCPU *cpu = POWERPC_CPU(cs);
CPUPPCState *env = &cpu->env;
- if (cs->halted) {
+ if (cpu_halted(cs)) {
if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
return false;
}
@@ -8701,7 +8701,7 @@ static bool cpu_has_work_POWER8(CPUState *cs)
PowerPCCPU *cpu = POWERPC_CPU(cs);
CPUPPCState *env = &cpu->env;
- if (cs->halted) {
+ if (cpu_halted(cs)) {
if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
return false;
}
@@ -8901,7 +8901,7 @@ static bool cpu_has_work_POWER9(CPUState *cs)
PowerPCCPU *cpu = POWERPC_CPU(cs);
CPUPPCState *env = &cpu->env;
- if (cs->halted) {
+ if (cpu_halted(cs)) {
uint64_t psscr = env->spr[SPR_PSSCR];
if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {
@@ -9117,7 +9117,7 @@ static bool cpu_has_work_POWER10(CPUState *cs)
PowerPCCPU *cpu = POWERPC_CPU(cs);
CPUPPCState *env = &cpu->env;
- if (cs->halted) {
+ if (cpu_halted(cs)) {
uint64_t psscr = env->spr[SPR_PSSCR];
if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) {