From patchwork Tue Jun 7 20:31:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 579324 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp5491980max; Tue, 7 Jun 2022 13:37:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqaWh10KVcW4f/vnRm990a5RBsxF/5uxh1vdrI4UILrQgm26B6dht1HmlhL7MPrCXCZXPV X-Received: by 2002:a05:6214:250d:b0:464:69ea:7725 with SMTP id gf13-20020a056214250d00b0046469ea7725mr27478154qvb.51.1654634267563; Tue, 07 Jun 2022 13:37:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654634267; cv=none; d=google.com; s=arc-20160816; b=HnKfnMKyjtp2o67g9ueBT7AB/Db97hZUGEDQmdE7+6c5zAMSRhdEWKjrRr5d1COSbf s3clot+7+kelhJvNzib/CI2x9kIgh6xgjRlB54+cn4X1uAdPga0W9NxB9qm9nqjRE3fo QTuUC4d4UGYLdJCNzHhZkBA8MLnrCW/Ux3SP/Eb5YlVk1iI7yDfHwWYWZeqUABQRdA1C t4H5XyiMwMreK3xjINbjZzsXSvrVC/qzgXJFzfjI7fVW5xr0lR1jbPvWuOzd+C8qWr2E js75bchQS3Y3fvP+Euemsmr9suSWmS2gOfMF3w5OEmW2Ot+XUyHWWFUyKjMPhqbHLN6/ 2tpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=e7CiA9DdlCOhWlL8CEoveJRO9oJ9GQCNXOqZts3HTb4=; b=t3XLcPoBI8swUfbGSsEve1WqW5yJv9rC3MD+JmZHAKb70n89PF0jV6ibrKsCUR0yP3 EbU9Mvrle9aR1VEVipSCFt+467n39Up2k1rf/A2s+6WbYnE3y1DP5P9SjeyfnqN6dfXO Eayq9zxIs1qoJ8CbylWXNcMjsiyBIi1qSNGygioBEf/yphQwazQoO5aBYum/uTPjqFBc tAExZOfsSELjo4cSxV4H9vLua0ss3UApq1OvanNiNdRc8r33Dtc9pmlu5iNWzCbc74iM atZy+m+2sYT7MdG4IDx/wR0QVFQvffb5qw4qahgA5aPq91BoYWyQFpI72beFGdHaeCtW YSOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J5l+3uNy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gw12-20020a0562140f0c00b00464562ac2d7si10547617qvb.327.2022.06.07.13.37.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 13:37:47 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=J5l+3uNy; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:49478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyfxT-0005WO-4L for patch@linaro.org; Tue, 07 Jun 2022 16:37:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33408) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyft9-0007LB-4B for qemu-devel@nongnu.org; Tue, 07 Jun 2022 16:33:19 -0400 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]:45954) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyft3-0007DT-TN for qemu-devel@nongnu.org; Tue, 07 Jun 2022 16:33:18 -0400 Received: by mail-pl1-x62b.google.com with SMTP id q18so15770169pln.12 for ; Tue, 07 Jun 2022 13:33:12 -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 :mime-version:content-transfer-encoding; bh=e7CiA9DdlCOhWlL8CEoveJRO9oJ9GQCNXOqZts3HTb4=; b=J5l+3uNyyW6MoPnfGXjWfbVBrdcuRdUBkBrsfu9urswiJraDqWhQr5kv0LIrqDutTR 0nM1Kv9UDP+b+8yFXywOa8r3m4bvV5MYJT1+L0lmnVAWnnUXeXiIfjOpwcBCJVV6hkr5 9zA0eRoncytGMjhIgaE6ivWfessl81U9fo3rqQBCCnkY8871I0eQgdIrtcv4fglIWS1l WP5zt7jo3wCHdbqdqyLxzZCt+JIBA/GB4EVEOjOx+W77BxtxSJeh+uD/3iB6lM40BdUg tJ3vWh7Co4dKSNfZSrzamh3RHs/X4BREesKAojQfunDDRKhRwrTdyPt0hsncA2d7+KJt XPag== 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=e7CiA9DdlCOhWlL8CEoveJRO9oJ9GQCNXOqZts3HTb4=; b=GPYL1kY9gr2Sqw4gY8ZajDqj6MbiYXfd4EUfuAA5rmc8CGnjtfObVi4V8v5HGLT7Au tL5s4t7yO7/rPXz0NXLzfh0PGerF373CcOl8bnXPmlqB/uZjy7UlNCm87uFOtvlT8MTC ff7oReoVbYazD9QS1wzvcUhafzegn70WFoD17703YgIlZAsxPbqqdKmDCkWeExb+fvE3 xM7OuZbFfW47E9OSbPAQagr9M7uyBrLjDtbfzKUr2wD4CQ/L6+X5UArT06Y1SXxedZ99 R85Nko1gu80OXEDUvAT/nfxJTdO2Iax8e94bEKfjTuyN4PMsbdoJ9ge1oai20aDsFdYd lmPg== X-Gm-Message-State: AOAM530RaOB1JIEF+ueiOTgEb8ZikNaWHvvE9YhIVVq40qa+hbHzeE34 cC326kUBb2t/n4GXYRT86Y9dIu9qih6NCA== X-Received: by 2002:a17:90b:350b:b0:1e8:5177:fe7d with SMTP id ls11-20020a17090b350b00b001e85177fe7dmr22022931pjb.142.1654633991509; Tue, 07 Jun 2022 13:33:11 -0700 (PDT) Received: from stoup.. ([2602:ae:1547:e101:3cf2:c634:5b19:25f6]) by smtp.gmail.com with ESMTPSA id s22-20020a17090aba1600b001d9780b7779sm4227856pjr.15.2022.06.07.13.33.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 13:33:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org Subject: [PATCH v2 04/71] target/arm: Remove fp checks from sve_exception_el Date: Tue, 7 Jun 2022 13:31:59 -0700 Message-Id: <20220607203306.657998-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220607203306.657998-1-richard.henderson@linaro.org> References: <20220607203306.657998-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62b; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Instead of checking these bits in fp_exception_el and also in sve_exception_el, document that we must compare the results. The only place where we have not already checked that FP EL is zero is in rebuild_hflags_a64. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/helper.c | 58 +++++++++++++++------------------------------ 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 8ace3ad533..bcf48f1b11 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6139,11 +6139,15 @@ static const ARMCPRegInfo minimal_ras_reginfo[] = { .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, cp15.vsesr_el2) }, }; -/* 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. +/* + * Return the exception level to which exceptions should be taken + * via SVEAccessTrap. This excludes the check for whether the exception + * should be routed through AArch64.AdvSIMDFPAccessTrap. That can easily + * be found by testing 0 < fp_exception_el < sve_exception_el. + * + * C.f. the ARM pseudocode function CheckSVEEnabled. Note that the + * pseudocode does *not* separate out the FP trap checks, but has them + * all in one function. */ int sve_exception_el(CPUARMState *env, int el) { @@ -6161,18 +6165,6 @@ int sve_exception_el(CPUARMState *env, int el) case 2: return 1; } - - /* Check CPACR.FPEN. */ - switch (FIELD_EX64(env->cp15.cpacr_el1, CPACR_EL1, FPEN)) { - case 1: - if (el != 0) { - break; - } - /* fall through */ - case 0: - case 2: - return 0; - } } /* @@ -6190,24 +6182,10 @@ int sve_exception_el(CPUARMState *env, int el) case 2: return 2; } - - switch (FIELD_EX32(env->cp15.cptr_el[2], CPTR_EL2, FPEN)) { - 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 (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, TZ)) { return 2; } - if (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, TFP)) { - return 0; - } } } @@ -13683,19 +13661,21 @@ static CPUARMTBFlags rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, if (cpu_isar_feature(aa64_sve, env_archcpu(env))) { int sve_el = sve_exception_el(env, el); - uint32_t zcr_len; /* - * If SVE is disabled, but FP is enabled, - * then the effective len is 0. + * If either FP or SVE are disabled, translator does not need len. + * If SVE EL > FP EL, FP exception has precedence, and translator + * does not need SVE EL. Save potential re-translations by forcing + * the unneeded data to zero. */ - if (sve_el != 0 && fp_el == 0) { - zcr_len = 0; - } else { - zcr_len = sve_zcr_len_for_el(env, el); + if (fp_el != 0) { + if (sve_el > fp_el) { + sve_el = 0; + } + } else if (sve_el == 0) { + DP_TBFLAG_A64(flags, VL, sve_zcr_len_for_el(env, el)); } DP_TBFLAG_A64(flags, SVEEXC_EL, sve_el); - DP_TBFLAG_A64(flags, VL, zcr_len); } sctlr = regime_sctlr(env, stage1);