From patchwork Wed Sep 26 19:23:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 147644 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp1109193lji; Wed, 26 Sep 2018 12:24:02 -0700 (PDT) X-Google-Smtp-Source: ACcGV62U142BKiBGW9ZASkMuFuwVF3P+xtRdqKufaK/7fSuFztAOs/kV1sJ0rg5JxuKROPqb28lX X-Received: by 2002:aed:3903:: with SMTP id l3-v6mr5854518qte.315.1537989842024; Wed, 26 Sep 2018 12:24:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537989842; cv=none; d=google.com; s=arc-20160816; b=Bds5Jlvw+lJAUi9hPIevPmoF+G0jPQBj85Fg35wOY46beYacV2i32Bg9MTGAWLAbVn 6n6YCBER2n5ngTcqyV0Zz/IBJbzVyrBkhQdmbdYkcmSYDDdEulccErEqVcjrRmGRsjHT eAu8E3MWCqM7EonoWQ5ibsLWtapjde07OjWZ2hVm35+8WQvYkT+zWcwztmdlsm4rg7fT wu11DcFbH4MZ0MqgbvwyB6sM8YFt3eQujPY86TbgwauDyutY+M9Io5di7JUlUKNmy5Pk r38nqTJDR8NsB/k2xObXWyj93/Ax7Tyn7lTB0Tcbm7P9r5+eA0Sajs9CycCiBh2ubENE LQdw== 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=jAjlxNVjb6tDjMBxlbOLmxzLm7nxIK1BhAMdl5XpufqbmDatEjWKxQ++62LTKPhSLJ lCzlrCUGMfkS3VD1DQredt/WfdsKHzFppQJ/Xk4oozutecRHDgc3blGBLd8ZaOtcH/06 R5e16K+Wl7zOEhtLeUwiPFK1ezADvhAZCTLTq2fwKp7B2CekkstezMj60x/fl1893c3g isHChEn6b+h3+IssQAJv3YAXAoOcTYLqRTBHcGPig+PGD52h+B3rH+jWljbTMB0qZcxD VPwhQqH/01PLEWv7d9B9E5mJPHZrNrlc4oxb7vlm0IMbRhwpmIgCaaPVDpZlQNVx6Sug 7A+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WRMKlRof; 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 h47-v6si552051qth.404.2018.09.26.12.24.01 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 26 Sep 2018 12:24:02 -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=WRMKlRof; 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]:60355 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5FPl-0001k7-15 for patch@linaro.org; Wed, 26 Sep 2018 15:24:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g5FPJ-0001hY-1l for qemu-devel@nongnu.org; Wed, 26 Sep 2018 15:23:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g5FPF-0006l4-8W for qemu-devel@nongnu.org; Wed, 26 Sep 2018 15:23:31 -0400 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:37044) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g5FPF-0006km-2W for qemu-devel@nongnu.org; Wed, 26 Sep 2018 15:23:29 -0400 Received: by mail-pf1-x433.google.com with SMTP id x26-v6so68416pfn.4 for ; Wed, 26 Sep 2018 12:23:28 -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=WRMKlRofXbmHGRgTnlCskD/yIbk1WCuJpfZc5sZdiBvWI253S6bfPFt9B8jafZN/2h G4bcf5eXfNCv3M9oV0xc8MHwDSrTodVrBff93Y5J8xpTNz9ulgo8d+eWUpko4Ub4rBrf INdc3fWWuIWZUiEum1rtr4vllcNuP3OBOqdFU= 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=c+g1igG7ShwyArOXo7YkDJ6oT2rrPh7N8ZDY7TIDDexhtuj5F4+bq2gXgUCYgsShDM qHDd/TdhVb9+k36tQWDE1TFRUtiSqwPEpTvToK8QxEgM6SgllGg+b1NH2nAyEEEanyr2 GqOCjYbK3ziahTruog/mqEz72OhYp5s4rSuBSjmJkk1+kN3Yvy7Vj1dMbBqVMvhQSxJX m7ZFgvAYyPIXMppnC0Di43dfVrQqMIP0/Sg0h0evNmspfBNvAfN1K8gqr1cLVoz7TUJS cNWoPJ21OgizJikwquk27rEdTPTQJ+jsdmXnt+IC2JU85btQnapeQg8vPvlr5BZpidve soZA== X-Gm-Message-State: ABuFfoha6ZOABupTumHF82tLPB5tbTFtrEZ/CDAeyPSkCNY6jNYOZRK/ UDaXB4W/7QOjL3KiM2Pq4MT8bwUZjI8= X-Received: by 2002:a62:4494:: with SMTP id m20-v6mr7742116pfi.205.1537989807707; Wed, 26 Sep 2018 12:23:27 -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 c2-v6sm8493486pfo.107.2018.09.26.12.23.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 26 Sep 2018 12:23:26 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Sep 2018 12:23:10 -0700 Message-Id: <20180926192323.12659-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180926192323.12659-1-richard.henderson@linaro.org> References: <20180926192323.12659-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::433 Subject: [Qemu-devel] [PATCH v2 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