From nobody Mon Feb 9 09:48:32 2026 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; dkim=fail; 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 153482624793522.059310444260404; Mon, 20 Aug 2018 21:37:27 -0700 (PDT) Received: from localhost ([::1]:50652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fryQ2-0006Vp-P7 for importer@patchew.org; Tue, 21 Aug 2018 00:37:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fryMp-00047S-7R for qemu-devel@nongnu.org; Tue, 21 Aug 2018 00:34:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fryMl-0000Ic-0C for qemu-devel@nongnu.org; Tue, 21 Aug 2018 00:34:06 -0400 Received: from ozlabs.org ([203.11.71.1]:53463) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fryMi-0000ES-Hn; Tue, 21 Aug 2018 00:34:02 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41vd9D3wFQz9sCc; Tue, 21 Aug 2018 14:33:51 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1534826032; bh=Km9eXb/mZ2tpaozjbe+pDID9meRNdhppZseGEKNjQC8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cbckIeKk5tjUVfc7rDpBPxDCVLBKX6QuqANPFFHea6qfobFIKxF2AMDLkzHL3InTj GT/BpP0S9mmj7k1pnEbycL7i+8O4VVYi9v7bG4Cx/c1sPOzxszwO0KEv3UaMcY95Mq 8Ei6H4hFBXXAXCOV80WuzG5Z6S5sHEnfDcBOaxyA= From: David Gibson To: peter.maydell@linaro.org Date: Tue, 21 Aug 2018 14:33:20 +1000 Message-Id: <20180821043343.7514-4-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180821043343.7514-1-david@gibson.dropbear.id.au> References: <20180821043343.7514-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 03/26] target/ppc: Enable fp exceptions for user-only 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: lvivier@redhat.com, aik@ozlabs.ru, Richard Henderson , groug@kaod.org, qemu-devel@nongnu.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Richard Henderson While just setting the MSR bits is sufficient, we can tidy the helper code by extracting the MSR test to a helper and then forcing it true for user-only. Signed-off-by: Richard Henderson Signed-off-by: David Gibson --- target/ppc/fpu_helper.c | 15 ++++++++++++--- target/ppc/translate_init.inc.c | 2 ++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/target/ppc/fpu_helper.c b/target/ppc/fpu_helper.c index 8675d931b6..9b39c4b3e5 100644 --- a/target/ppc/fpu_helper.c +++ b/target/ppc/fpu_helper.c @@ -36,6 +36,15 @@ static inline float128 float128_snan_to_qnan(float128 x) #define float32_snan_to_qnan(x) ((x) | 0x00400000) #define float16_snan_to_qnan(x) ((x) | 0x0200) =20 +static inline bool fp_exceptions_enabled(CPUPPCState *env) +{ +#ifdef CONFIG_USER_ONLY + return true; +#else + return (env->msr & ((1U << MSR_FE0) | (1U << MSR_FE1))) !=3D 0; +#endif +} + /*************************************************************************= ****/ /* Floating point operations helpers */ uint64_t helper_float32_to_float64(CPUPPCState *env, uint32_t arg) @@ -207,7 +216,7 @@ uint64_t float_invalid_op_excp(CPUPPCState *env, int op= , int set_fpcc) if (ve !=3D 0) { /* Update the floating-point enabled exception summary */ env->fpscr |=3D 1 << FPSCR_FEX; - if (msr_fe0 !=3D 0 || msr_fe1 !=3D 0) { + if (fp_exceptions_enabled(env)) { /* GETPC() works here because this is inline */ raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM, POWERPC_EXCP_FP | op, GETPC()); @@ -225,7 +234,7 @@ static inline void float_zero_divide_excp(CPUPPCState *= env, uintptr_t raddr) if (fpscr_ze !=3D 0) { /* Update the floating-point enabled exception summary */ env->fpscr |=3D 1 << FPSCR_FEX; - if (msr_fe0 !=3D 0 || msr_fe1 !=3D 0) { + if (fp_exceptions_enabled(env)) { raise_exception_err_ra(env, POWERPC_EXCP_PROGRAM, POWERPC_EXCP_FP | POWERPC_EXCP_FP_ZX, raddr); @@ -555,7 +564,7 @@ static void do_float_check_status(CPUPPCState *env, uin= tptr_t raddr) if (cs->exception_index =3D=3D POWERPC_EXCP_PROGRAM && (env->error_code & POWERPC_EXCP_FP)) { /* Differred floating-point exception after target FPR update */ - if (msr_fe0 !=3D 0 || msr_fe1 !=3D 0) { + if (fp_exceptions_enabled(env)) { raise_exception_err_ra(env, cs->exception_index, env->error_code, raddr); } diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.in= c.c index 7813b1b004..fe0cb98e6d 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -10278,6 +10278,8 @@ static void ppc_cpu_reset(CPUState *s) #endif #if defined(CONFIG_USER_ONLY) msr |=3D (target_ulong)1 << MSR_FP; /* Allow floating point usage */ + msr |=3D (target_ulong)1 << MSR_FE0; /* Allow floating point exception= s */ + msr |=3D (target_ulong)1 << MSR_FE1; msr |=3D (target_ulong)1 << MSR_VR; /* Allow altivec usage */ msr |=3D (target_ulong)1 << MSR_VSX; /* Allow VSX usage */ msr |=3D (target_ulong)1 << MSR_SPE; /* Allow SPE usage */ --=20 2.17.1