From patchwork Fri Oct 5 17:53:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 148273 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp747867lji; Fri, 5 Oct 2018 10:57:04 -0700 (PDT) X-Google-Smtp-Source: ACcGV60GwjQApOWA0j5aiVf4wDPY5fB7eYP5JZv8XrFn0C1kyeR/ggel9oQSgCaZTLTGIBCfIHla X-Received: by 2002:ac8:19ea:: with SMTP id s39-v6mr10494965qtk.215.1538762224895; Fri, 05 Oct 2018 10:57:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538762224; cv=none; d=google.com; s=arc-20160816; b=Z0RlNrMSmdpCiuSJDRi9HmXlfyfPuAEg3e7hw9znxzQcxhlL8+PzWbNd1szSuYkdaP KJFjSmb0Y6T77rxiDwX+nlnmyXg7AbCbgLWe5/E6HI2Pm6OczSWOsg66JCBdyAAGEwbg Wdq2NrAiUktYoJU5UVffBUNIA8cIVS1ThO17G1Zd+VY4CGYRN+UCe+LcINuYD5o4UiWB ixAhNMRKY1sPp523v+GASGK2BNIjGD9X8JymCetCMtF8L7nKeXM0Aaaw0vfZdYhSd2qW x6PhX7F4FRUcNevKAMPw2txkuRKjhNJ6HSKc7TdBjkcUfE/VUI65ng69qR7DQWCWNxfj dNTQ== 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; bh=7JcMGDXSJApERDq15iBwcrKLwrcDS2O+kXSvD0/ghx4=; b=b8s8+eCKj7vJ4oCZemzymLbb/CC8PqbWseBNJQEjkXV8Uywh8369ZF3inrhmlIK4F1 C8HDbGtgCiR2dj4NGR7Mz7olGPqcURag5RA2VUCS/KgcotrDi4I2nry+hu7n196rU8ic ciXUUTVITM5mfu8Y5RwLrYuUt//ybpstXhDzehCQkRwtimmfS09gEYlAcrtJNvWZeV1C 8Yokx08EWMLzJFDkoPBokqBh7ZlvFzw3zQ7SFB14lTXzinekuQkiKLNywTTeS93j9w0u p3ifh2FRs0JN0qBWqa9eKStGvhVFxe+PqE0Pliie2jU8osy9spWAurs6oOv1qRt9h07j KQTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=eRtvU5M+; 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 j123-v6si938940qkc.18.2018.10.05.10.57.04 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 05 Oct 2018 10:57:04 -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=eRtvU5M+; 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]:36345 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8ULY-0004Av-A1 for patch@linaro.org; Fri, 05 Oct 2018 13:57:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35382) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g8UIb-00011h-4H for qemu-devel@nongnu.org; Fri, 05 Oct 2018 13:54:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g8UIa-0003BP-4K for qemu-devel@nongnu.org; Fri, 05 Oct 2018 13:54:00 -0400 Received: from mail-oi1-x232.google.com ([2607:f8b0:4864:20::232]:44190) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g8UIZ-0003B2-SZ for qemu-devel@nongnu.org; Fri, 05 Oct 2018 13:54:00 -0400 Received: by mail-oi1-x232.google.com with SMTP id u74-v6so11054203oia.11 for ; Fri, 05 Oct 2018 10:53:59 -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=7JcMGDXSJApERDq15iBwcrKLwrcDS2O+kXSvD0/ghx4=; b=eRtvU5M+qbzLDIQp4OIb29jzpu2yojXQ5zYy2++IgxcG8/nGULmg4yaJYFCfG1sMou WLCe6aVYUT/VwGC33jEZMcNmTT2iWYZy0pSbxu5wbQyAdFzphc07JmYcrZ1h0i4IwwcL ciU8pdCCpfg21FzNiq0DIqdZ6l9zWlFTw374I= 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=7JcMGDXSJApERDq15iBwcrKLwrcDS2O+kXSvD0/ghx4=; b=LXcSODDAaNFPBt1DriTXT3je73Qxm/z6wZVpSTYi6N/t0j+rQRJu4XYJNZklHxOkzy 0Fssdg7Au8Ydih/bU7cP8IKhjT+25V25AixKcXZHOzaQKKWWEydcsU7IiREwlRYhDBS0 0qOMnoWpNoFpwtHPndW7zBiYXAkD/d86VEFfloxSk62DJgU3tSUNpwZdBX7yz/Rtxl4N nNH8fnX6QcScMacVhhb87L4ZFtIRTmHAVKzPY5Qsg+/Hg9A45o/j4Yjp3+7V6PUPxBG2 8C1hEHmuQgLYpOb1EKVXX6OgSBHI4l5/+Pu+KNtRlADvlKdbUTKXCy2cRuxFBsquOqJc zZ/g== X-Gm-Message-State: ABuFfoixHTJpTGF2rKbKJM3tFAhpssj0HUy+g/axN/ALUToA25G/N7xw gJHYvgHpPL9rCRmfOOMubaZjARhtUWkGqw== X-Received: by 2002:aca:e7d0:: with SMTP id e199-v6mr6160oih.187.1538762038711; Fri, 05 Oct 2018 10:53:58 -0700 (PDT) Received: from cloudburst.twiddle.net ([187.217.230.84]) by smtp.gmail.com with ESMTPSA id q10-v6sm2672278otg.31.2018.10.05.10.53.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 05 Oct 2018 10:53:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 5 Oct 2018 12:53:37 -0500 Message-Id: <20181005175350.30752-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181005175350.30752-1-richard.henderson@linaro.org> References: <20181005175350.30752-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::232 Subject: [Qemu-devel] [PATCH v3 02/15] 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: peter.maydell@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 Reviewed-by: Peter Maydell Tested-by: Laurent Desnogues Signed-off-by: Richard Henderson --- target/arm/helper.c | 96 ++++++++++++++++++++++----------------------- 1 file changed, 46 insertions(+), 50 deletions(-) -- 2.17.1 diff --git a/target/arm/helper.c b/target/arm/helper.c index ef85ef230a..38a9d32dc4 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4400,67 +4400,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