From patchwork Tue Aug 21 04:33:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 144672 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp4784710ljj; Mon, 20 Aug 2018 21:35:49 -0700 (PDT) X-Google-Smtp-Source: AA+uWPx++f8ok1qwK2zHz3fn+CbrgLbooVW9z+Grt3TzlIQq10iZMynW6ItxNXZc3WKwJJKz6/VY X-Received: by 2002:a37:1adb:: with SMTP id l88-v6mr11249890qkh.43.1534826149666; Mon, 20 Aug 2018 21:35:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534826149; cv=none; d=google.com; s=arc-20160816; b=vEz3ihQzI7wHnEBFLeP5OpnX/Ala0/+dGoa2Jec3aQALAjYue6BNy9pziYSwgeamJ7 WCXlLRy1SlxYzCV0/Vs51SPw9yayKsobEwLY1p+/gUnWw2DMzMOo8ct9Q+hikxsD+KmJ Jk9re9J4Q1jOqZVPmm5OX8sjms/ZV8rJ0U5gdb7D+F/5ElonWKYt5O9uH9V8wEuFv0I1 tnRzfpxVuNujOQiJHofkHb04xqadGzxCwzCoEmeiOmGjDBK+gr0WzPV0MJD55F8kgDty v01JKCuAOr6V+Tdvrsj5HyDBMjd9OXsYfz9Xd61q1Rhud04c/wzvkSyHBimRyVw9oJS5 fDPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=sZTaSTb9OVm8q+jg+7OXO2Lb5HVjSzPX0A9pUcGBU4g=; b=SRN7lwxQzAGoHjgOmgIhyLJNBBxWON4PFQLoNSaVJMXMP+VTzWhv/cZRW9Tn12X34G BX6oUErScuJi40ePg6lsDPqyiAhPb4KmUqoN6n5ODQBuMBAr7omf/y4XAen+SZ2n3X75 rZaClklmRi7ItlTDI3MCovk8INIBL48YvQzEJD3S9oolcHSjmZnTUi+qpduXggFjbeyt G9Q/nWr4Ur+tmmlu8DoEGvVrHiU4yZksuN3mkR3+eTfvmMIVZlhkd/B9CUCIuaybtDTC qKTf26O7AcCMYuCNUrl0BLHa9hKjFMEjGP0QA0WzQCqCrSFFAzubcXlpMYyCdMSNBmeT L1HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gibson.dropbear.id.au header.s=201602 header.b=cbckIeKk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id f53-v6si8921211qta.336.2018.08.20.21.35.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 20 Aug 2018 21:35:49 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gibson.dropbear.id.au header.s=201602 header.b=cbckIeKk; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:50648 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fryOT-0005Oc-35 for patch@linaro.org; Tue, 21 Aug 2018 00:35:49 -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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.17.1 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) +static inline bool fp_exceptions_enabled(CPUPPCState *env) +{ +#ifdef CONFIG_USER_ONLY + return true; +#else + return (env->msr & ((1U << MSR_FE0) | (1U << MSR_FE1))) != 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 != 0) { /* Update the floating-point enabled exception summary */ env->fpscr |= 1 << FPSCR_FEX; - if (msr_fe0 != 0 || msr_fe1 != 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 != 0) { /* Update the floating-point enabled exception summary */ env->fpscr |= 1 << FPSCR_FEX; - if (msr_fe0 != 0 || msr_fe1 != 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, uintptr_t raddr) if (cs->exception_index == POWERPC_EXCP_PROGRAM && (env->error_code & POWERPC_EXCP_FP)) { /* Differred floating-point exception after target FPR update */ - if (msr_fe0 != 0 || msr_fe1 != 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.inc.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 |= (target_ulong)1 << MSR_FP; /* Allow floating point usage */ + msr |= (target_ulong)1 << MSR_FE0; /* Allow floating point exceptions */ + msr |= (target_ulong)1 << MSR_FE1; msr |= (target_ulong)1 << MSR_VR; /* Allow altivec usage */ msr |= (target_ulong)1 << MSR_VSX; /* Allow VSX usage */ msr |= (target_ulong)1 << MSR_SPE; /* Allow SPE usage */