From nobody Tue Feb 10 13:18:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1544454425099117.58360962940856; Mon, 10 Dec 2018 07:07:05 -0800 (PST) Received: from localhost ([::1]:33216 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWN9A-0003aj-TG for importer@patchew.org; Mon, 10 Dec 2018 10:07:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gWN7N-0002gS-Lc for qemu-devel@nongnu.org; Mon, 10 Dec 2018 10:05:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gWN7M-0003jb-8h for qemu-devel@nongnu.org; Mon, 10 Dec 2018 10:05:09 -0500 Received: from mail-oi1-x242.google.com ([2607:f8b0:4864:20::242]:46252) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gWN7M-0003jL-3E for qemu-devel@nongnu.org; Mon, 10 Dec 2018 10:05:08 -0500 Received: by mail-oi1-x242.google.com with SMTP id x202so9156102oif.13 for ; Mon, 10 Dec 2018 07:05:08 -0800 (PST) Received: from cloudburst.twiddle.net ([187.217.227.243]) by smtp.gmail.com with ESMTPSA id b18sm5694734oii.51.2018.12.10.07.05.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 10 Dec 2018 07:05:06 -0800 (PST) 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=CkPc61eIpCVWmyDPgstZ8J1bd1SqGM9XNiDjV1wFZ/Q=; b=RFh4+ZysfxLkhz2WOLTcLpaadSic8XXIzPGSZjRKWMpw3fn6jOjxHdf33++ZkYSdTJ CYUE+HbXLhCy/PEXkgJE9QPgXjB3Z9I6221RQFFp424d1QOzFHro8O/XoVbnSQ3HLYFn XMbTcoupyJTitHDB1tqFShBdDiRCdNy44ZnjY= 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=CkPc61eIpCVWmyDPgstZ8J1bd1SqGM9XNiDjV1wFZ/Q=; b=f4S4jG3WlFav5FYlJBSQTUkYGXhekjggYBFOt3B9X9FGTitbp7KOLo3vWRTqAGH809 3p0oCZEyN3eHsgyT4CTSArI2C4Bmx+cO0lhukhQ2LOtmgOLg45KIqOWJP8M4fRJryquK JgGOsBNwDo3UZjOPjoXUGu7D+AWOZPeSA5hq71yaCMLcDFNfhesvOXEmb/Y9+sR51yej bAa22JOlBHdd4zbVB2jeKOK6/rxWUpFDnmIwS7nvT6hNC8bGYTzsmD5uz5dtqtjvJ96T m9oLkcn3YEuA28VMeAAGp7oKxVrAS6M8Nr5WcSH16/ZGFvWa/NCF7vfz2qK9TLZPGqFe MAhg== X-Gm-Message-State: AA+aEWaY7yt96czoZOEqDg2noW8dPZLqolxiLuiGSPWN/Y8cg5P2nS4b Mxd1eg2f7YrpLZIv7WSpo1a5AssEMtBeSA== X-Google-Smtp-Source: AFSGD/WvbuZJaZzj9CXxPgDp9bJCfdGuKMrN2CEjKwTLe0kT3DZPYrH6pc23T/fq+lokYbhp8E4/hg== X-Received: by 2002:aca:bf06:: with SMTP id p6mr7139085oif.269.1544454306818; Mon, 10 Dec 2018 07:05:06 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 10 Dec 2018 09:05:00 -0600 Message-Id: <20181210150501.7990-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181210150501.7990-1-richard.henderson@linaro.org> References: <20181210150501.7990-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::242 Subject: [Qemu-devel] [PATCH v4 2/3] target/arm: Use arm_hcr_el2_eff more places 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Since arm_hcr_el2_eff includes a check against arm_is_secure_below_el3, we can often remove a nearby check against secure state. In some cases, sort the call to arm_hcr_el2_eff to the end of a short-circuit logical sequence. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- v3: Do not change regime_translation_disabled. --- target/arm/helper.c | 12 +++++------- target/arm/op_helper.c | 14 ++++++-------- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/target/arm/helper.c b/target/arm/helper.c index 95d59e07fb..d6f8be9f4e 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -448,7 +448,7 @@ static CPAccessResult access_tdosa(CPUARMState *env, co= nst ARMCPRegInfo *ri, int el =3D arm_current_el(env); bool mdcr_el2_tdosa =3D (env->cp15.mdcr_el2 & MDCR_TDOSA) || (env->cp15.mdcr_el2 & MDCR_TDE) || - (env->cp15.hcr_el2 & HCR_TGE); + (arm_hcr_el2_eff(env) & HCR_TGE); =20 if (el < 2 && mdcr_el2_tdosa && !arm_is_secure_below_el3(env)) { return CP_ACCESS_TRAP_EL2; @@ -468,7 +468,7 @@ static CPAccessResult access_tdra(CPUARMState *env, con= st ARMCPRegInfo *ri, int el =3D arm_current_el(env); bool mdcr_el2_tdra =3D (env->cp15.mdcr_el2 & MDCR_TDRA) || (env->cp15.mdcr_el2 & MDCR_TDE) || - (env->cp15.hcr_el2 & HCR_TGE); + (arm_hcr_el2_eff(env) & HCR_TGE); =20 if (el < 2 && mdcr_el2_tdra && !arm_is_secure_below_el3(env)) { return CP_ACCESS_TRAP_EL2; @@ -488,7 +488,7 @@ static CPAccessResult access_tda(CPUARMState *env, cons= t ARMCPRegInfo *ri, int el =3D arm_current_el(env); bool mdcr_el2_tda =3D (env->cp15.mdcr_el2 & MDCR_TDA) || (env->cp15.mdcr_el2 & MDCR_TDE) || - (env->cp15.hcr_el2 & HCR_TGE); + (arm_hcr_el2_eff(env) & HCR_TGE); =20 if (el < 2 && mdcr_el2_tda && !arm_is_secure_below_el3(env)) { return CP_ACCESS_TRAP_EL2; @@ -4566,8 +4566,7 @@ int sve_exception_el(CPUARMState *env, int el) if (disabled) { /* route_to_el2 */ return (arm_feature(env, ARM_FEATURE_EL2) - && !arm_is_secure(env) - && (env->cp15.hcr_el2 & HCR_TGE) ? 2 : 1); + && (arm_hcr_el2_eff(env) & HCR_TGE) ? 2 : 1); } =20 /* Check CPACR.FPEN. */ @@ -6216,9 +6215,8 @@ static int bad_mode_switch(CPUARMState *env, int mode= , CPSRWriteType write_type) * and CPS are treated as illegal mode changes. */ if (write_type =3D=3D CPSRWriteByInstr && - (env->cp15.hcr_el2 & HCR_TGE) && (env->uncached_cpsr & CPSR_M) =3D=3D ARM_CPU_MODE_MON && - !arm_is_secure_below_el3(env)) { + (arm_hcr_el2_eff(env) & HCR_TGE)) { return 1; } return 0; diff --git a/target/arm/op_helper.c b/target/arm/op_helper.c index 0d6e89e474..ef72361a36 100644 --- a/target/arm/op_helper.c +++ b/target/arm/op_helper.c @@ -33,8 +33,7 @@ void raise_exception(CPUARMState *env, uint32_t excp, { CPUState *cs =3D CPU(arm_env_get_cpu(env)); =20 - if ((env->cp15.hcr_el2 & HCR_TGE) && - target_el =3D=3D 1 && !arm_is_secure(env)) { + if (target_el =3D=3D 1 && (arm_hcr_el2_eff(env) & HCR_TGE)) { /* * Redirect NS EL1 exceptions to NS EL2. These are reported with * their original syndrome register value, with the exception of @@ -428,9 +427,9 @@ static inline int check_wfx_trap(CPUARMState *env, bool= is_wfe) * No need for ARM_FEATURE check as if HCR_EL2 doesn't exist the * bits will be zero indicating no trap. */ - if (cur_el < 2 && !arm_is_secure(env)) { - mask =3D (is_wfe) ? HCR_TWE : HCR_TWI; - if (env->cp15.hcr_el2 & mask) { + if (cur_el < 2) { + mask =3D is_wfe ? HCR_TWE : HCR_TWI; + if (arm_hcr_el2_eff(env) & mask) { return 2; } } @@ -995,7 +994,7 @@ void HELPER(pre_smc)(CPUARMState *env, uint32_t syndrom= e) exception_target_el(env)); } =20 - if (!secure && cur_el =3D=3D 1 && (env->cp15.hcr_el2 & HCR_TSC)) { + if (cur_el =3D=3D 1 && (arm_hcr_el2_eff(env) & HCR_TSC)) { /* In NS EL1, HCR controlled routing to EL2 has priority over SMD. * We also want an EL2 guest to be able to forbid its EL1 from * making PSCI calls into QEMU's "firmware" via HCR.TSC. @@ -1098,8 +1097,7 @@ void HELPER(exception_return)(CPUARMState *env) goto illegal_return; } =20 - if (new_el =3D=3D 1 && (env->cp15.hcr_el2 & HCR_TGE) - && !arm_is_secure_below_el3(env)) { + if (new_el =3D=3D 1 && (arm_hcr_el2_eff(env) & HCR_TGE)) { goto illegal_return; } =20 --=20 2.17.2