From patchwork Thu Aug 9 04:21:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 143657 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp1601831ljj; Wed, 8 Aug 2018 21:22:47 -0700 (PDT) X-Google-Smtp-Source: AA+uWPz1TdqSJ/giPaipp9C6X9hnlvJZGuCsoHfy6zVNtW+nqd6iVSzHBi2bF0c2Mrh1aSCP/pm8 X-Received: by 2002:ac8:2bb3:: with SMTP id m48-v6mr438158qtm.207.1533788567072; Wed, 08 Aug 2018 21:22:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533788567; cv=none; d=google.com; s=arc-20160816; b=wR4bc1gbULHN0IvMc+QIp07MhK9EPYM+xKSX4aCfCY4L2+IZOvj9bLZrwaYnVOjVL0 1DQef+FmQagbRAxFF6rWmZVoB7YMyniU8Cg9ozm+DNGCJbTUXz5Y7LGWhdrMJqh3k+UI fM8RMkwTS1xZcWz3MUeGji1sdET4mG7Y5chxOwULtJjT0JN+XSh+OEwkSJxLsoFmUTUc Ll05JJ+7qs17eIDyABMX0gvt141fuFe9lV8NlICjV4cUPKj5Q8h/Jn8YEpJ2FEOtTzr9 hyaIFx2Mi6RXt/CPs7V7iUn+dZYaHSQTE7RESTCJMhRf7BhMV20aGvWO9HEJrKt/JvfF 4JLw== 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=GHNmLdKb7IekLRFejxMlqEkz2+Rx9y/cL35+qY06ZJM=; b=iO/eo8ZnWeZ9Mlx237sMV4D1W4KRrgXmDUvWEg0Tj/38y+/XsAjMjdl8WLrzOzaZ7X VIWoM/cLdW96cVaozsoOc/e/3vPPD/hbjSFaZneUT3fhGLlMAxvOnaN02BjVrJ6kq4v1 Vrkn7vaD58mlmyJhfLMpOZyOhH7IkUyru3vtgdpirWcgVRFm9WwJ8YbASeZJ8nBbJWXs BMV3b+ROFhYfFGlcG3ImDBD68NNYDzdyldjHkUZ1WDPsHIC6cZgDz/qj5Kw54iGcJ5Gb fYly1ZryXt4NNOm6C5ErOp1R3KROdnTudOy1Wi+plQjGFgy8HF0PDBS3I5jH7EVrRHwn 8PHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=em5yQ7pL; 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 g2-v6si5175034qtj.99.2018.08.08.21.22.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 08 Aug 2018 21:22:47 -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=em5yQ7pL; 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]:47227 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fncTG-0000lY-Ce for patch@linaro.org; Thu, 09 Aug 2018 00:22:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fncSm-0000im-Im for qemu-devel@nongnu.org; Thu, 09 Aug 2018 00:22:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fncSl-00079t-Id for qemu-devel@nongnu.org; Thu, 09 Aug 2018 00:22:16 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]:36973) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fncSl-00079K-BP for qemu-devel@nongnu.org; Thu, 09 Aug 2018 00:22:15 -0400 Received: by mail-pf1-x42f.google.com with SMTP id a26-v6so2199430pfo.4 for ; Wed, 08 Aug 2018 21:22:15 -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=GHNmLdKb7IekLRFejxMlqEkz2+Rx9y/cL35+qY06ZJM=; b=em5yQ7pLvsBPoszuY7qqe8UwNH/udxcSZv7GQRxhL3qVe+mO0iGmwmePeroWGxB+1j Emiod/sDslAJNNdD7tnZyQfP8YxE+BhcUHRqf7bRptAiH/LBOJSmxXID+eSqe0Bd5Gty BE4Hw8pOu6GwI+glvstznL7oNHAbCiU3BNd64= 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=GHNmLdKb7IekLRFejxMlqEkz2+Rx9y/cL35+qY06ZJM=; b=B5a/PZS38Xcu23QzyhLimp4dG9IvvI/dd0Se+oIWb6pZTbJ9FUJFcTsp9MG8Z+l5+t lYYz7CBODR5fC3Qr9fu9Y5wzTzLiCSulRbad+K87u/vBNChVfMi1EbiwnTxx2I5umMNS /zE7A5GzSxaoqVCQ29tLX1/2HnV3mCoNYGqImWKsNhCMHKQ37jVwXLaTLE3p6NNyR6T6 asH9gl1fNC8zrSjKdcpjvjInHxydt8Vyuek6ykMkVszPCU+JMYiBd4z6VdDFx+WsjMHa 1nudVxDuw+dJyJRrab0wAlyB5b8nounnGo6TLsob+NQ8g9I7wdrilQdEmWITInQzvqJX axYw== X-Gm-Message-State: AOUpUlFQoJfShMiSFIPX8Z52JmNBEXSNSFrFjmdYdyz5KN9yGaClsJLy U62THde9hiNL+MUjyG2xlDq6+I/i3Jc= X-Received: by 2002:a62:d45d:: with SMTP id u29-v6mr568852pfl.51.1533788534103; Wed, 08 Aug 2018 21:22:14 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-8-179.tukw.qwest.net. [97.113.8.179]) by smtp.gmail.com with ESMTPSA id m30-v6sm7355799pff.121.2018.08.08.21.22.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Aug 2018 21:22:13 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 8 Aug 2018 21:21:50 -0700 Message-Id: <20180809042206.15726-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180809042206.15726-1-richard.henderson@linaro.org> References: <20180809042206.15726-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::42f Subject: [Qemu-devel] [PATCH 04/20] target/arm: Adjust sve_exception_el 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: laurent.desnogues@gmail.com, peter.maydell@linaro.org, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Check for EL3 before testing CPTR_EL3.EZ. Return 0 when the exception should be routed via AdvSIMDFPAccessTrap. Mirror the structure of CheckSVEEnabled more closely. Fixes: 5be5e8eda78 Signed-off-by: Richard Henderson --- target/arm/helper.c | 96 ++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 50 deletions(-) -- 2.17.1 Reviewed-by: Peter Maydell diff --git a/target/arm/helper.c b/target/arm/helper.c index 61a79e4c44..26e9098c5f 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4338,67 +4338,63 @@ static const ARMCPRegInfo debug_lpae_cp_reginfo[] = { REGINFO_SENTINEL }; -/* Return the exception level to which SVE-disabled exceptions should - * be taken, or 0 if SVE is enabled. +/* Return the exception level to which exceptions should be taken + * via SVEAccessTrap. If an exception should be routed through + * AArch64.AdvSIMDFPAccessTrap, return 0; fp_exception_el should + * take care of raising that exception. + * C.f. the ARM pseudocode function CheckSVEEnabled. */ static int sve_exception_el(CPUARMState *env) { #ifndef CONFIG_USER_ONLY unsigned current_el = arm_current_el(env); - /* The CPACR.ZEN controls traps to EL1: - * 0, 2 : trap EL0 and EL1 accesses - * 1 : trap only EL0 accesses - * 3 : trap no accesses + if (current_el <= 1) { + 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 = current_el == 0; + } + if (disabled) { + /* route_to_el2 */ + return (arm_feature(env, ARM_FEATURE_EL2) + && !arm_is_secure(env) + && (env->cp15.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 = current_el == 0; + } + if (disabled) { + return 0; + } + } + + /* CPTR_EL2. Since TZ and TFP are positive, + * they will be zero when EL2 is not present. */ - switch (extract32(env->cp15.cpacr_el1, 16, 2)) { - default: - if (current_el <= 1) { - /* Trap to PL1, which might be EL1 or EL3 */ - if (arm_is_secure(env) && !arm_el_is_aa64(env, 3)) { - return 3; - } - return 1; + if (current_el <= 2 && !arm_is_secure_below_el3(env)) { + if (env->cp15.cptr_el[2] & CPTR_TZ) { + return 2; } - break; - case 1: - if (current_el == 0) { - return 1; + if (env->cp15.cptr_el[2] & CPTR_TFP) { + return 0; } - break; - case 3: - break; } - /* Similarly for CPACR.FPEN, after having checked ZEN. */ - switch (extract32(env->cp15.cpacr_el1, 20, 2)) { - default: - if (current_el <= 1) { - if (arm_is_secure(env) && !arm_el_is_aa64(env, 3)) { - return 3; - } - return 1; - } - break; - case 1: - if (current_el == 0) { - return 1; - } - break; - case 3: - break; - } - - /* CPTR_EL2. Check both TZ and TFP. */ - if (current_el <= 2 - && (env->cp15.cptr_el[2] & (CPTR_TFP | CPTR_TZ)) - && !arm_is_secure_below_el3(env)) { - return 2; - } - - /* CPTR_EL3. Check both EZ and TFP. */ - if (!(env->cp15.cptr_el[3] & CPTR_EZ) - || (env->cp15.cptr_el[3] & CPTR_TFP)) { + /* CPTR_EL3. Since EZ is negative we must check for EL3. */ + if (arm_feature(env, ARM_FEATURE_EL3) + && !(env->cp15.cptr_el[3] & CPTR_EZ)) { return 3; } #endif