From patchwork Thu Jan 27 06:34:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12726342 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 94BE6C433EF for ; Thu, 27 Jan 2022 07:05:20 +0000 (UTC) Received: from localhost ([::1]:59110 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCyqN-0001PT-8Q for qemu-devel@archiver.kernel.org; Thu, 27 Jan 2022 02:05:19 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38914) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCyMh-00043s-D8 for qemu-devel@nongnu.org; Thu, 27 Jan 2022 01:34:41 -0500 Received: from [2607:f8b0:4864:20::1036] (port=38563 helo=mail-pj1-x1036.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCyMf-0005ib-PN for qemu-devel@nongnu.org; Thu, 27 Jan 2022 01:34:38 -0500 Received: by mail-pj1-x1036.google.com with SMTP id d12-20020a17090a628c00b001b4f47e2f51so6583112pjj.3 for ; Wed, 26 Jan 2022 22:34:37 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=E75DjW4QVNIQo9iQ7CSqAeo7IxlAo+AuZWRbk+594s4=; b=Rs3dXyFlt76aY9nfZGtdOqYTIllhdbtDsJjTrXpaojxuneTJQubSdUoPBw6BMLhxgU 4pxj7sy2q4HMrNidZL33uc3TN4aMLX5ndC2UFkyPZ8UztVmOb9wo4aBS2nqgXg+M5stm ubFY2y+7z9FhY3fOP9NeVeigjDBk7GvHRk1IZtYQSwQBpjZ0KdtC7ehgZQoZ7VnrWm/4 lOMRmeb4NNogoOqf9RFF+H1YkjMw+Q+BJCr2kKgUj0MS43PXNngdYiQc3vQLoIF8zIYZ e8zoYfln9i/jlfmXM8vD2EVqsvdvpcvi8BSfzAw952fSrnW1pWVz7An6Xk+Z8YI7cG03 p8zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=E75DjW4QVNIQo9iQ7CSqAeo7IxlAo+AuZWRbk+594s4=; b=DAQgBx5OlBF4bPY3kH9yLQGkuC9hFLvf3Bt+iEB+8NI+dwCyHNTCmpJYlTtmkrmO1a 2F8jnkLWVP8g9YzxlcHAge/NcPiIGG1qmn/sMXYUfiT+T1ETWjxPj3Aa9JIwbKJ1p0GA yGrHJEM3FBYyDupMGTBmdTabLDhHSJTc47h/SKyJSgSeoPLdjYulwj0IZ9944VbOV7ei FLUIceHd0QQjTDhb87yftxJIBnBsY3tG6O3e2Rqicqmime7meVa5IhTGLi541iQOtsZm lIFo+YKYRavA5tA8vD2kyU9tm+iVBc1HfRy6Hc/LAm20oq5h89u/A/4+PXuxdMxcItXc 11Dw== X-Gm-Message-State: AOAM532UNV+UIQa31yiULhHNOSxN5+ZCM87Id0nBxmNYjAgnxe2om903 PQpIpk/pmqs75AS3TIRRLWtu+yop+bCbQING X-Google-Smtp-Source: ABdhPJxRVrpD7QchzXhknYWFRCPUYQ4jfV1Mq4N4ngifqJi3xWOneimUNVdNGRaL2/W8NJTspzBujg== X-Received: by 2002:a17:902:8d96:: with SMTP id v22mr2471111plo.77.1643265276453; Wed, 26 Jan 2022 22:34:36 -0800 (PST) Received: from localhost.localdomain (alanje.lnk.telstra.net. [120.151.179.201]) by smtp.gmail.com with ESMTPSA id y20sm4231855pfi.78.2022.01.26.22.34.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jan 2022 22:34:36 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 1/4] target/arm: Fix sve_zcr_len_for_el for VHE mode running Date: Thu, 27 Jan 2022 17:34:25 +1100 Message-Id: <20220127063428.30212-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127063428.30212-1-richard.henderson@linaro.org> References: <20220127063428.30212-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1036 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1036; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1036.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yuzenghui@huawei.com, peter.maydell@linaro.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" When HCR_EL2.{E2H,TGE} == '11', ZCR_EL1 is unused. Reported-by: Zenghui Yu Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Reviewed-by: Zenghui Yu --- target/arm/helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index cfca0f5ba6..d9ee2ba5f4 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6225,7 +6225,8 @@ uint32_t sve_zcr_len_for_el(CPUARMState *env, int el) ARMCPU *cpu = env_archcpu(env); uint32_t zcr_len = cpu->sve_max_vq - 1; - if (el <= 1) { + if (el <= 1 && + (arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { zcr_len = MIN(zcr_len, 0xf & (uint32_t)env->vfp.zcr_el[1]); } if (el <= 2 && arm_feature(env, ARM_FEATURE_EL2)) { From patchwork Thu Jan 27 06:34:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12726352 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3CE2EC433F5 for ; Thu, 27 Jan 2022 07:14:40 +0000 (UTC) Received: from localhost ([::1]:36010 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCyzO-0006HT-V4 for qemu-devel@archiver.kernel.org; Thu, 27 Jan 2022 02:14:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38938) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCyMj-000444-Eu for qemu-devel@nongnu.org; Thu, 27 Jan 2022 01:34:41 -0500 Received: from [2607:f8b0:4864:20::436] (port=42576 helo=mail-pf1-x436.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCyMi-0005iy-0U for qemu-devel@nongnu.org; Thu, 27 Jan 2022 01:34:41 -0500 Received: by mail-pf1-x436.google.com with SMTP id i65so1768200pfc.9 for ; Wed, 26 Jan 2022 22:34:39 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=OnCbwXhM9/o/J8yHFW89wxfhUkfvaIKD6NjXHeW3Thc=; b=APGbKKDARtRzYgk0pW3JYlGmeECbs7z71LfffzOQJOWZHVOFqcKFeMw1u8KElSBS8R /t1e455RPe9PLWoTM0eP5cSXjynSQ3mZuDeEu3j0Imgbz31wlBfyPZ4BiAgZI4HCeLSg roIEjoQHA6MMeIWZ6tAWvHYeB654evQeEg69xS/Oyfna6XgWn/3P5wMRFckPtsGK7hdy 6tNXfUWZB/y2TKLgW0TlhGR7x24gbZeatW11cKeCk8fEc7OBAC5Ffe0Ve+NU15Ac8p1v NffvyEU0c1LeSvC2Ur5zbrMXTYyl0v1rmnmISr55aS2g8qyaHCVLWNCgwK5Imly2VtHU AGmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OnCbwXhM9/o/J8yHFW89wxfhUkfvaIKD6NjXHeW3Thc=; b=FhwChfqV/f+/51atJX5UP4XCsT9hd+gv+H+46FoDwLBUQziO9DnZUB4yp4W//I9aIe sMzTF0ZrvnDCq/MgjEbXDV4QQOxEp9aOWCF94RBNuE61mb80ldSGFAPWcGjYeg1S++8q Zj+pPd380ei3WYUu9r2plF5pSVS2OHW79LOYCsjcIWUxXIO8DhCZTmZyiqoyT4HLjobR ud0AwNzH7Nrr7AZ0HOnxUhn5ziBBBYAJ5os+cJoJtR2740Rv1fDDtpENL4Ltdh6PnCv9 /Vvy1vcEQ+mojvSaOUg5GUnQ2aLcU2dSOgX4wEbM2FOJcOPcLaElCGHuqn5ch8Zgmg+0 LKxw== X-Gm-Message-State: AOAM531VUyDKPZnxNab1WFgh2yppxN3QFGCGW5IBRdEU+BneIdh2lF4L a8nOXBydrOSwxqA93R/+P5mQlwbt4vdyyjvT X-Google-Smtp-Source: ABdhPJzOPlwrV4KBztxDpjk2OOtVeUftsqRz3XKwCpNs9rFa5aJ4ew+I/ou7uNyCiiOWO9jmBJECMQ== X-Received: by 2002:aa7:88c9:: with SMTP id k9mr1882623pff.58.1643265278574; Wed, 26 Jan 2022 22:34:38 -0800 (PST) Received: from localhost.localdomain (alanje.lnk.telstra.net. [120.151.179.201]) by smtp.gmail.com with ESMTPSA id y20sm4231855pfi.78.2022.01.26.22.34.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jan 2022 22:34:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 2/4] target/arm: Tidy sve_exception_el for CPACR_EL1 access Date: Thu, 27 Jan 2022 17:34:26 +1100 Message-Id: <20220127063428.30212-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127063428.30212-1-richard.henderson@linaro.org> References: <20220127063428.30212-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::436 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yuzenghui@huawei.com, peter.maydell@linaro.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Extract entire fields for ZEN and FPEN, rather than testing specific bits. This makes it easier to follow the code versus the ARM spec. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Reviewed-by: Zenghui Yu --- target/arm/helper.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index d9ee2ba5f4..cd48560786 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6154,30 +6154,28 @@ int sve_exception_el(CPUARMState *env, int el) uint64_t hcr_el2 = arm_hcr_el2_eff(env); if (el <= 1 && (hcr_el2 & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { - bool disabled = false; - - /* The CPACR.ZEN controls traps to EL1: - * 0, 2 : trap EL0 and EL1 accesses - * 1 : trap only EL0 accesses - * 3 : trap no accesses - */ - if (!extract32(env->cp15.cpacr_el1, 16, 1)) { - disabled = true; - } else if (!extract32(env->cp15.cpacr_el1, 17, 1)) { - disabled = el == 0; - } - if (disabled) { + /* Check CPACR.ZEN. */ + switch (extract32(env->cp15.cpacr_el1, 16, 2)) { + case 1: + if (el != 0) { + break; + } + /* fall through */ + case 0: + case 2: /* route_to_el2 */ return hcr_el2 & HCR_TGE ? 2 : 1; } /* Check CPACR.FPEN. */ - if (!extract32(env->cp15.cpacr_el1, 20, 1)) { - disabled = true; - } else if (!extract32(env->cp15.cpacr_el1, 21, 1)) { - disabled = el == 0; - } - if (disabled) { + switch (extract32(env->cp15.cpacr_el1, 20, 2)) { + case 1: + if (el != 0) { + break; + } + /* fall through */ + case 0: + case 2: return 0; } } From patchwork Thu Jan 27 06:34:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12726367 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B52C4C433EF for ; Thu, 27 Jan 2022 07:39:07 +0000 (UTC) Received: from localhost ([::1]:49830 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCzN4-0000R9-7I for qemu-devel@archiver.kernel.org; Thu, 27 Jan 2022 02:39:06 -0500 Received: from eggs.gnu.org ([209.51.188.92]:38996) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCyMz-00046W-JK for qemu-devel@nongnu.org; Thu, 27 Jan 2022 01:35:01 -0500 Received: from [2607:f8b0:4864:20::1033] (port=39636 helo=mail-pj1-x1033.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCyMo-0005jF-By for qemu-devel@nongnu.org; Thu, 27 Jan 2022 01:34:57 -0500 Received: by mail-pj1-x1033.google.com with SMTP id s61-20020a17090a69c300b001b4d0427ea2so6576739pjj.4 for ; Wed, 26 Jan 2022 22:34:42 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=HwDFJsijN3KKV3amxkEWOLWADJe1maxxFGeKyIOR3PU=; b=V1p00VeweS5Uc25Ad+3Wyy6haEL+ELgetSOoQ/vE2U+hHCGLkfqgzl2yyRm0Olhanv tqeqpX8ykPgUYBzmTZAGheH2iwFgcCqSoBubwOu45eys0c5G48Gr54hVq8tRBbWGZu2u Z1zew06GdwO+Gfjx/ct2gtLeXGp9jwkTWEowqW6UdqIpd/oMj8+J+qbQaWHu35VTV7k/ 2PdQDx5YKzzvdpBWKTBi32Dl3A3YS0TTCQxKHw8ywryLKVy6rrvBs4KVt5g5efe8zDTr P9FSwLuvB2/CYMCRPsgb111fJkcFN6Kbos+jNuW4YekdO/VP+QKDhkd8z/m5Hgxnc+SD yBrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HwDFJsijN3KKV3amxkEWOLWADJe1maxxFGeKyIOR3PU=; b=sWS2goHXz5fHtmcJs6o7rxLofQ/wTY0Uy+u5nyGjfha8xmMIkQPl7jB6iL3Z8fvoIi fzCSvZdkkBzSZzOPa6o/W5eGjh01x1gKmrSQDTwd/jG4uA+Ir/WJYI75Lv4d9+oAh3rh 6s+lDSFhFIFB0HImrke4BT+sZcB8W5RKmkvJuXmIk8+RQS6XyeHnqrlx6jxeK/rINWSt +GbGdyBfg6eVotwSrd0JvQAvBaVYSV3CpBzq4DTFxjwwQ7XJ37nMvg+N3Eqrq0bMSnd3 9xvaX/ganOPf1PcWRfYwOLTWJXnh647EtwoVqy5aUznBPF0ijI8fpTanG8Lzamli4XFQ rtyg== X-Gm-Message-State: AOAM533PBADZu7rbJVhSgUtVkt3XX9H+9bfUEwB948Bj5Loh0HZfKZ83 HykatyZkgzuxgMzveGizus2kiVpVrsNEnOQY X-Google-Smtp-Source: ABdhPJz0o9ofx5/lFnsE1a4CtbXOKyNL3TwpvVaia1UzXuRyHVa17jJ+pRn9cv/sPOBLe0sVWqVdsg== X-Received: by 2002:a17:90b:1b52:: with SMTP id nv18mr3718066pjb.136.1643265281039; Wed, 26 Jan 2022 22:34:41 -0800 (PST) Received: from localhost.localdomain (alanje.lnk.telstra.net. [120.151.179.201]) by smtp.gmail.com with ESMTPSA id y20sm4231855pfi.78.2022.01.26.22.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jan 2022 22:34:40 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 3/4] target/arm: Fix {fp, sve}_exception_el for VHE mode running Date: Thu, 27 Jan 2022 17:34:27 +1100 Message-Id: <20220127063428.30212-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127063428.30212-1-richard.henderson@linaro.org> References: <20220127063428.30212-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::1033 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::1033; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1033.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yuzenghui@huawei.com, peter.maydell@linaro.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" When HCR_EL2.E2H is set, the format of CPTR_EL2 changes to look more like CPACR_EL1, with ZEN and FPEN fields instead of TZ and TFP fields. Reported-by: Zenghui Yu Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- target/arm/helper.c | 77 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 17 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index cd48560786..ca916139e8 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6180,15 +6180,41 @@ int sve_exception_el(CPUARMState *env, int el) } } - /* CPTR_EL2. Since TZ and TFP are positive, - * they will be zero when EL2 is not present. + /* + * CPTR_EL2 changes format with HCR_EL2.E2H (regardless of TGE). */ - if (el <= 2 && arm_is_el2_enabled(env)) { - if (env->cp15.cptr_el[2] & CPTR_TZ) { - return 2; - } - if (env->cp15.cptr_el[2] & CPTR_TFP) { - return 0; + if (el <= 2) { + if (hcr_el2 & HCR_E2H) { + /* Check CPTR_EL2.ZEN. */ + switch (extract32(env->cp15.cptr_el[2], 16, 2)) { + case 1: + if (el != 0 || !(hcr_el2 & HCR_TGE)) { + break; + } + /* fall through */ + case 0: + case 2: + return 2; + } + + /* Check CPTR_EL2.FPEN. */ + switch (extract32(env->cp15.cptr_el[2], 20, 2)) { + case 1: + if (el == 2 || !(hcr_el2 & HCR_TGE)) { + break; + } + /* fall through */ + case 0: + case 2: + return 0; + } + } else if (arm_is_el2_enabled(env)) { + if (env->cp15.cptr_el[2] & CPTR_TZ) { + return 2; + } + if (env->cp15.cptr_el[2] & CPTR_TFP) { + return 0; + } } } @@ -12909,6 +12935,8 @@ uint32_t HELPER(crc32c)(uint32_t acc, uint32_t val, uint32_t bytes) int fp_exception_el(CPUARMState *env, int cur_el) { #ifndef CONFIG_USER_ONLY + uint64_t hcr_el2; + /* CPACR and the CPTR registers don't exist before v6, so FP is * always accessible */ @@ -12932,13 +12960,15 @@ int fp_exception_el(CPUARMState *env, int cur_el) return 0; } + hcr_el2 = arm_hcr_el2_eff(env); + /* The CPACR controls traps to EL1, or PL1 if we're 32 bit: * 0, 2 : trap EL0 and EL1/PL1 accesses * 1 : trap only EL0 accesses * 3 : trap no accesses * This register is ignored if E2H+TGE are both set. */ - if ((arm_hcr_el2_eff(env) & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { + if ((hcr_el2 & (HCR_E2H | HCR_TGE)) != (HCR_E2H | HCR_TGE)) { int fpen = extract32(env->cp15.cpacr_el1, 20, 2); switch (fpen) { @@ -12979,15 +13009,28 @@ int fp_exception_el(CPUARMState *env, int cur_el) } } - /* For the CPTR registers we don't need to guard with an ARM_FEATURE - * check because zero bits in the registers mean "don't trap". + /* + * CPTR_EL2 is present in v7VE or v8, and changes format + * with HCR_EL2.E2H (regardless of TGE). */ - - /* CPTR_EL2 : present in v7VE or v8 */ - if (cur_el <= 2 && extract32(env->cp15.cptr_el[2], 10, 1) - && arm_is_el2_enabled(env)) { - /* Trap FP ops at EL2, NS-EL1 or NS-EL0 to EL2 */ - return 2; + if (cur_el <= 2) { + if (hcr_el2 & HCR_E2H) { + /* Check CPTR_EL2.FPEN. */ + switch (extract32(env->cp15.cptr_el[2], 20, 2)) { + case 1: + if (cur_el != 0 || !(hcr_el2 & HCR_TGE)) { + break; + } + /* fall through */ + case 0: + case 2: + return 2; + } + } else if (arm_is_el2_enabled(env)) { + if (env->cp15.cptr_el[2] & CPTR_TFP) { + return 2; + } + } } /* CPTR_EL3 : present in v8 */ From patchwork Thu Jan 27 06:34:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 12726359 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5D481C433F5 for ; Thu, 27 Jan 2022 07:30:25 +0000 (UTC) Received: from localhost ([::1]:42834 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nCzEd-0003mz-QF for qemu-devel@archiver.kernel.org; Thu, 27 Jan 2022 02:30:23 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nCyN0-00046X-Ih for qemu-devel@nongnu.org; Thu, 27 Jan 2022 01:35:01 -0500 Received: from [2607:f8b0:4864:20::530] (port=46873 helo=mail-pg1-x530.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nCyMt-0005jV-OJ for qemu-devel@nongnu.org; Thu, 27 Jan 2022 01:34:58 -0500 Received: by mail-pg1-x530.google.com with SMTP id s16so1355349pgs.13 for ; Wed, 26 Jan 2022 22:34:44 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=JU8yAS18Zn8UE6eQ0birh8Z76witKI8Q/wDr72MGSnc=; b=eYkUEFBKjjlKEVHDUtsYLfpArcC4einqAF8n6EINI5zI+s0lHfF+Jk64CneThSUa5Y G0WbTDCpAVxlgQ4/izbPAu7Jvl8mFu6oauaF8W3R+ujx1+OabMGYDqAKvsKK3CksoEgM DATuJOLfTuFpZeaWoMWypFRUSW8c9n6FSkwwJIPwTOKYwy0zWu6frARq3fIfhtu1ce+g 0/eKDFRrQ/ez+2uIcTbBqfwl4K3qtBBM4GMmnsAfEhg/YpoMTWsETPnA/eFIgrv27ZOx 0J119hVLFVaaHP9/j8TA7OecZFRNggTv2rST8Ob5OcGwnhfnOUvlqOw4LrBzbr7jMPj0 mmYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JU8yAS18Zn8UE6eQ0birh8Z76witKI8Q/wDr72MGSnc=; b=LWLR1dttHzUVmIWVEeNQbP2SL9uDcoRfbsiMmTqq/jHeMVwI+fnh2WmsDj8w6BZ1aY aJ9K4SypgKz1WRRSP7Spg0VwR8Ej93Lc8RNSrJHWKC4rx/XLYPcIRRAzmgH1F8yaYLaL 55P9NL66ODUtUUslA4LNOa2TY5JJSWHTiyyjDWx5qHNP5vK3LcDUIYYOFurOuzwe5s52 4x9opZB46dJtE+QiWU4Rclop8BpyJ2/FmBG5DGFZm6BX8MlTfv7QsKJxglIcKqvt3Ids pWXI7+e9VZwxa1bbv60eQTgF8n3sLnu9Ks6cwCWW0on+RnzwPNm9Ca8rzGTCgJJzLidT inXQ== X-Gm-Message-State: AOAM532ziV7YsVhhcwKY5q0tb2TmUrHTuRgZn8ghAiq5bdJ+66hch8g2 OdE7q9erIHjN2sokvDIv+ZGchxXFhxzGox74 X-Google-Smtp-Source: ABdhPJxM+dQ7qf/ebyZXlGq18T8+jqwRRZoYvkqnT+CZMyBP3j3KwhJjuMkZ96O0Kmked8B+pPaWXA== X-Received: by 2002:a63:690:: with SMTP id 138mr1794210pgg.364.1643265283401; Wed, 26 Jan 2022 22:34:43 -0800 (PST) Received: from localhost.localdomain (alanje.lnk.telstra.net. [120.151.179.201]) by smtp.gmail.com with ESMTPSA id y20sm4231855pfi.78.2022.01.26.22.34.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jan 2022 22:34:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH 4/4] target/arm: Use CPTR_TFP with CPTR_EL3 in fp_exception_el Date: Thu, 27 Jan 2022 17:34:28 +1100 Message-Id: <20220127063428.30212-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220127063428.30212-1-richard.henderson@linaro.org> References: <20220127063428.30212-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::530 (failed) Received-SPF: pass client-ip=2607:f8b0:4864:20::530; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x530.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yuzenghui@huawei.com, peter.maydell@linaro.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" Use the named bit rather than a bare extract32. Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell Reviewed-by: Zenghui Yu --- target/arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index ca916139e8..5610879680 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -13034,7 +13034,7 @@ int fp_exception_el(CPUARMState *env, int cur_el) } /* CPTR_EL3 : present in v8 */ - if (extract32(env->cp15.cptr_el[3], 10, 1)) { + if (env->cp15.cptr_el[3] & CPTR_TFP) { /* Trap all FP ops to EL3 */ return 3; }