misc_helper.c won't be compiled with --disable-tcg anymore, but we
still need the program_interrupt() function in that case. Move it
to interrupt.c instead, and refactor it a little bit to re-use the
code from trigger_pgm_exception() here, too.
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
target/s390x/cpu.h | 5 +----
target/s390x/helper.c | 10 ----------
target/s390x/interrupt.c | 36 ++++++++++++++++++++++++++++++++++++
target/s390x/misc_helper.c | 26 --------------------------
4 files changed, 37 insertions(+), 40 deletions(-)
diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h
index 7732d01..aec9aac 100644
--- a/target/s390x/cpu.h
+++ b/target/s390x/cpu.h
@@ -474,10 +474,6 @@ static inline bool get_per_in_range(CPUS390XState *env, uint64_t addr)
}
}
-#ifndef CONFIG_USER_ONLY
-void trigger_pgm_exception(CPUS390XState *env, uint32_t code, uint32_t ilen);
-#endif
-
S390CPU *cpu_s390x_init(const char *cpu_model);
S390CPU *s390x_new_cpu(const char *cpu_model, int64_t id, Error **errp);
S390CPU *cpu_s390x_create(const char *cpu_model, Error **errp);
@@ -1146,6 +1142,7 @@ void handle_diag_308(CPUS390XState *env, uint64_t r1, uint64_t r3);
/* automatically detect the instruction length */
#define ILEN_AUTO 0xff
void program_interrupt(CPUS390XState *env, uint32_t code, int ilen);
+void trigger_pgm_exception(CPUS390XState *env, uint32_t code, uint32_t ilen);
void QEMU_NORETURN runtime_exception(CPUS390XState *env, int excp,
uintptr_t retaddr);
diff --git a/target/s390x/helper.c b/target/s390x/helper.c
index aef09e1..2a89029 100644
--- a/target/s390x/helper.c
+++ b/target/s390x/helper.c
@@ -165,16 +165,6 @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr address,
#else /* !CONFIG_USER_ONLY */
-/* Ensure to exit the TB after this call! */
-void trigger_pgm_exception(CPUS390XState *env, uint32_t code, uint32_t ilen)
-{
- CPUState *cs = CPU(s390_env_get_cpu(env));
-
- cs->exception_index = EXCP_PGM;
- env->int_pgm_code = code;
- env->int_pgm_ilen = ilen;
-}
-
int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr orig_vaddr,
int rw, int mmu_idx)
{
diff --git a/target/s390x/interrupt.c b/target/s390x/interrupt.c
index 9edef96..b30c95c 100644
--- a/target/s390x/interrupt.c
+++ b/target/s390x/interrupt.c
@@ -8,10 +8,46 @@
*/
#include "qemu/osdep.h"
+#include "qemu/log.h"
#include "cpu.h"
+#include "exec/exec-all.h"
#include "sysemu/kvm.h"
#include "hw/s390x/ioinst.h"
+/* Ensure to exit the TB after this call! */
+void trigger_pgm_exception(CPUS390XState *env, uint32_t code, uint32_t ilen)
+{
+ CPUState *cs = CPU(s390_env_get_cpu(env));
+
+ cs->exception_index = EXCP_PGM;
+ env->int_pgm_code = code;
+ env->int_pgm_ilen = ilen;
+}
+
+void program_interrupt(CPUS390XState *env, uint32_t code, int ilen)
+{
+ S390CPU *cpu = s390_env_get_cpu(env);
+
+ qemu_log_mask(CPU_LOG_INT, "program interrupt at %#" PRIx64 "\n",
+ env->psw.addr);
+
+ if (kvm_enabled()) {
+#ifdef CONFIG_KVM
+ struct kvm_s390_irq irq = {
+ .type = KVM_S390_PROGRAM_INT,
+ .u.pgm.code = code,
+ };
+
+ kvm_s390_vcpu_interrupt(cpu, &irq);
+#endif
+ } else {
+ trigger_pgm_exception(env, code, ilen);
+#ifdef CONFIG_TCG
+ cpu_loop_exit(CPU(cpu));
+#endif
+ }
+}
+
#if !defined(CONFIG_USER_ONLY)
void cpu_inject_ext(S390CPU *cpu, uint32_t code, uint32_t param,
uint64_t param64)
diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c
index b508101..3fd7070 100644
--- a/target/s390x/misc_helper.c
+++ b/target/s390x/misc_helper.c
@@ -75,32 +75,6 @@ void HELPER(exception)(CPUS390XState *env, uint32_t excp)
cpu_loop_exit(cs);
}
-void program_interrupt(CPUS390XState *env, uint32_t code, int ilen)
-{
- S390CPU *cpu = s390_env_get_cpu(env);
-
- qemu_log_mask(CPU_LOG_INT, "program interrupt at %#" PRIx64 "\n",
- env->psw.addr);
-
- if (kvm_enabled()) {
-#ifdef CONFIG_KVM
- struct kvm_s390_irq irq = {
- .type = KVM_S390_PROGRAM_INT,
- .u.pgm.code = code,
- };
-
- kvm_s390_vcpu_interrupt(cpu, &irq);
-#endif
- } else {
- CPUState *cs = CPU(cpu);
-
- env->int_pgm_code = code;
- env->int_pgm_ilen = ilen;
- cs->exception_index = EXCP_PGM;
- cpu_loop_exit(cs);
- }
-}
-
#ifndef CONFIG_USER_ONLY
/* SCLP service call */
--
1.8.3.1
On 07/19/2017 02:54 AM, Thomas Huth wrote:
> +void program_interrupt(CPUS390XState *env, uint32_t code, int ilen)
> +{
> + S390CPU *cpu = s390_env_get_cpu(env);
> +
> + qemu_log_mask(CPU_LOG_INT, "program interrupt at %#" PRIx64 "\n",
> + env->psw.addr);
> +
> + if (kvm_enabled()) {
> +#ifdef CONFIG_KVM
> + struct kvm_s390_irq irq = {
> + .type = KVM_S390_PROGRAM_INT,
> + .u.pgm.code = code,
> + };
> +
> + kvm_s390_vcpu_interrupt(cpu, &irq);
> +#endif
> + } else {
> + trigger_pgm_exception(env, code, ilen);
> +#ifdef CONFIG_TCG
> + cpu_loop_exit(CPU(cpu));
> +#endif
> + }
> +}
I would like to take the opportunity to split the kvm and tcg versions apart.
Primarily because the tcg half is noreturn, and I keep having to add
g_assert_not_reached after calling it to avoid other Werrors.
That might also help with the ifdeffing a little so you can write
if (kvm_enabled()) {
kvm_program_interrupt(...);
} else if (tcg_enabled()) {
tcg_program_interrupt(...);
} else {
g_assert_not_reached();
}
r~
© 2016 - 2026 Red Hat, Inc.