From patchwork Tue Jun 7 20:32:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 579325 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:5806:0:0:0:0 with SMTP id j6csp5493127max; Tue, 7 Jun 2022 13:39:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqw3nb9OCdpx1xhTMFu/l43aA/7cyiHzYi1yX53JWQP4DprRjlUxjf+460h1bmNtYrB0An X-Received: by 2002:a05:620a:895:b0:6a6:a15d:3018 with SMTP id b21-20020a05620a089500b006a6a15d3018mr15943917qka.451.1654634371123; Tue, 07 Jun 2022 13:39:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654634371; cv=none; d=google.com; s=arc-20160816; b=M/2aBEzU8d7YT7d6qkZERNZ2cGiM9tTBoKyTKsSw6IpkyVKWfongrlIkeUlnQtTAwy Hc46XYh37uWoM4YZHaTDcnwDZQL6JwBI1hGpEqjzQyLXiMTCwhRb9kBTi9mmoCrKvpRA BQ/+O06gp/5W+n1Epue58xWuTFOfQ0IPWDPGTPjXq0Ha4JG6DD5J7Q1ml19B39vCJZx+ AlrNJUBiqQNDj4NcNJnOfXoJHMc6Zy4JQ9muhVn8uWTV2wWde2JPlG9g4JzRygVfdQpg N70sP/EjA+lmpz4Q2slmvYq0Aeje2jJ/9qrn/xY1/wVDaI2vCxZDXhhqWjlI7zpQES98 sf8Q== 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=ReHRR17phjztnIWJ+KLGspDttklUzkMcS8o12wYY8cA=; b=CidC0VOZwda/6p8QfIcMh6gVzRPrY8IpzRBoTzSoTD7p3CZcmbbVQHWyWRk9yK2hq6 pKXQmjN7121M0NWsgiXbqBiqmDBIDIQwbnv4gc1UpUGreYA++BrXBBWpBBbF3Zutx9KC romJKuHfBYza53JRW63QUCiRYp7qtgSUVoR9R65qzn0NDUI4h+L662SzGWdk3TVcKWLm RNaZkV30f1N4WDCXyborNbsK0L9yuDczB0JqKRD0F94yYIPZF00byRoZ6EqLYjQR0M/C rMNxX9S98l6S4sm1FTxNhxbcfsZUO9zaQA/fCgz08FZIAjcc10GAKHObIVvcdTyA1b3z 0zMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="e9BN7/xS"; 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 a27-20020a0cb35b000000b004623a57b7a1si989469qvf.160.2022.06.07.13.39.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 07 Jun 2022 13:39:31 -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="e9BN7/xS"; 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]:54216 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nyfz8-0000U8-Ms for patch@linaro.org; Tue, 07 Jun 2022 16:39:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33570) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nyftD-0007WL-TS for qemu-devel@nongnu.org; Tue, 07 Jun 2022 16:33:23 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]:44594) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nyft7-0007ES-AV for qemu-devel@nongnu.org; Tue, 07 Jun 2022 16:33:23 -0400 Received: by mail-pf1-x42c.google.com with SMTP id g205so16481156pfb.11 for ; Tue, 07 Jun 2022 13:33:16 -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=ReHRR17phjztnIWJ+KLGspDttklUzkMcS8o12wYY8cA=; b=e9BN7/xSLuPtXuL6vRHjV9as0GFq/GnZODWXpriRnrJm3RvSAsqX9AdN8nZTIHxB+C DJ5LfEsRqjkCGIZ29Qoj8GEKwIvVcUbV8Eh9lqbIW4tE1zdpjNnJAbxi3RjN1JwofBft Tz9lZF+IwOIbawWLp88v8Xtc2pC20y+tx3+HfBvVjfm3zWRmmIFvNSGVw+lWI56B4K10 9fWOCzW88C6CumY6yK3MW504OkZT8ffKjbKdVG51lvYRzNDqe6nKa3PHksjZrJVHEnOE actxDmItbH/BF0XO2XMJVi3LQJd4VipkRForI2JcrwwykY1v2+wP/Mmotqu4RL+d/VrL LEbA== 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=ReHRR17phjztnIWJ+KLGspDttklUzkMcS8o12wYY8cA=; b=bhZDj/sWcQk2xglF9JQWcX3CUIZ+zhIrbzPFF1q7VB0MaxcwpK4IMUHHldf2DOpq1a meUjU0UroPAwjHk+p00aFL815ALyCwCN6sD+Nv6I2fHJzMeb1/iE2AzlegHCMa+U8N2x xhXSlKJUvPWC+bhtAxJyXzP6GCT7mElDMGZWyykZ4tLXojk1vNiS6TyE2FGJ2GMYwfj4 VrD0/iqw2YTwBDCLw9pf3m5YGtx+zsf9tJhb/vecsPWEf4BpCSHLQ66dY2vE8cl+/pfW zsq4SPU3ukU8Jgzly0FetPbqotXCpSKTPylJzmnr9W9VmPiC0c34GviXr3fQNSS0/OEg Q7bA== X-Gm-Message-State: AOAM5315nW4+vVYMSSanKLsEnEzA/uKrguRFhHIlEJrmJSZdHzQdhtqO K4K+wfkr95xz0rFv4oe3Q35Uwv9cMgvw/w== X-Received: by 2002:a63:5607:0:b0:3fc:910a:15e9 with SMTP id k7-20020a635607000000b003fc910a15e9mr26964535pgb.553.1654633994692; Tue, 07 Jun 2022 13:33:14 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 13:33:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, qemu-arm@nongnu.org Subject: [PATCH v2 08/71] target/arm: Hoist arm_is_el2_enabled check in sve_exception_el Date: Tue, 7 Jun 2022 13:32:03 -0700 Message-Id: <20220607203306.657998-9-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::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.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" This check is buried within arm_hcr_el2_eff(), but since we have to have the explicit check for CPTR_EL2.TZ, we might as well just check it once at the beginning of the block. Once this is done, we can test HCR_EL2.{E2H,TGE} directly, rather than going through arm_hcr_el2_eff(). Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/helper.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 7319c91fc2..dc8f1e44cc 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6193,15 +6193,12 @@ int sve_exception_el(CPUARMState *env, int el) } } - /* - * CPTR_EL2 changes format with HCR_EL2.E2H (regardless of TGE). - */ - if (el <= 2) { - uint64_t hcr_el2 = arm_hcr_el2_eff(env); - if (hcr_el2 & HCR_E2H) { + if (el <= 2 && arm_is_el2_enabled(env)) { + /* CPTR_EL2 changes format with HCR_EL2.E2H (regardless of TGE). */ + if (env->cp15.hcr_el2 & HCR_E2H) { switch (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, ZEN)) { case 1: - if (el != 0 || !(hcr_el2 & HCR_TGE)) { + if (el != 0 || !(env->cp15.hcr_el2 & HCR_TGE)) { break; } /* fall through */ @@ -6209,7 +6206,7 @@ int sve_exception_el(CPUARMState *env, int el) case 2: return 2; } - } else if (arm_is_el2_enabled(env)) { + } else { if (FIELD_EX64(env->cp15.cptr_el[2], CPTR_EL2, TZ)) { return 2; }