From nobody Wed Nov 5 02:51:24 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500648723703973.5784468393042; Fri, 21 Jul 2017 07:52:03 -0700 (PDT) Received: from localhost ([::1]:43580 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYZHc-0001kS-47 for importer@patchew.org; Fri, 21 Jul 2017 10:52:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40341) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dYZC9-0005tO-Jv for qemu-devel@nongnu.org; Fri, 21 Jul 2017 10:46:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dYZC4-0002LR-N8 for qemu-devel@nongnu.org; Fri, 21 Jul 2017 10:46:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51458) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dYZC4-0002Kz-EH for qemu-devel@nongnu.org; Fri, 21 Jul 2017 10:46:16 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2061420A9B; Fri, 21 Jul 2017 14:46:15 +0000 (UTC) Received: from thh440s.redhat.com (ovpn-117-121.ams2.redhat.com [10.36.117.121]) by smtp.corp.redhat.com (Postfix) with ESMTP id 19FB817160; Fri, 21 Jul 2017 14:46:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 2061420A9B Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx06.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=thuth@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 2061420A9B From: Thomas Huth To: qemu-devel@nongnu.org, Richard Henderson Date: Fri, 21 Jul 2017 16:45:57 +0200 Message-Id: <1500648359-25931-4-git-send-email-thuth@redhat.com> In-Reply-To: <1500648359-25931-1-git-send-email-thuth@redhat.com> References: <1500648359-25931-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 21 Jul 2017 14:46:15 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 3/5] target/s390x: Rework program_interrupt() and related functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Christian Borntraeger , Cornelia Huck , Alexander Graf Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 to re-use the code from trigger_pgm_exception() (for TCG) and enter_pgmcheck() (for KVM, which now got renamed to kvm_s390_program_interrupt() for clarity). Signed-off-by: Thomas Huth Reviewed-by: Richard Henderson --- target/s390x/cpu.h | 9 +++++---- target/s390x/helper.c | 10 ---------- target/s390x/interrupt.c | 37 +++++++++++++++++++++++++++++++++++++ target/s390x/kvm.c | 16 ++++++++-------- target/s390x/misc_helper.c | 26 -------------------------- 5 files changed, 50 insertions(+), 48 deletions(-) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 7732d01..a9c0f3a 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) } } =20 -#ifndef CONFIG_USER_ONLY -void trigger_pgm_exception(CPUS390XState *env, uint32_t code, uint32_t ile= n); -#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); @@ -538,6 +534,7 @@ int s390_virtio_hypercall(CPUS390XState *env); =20 #ifdef CONFIG_KVM void kvm_s390_service_interrupt(uint32_t parm); +void kvm_s390_program_interrupt(S390CPU *cpu, uint16_t code); void kvm_s390_vcpu_interrupt(S390CPU *cpu, struct kvm_s390_irq *irq); void kvm_s390_floating_interrupt(struct kvm_s390_irq *irq); int kvm_s390_inject_flic(struct kvm_s390_irq *irq); @@ -550,6 +547,9 @@ int kvm_s390_set_clock(uint8_t *tod_high, uint64_t *tod= _clock); static inline void kvm_s390_service_interrupt(uint32_t parm) { } +static inline void kvm_s390_program_interrupt(S390CPU *cpu, uint16_t code) +{ +} static inline int kvm_s390_get_clock(uint8_t *tod_high, uint64_t *tod_low) { return -ENOSYS; @@ -1146,6 +1146,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 ile= n); void QEMU_NORETURN runtime_exception(CPUS390XState *env, int excp, uintptr_t retaddr); =20 diff --git a/target/s390x/helper.c b/target/s390x/helper.c index 30ac2a7..e2040d6 100644 --- a/target/s390x/helper.c +++ b/target/s390x/helper.c @@ -165,16 +165,6 @@ int s390_cpu_handle_mmu_fault(CPUState *cs, vaddr addr= ess, =20 #else /* !CONFIG_USER_ONLY */ =20 -/* Ensure to exit the TB after this call! */ -void trigger_pgm_exception(CPUS390XState *env, uint32_t code, uint32_t ile= n) -{ - CPUState *cs =3D CPU(s390_env_get_cpu(env)); - - cs->exception_index =3D EXCP_PGM; - env->int_pgm_code =3D code; - env->int_pgm_ilen =3D 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..6839aad 100644 --- a/target/s390x/interrupt.c +++ b/target/s390x/interrupt.c @@ -8,10 +8,47 @@ */ =20 #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" =20 +/* Ensure to exit the TB after this call! */ +void trigger_pgm_exception(CPUS390XState *env, uint32_t code, uint32_t ile= n) +{ + CPUState *cs =3D CPU(s390_env_get_cpu(env)); + + cs->exception_index =3D EXCP_PGM; + env->int_pgm_code =3D code; + env->int_pgm_ilen =3D ilen; +} + +static void tcg_s390_program_interrupt(CPUS390XState *env, uint32_t code, + int ilen) +{ + trigger_pgm_exception(env, code, ilen); +#ifdef CONFIG_TCG + cpu_loop_exit(CPU(s390_env_get_cpu(env))); +#endif +} + +void program_interrupt(CPUS390XState *env, uint32_t code, int ilen) +{ + S390CPU *cpu =3D s390_env_get_cpu(env); + + qemu_log_mask(CPU_LOG_INT, "program interrupt at %#" PRIx64 "\n", + env->psw.addr); + + if (kvm_enabled()) { + kvm_s390_program_interrupt(cpu, code); + } else if (tcg_enabled()) { + tcg_s390_program_interrupt(env, code, ilen); + } else { + g_assert_not_reached(); + } +} + #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/kvm.c b/target/s390x/kvm.c index 831492f..4dd85e4 100644 --- a/target/s390x/kvm.c +++ b/target/s390x/kvm.c @@ -1032,7 +1032,7 @@ void kvm_s390_service_interrupt(uint32_t parm) kvm_s390_floating_interrupt(&irq); } =20 -static void enter_pgmcheck(S390CPU *cpu, uint16_t code) +void kvm_s390_program_interrupt(S390CPU *cpu, uint16_t code) { struct kvm_s390_irq irq =3D { .type =3D KVM_S390_PROGRAM_INT, @@ -1068,7 +1068,7 @@ static int kvm_sclp_service_call(S390CPU *cpu, struct= kvm_run *run, =20 r =3D sclp_service_call(env, sccb, code); if (r < 0) { - enter_pgmcheck(cpu, -r); + kvm_s390_program_interrupt(cpu, -r); } else { setcc(cpu, r); } @@ -1236,7 +1236,7 @@ static int kvm_sic_service_call(S390CPU *cpu, struct = kvm_run *run) isc =3D (env->regs[r3] >> 27) & 0x7; r =3D css_do_sic(env, isc, mode); if (r) { - enter_pgmcheck(cpu, -r); + kvm_s390_program_interrupt(cpu, -r); } =20 return 0; @@ -1357,7 +1357,7 @@ static int handle_hypercall(S390CPU *cpu, struct kvm_= run *run) cpu_synchronize_state(CPU(cpu)); ret =3D s390_virtio_hypercall(env); if (ret =3D=3D -EINVAL) { - enter_pgmcheck(cpu, PGM_SPECIFICATION); + kvm_s390_program_interrupt(cpu, PGM_SPECIFICATION); return 0; } =20 @@ -1374,7 +1374,7 @@ static void kvm_handle_diag_288(S390CPU *cpu, struct = kvm_run *run) r3 =3D run->s390_sieic.ipa & 0x000f; rc =3D handle_diag_288(&cpu->env, r1, r3); if (rc) { - enter_pgmcheck(cpu, PGM_SPECIFICATION); + kvm_s390_program_interrupt(cpu, PGM_SPECIFICATION); } } =20 @@ -1431,7 +1431,7 @@ static int handle_diag(S390CPU *cpu, struct kvm_run *= run, uint32_t ipb) break; default: DPRINTF("KVM: unknown DIAG: 0x%x\n", func_code); - enter_pgmcheck(cpu, PGM_SPECIFICATION); + kvm_s390_program_interrupt(cpu, PGM_SPECIFICATION); break; } =20 @@ -1899,7 +1899,7 @@ static int handle_instruction(S390CPU *cpu, struct kv= m_run *run) =20 if (r < 0) { r =3D 0; - enter_pgmcheck(cpu, 0x0001); + kvm_s390_program_interrupt(cpu, PGM_OPERATION); } =20 return r; @@ -2009,7 +2009,7 @@ static int handle_intercept(S390CPU *cpu) /* Then check for potential pgm check loops */ r =3D handle_oper_loop(cpu, run); if (r =3D=3D 0) { - enter_pgmcheck(cpu, PGM_OPERATION); + kvm_s390_program_interrupt(cpu, PGM_OPERATION); } } break; diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c index 6a90ad5..44c5c40 100644 --- a/target/s390x/misc_helper.c +++ b/target/s390x/misc_helper.c @@ -68,32 +68,6 @@ void HELPER(exception)(CPUS390XState *env, uint32_t excp) cpu_loop_exit(cs); } =20 -void program_interrupt(CPUS390XState *env, uint32_t code, int ilen) -{ - S390CPU *cpu =3D 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 =3D { - .type =3D KVM_S390_PROGRAM_INT, - .u.pgm.code =3D code, - }; - - kvm_s390_vcpu_interrupt(cpu, &irq); -#endif - } else { - CPUState *cs =3D CPU(cpu); - - env->int_pgm_code =3D code; - env->int_pgm_ilen =3D ilen; - cs->exception_index =3D EXCP_PGM; - cpu_loop_exit(cs); - } -} - #ifndef CONFIG_USER_ONLY =20 /* SCLP service call */ --=20 1.8.3.1