From patchwork Mon Feb 27 22:58:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 657135 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp2614860wrb; Mon, 27 Feb 2023 15:00:01 -0800 (PST) X-Google-Smtp-Source: AK7set+2TOqDE1BUsLyIdp8qlhH58mkCpm06ettJE89h4009eqs2wROv5fxhKF2IAKuJNA/OaR+d X-Received: by 2002:ac8:5acb:0:b0:3a6:8f7c:5936 with SMTP id d11-20020ac85acb000000b003a68f7c5936mr1717161qtd.25.1677538801072; Mon, 27 Feb 2023 15:00:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677538801; cv=none; d=google.com; s=arc-20160816; b=whsKCjg5pZ5puVVu23QrWn4HBhIxeDVw66dQX8u+8GJVzUnimFIPnJsYMpmGqnL541 YvQFJLbJnUm4VZLoIcwqWYf635k83FTMmYM0yjLuxwVdQ9f1HuOxsDicBAD+ZXQ7BuXX o01+wH9XhbiU5fs//8Qnh4zELCIocCjcdbg887HC2NFaxsxuSkal7ZNnx5VOe60XHOVK RMRROujuaGkRkiYr4pPSzAdioRiQnMSGF6zZIrnp5Twx6RmT+muRnptyV/5rmIyCuHLX olgMF31kOmMOrPiLFWD5IhBOTpPEpPw/+2Loxy//CNMK2GEY9w9CAmtcQVCa6TOoyEJq zymw== 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=pUw/Q9WV6uI2o5+wRzg6/DeRVdVBmeUlUspfEoqm0lE=; b=KqzBIagpMZVrQZsPhwU7Sn6JnLq3ics6sNl8BnaiJ/ljOKtfQu87SmPfGtl5r5yzA3 9AoDDTU0DQQYF2w6oEgkLdJhecH0wg6V3+bmm2aAxM2j/0GX4InNzOCG+VrYGxTwNtdQ ad8E2nbS7Y3zQrhz85+j9Tif/nYwkfRLI5L+HTfVFg81Xen1wPtONssvMJFPf8tm3/bb bL2UjsDhEltfO4KtgHW140G7HfuBDEIsynQcwgQqiL67HZmw9gkY7ONewYKXRUnk784Q uw4QK5qrGYuxFlG9qc1iFH9aqaIGOCTpuMEfDjcSkT8uYKD6n2SUULT5LCfzH4zUtr1z X3kA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vECubhlK; 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 u14-20020a05620a454e00b0073b83b0eccbsi8096720qkp.296.2023.02.27.15.00.00 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Feb 2023 15:00:01 -0800 (PST) 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=vECubhlK; 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] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pWmSD-0001RQ-5d; Mon, 27 Feb 2023 17:58:45 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pWmSB-0001Q8-KW for qemu-devel@nongnu.org; Mon, 27 Feb 2023 17:58:43 -0500 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pWmSA-0008Vc-2F for qemu-devel@nongnu.org; Mon, 27 Feb 2023 17:58:43 -0500 Received: by mail-pl1-x62e.google.com with SMTP id i3so8492199plg.6 for ; Mon, 27 Feb 2023 14:58:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=pUw/Q9WV6uI2o5+wRzg6/DeRVdVBmeUlUspfEoqm0lE=; b=vECubhlKRdQsN3lP8ZDYsjEKaVPJU7IbO2Bi8mzQPB6UOv7S2WTn3+w4fr8Ba6PlJ5 0B+EkahIrihV88wCB5zYCRFbUWLtnSNNXB1mYZ9aFE8o7QXF16rw9yZc6ADmhKLhUVeS Qpx2TZfgco2oVSGtNVcIDADi3VdreXHMHyL8H3BRWrs6015roN0+dKGPdQP1+wNLehwz 2Pm1zbVWyI4zZrvo+glxMCmJmEj2KK/NqvdUv5Sl6w7uxewrQ4PxjOpO5U9FT8orU81g H6BPHLWOcjdL91Hpv5L9FnvN5wH58IUvub6HhLpJ9qZgxDcUoAlCppOMf3Lm1S3pOchS xx6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=pUw/Q9WV6uI2o5+wRzg6/DeRVdVBmeUlUspfEoqm0lE=; b=TFWK/RHtlP8U3N7qUTr+i7CADVinQFV8aIdWLo0W7IrkIqKoNeGLcqzgOrlChvjIHO ARqmQ3LA+Gjkx3hxgTyHK4BnbP6zgqLK0SWH7hO593UXHbjR4qO6Q4cQUuVodLtYQZY0 fIUAbd0qlATj1J8U7Sgvu7Ls9sAM1a0JsRjHSTLGkHRqnPkViGI/B2/hOnpybMk65j61 KtOCGwfL2khM7pENhh0iXBRf0YuWBjYrmbLbARSaOSihIl/ZYHUHuS3XRsQP0S+hmOEj YcBf8zi+uGQL5k3AbahLtWaZGT0E297c6sb7EsOCc5nHl6DTMnGwg+GbQAUXE3QcTRvj c/0w== X-Gm-Message-State: AO0yUKXQ3H3R/U0eUvdj8qVqed6z1V1Db27DfL18fXtVsFtrPgkirgpP FrzSXkMz+xSO6gtKo1EDbr5nvN/Z06Qon8FTNE4= X-Received: by 2002:a05:6a20:691b:b0:cd:a358:bb7 with SMTP id q27-20020a056a20691b00b000cda3580bb7mr972153pzj.37.1677538720613; Mon, 27 Feb 2023 14:58:40 -0800 (PST) Received: from stoup.. (rrcs-173-198-77-218.west.biz.rr.com. [173.198.77.218]) by smtp.gmail.com with ESMTPSA id c2-20020a6566c2000000b00503000f0492sm4441050pgw.14.2023.02.27.14.58.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 14:58:40 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH for-8.0 v4 3/4] target/arm: Diagnose incorrect usage of arm_is_secure subroutines Date: Mon, 27 Feb 2023 12:58:31 -1000 Message-Id: <20230227225832.816605-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230227225832.816605-1-richard.henderson@linaro.org> References: <20230227225832.816605-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::62e; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x62e.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 autolearn=unavailable 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-bounces+patch=linaro.org@nongnu.org In several places we use arm_is_secure_below_el3 and arm_is_el3_or_mon separately from arm_is_secure. These functions make no sense for m-profile, and would indicate prior incorrect feature testing. Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson --- target/arm/cpu.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 7a2f804aeb..cb4e405f04 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2389,7 +2389,8 @@ static inline int arm_feature(CPUARMState *env, int feature) void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp); #if !defined(CONFIG_USER_ONLY) -/* Return true if exception levels below EL3 are in secure state, +/* + * Return true if exception levels below EL3 are in secure state, * or would be following an exception return to that level. * Unlike arm_is_secure() (which is always a question about the * _current_ state of the CPU) this doesn't care about the current @@ -2397,6 +2398,7 @@ void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp); */ static inline bool arm_is_secure_below_el3(CPUARMState *env) { + assert(!arm_feature(env, ARM_FEATURE_M)); if (arm_feature(env, ARM_FEATURE_EL3)) { return !(env->cp15.scr_el3 & SCR_NS); } else { @@ -2410,6 +2412,7 @@ static inline bool arm_is_secure_below_el3(CPUARMState *env) /* Return true if the CPU is AArch64 EL3 or AArch32 Mon */ static inline bool arm_is_el3_or_mon(CPUARMState *env) { + assert(!arm_feature(env, ARM_FEATURE_M)); if (arm_feature(env, ARM_FEATURE_EL3)) { if (is_a64(env) && extract32(env->pstate, 2, 2) == 3) { /* CPU currently in AArch64 state and EL3 */