From patchwork Tue Jul 3 15:17:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 140975 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1294345ljj; Tue, 3 Jul 2018 08:21:00 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfZ+E0ZgaSLbpaWynHAxKUyNxCBuIVBBRVbXXu4xJktyf0iy595DVVq8X+WipBY3QtvDTVG X-Received: by 2002:ac8:809:: with SMTP id u9-v6mr10256756qth.303.1530631260628; Tue, 03 Jul 2018 08:21:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530631260; cv=none; d=google.com; s=arc-20160816; b=lPlVwkIdZ+1skUZM6h5IOeBaTz7nzcuAw8n+YXptj1iPVKkUKppJ+XIE/CZJVRlhgp vSGDLLzjXv+3KTzaf6/flYLSOBT//1D669WoWFUjFdYX40oDrRbQiZH2ddUYCUSQYpGL i0unposQjrmVS315RCJHcsq+Qo1Oi9gL19NhT7Xpn7kvBKb9qGVtyIjDTY726NM4DcrA iU8GmP3iB1FmjTp7DTPuujiiWguVuv65QuhvQn9646XYGla9c+uxihSQ04JhHa30HSMX VfFERWvjYDOyD7Mn3F5ZCtGGcHHjKTmQvt6gTbrPDwAR20S67UnxLa6fZUWCh0tUA8u3 zRxw== 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=eZ2NTaqa03xWjVw1EbNchX+4D4CGNGoex5E3ASWvXK8=; b=ODjvUbLsTh5ZJvZeRtVlHovLXQBsbKlvLKW6K4gA/mX/ZeBKExvBiQNke+/wNC/VSM IEVIcFYv2dMszqBak/q/6U0sXZJrHwU2PZYkXfa5QPjK4Bq+ZIajDQmly0Km0xH3icgs nop8JmEsZqfoE9F8as0t1TUrIHTeLna+vThKCsnZGZ1haxztignFzzqlr0J5lwXKvNFb mnOsIUREdHw0qoJpr1g9Hbrp1pfRdMo3mPLYfpUkpehMg+2iRwQ070dZ5Uupr8yzHTr/ 5Ke9xDlsvSLjHK1Q7xAmCycg9JIMrCJNwgOZr3JiINEklGQ3z9H6kjGZ6zz3IyqmLZik ZsVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ZCB6IEuc; 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x8-v6si1280209qvb.258.2018.07.03.08.21.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 03 Jul 2018 08:21:00 -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=@linaro.org header.s=google header.b=ZCB6IEuc; 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41042 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faN6x-0007aZ-O8 for patch@linaro.org; Tue, 03 Jul 2018 11:20:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57646) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1faN3k-0006IL-1g for qemu-devel@nongnu.org; Tue, 03 Jul 2018 11:17:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1faN3h-0000Ls-9q for qemu-devel@nongnu.org; Tue, 03 Jul 2018 11:17:40 -0400 Received: from mail-pg0-x236.google.com ([2607:f8b0:400e:c05::236]:42736) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1faN3h-0000LQ-3t for qemu-devel@nongnu.org; Tue, 03 Jul 2018 11:17:37 -0400 Received: by mail-pg0-x236.google.com with SMTP id c10-v6so1126238pgu.9 for ; Tue, 03 Jul 2018 08:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eZ2NTaqa03xWjVw1EbNchX+4D4CGNGoex5E3ASWvXK8=; b=ZCB6IEucnmVhss5RFtTElFxMI093643vHWfE47x9gtn8RJ4DlOm8Xrkezp2ct4Y3qA xmu0y0D/GMWAbZUP/NyJ9s5phwBcCoNaeXb2AvZXSLxOw8cd9BXlKoJteaxZOsZ27tOK NvppcvhK8tG5rPUrhZ3Yr5T6lcA0BHVpG55n8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eZ2NTaqa03xWjVw1EbNchX+4D4CGNGoex5E3ASWvXK8=; b=BafSO1cX7WrZH/JHWYHVK03hfjJDJj+LVhHlk1x2u/eZOdK2opBMmgXn28YOjbuvj1 dKmgNPiUPVWJN4EweyVo5709URL2AJXVnRTCTgCH2aJf3Wo1xnreNOI3UAz7b4YomLOP 2nR3oM9OZcLmVCDGMq9q0C3Fg694AX3Q4Qt8gZBi3k1mLz2VyIQUgjmlfLhU8ZGFPBgM wbsY4NuZmlKPYxE32BCgNxaYwNMjF/jM3rldd8ptdZS87JjD+HPRq3ZvMnSvkN6t6dlL JJj9oxTeHwJVMf1MZa4nBlyVUKCsEpsB8j2ghiVMEwGxL7R1w/TAyhAHd+kz+sQhM2lk pt6Q== X-Gm-Message-State: APt69E2hLzTppIgoUz/L6xKqCKxUuYNz3otuiKd8YcbL3fe88c37SZDm DmrjnxrBOOJXwZVuAAPIhteiZA5J5kk= X-Received: by 2002:a63:9a52:: with SMTP id e18-v6mr9207857pgo.188.1530631055917; Tue, 03 Jul 2018 08:17:35 -0700 (PDT) Received: from cloudburst.twiddle.net (97-126-112-211.tukw.qwest.net. [97.126.112.211]) by smtp.gmail.com with ESMTPSA id s185-v6sm4834201pfb.116.2018.07.03.08.17.34 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jul 2018 08:17:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 3 Jul 2018 08:17:26 -0700 Message-Id: <20180703151732.29843-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703151732.29843-1-richard.henderson@linaro.org> References: <20180703151732.29843-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::236 Subject: [Qemu-devel] [PATCH 1/7] 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: programmingkidx@gmail.com, qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 7714bfe0f9..119826b5a7 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); @@ -547,7 +556,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 76d6f3fd5e..ffa74a1026 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 */