From: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
To: qemu-devel@nongnu.org
Cc: qemu-s390x@nongnu.org, qemu-ppc@nongnu.org, qemu-arm@nongnu.org,
"Paolo Bonzini" <pbonzini@redhat.com>,
qemu-riscv@nongnu.org,
"Richard Henderson" <richard.henderson@linaro.org>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
"Halil Pasic" <pasic@linux.ibm.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"David Hildenbrand" <david@kernel.org>,
"Jason Herne" <jjherne@linux.ibm.com>,
"Cornelia Huck" <cohuck@redhat.com>,
"Eric Farman" <farman@linux.ibm.com>,
"Matthew Rosato" <mjrosato@linux.ibm.com>,
"Ilya Leoshkevich" <iii@linux.ibm.com>
Subject: [PATCH v3 04/21] target/s390x: Use S390CpuState for CPU state APIs
Date: Wed, 23 Sep 2026 19:10:58 +0200 [thread overview]
Message-ID: <20260923171116.31276-5-philmd@oss.qualcomm.com> (raw)
In-Reply-To: <20260923171116.31276-1-philmd@oss.qualcomm.com>
Use the QAPI S390CpuState enum for CPU state accessors instead
of uint8_t. Handle state checks with switch statements.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
target/s390x/cpu.h | 6 +++---
target/s390x/kvm/kvm_s390x.h | 2 +-
hw/intc/s390_flic.c | 7 +++++--
target/s390x/cpu-system.c | 18 ++++++++++++------
target/s390x/kvm/kvm.c | 2 +-
target/s390x/kvm/stubs.c | 2 +-
target/s390x/sigp.c | 6 +++++-
7 files changed, 28 insertions(+), 15 deletions(-)
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index 2d1dcc7045c..bf9f6ed1de2 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -847,13 +847,13 @@ void s390_do_cpu_set_diag318(CPUState *cs, run_on_cpu_data arg);
int s390_assign_subch_ioeventfd(EventNotifier *notifier, uint32_t sch_id,
int vq, bool assign);
#ifndef CONFIG_USER_ONLY
-void s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu);
+void s390_cpu_set_state(S390CpuState cpu_state, S390CPU *cpu);
#else
-static inline void s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu)
+static inline void s390_cpu_set_state(S390CpuState cpu_state, S390CPU *cpu)
{
}
#endif /* CONFIG_USER_ONLY */
-static inline uint8_t s390_cpu_get_state(const S390CPU *cpu)
+static inline S390CpuState s390_cpu_get_state(const S390CPU *cpu)
{
return cpu->env.cpu_state;
}
diff --git a/target/s390x/kvm/kvm_s390x.h b/target/s390x/kvm/kvm_s390x.h
index 3c4fa0489cf..b1ff66f04e3 100644
--- a/target/s390x/kvm/kvm_s390x.h
+++ b/target/s390x/kvm/kvm_s390x.h
@@ -22,7 +22,7 @@ int kvm_s390_mem_op(S390CPU *cpu, vaddr addr, uint8_t ar, void *hostbuf,
int kvm_s390_mem_op_pv(S390CPU *cpu, vaddr addr, void *hostbuf, int len,
bool is_write);
void kvm_s390_program_interrupt(S390CPU *cpu, uint16_t code);
-int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state);
+int kvm_s390_set_cpu_state(S390CPU *cpu, S390CpuState cpu_state);
void kvm_s390_vcpu_interrupt_pre_save(S390CPU *cpu);
int kvm_s390_vcpu_interrupt_post_load(S390CPU *cpu);
int kvm_s390_get_hpage(void);
diff --git a/hw/intc/s390_flic.c b/hw/intc/s390_flic.c
index 57fd4b2b81c..b5256b3ba88 100644
--- a/hw/intc/s390_flic.c
+++ b/hw/intc/s390_flic.c
@@ -193,8 +193,11 @@ static void qemu_s390_flic_notify(uint32_t type)
cpu_set_interrupt(cs, CPU_INTERRUPT_HARD);
/* ignore CPUs that are not sleeping */
- if (s390_cpu_get_state(cpu) != S390_CPU_STATE_OPERATING &&
- s390_cpu_get_state(cpu) != S390_CPU_STATE_LOAD) {
+ switch (s390_cpu_get_state(cpu)) {
+ case S390_CPU_STATE_LOAD:
+ case S390_CPU_STATE_OPERATING:
+ break;
+ default:
continue;
}
diff --git a/target/s390x/cpu-system.c b/target/s390x/cpu-system.c
index 52561fffa3a..fffac09f241 100644
--- a/target/s390x/cpu-system.c
+++ b/target/s390x/cpu-system.c
@@ -44,8 +44,11 @@ bool s390_cpu_has_work(CPUState *cs)
S390CPU *cpu = S390_CPU(cs);
/* STOPPED cpus can never wake up */
- if (s390_cpu_get_state(cpu) != S390_CPU_STATE_LOAD &&
- s390_cpu_get_state(cpu) != S390_CPU_STATE_OPERATING) {
+ switch (s390_cpu_get_state(cpu)) {
+ case S390_CPU_STATE_LOAD:
+ case S390_CPU_STATE_OPERATING:
+ break;
+ default:
return false;
}
@@ -202,12 +205,15 @@ unsigned s390_count_running_cpus(void)
int nr_running = 0;
CPU_FOREACH(cpu) {
- uint8_t state = S390_CPU(cpu)->env.cpu_state;
- if (state == S390_CPU_STATE_OPERATING ||
- state == S390_CPU_STATE_LOAD) {
+ switch (s390_cpu_get_state(S390_CPU(cpu))) {
+ case S390_CPU_STATE_LOAD:
+ case S390_CPU_STATE_OPERATING:
if (!disabled_wait(cpu)) {
nr_running++;
}
+ break;
+ default:
+ break;
}
}
@@ -236,7 +242,7 @@ void s390_cpu_unhalt(S390CPU *cpu)
}
}
-void s390_cpu_set_state(uint8_t cpu_state, S390CPU *cpu)
+void s390_cpu_set_state(S390CpuState cpu_state, S390CPU *cpu)
{
trace_cpu_set_state(CPU(cpu)->cpu_index, cpu_state);
diff --git a/target/s390x/kvm/kvm.c b/target/s390x/kvm/kvm.c
index 6622886032e..dc67e848864 100644
--- a/target/s390x/kvm/kvm.c
+++ b/target/s390x/kvm/kvm.c
@@ -2007,7 +2007,7 @@ int kvm_s390_get_ri(void)
return cap_ri;
}
-int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state)
+int kvm_s390_set_cpu_state(S390CPU *cpu, S390CpuState cpu_state)
{
struct kvm_mp_state mp_state = {};
int ret;
diff --git a/target/s390x/kvm/stubs.c b/target/s390x/kvm/stubs.c
index ebf3c83994d..c5ec7d3f1d3 100644
--- a/target/s390x/kvm/stubs.c
+++ b/target/s390x/kvm/stubs.c
@@ -128,7 +128,7 @@ int kvm_s390_mem_op_pv(S390CPU *cpu, vaddr addr, void *hostbuf, int len,
g_assert_not_reached();
}
-int kvm_s390_set_cpu_state(S390CPU *cpu, uint8_t cpu_state)
+int kvm_s390_set_cpu_state(S390CPU *cpu, S390CpuState cpu_state)
{
g_assert_not_reached();
}
diff --git a/target/s390x/sigp.c b/target/s390x/sigp.c
index 1801b8caa6e..09004e98a21 100644
--- a/target/s390x/sigp.c
+++ b/target/s390x/sigp.c
@@ -39,7 +39,7 @@ static void set_sigp_status(SigpInfo *si, uint64_t status)
static void sigp_sense(S390CPU *dst_cpu, SigpInfo *si)
{
- uint8_t state = s390_cpu_get_state(dst_cpu);
+ S390CpuState state = s390_cpu_get_state(dst_cpu);
bool ext_call = dst_cpu->env.pending_int & INTERRUPT_EXTERNAL_CALL;
uint64_t status = 0;
@@ -221,6 +221,8 @@ static void sigp_stop_and_store_status(CPUState *cs, run_on_cpu_data arg)
cpu_synchronize_state(cs);
s390_store_status(cpu, S390_STORE_STATUS_DEF_ADDR, true);
break;
+ default:
+ break;
}
si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;
}
@@ -362,6 +364,8 @@ static void sigp_restart(CPUState *cs, run_on_cpu_data arg)
case S390_CPU_STATE_OPERATING:
cpu_inject_restart(cpu);
break;
+ default:
+ break;
}
si->cc = SIGP_CC_ORDER_CODE_ACCEPTED;
}
--
2.53.0
next prev parent reply other threads:[~2026-09-23 17:14 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 17:10 [PATCH v3 00/21] accel/tcg: Make halt-to-exec transition explicit and remove cpu_exec_halt Philippe Mathieu-Daudé
2026-09-23 17:10 ` [PATCH v3 01/21] system: Document has_work() synchronization requirements Philippe Mathieu-Daudé
2026-09-23 17:10 ` [PATCH v3 02/21] target/s390x: Use s390_cpu_get_state() consistently Philippe Mathieu-Daudé
2026-09-23 17:10 ` [PATCH v3 03/21] target/s390x: Make s390_cpu_set_state() return void Philippe Mathieu-Daudé
2026-09-23 17:10 ` Philippe Mathieu-Daudé [this message]
2026-09-23 17:32 ` [PATCH v3 04/21] target/s390x: Use S390CpuState for CPU state APIs Eric Farman
2026-09-23 17:10 ` [PATCH v3 05/21] target/s390x: Access S390CpuState atomically Philippe Mathieu-Daudé
2026-09-23 17:11 ` [PATCH v3 06/21] target/arm: Un-inline arm_set_cpu_power_state() Philippe Mathieu-Daudé
2026-09-23 17:11 ` [PATCH v3 07/21] target/arm: Kick vCPU after updating PSCI power state Philippe Mathieu-Daudé
2026-09-23 17:11 ` [PATCH v3 08/21] target/arm: Access PSCI state atomically Philippe Mathieu-Daudé
2026-09-23 17:11 ` [PATCH v3 09/21] target/arm: Access halt " Philippe Mathieu-Daudé
2026-09-23 17:29 ` Richard Henderson
2026-09-23 17:11 ` [PATCH v3 10/21] target/riscv: Skip empty MIP updates Philippe Mathieu-Daudé
2026-09-23 19:02 ` Richard Henderson
2026-09-23 17:11 ` [PATCH v3 11/21] target/riscv: Add riscv_cpu_get_mip() Philippe Mathieu-Daudé
2026-09-23 19:04 ` Richard Henderson
2026-09-23 17:11 ` [PATCH v3 12/21] target/riscv: Access MIP atomically Philippe Mathieu-Daudé
2026-09-23 19:05 ` Richard Henderson
2026-09-23 17:11 ` [PATCH v3 13/21] accel/tcg: Refactor poll-while-halted flow in cpu_exec() Philippe Mathieu-Daudé
2026-09-23 17:11 ` [PATCH v3 14/21] accel/tcg: Introduce poll_during_halt() and leaving_halt() Philippe Mathieu-Daudé
2026-09-23 17:11 ` [PATCH v3 15/21] target/arm: Split leaving-halt handling from arm_cpu_exec_halt() Philippe Mathieu-Daudé
2026-09-23 17:11 ` [PATCH v3 16/21] target/arm: Convert cpu_exec_halt() to leaving_halt() Philippe Mathieu-Daudé
2026-09-23 17:11 ` [PATCH v3 17/21] target/i386: Use an acquire load for interrupt_request Philippe Mathieu-Daudé
2026-09-23 19:18 ` Richard Henderson
2026-09-28 6:26 ` Zhao Liu
2026-09-23 17:11 ` [PATCH v3 18/21] target/i386: Split APIC polling from x86_cpu_exec_halt() Philippe Mathieu-Daudé
2026-09-23 17:11 ` [PATCH v3 19/21] target/i386: Split leaving-halt handling " Philippe Mathieu-Daudé
2026-09-23 17:11 ` [PATCH v3 20/21] target/i386: Use generic halt transition handlers Philippe Mathieu-Daudé
2026-09-23 17:11 ` [PATCH v3 21/21] accel/tcg: Remove the redundant cpu_exec_halt() hook Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260923171116.31276-5-philmd@oss.qualcomm.com \
--to=philmd@oss.qualcomm.com \
--cc=borntraeger@linux.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@kernel.org \
--cc=farman@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=jjherne@linux.ibm.com \
--cc=mjrosato@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.