From nobody Sun May 19 05:00:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677538786; cv=none; d=zohomail.com; s=zohoarc; b=S/mNxpiF7oV6Evzt8j2e5AtqKbBxeSKMUXYlp2cikTkND86JQ6DWnO6QJTS3vOXuCue6mRPKog8d46do3zB43PYP9oiDjZ9eg/MAMQJDtj7+lC6DQpneiSjVndiCGMR8DaiUKJYMkwVLYDAFuq+pNjT5DJfsgs5epn6QgklkJ/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677538786; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=q0fgtLVdBUMwB3yUfv+ziuHCcXc1on+zqZqgclTP9ko=; b=klcRhee8YoCqS2YahIKlJ1NnUEsWFVD6MPfezQUw4x+zTGyTxJvD9uEKqLwV4MfQuuODx58ZnhuO+rOAF0ztK1hmLD8wRMD2TkUhM775M3sZw+2SNvKgqDV3TLnvq6uj+/gtCbZl4VFnB8prEyQQKtP+oeQYQPc8yexSTQ8EzWk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677538786168405.32218980784376; Mon, 27 Feb 2023 14:59:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pWmSB-0001PZ-0x; Mon, 27 Feb 2023 17:58:43 -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 1pWmS9-0001OZ-EV for qemu-devel@nongnu.org; Mon, 27 Feb 2023 17:58:41 -0500 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pWmS6-0008Uo-PS for qemu-devel@nongnu.org; Mon, 27 Feb 2023 17:58:41 -0500 Received: by mail-pl1-x644.google.com with SMTP id ky4so8513669plb.3 for ; Mon, 27 Feb 2023 14:58:38 -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.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 14:58:36 -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=q0fgtLVdBUMwB3yUfv+ziuHCcXc1on+zqZqgclTP9ko=; b=J9DPPP0suABEI6AAP/0AxcqBSDcv2wwGPNnys3hbNp/6g9qWO6J45t5/sxA4Q7yvvN RlA5s2R+DgWJzGREp7V9we7YUuSfB8tM4aoGUWS+q7etimdcy3nqpI9/FZ4mAzbIJZpP M+IvHP8XoUjy7l9HCqeCKMSK4knSKVCWPhbStpRX0SONbD3cCUqGl50p+7aHanfN4bHp SGti50OODFC6Ts1hDw89Y68Iuilt8Y596e4UFzXTxHAEFidg084PznZszsu2metDvnRc Tk15ETQ12JCebVvsnqLykFZ6qulFTZ/YA0L64HLoc+fQih4HbGNKiv4se5rbmLU6evqG V8BA== 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=q0fgtLVdBUMwB3yUfv+ziuHCcXc1on+zqZqgclTP9ko=; b=iZgcGsJqUvu2r8GU7e3rjVCvfcRaI1WmCKubRgoTHsj42CJDcPCnVZ0dUJibBl5moP hMyKbpjYvqC6h7TdzUdPz9z2Uix76HKmQtYKnAQS2tVU10w3NDP+td/0w2w+VIJfGlHv dZfWdFALU4hyxhWFl6pMgP5lkDcwDV6OUEMVHCQdftfIa4gf0DCB0Dc6undzGYQsLvAy KY7cQqDTt7ofBtvaAnlF1cAPujtLwweNX0wcbJRWNBHkYyiP5+KbZLWwg1rEOxd+H8eP 3voZPX/ERyspp8ZxgOMjUGq5XCVKy0YQZjdS2j+/w57ocwgg3Nx5ynAbdThJJX6Bj83N Yjyg== X-Gm-Message-State: AO0yUKWGVwcXzOU/ycmDpaut30sU43Z5z9a2Ba8Cpa1jZKgQbjpX9RwH q6ci4oeYEqC84i1Kp5ju0xptH4efLz5s0wWnUU3T+w== X-Google-Smtp-Source: AK7set/xctpDdfXTPcQmx99FkP06/VAYBYOjwQ6bR9YtsLVde1SgYgirW6SH8ErP2wrBWyLZZATlBA== X-Received: by 2002:a17:90b:2248:b0:237:8c42:27bc with SMTP id hk8-20020a17090b224800b002378c4227bcmr978712pjb.13.1677538717315; Mon, 27 Feb 2023 14:58:37 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH for-8.0 v4 1/4] target/arm: Handle m-profile in arm_is_secure Date: Mon, 27 Feb 2023 12:58:29 -1000 Message-Id: <20230227225832.816605-2-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::644; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x644.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=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677538788374100005 Content-Type: text/plain; charset="utf-8" Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1421 Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/cpu.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 12b1082537..7a2f804aeb 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2426,6 +2426,9 @@ static inline bool arm_is_el3_or_mon(CPUARMState *env) /* Return true if the processor is in secure state */ static inline bool arm_is_secure(CPUARMState *env) { + if (arm_feature(env, ARM_FEATURE_M)) { + return env->v7m.secure; + } if (arm_is_el3_or_mon(env)) { return true; } --=20 2.34.1 From nobody Sun May 19 05:00:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677538786; cv=none; d=zohomail.com; s=zohoarc; b=ZNd2izhnrNQrU4q1/KpcqXFKNePOyLAFkUYhCKQOfzM3oOGxChdXYxK2D9BrqyWPgPU21AP6MavXUHyDm6M/xmcPL3qA+lxNBg/dbFXdfPK3lk7kzyqj4Ux9fZWq7J3zmcWMKCUwO1JIjN6uuadN1p+RRONyRS7LV7PKkDPUmNU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677538786; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=J33WqVqAxFla+dpmD2MbLyNB18FeHqj+AFmY8xo8oOg=; b=BtRpfdwIyyNCY/EKre/Qme8cRKaZD+xdddDmhpbroMm+1IxT7PyspJx7SHCKfa41sWRw6r46Zct2BCyyWM6/TYOTtuwXsyjh1aqOGyo57oo1GVZBwuIvLINvwgHrOWhMD5FpFsb00No4VS4RigIjZpPsAD462BMw0ZlmcGduoso= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677538786270230.55615395447933; Mon, 27 Feb 2023 14:59:46 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pWmSB-0001Q0-Gg; Mon, 27 Feb 2023 17:58:43 -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 1pWmSA-0001PD-LA for qemu-devel@nongnu.org; Mon, 27 Feb 2023 17:58:42 -0500 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pWmS8-0008VL-5A for qemu-devel@nongnu.org; Mon, 27 Feb 2023 17:58:42 -0500 Received: by mail-pj1-x1035.google.com with SMTP id k21-20020a17090aaa1500b002376652e160so7811332pjq.0 for ; Mon, 27 Feb 2023 14:58:39 -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.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Feb 2023 14:58:38 -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=J33WqVqAxFla+dpmD2MbLyNB18FeHqj+AFmY8xo8oOg=; b=Q9Ddh4nAqUVNIP3p/merUIIeqsHyMC0zpe6gxHTvWWr2TRkPXf/W0fQF6n6bnhN14x UuohiUN5eRTOL05z8hKraKpy6Tu1jlASLyT+aifFtUtaWCXejSbmZ1OGa8efZNFDtDTN vgmyIebL/NWQG2v3G+Ab1m26wtrcEGJw1w/P8Qp9Ngbaqq0cBj53WFCLtHbgjCol9FSf VAgtXymBGNuub9b+a+L6bkEA7LRqJz8YQIZ53+FjeTHm+gxjNLrhWVS5CU4ihjVDl8Yj 5wK1sHe7Sd04b2jNJtPafLUMVMUgjPwyiJ63AqTXy+bRrXdtiAM4f3I1ApPhHwSbXIne vzdA== 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=J33WqVqAxFla+dpmD2MbLyNB18FeHqj+AFmY8xo8oOg=; b=527tgDKxRSGur0sP/g+aEOyeJgenyiwWszIcyohjo9udYhB6CXJ2ahvtShPZl1pngZ sYW5k9gdI5TYYU41+K3IbhBOqI7vgiJ04n8oFko/DIH9VYr0K8BOhRNTAIM2Lc6i1+CL nXVl0vNvoM2W04WVuVG7Fvn9qR3hjwTTlqPt3sjQzziqfMBMOY91KyWk8ybrgspQdXCU Werzzykhn35DmpE7HFMNWXv/ODe1FTR0zQE8Skrmbl40XCd61MlvDOchXMM6pMwheBmt duF0al86UTqGryF6ZMyTr5P+7CyKHPWdlVtP1YDl14tohWbV8bku6Wz73gM1EYz5V4Mf 8V3w== X-Gm-Message-State: AO0yUKVoNjnQBEJqUq4VlcU3UQoesEHu+1uYRL+QXfCY55jDMXxTZG1Z 9PxoYFZRtziLSoKc1qy5Cm/RLIeMBgBa3EhsDxg= X-Google-Smtp-Source: AK7set+atZxqKultIk7M+pjqQqfqad/wJEH1S1dy3lCqcHRjvAfyhFI9i62lKDjnO6uES2Pb3hLwgQ== X-Received: by 2002:a05:6a20:c323:b0:c7:1da3:e3a with SMTP id dk35-20020a056a20c32300b000c71da30e3amr924967pzb.16.1677538718760; Mon, 27 Feb 2023 14:58:38 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH for-8.0 v4 2/4] target/arm: Stub arm_hcr_el2_eff for m-profile Date: Mon, 27 Feb 2023 12:58:30 -1000 Message-Id: <20230227225832.816605-3-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1035; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1035.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=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677538788380100006 Content-Type: text/plain; charset="utf-8" M-profile doesn't have HCR_EL2. While we could test features before each call, zero is a generally safe return value to disable the code in the caller. This test is required to avoid an assert in arm_is_secure_below_el3. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/helper.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/target/arm/helper.c b/target/arm/helper.c index 14af7ba095..bd12efd392 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5788,6 +5788,9 @@ uint64_t arm_hcr_el2_eff_secstate(CPUARMState *env, b= ool secure) =20 uint64_t arm_hcr_el2_eff(CPUARMState *env) { + if (arm_feature(env, ARM_FEATURE_M)) { + return 0; + } return arm_hcr_el2_eff_secstate(env, arm_is_secure_below_el3(env)); } =20 --=20 2.34.1 From nobody Sun May 19 05:00:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677538801; cv=none; d=zohomail.com; s=zohoarc; b=XxXvh8KxtYQNayyW1lnEhfnmZ8SMT8li/hEiUgreei37TcBeHIpCOSEEQzyD1LZjF0R0Ry/oc1lv8D9QsnvOy5qrwnBYY8uGN6wZkRWMtff17IvwpskgudhqZ/SrOHHCMsOq6tQAnP5HSy+DaMcYW+1HQk5u+TtwSBs4ssJyLco= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677538801; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=pUw/Q9WV6uI2o5+wRzg6/DeRVdVBmeUlUspfEoqm0lE=; b=BXDgTpjyrAxRiW85CWi+Rg8qkhpIxEQTApl04AJWdCMmz4vWgTwkER1hKjgWpnkWpV9ptgKdskBRtDjns+drtD1udBlJ6sR7+cTypmcyfq3lKjOTkm40xyAknrGMFYK0Z4kWT9D3adLFNwt1CNubVV+2FdFFIV3YrdRO7BvY6Wc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677538801474476.5912130564154; Mon, 27 Feb 2023 15:00:01 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AK7set/6MaWdpOf7eIWaCjsp11jMQxRfjx41+UoheAxKTRgjXcceybTo24lxvLElAEIxgIQLTI3KJg== 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) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677538802277100001 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=C3=A9 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 f= eature) void arm_cpu_finalize_features(ARMCPU *cpu, Error **errp); =20 #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 **e= rrp); */ 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(CPUARMStat= e *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) =3D=3D 3) { /* CPU currently in AArch64 state and EL3 */ --=20 2.34.1 From nobody Sun May 19 05:00:15 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1677538812; cv=none; d=zohomail.com; s=zohoarc; b=MNotlH6ubTOsFWmnuTTOJA7arSOfonBcqYkUyWgGcQHzcTo2CTv+kp3/D1IOKm2yaOxn2Z40Rj3oX73BzUG3ZBE+uCIPi/e1+yhuBL0n70trKrXvH/ttCuEQAfSo475J+mFyaAjZrgE4xAHcnEBfsrpKqLCAajOf0YuvKweFaeQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1677538812; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6o3dC89BjnRs5h0SAtcviZdfOy/i5kYTa1NGTzWCcT4=; b=JenWS9cFeWONaZLqE2ftzhICxnqRJUg8Bq+hu9zId6RdAEIllKRuPeuHLMVa9KXSiqkgHq0n6cd5ip6e8RRKBLZkSTrTY1um0U4Z087TTAVYH/Mc5AfdsBNhS7O0YXLvClWyzHSSRb4DvhxFhUmaDsKkpb8ZgHgi/J+5WX4H1XE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1677538812149175.31464203352994; Mon, 27 Feb 2023 15:00:12 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pWmSE-0001S7-QW; Mon, 27 Feb 2023 17:58:46 -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 1pWmSD-0001RU-D3 for qemu-devel@nongnu.org; Mon, 27 Feb 2023 17:58:45 -0500 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pWmSB-0008WH-Gg for qemu-devel@nongnu.org; Mon, 27 Feb 2023 17:58:45 -0500 Received: by mail-pl1-x642.google.com with SMTP id h8so5186907plf.10 for ; Mon, 27 Feb 2023 14:58:43 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); 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=6o3dC89BjnRs5h0SAtcviZdfOy/i5kYTa1NGTzWCcT4=; b=C5cPbyWfKJWRvwTjYv3qEdDVrfWsNLLT0XdMQQLyWSgmLavJYE9lb7yum2L/BDKIbd 30dg3cWCHGDtf7gf8Fqk1DRZliLUic/A5rap3xUiVw2l+99Ao1NEJOWJqyDSCULoZbiL HP64jvj4ftjH+A9sQoetzKLVIE3wzcWD8DO5BWWGx9FnLIoVhggY3/7HMfFt6+shRhBA m3GzOKsWwi1PAhbeT326Mi4IKCS/+c4pidvdUwgnHMlX74jB4rVwsnnNf8FqPi4jMgwt WMqg6jiU5FDJ2bIWHnZRYPvbT2ndrSCRJ1Xn/AKe0b5ouBD/m4/GzHsN/SX/oJ4zw+1P w1bw== 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=6o3dC89BjnRs5h0SAtcviZdfOy/i5kYTa1NGTzWCcT4=; b=EQHfgHrt5iRA3nEvHq/eQtXIw8KzFtuKk5hviPioeeLlGQeJH5pAmE2K2ffFIQjl5Z JPEPiRtt2JAHxO0pB6InEIKNNd8MYMZRWDcTonurGMo8VmlLYw4xXRBluGJ01pFR9gGz ueNwcivm4sOzfkADQXm41fQy9ph68G+ugHndVIvCe0uPMbnw3Vs92Di+IdIPPX7RMNtc +xyDsHXoPkPNG2sXN4doPImo3qPq+7oqU9fFT1jmNfkZ14mR9TJ1wQTFapXeu+D+Oqd0 pgaI9Z7T6Wp7wmIHkvfdv3jgNXEoNufqJstql93YvQqmuTQ1dvyUSpnWpJ76sNh5MJe3 7Xog== X-Gm-Message-State: AO0yUKWBFHKuoPAx7JRLE/O/dC0RnpGqBXyy6iCvBbX5FoBpreVZ5Xhq RtGs8/CeF01cSWK3IYnY1Xq+p27n+dVDWOHkFNf21A== X-Google-Smtp-Source: AK7set/qIXf3r0grIcu++KqHOljIrxSgrB1CYVspc0HSqq5XbfSMkAZi18u7v/aiA/CsnM/Uy9V8gA== X-Received: by 2002:a05:6a20:a624:b0:cc:75b8:7cba with SMTP id bb36-20020a056a20a62400b000cc75b87cbamr763199pzb.43.1677538722117; Mon, 27 Feb 2023 14:58:42 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH for-8.0 v4 4/4] target/arm: Rewrite check_s2_mmu_setup Date: Mon, 27 Feb 2023 12:58:32 -1000 Message-Id: <20230227225832.816605-5-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::642; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x642.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1677538814325100001 Content-Type: text/plain; charset="utf-8" Integrate neighboring code from get_phys_addr_lpae which computed starting level, as it is easier to validate when doing both at the same time. Mirror the checks at the start of AArch{64,32}.S2Walk, especially S2InvalidSL and S2InconsistentSL. This reverts 49ba115bb74, which was incorrect -- there is nothing in the ARM pseudocode that depends on TxSZ, i.e. outputsize; the pseudocode is consistent in referencing PAMax. Fixes: 49ba115bb74 ("target/arm: Pass outputsize down to check_s2_mmu_setup= ") Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/ptw.c | 173 ++++++++++++++++++++++++++--------------------- 1 file changed, 97 insertions(+), 76 deletions(-) diff --git a/target/arm/ptw.c b/target/arm/ptw.c index be0cc6bc15..89cc7e2aff 100644 --- a/target/arm/ptw.c +++ b/target/arm/ptw.c @@ -1081,70 +1081,119 @@ static ARMVAParameters aa32_va_parameters(CPUARMSt= ate *env, uint32_t va, * check_s2_mmu_setup * @cpu: ARMCPU * @is_aa64: True if the translation regime is in AArch64 state - * @startlevel: Suggested starting level - * @inputsize: Bitsize of IPAs + * @tcr: VTCR_EL2 or VSTCR_EL2 + * @ds: Effective value of TCR.DS. + * @iasize: Bitsize of IPAs * @stride: Page-table stride (See the ARM ARM) * - * Returns true if the suggested S2 translation parameters are OK and - * false otherwise. + * Decode the starting level of the S2 lookup, returning INT_MIN if + * the configuration is invalid. */ -static bool check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, int level, - int inputsize, int stride, int outputsize) +static int check_s2_mmu_setup(ARMCPU *cpu, bool is_aa64, uint64_t tcr, + bool ds, int iasize, int stride) { - const int grainsize =3D stride + 3; - int startsizecheck; - - /* - * Negative levels are usually not allowed... - * Except for FEAT_LPA2, 4k page table, 52-bit address space, which - * begins with level -1. Note that previous feature tests will have - * eliminated this combination if it is not enabled. - */ - if (level < (inputsize =3D=3D 52 && stride =3D=3D 9 ? -1 : 0)) { - return false; - } - - startsizecheck =3D inputsize - ((3 - level) * stride + grainsize); - if (startsizecheck < 1 || startsizecheck > stride + 4) { - return false; - } + int sl0, sl2, startlevel, granulebits, levels; + int s1_min_iasize, s1_max_iasize; =20 + sl0 =3D extract32(tcr, 6, 2); if (is_aa64) { + /* + * AArch64.S2InvalidTxSZ: While we checked tsz_oob near the top of + * get_phys_addr_lpae, that used aa64_va_parameters which apply + * to aarch64. If Stage1 is aarch32, the min_txsz is larger. + * See AArch64.S2MinTxSZ, where min_tsz is 24, translated to + * inputsize is 64 - 24 =3D 40. + */ + if (iasize < 40 && !arm_el_is_aa64(&cpu->env, 1)) { + goto fail; + } + + /* + * AArch64.S2InvalidSL: Interpretation of SL depends on the page s= ize, + * so interleave AArch64.S2StartLevel. + */ switch (stride) { - case 13: /* 64KB Pages. */ - if (level =3D=3D 0 || (level =3D=3D 1 && outputsize <=3D 42)) { - return false; + case 9: /* 4KB */ + /* SL2 is RES0 unless DS=3D1 & 4KB granule. */ + sl2 =3D extract64(tcr, 33, 1); + if (ds && sl2) { + if (sl0 !=3D 0) { + goto fail; + } + startlevel =3D -1; + } else { + startlevel =3D 2 - sl0; + switch (sl0) { + case 2: + if (arm_pamax(cpu) < 44) { + goto fail; + } + break; + case 3: + if (!cpu_isar_feature(aa64_st, cpu)) { + goto fail; + } + startlevel =3D 3; + break; + } } break; - case 11: /* 16KB Pages. */ - if (level =3D=3D 0 || (level =3D=3D 1 && outputsize <=3D 40)) { - return false; + case 11: /* 16KB */ + switch (sl0) { + case 2: + if (arm_pamax(cpu) < 42) { + goto fail; + } + break; + case 3: + if (!ds) { + goto fail; + } + break; } + startlevel =3D 3 - sl0; break; - case 9: /* 4KB Pages. */ - if (level =3D=3D 0 && outputsize <=3D 42) { - return false; + case 13: /* 64KB */ + switch (sl0) { + case 2: + if (arm_pamax(cpu) < 44) { + goto fail; + } + break; + case 3: + goto fail; } + startlevel =3D 3 - sl0; break; default: g_assert_not_reached(); } - - /* Inputsize checks. */ - if (inputsize > outputsize && - (arm_el_is_aa64(&cpu->env, 1) || inputsize > 40)) { - /* This is CONSTRAINED UNPREDICTABLE and we choose to fault. = */ - return false; - } } else { - /* AArch32 only supports 4KB pages. Assert on that. */ + /* + * Things are simpler for AArch32 EL2, with only 4k pages. + * There is no separate S2InvalidSL function, but AArch32.S2Walk + * begins with walkparms.sl0 in {'1x'}. + */ assert(stride =3D=3D 9); - - if (level =3D=3D 0) { - return false; + if (sl0 >=3D 2) { + goto fail; } + startlevel =3D 2 - sl0; } - return true; + + /* AArch{64,32}.S2InconsistentSL are functionally equivalent. */ + levels =3D 3 - startlevel; + granulebits =3D stride + 3; + + s1_min_iasize =3D levels * stride + granulebits + 1; + s1_max_iasize =3D s1_min_iasize + (stride - 1) + 4; + + if (iasize >=3D s1_min_iasize && iasize <=3D s1_max_iasize) { + return startlevel; + } + + fail: + return INT_MIN; } =20 /** @@ -1300,38 +1349,10 @@ static bool get_phys_addr_lpae(CPUARMState *env, S1= Translate *ptw, */ level =3D 4 - (inputsize - 4) / stride; } else { - /* - * For stage 2 translations the starting level is specified by the - * VTCR_EL2.SL0 field (whose interpretation depends on the page si= ze) - */ - uint32_t sl0 =3D extract32(tcr, 6, 2); - uint32_t sl2 =3D extract64(tcr, 33, 1); - int32_t startlevel; - bool ok; - - /* SL2 is RES0 unless DS=3D1 & 4kb granule. */ - if (param.ds && stride =3D=3D 9 && sl2) { - if (sl0 !=3D 0) { - level =3D 0; - goto do_translation_fault; - } - startlevel =3D -1; - } else if (!aarch64 || stride =3D=3D 9) { - /* AArch32 or 4KB pages */ - startlevel =3D 2 - sl0; - - if (cpu_isar_feature(aa64_st, cpu)) { - startlevel &=3D 3; - } - } else { - /* 16KB or 64KB pages */ - startlevel =3D 3 - sl0; - } - - /* Check that the starting level is valid. */ - ok =3D check_s2_mmu_setup(cpu, aarch64, startlevel, - inputsize, stride, outputsize); - if (!ok) { + int startlevel =3D check_s2_mmu_setup(cpu, aarch64, tcr, param.ds, + inputsize, stride); + if (startlevel =3D=3D INT_MIN) { + level =3D 0; goto do_translation_fault; } level =3D startlevel; --=20 2.34.1