CPUXtensa::runstall and CPUState::start_powered_off are
semantically equivalent. Replace the target specific field
by the generic one.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/xtensa/cpu.h | 1 -
target/xtensa/cpu.c | 8 ++++++--
target/xtensa/helper.c | 6 ++++--
3 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h
index 74122ebe15c..43b8cabdcd3 100644
--- a/target/xtensa/cpu.h
+++ b/target/xtensa/cpu.h
@@ -529,7 +529,6 @@ struct CPUArchState {
xtensa_tlb_entry dtlb[10][MAX_TLB_WAY_SIZE];
xtensa_mpu_entry mpu_fg[MAX_MPU_FOREGROUND_SEGMENTS];
unsigned autorefill_idx;
- bool runstall;
AddressSpace *address_space_er;
MemoryRegion *system_er;
int pending_irq_level; /* level of last raised IRQ */
diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c
index ea9b6df3aa2..65f0e778775 100644
--- a/target/xtensa/cpu.c
+++ b/target/xtensa/cpu.c
@@ -143,7 +143,7 @@ static bool xtensa_cpu_has_work(CPUState *cs)
{
CPUXtensaState *env = cpu_env(cs);
- return !env->runstall && env->pending_irq_level;
+ return !cs->start_powered_off && env->pending_irq_level;
}
#endif /* !CONFIG_USER_ONLY */
@@ -204,7 +204,11 @@ static void xtensa_cpu_reset_hold(Object *obj, ResetType type)
#ifndef CONFIG_USER_ONLY
reset_mmu(env);
- cs->halted = env->runstall;
+ if (cs->start_powered_off) {
+ cs->halted = 1;
+ } else {
+ cs->halted = 0;
+ }
#endif
/* For inf * 0 + NaN, return the input NaN */
set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status);
diff --git a/target/xtensa/helper.c b/target/xtensa/helper.c
index 2d93b45036d..a64df1cadac 100644
--- a/target/xtensa/helper.c
+++ b/target/xtensa/helper.c
@@ -311,11 +311,13 @@ void xtensa_runstall(CPUXtensaState *env, bool runstall)
{
CPUState *cpu = env_cpu(env);
- env->runstall = runstall;
- cpu->halted = runstall;
if (runstall) {
+ cpu->start_powered_off = true;
+ cpu->halted = 1;
cpu_interrupt(cpu, CPU_INTERRUPT_HALT);
} else {
+ cpu->start_powered_off = false;
+ cpu->halted = 0;
qemu_cpu_kick(cpu);
}
}
--
2.51.0
On 9/24/25 10:40, Philippe Mathieu-Daudé wrote: > CPUXtensa::runstall and CPUState::start_powered_off are > semantically equivalent. Replace the target specific field > by the generic one. > > Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> > --- > target/xtensa/cpu.h | 1 - > target/xtensa/cpu.c | 8 ++++++-- > target/xtensa/helper.c | 6 ++++-- > 3 files changed, 10 insertions(+), 5 deletions(-) > > diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h > index 74122ebe15c..43b8cabdcd3 100644 > --- a/target/xtensa/cpu.h > +++ b/target/xtensa/cpu.h > @@ -529,7 +529,6 @@ struct CPUArchState { > xtensa_tlb_entry dtlb[10][MAX_TLB_WAY_SIZE]; > xtensa_mpu_entry mpu_fg[MAX_MPU_FOREGROUND_SEGMENTS]; > unsigned autorefill_idx; > - bool runstall; > AddressSpace *address_space_er; > MemoryRegion *system_er; > int pending_irq_level; /* level of last raised IRQ */ > diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c > index ea9b6df3aa2..65f0e778775 100644 > --- a/target/xtensa/cpu.c > +++ b/target/xtensa/cpu.c > @@ -143,7 +143,7 @@ static bool xtensa_cpu_has_work(CPUState *cs) > { > CPUXtensaState *env = cpu_env(cs); > > - return !env->runstall && env->pending_irq_level; > + return !cs->start_powered_off && env->pending_irq_level; > } > #endif /* !CONFIG_USER_ONLY */ > > @@ -204,7 +204,11 @@ static void xtensa_cpu_reset_hold(Object *obj, ResetType type) > > #ifndef CONFIG_USER_ONLY > reset_mmu(env); > - cs->halted = env->runstall; > + if (cs->start_powered_off) { > + cs->halted = 1; > + } else { > + cs->halted = 0; > + } This would of course be cs->halted = cs->start_powered_off; though I'm a bit surprised that such generic fields must be handled in target-specific code. > #endif > /* For inf * 0 + NaN, return the input NaN */ > set_float_infzeronan_rule(float_infzeronan_dnan_never, &env->fp_status); > diff --git a/target/xtensa/helper.c b/target/xtensa/helper.c > index 2d93b45036d..a64df1cadac 100644 > --- a/target/xtensa/helper.c > +++ b/target/xtensa/helper.c > @@ -311,11 +311,13 @@ void xtensa_runstall(CPUXtensaState *env, bool runstall) > { > CPUState *cpu = env_cpu(env); > > - env->runstall = runstall; > - cpu->halted = runstall; > if (runstall) { > + cpu->start_powered_off = true; > + cpu->halted = 1; > cpu_interrupt(cpu, CPU_INTERRUPT_HALT); > } else { > + cpu->start_powered_off = false; > + cpu->halted = 0; > qemu_cpu_kick(cpu); > } > } Why this change? r~
On 9/24/25 10:50, Richard Henderson wrote: >> - cs->halted = env->runstall; >> + if (cs->start_powered_off) { >> + cs->halted = 1; >> + } else { >> + cs->halted = 0; >> + } > > This would of course be > > cs->halted = cs->start_powered_off; > > though I'm a bit surprised that such generic fields must > be handled in target-specific code. Indeed, this is done by cpu_common_reset_hold. r~
© 2016 - 2025 Red Hat, Inc.