From nobody Sat Feb 7 08:43:50 2026 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1511901360666404.1448008396035; Tue, 28 Nov 2017 12:36:00 -0800 (PST) Received: from localhost ([::1]:39979 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJmbc-00026t-Cb for importer@patchew.org; Tue, 28 Nov 2017 15:35:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46288) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eJmZX-0000oT-HC for qemu-devel@nongnu.org; Tue, 28 Nov 2017 15:33:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eJmZV-0003ZF-Vr for qemu-devel@nongnu.org; Tue, 28 Nov 2017 15:33:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57790) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eJmZV-0003Ya-Mi; Tue, 28 Nov 2017 15:33:37 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CE1798046F; Tue, 28 Nov 2017 20:33:36 +0000 (UTC) Received: from t460s.redhat.com (ovpn-116-100.ams2.redhat.com [10.36.116.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFE2660600; Tue, 28 Nov 2017 20:33:30 +0000 (UTC) From: David Hildenbrand To: qemu-s390x@nongnu.org, qemu-devel@nongnu.org Date: Tue, 28 Nov 2017 21:33:11 +0100 Message-Id: <20171128203326.6062-2-david@redhat.com> In-Reply-To: <20171128203326.6062-1-david@redhat.com> References: <20171128203326.6062-1-david@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 28 Nov 2017 20:33:36 +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 v1 for-2.12 01/15] s390x/tcg: introduce and use program_interrupt_ra() 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 , David Hildenbrand , Alexander Graf , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Allows to easily convert more callers of program_interrupt() and to easily introduce new exceptions without forgetting about the cpu state reset. Use program_interrupt_ra() in places where we already had the same pattern. Signed-off-by: David Hildenbrand Reviewed-by: Richard Henderson --- target/s390x/cpu.h | 2 ++ target/s390x/crypto_helper.c | 7 ++----- target/s390x/excp_helper.c | 5 +---- target/s390x/interrupt.c | 13 +++++++++++++ target/s390x/mem_helper.c | 35 +++++++++++------------------------ target/s390x/misc_helper.c | 3 +-- 6 files changed, 30 insertions(+), 35 deletions(-) diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 4db8b5409e..e21d63ae04 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -720,6 +720,8 @@ void s390_io_interrupt(uint16_t subchannel_id, uint16_t= subchannel_nr, /* automatically detect the instruction length */ #define ILEN_AUTO 0xff void program_interrupt(CPUS390XState *env, uint32_t code, int ilen); +void program_interrupt_ra(CPUS390XState *env, uint32_t code, int ilen, + uintptr_t ra); /* service interrupts are floating therefore we must not pass an cpustate = */ void s390_sclp_extint(uint32_t parm); =20 diff --git a/target/s390x/crypto_helper.c b/target/s390x/crypto_helper.c index fa360a2d6e..38f7943778 100644 --- a/target/s390x/crypto_helper.c +++ b/target/s390x/crypto_helper.c @@ -23,7 +23,6 @@ uint32_t HELPER(msa)(CPUS390XState *env, uint32_t r1, uin= t32_t r2, uint32_t r3, const uintptr_t ra =3D GETPC(); const uint8_t mod =3D env->regs[0] & 0x80ULL; const uint8_t fc =3D env->regs[0] & 0x7fULL; - CPUState *cs =3D CPU(s390_env_get_cpu(env)); uint8_t subfunc[16] =3D { 0 }; uint64_t param_addr; int i; @@ -35,8 +34,7 @@ uint32_t HELPER(msa)(CPUS390XState *env, uint32_t r1, uin= t32_t r2, uint32_t r3, case S390_FEAT_TYPE_PCKMO: case S390_FEAT_TYPE_PCC: if (mod) { - cpu_restore_state(cs, ra); - program_interrupt(env, PGM_SPECIFICATION, 4); + program_interrupt_ra(env, PGM_SPECIFICATION, 4, ra); return 0; } break; @@ -44,8 +42,7 @@ uint32_t HELPER(msa)(CPUS390XState *env, uint32_t r1, uin= t32_t r2, uint32_t r3, =20 s390_get_feat_block(type, subfunc); if (!test_be_bit(fc, subfunc)) { - cpu_restore_state(cs, ra); - program_interrupt(env, PGM_SPECIFICATION, 4); + program_interrupt_ra(env, PGM_SPECIFICATION, 4, ra); return 0; } =20 diff --git a/target/s390x/excp_helper.c b/target/s390x/excp_helper.c index e04b670663..9423bb6f36 100644 --- a/target/s390x/excp_helper.c +++ b/target/s390x/excp_helper.c @@ -554,10 +554,7 @@ void s390x_cpu_do_unaligned_access(CPUState *cs, vaddr= addr, S390CPU *cpu =3D S390_CPU(cs); CPUS390XState *env =3D &cpu->env; =20 - if (retaddr) { - cpu_restore_state(cs, retaddr); - } - program_interrupt(env, PGM_SPECIFICATION, ILEN_AUTO); + program_interrupt_ra(env, PGM_SPECIFICATION, ILEN_AUTO, retaddr); } =20 #endif /* CONFIG_USER_ONLY */ diff --git a/target/s390x/interrupt.c b/target/s390x/interrupt.c index ce6177c141..6ce06bb549 100644 --- a/target/s390x/interrupt.c +++ b/target/s390x/interrupt.c @@ -53,6 +53,19 @@ void program_interrupt(CPUS390XState *env, uint32_t code= , int ilen) } } =20 +void program_interrupt_ra(CPUS390XState *env, uint32_t code, int ilen, + uintptr_t ra) +{ + S390CPU *cpu =3D s390_env_get_cpu(env); + +#ifdef CONFIG_TCG + if (tcg_enabled() && ra) { + cpu_restore_state(CPU(cpu), ra); + } +#endif + program_interrupt(env, code, ilen); +} + #if !defined(CONFIG_USER_ONLY) static void cpu_inject_service(S390CPU *cpu, uint32_t param) { diff --git a/target/s390x/mem_helper.c b/target/s390x/mem_helper.c index a1652d4849..47f327538c 100644 --- a/target/s390x/mem_helper.c +++ b/target/s390x/mem_helper.c @@ -85,9 +85,7 @@ static inline void check_alignment(CPUS390XState *env, ui= nt64_t v, int wordsize, uintptr_t ra) { if (v % wordsize) { - CPUState *cs =3D CPU(s390_env_get_cpu(env)); - cpu_restore_state(cs, ra); - program_interrupt(env, PGM_SPECIFICATION, 6); + program_interrupt_ra(env, PGM_SPECIFICATION, 6, ra); } } =20 @@ -545,8 +543,7 @@ void HELPER(srst)(CPUS390XState *env, uint32_t r1, uint= 32_t r2) =20 /* Bits 32-55 must contain all 0. */ if (env->regs[0] & 0xffffff00u) { - cpu_restore_state(ENV_GET_CPU(env), ra); - program_interrupt(env, PGM_SPECIFICATION, 6); + program_interrupt_ra(env, PGM_SPECIFICATION, 6, ra); } =20 str =3D get_address(env, r2); @@ -583,8 +580,7 @@ void HELPER(srstu)(CPUS390XState *env, uint32_t r1, uin= t32_t r2) =20 /* Bits 32-47 of R0 must be zero. */ if (env->regs[0] & 0xffff0000u) { - cpu_restore_state(ENV_GET_CPU(env), ra); - program_interrupt(env, PGM_SPECIFICATION, 6); + program_interrupt_ra(env, PGM_SPECIFICATION, 6, ra); } =20 str =3D get_address(env, r2); @@ -1600,8 +1596,7 @@ static uint32_t do_csst(CPUS390XState *env, uint32_t = r3, uint64_t a1, return cc; =20 spec_exception: - cpu_restore_state(ENV_GET_CPU(env), ra); - program_interrupt(env, PGM_SPECIFICATION, 6); + program_interrupt_ra(env, PGM_SPECIFICATION, 6, ra); g_assert_not_reached(); } =20 @@ -1865,8 +1860,7 @@ void HELPER(idte)(CPUS390XState *env, uint64_t r1, ui= nt64_t r2, uint32_t m4) uint16_t entries, i, index =3D 0; =20 if (r2 & 0xff000) { - cpu_restore_state(cs, ra); - program_interrupt(env, PGM_SPECIFICATION, 4); + program_interrupt_ra(env, PGM_SPECIFICATION, 4, ra); } =20 if (!(r2 & 0x800)) { @@ -2014,8 +2008,7 @@ uint64_t HELPER(lra)(CPUS390XState *env, uint64_t add= r) =20 /* XXX incomplete - has more corner cases */ if (!(env->psw.mask & PSW_MASK_64) && (addr >> 32)) { - cpu_restore_state(cs, GETPC()); - program_interrupt(env, PGM_SPECIAL_OP, 2); + program_interrupt_ra(env, PGM_SPECIAL_OP, 2, GETPC()); } =20 old_exc =3D cs->exception_index; @@ -2185,7 +2178,6 @@ uint32_t HELPER(mvcos)(CPUS390XState *env, uint64_t d= est, uint64_t src, const uint8_t psw_as =3D (env->psw.mask & PSW_MASK_ASC) >> PSW_SHIFT_A= SC; const uint64_t r0 =3D env->regs[0]; const uintptr_t ra =3D GETPC(); - CPUState *cs =3D CPU(s390_env_get_cpu(env)); uint8_t dest_key, dest_as, dest_k, dest_a; uint8_t src_key, src_as, src_k, src_a; uint64_t val; @@ -2195,8 +2187,7 @@ uint32_t HELPER(mvcos)(CPUS390XState *env, uint64_t d= est, uint64_t src, __func__, dest, src, len); =20 if (!(env->psw.mask & PSW_MASK_DAT)) { - cpu_restore_state(cs, ra); - program_interrupt(env, PGM_SPECIAL_OP, 6); + program_interrupt_ra(env, PGM_SPECIAL_OP, 6, ra); } =20 /* OAC (operand access control) for the first operand -> dest */ @@ -2227,17 +2218,14 @@ uint32_t HELPER(mvcos)(CPUS390XState *env, uint64_t= dest, uint64_t src, } =20 if (dest_a && dest_as =3D=3D AS_HOME && (env->psw.mask & PSW_MASK_PSTA= TE)) { - cpu_restore_state(cs, ra); - program_interrupt(env, PGM_SPECIAL_OP, 6); + program_interrupt_ra(env, PGM_SPECIAL_OP, 6, ra); } if (!(env->cregs[0] & CR0_SECONDARY) && (dest_as =3D=3D AS_SECONDARY || src_as =3D=3D AS_SECONDARY)) { - cpu_restore_state(cs, ra); - program_interrupt(env, PGM_SPECIAL_OP, 6); + program_interrupt_ra(env, PGM_SPECIAL_OP, 6, ra); } if (!psw_key_valid(env, dest_key) || !psw_key_valid(env, src_key)) { - cpu_restore_state(cs, ra); - program_interrupt(env, PGM_PRIVILEGED, 6); + program_interrupt_ra(env, PGM_PRIVILEGED, 6, ra); } =20 len =3D wrap_length(env, len); @@ -2251,8 +2239,7 @@ uint32_t HELPER(mvcos)(CPUS390XState *env, uint64_t d= est, uint64_t src, (env->psw.mask & PSW_MASK_PSTATE)) { qemu_log_mask(LOG_UNIMP, "%s: AR-mode and PSTATE support missing\n= ", __func__); - cpu_restore_state(cs, ra); - program_interrupt(env, PGM_ADDRESSING, 6); + program_interrupt_ra(env, PGM_ADDRESSING, 6, ra); } =20 /* FIXME: a) LAP diff --git a/target/s390x/misc_helper.c b/target/s390x/misc_helper.c index d272851e1c..fbb446db70 100644 --- a/target/s390x/misc_helper.c +++ b/target/s390x/misc_helper.c @@ -519,8 +519,7 @@ uint32_t HELPER(stfle)(CPUS390XState *env, uint64_t add= r) int i; =20 if (addr & 0x7) { - cpu_restore_state(ENV_GET_CPU(env), ra); - program_interrupt(env, PGM_SPECIFICATION, 4); + program_interrupt_ra(env, PGM_SPECIFICATION, 4, ra); } =20 prepare_stfl(); --=20 2.14.3