From nobody Sat Nov 15 12:44:15 2025 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=1752009913; cv=none; d=zohomail.com; s=zohoarc; b=d5tQMW//0KqTNX4uhx1RpesY7FhPJow+LCGx/FWdz+w6MKGWSowXRVeEIKzBkYxOhk5Xrs2c6asSPj4009fDmfpkL2J1DFW8PujF43ZLOifZHd1A5N7f/L2kwS8CAhi4o90cyyR1m521QEe4c+hXVEjRyL6YrKR5mqwwnitxpHk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752009913; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vSHu2C6AHkdi6I2MI+MN+9VTwDs09gk+qY11owIPdS8=; b=O/1Z14OnJ+o2wu5hG80fpaA5wSpHWCOAte70q/B8S75YHc/zgDiynWJFj8LaBvu7ofAAhvyUPVFACZY8FaQ564c7Z3frT8B2oXSHdpczvp0qnEM0H+/b/GhvNVIexB6b2n/Avjg2DfwwDNtge/Sd7nl4omFp318oB/97g4x7220= 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 1752009913265465.77881375073605; Tue, 8 Jul 2025 14:25:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uZFE4-0005mB-JP; Tue, 08 Jul 2025 16:47:40 -0400 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 1uZDqm-000762-S3 for qemu-devel@nongnu.org; Tue, 08 Jul 2025 15:19:38 -0400 Received: from mail-qv1-xf34.google.com ([2607:f8b0:4864:20::f34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uZDqg-00086D-O0 for qemu-devel@nongnu.org; Tue, 08 Jul 2025 15:19:29 -0400 Received: by mail-qv1-xf34.google.com with SMTP id 6a1803df08f44-6fae04a3795so52018746d6.3 for ; Tue, 08 Jul 2025 12:19:14 -0700 (PDT) Received: from gromero0.. ([189.110.24.38]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-702d638846asm56289096d6.22.2025.07.08.12.19.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jul 2025 12:19:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1752002354; x=1752607154; darn=nongnu.org; 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=vSHu2C6AHkdi6I2MI+MN+9VTwDs09gk+qY11owIPdS8=; b=nh4K83BCOakJ5XXA29pCLwszfOv10O2HVUmBrG4keb/Jk9Y7NLfk7JcKRPTW8itMFR oe/1T3PiTpswA+ar4EVsl8T+HaA+diLUgm/zzRm79OIJkOVOcynOMyf21o7+qxzfNoU0 jvYyFh6dVjJ9jDMBB+loBg3xr7i+gNFt0e1M+xW2bvd//IEpQ53369fc+413nYk+Bui7 wYg0PKEBgx9u7EdMWYOGl141qOzcr0wj1NiUAtdKOyJ5OG0pT1g/YS1nrvKgUHROOXcP QLpY6PchjhBzXcMCry9tWqhPW6AsH4oQ7rOrYUHpKloVeHHgRkyZKKHHVqMTJ530s0zs Z3ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752002354; x=1752607154; 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=vSHu2C6AHkdi6I2MI+MN+9VTwDs09gk+qY11owIPdS8=; b=WlKWpigic082tGcN6w9iNaAK763pt/bIih2/DuxriJNUcs2KCOx8VxCbsciBTDrGzF aFD5UUpkoHJ1/8nqFqtfbL8QLenMEuK6K3LrZYHhGsxUOtnMRt/gTqVAhIAH7HZ6NuVh cerJfsNB77myagwoAJWDq0fYAhfn3eu2HX/fMb0Ty9KhFxQwlnGu2Fslkc+ku92lMmr9 dJAXu8tscc7PvMkMY3zb13N651j/ZjdJA8ymh+l9GVQ4BQ3+nzgfE5OsnFyhsolmvxQg 9GDQ3EOWtSifvVhsuMfypYcbs007YXUgTjJL3uvjXUfypJWCKEx46IBFv/kABmjFC3zd Hx8Q== X-Gm-Message-State: AOJu0YwYtn+g0r9Tyv+pCoDf4XcPx9/4m10nKoKc1S/RPxwyS5/6HRK0 98NROCMVCl1GshPNrODfTDykugu8x2B2B5UQ+byPM8Ehap+LytzWDYSCoMH6js44D+E= X-Gm-Gg: ASbGncsO7iv0wglCDC8ORh/bIgj73nMoKq0Mb/tazbe8BvX2nFAChiFC/dvaE/XPaKO FcbQwhhAktjY/2qymam/HNx9CF5CNcWCHSaYZDgvko1+mq5tG1+85ZY8RdmL1rU6cmFVsNaz7La /OckGqKzAvw0P6t5T8/kchrP2FpbFn6FSO5FqgaBqlx31/5R7kbsy7GmPTweMjVoGRWnM3TGCqA PHgVDv4XkxAiJP4s80YZ00b39Vq/RBIx0rciLOd93G8suMj8rrZHNN9XcEovIX81dX0VhbK4Vu7 L1l6LuRMs5DHG76f+QT3rrMYwiOG9zzwcOpwRhwko7iqqMHqFNAsVyCuS6702obf/Yo= X-Google-Smtp-Source: AGHT+IEPVtapxFZtywAliaVxF1CHWD1ZAc5Em284q4ol+mGChMbTsCoMBELPXXvtyKtgjOyuBt2igA== X-Received: by 2002:a05:6214:31a0:b0:6fb:1fc:788e with SMTP id 6a1803df08f44-70489abc6bcmr10112406d6.2.1752002353700; Tue, 08 Jul 2025 12:19:13 -0700 (PDT) From: Gustavo Romero To: qemu-arm@nongnu.org, richard.henderson@linaro.org, alex.bennee@linaro.org Cc: qemu-devel@nongnu.org, gustavo.romero@linaro.org Subject: [RFC PATCH-for-10.1 v3 1/5] target/arm: Add the MECEn SCR_EL3 bit Date: Tue, 8 Jul 2025 19:17:00 +0000 Message-Id: <20250708191704.1068604-2-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250708191704.1068604-1-gustavo.romero@linaro.org> References: <20250708191704.1068604-1-gustavo.romero@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::f34; envelope-from=gustavo.romero@linaro.org; helo=mail-qv1-xf34.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: 1752009915346116600 Content-Type: text/plain; charset="utf-8" The MECEn bit in SCR_EL3 enables access to the EL2 MECID registers from EL2, so add it to the SCR mask list to use it later on. Signed-off-by: Gustavo Romero Reviewed-by: Richard Henderson --- target/arm/cpu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index c8cf0ab417..0f64c7b163 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1717,6 +1717,7 @@ static inline void xpsr_write(CPUARMState *env, uint3= 2_t val, uint32_t mask) #define SCR_TRNDR (1ULL << 40) #define SCR_ENTP2 (1ULL << 41) #define SCR_GPF (1ULL << 48) +#define SCR_MECEN (1ULL << 49) #define SCR_NSE (1ULL << 62) =20 /* Return the current FPSCR value. */ --=20 2.34.1 From nobody Sat Nov 15 12:44:15 2025 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=1752008059; cv=none; d=zohomail.com; s=zohoarc; b=Nwhz+7LZ3peTF+UHBkKjf6/SNdbBtq+nXZptdEvunxUfA6YPpZ0YLg4ZdnK3cONRQX6U2Wz3cRVp7jPwOStaS9KYs0LzoxM4kWU5tsedDgrfi4g9MKiFnTipu+59qp5YlLCcbmut3KCWls71SE6Z9CZB4I8KsLgL81eIpkrtqg4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752008059; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AmhliCegNfZGHfr7J+p0jeoV/6BX3pT1C+80y0xkf40=; b=h11P/3WFENM8nIxAmnC48s9C+ovDVLn3nGzOETznGzz3vwAWpOcKyKXuRaOo9zyGNE4UItuyjzfX2pVX/NR6/F261U1LD+/AY8oj8zKlrhG2uGG55Ja/sY4oqWqgUATSffW8gs+MOj2aSlHhk67HSIArwhe5JYHiGt59wqO3/Vg= 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 1752008059323317.3958134907032; Tue, 8 Jul 2025 13:54:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uZFEq-0007DG-3b; Tue, 08 Jul 2025 16:48:28 -0400 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 1uZDqx-0007Dn-5H for qemu-devel@nongnu.org; Tue, 08 Jul 2025 15:19:47 -0400 Received: from mail-qv1-xf2c.google.com ([2607:f8b0:4864:20::f2c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uZDqq-00087I-7f for qemu-devel@nongnu.org; Tue, 08 Jul 2025 15:19:41 -0400 Received: by mail-qv1-xf2c.google.com with SMTP id 6a1803df08f44-6fafdd322d3so60041966d6.3 for ; Tue, 08 Jul 2025 12:19:17 -0700 (PDT) Received: from gromero0.. ([189.110.24.38]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-702d638846asm56289096d6.22.2025.07.08.12.19.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jul 2025 12:19:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1752002356; x=1752607156; darn=nongnu.org; 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=AmhliCegNfZGHfr7J+p0jeoV/6BX3pT1C+80y0xkf40=; b=qJpaMapCABOibg96xQyPBepmRzEv9Wh1ApEcdV3xJdh6mi9lkWoQB0cmqY0lfogOQP 8OeaqJCu6FJPGn8wcS2t7tTXsnIJC5luF3ckur+k0oj/I4E+Kut4aHbbuGTuhjnbfqq9 NnovCXRoUmydcuepST7U3KsmBt69mRVRFE0mT1Hu6hxIREHE9mD/XU78d0HROGm2XcgN rRU35K1fdlw01WSDmmadDBVhxagAN3m9FnTaUJ7rFOXYleFf9pt6gKWzqyQtYOURdoeE 1fgkn/evWOgx7XxPlAWpilUeAopd6qparHcrFpaN+YzlF9Bu2QYM6XQlgc1dfOauC+yG AbSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752002356; x=1752607156; 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=AmhliCegNfZGHfr7J+p0jeoV/6BX3pT1C+80y0xkf40=; b=VLpS/iNQhOnLPEr53F1I9BuRLoyi2rbF28v/rePo8M56/0SwAWoqmUpsdbhedW2nxQ IqG3NHGXHvPuh4wi8e8OQXe84ySLOc0w2RtY90kGwFtm9iVWiaqFcZr9rwMPHqOfiHiz RfI6ztixcTELEQsoLQdAGpKFzSXWOr5YhIle9VCJcZ7SZMFJz0QuffXBIhPRWFGgc2zV ta4eCQeDwFsrTuEcyeCuvfeM9S5qJ02PKvOMeMIXvvsYSLVQNofM/PQPIMd5P1VLsCIb 7tsWeqXN2Yianr1/SLDGzMZKbBagL/asQnagR8sWDrf6aDJd0wogEUz6FduqQp7G0eSy LDGA== X-Gm-Message-State: AOJu0Yy/m+LA35WF6SZJK1cHCgOOGG4j+9F+GUjdoY5nlTcUKN/p8T7d nv24y1IXdSJAR+QFckW6XQbJjpHs4BrGg76rMICh2275ToQdyS5RL8veNmzW2yyHCRCD7i13IET 4ziCZ0Yw= X-Gm-Gg: ASbGncsT5DNyYsfvp8VpQbwET89YRgE91aFit14+TS2kMpXlYNPDF0MIhzt6+fzDQpf OlwXTlgXQx3dFS+z+2xfSkaJf/t8P8+ObF/ictOYZFRn/hmFi/0+PLehq8Vi7h0Z/ceuSllKBgp GvhLO8HW/5IfRTOgBssC7dkep8ZKQeQ9ooox2rrsJOptiTixcivX3yiVlDyCYbt2RBstrBd/SVD NyE4S7Obo0eoqXvpbHc3WXFk2WwShQqa5lzbyXhEIL8yacWCZ/jqUx2p3rgqFv1oNPnMYXoDOXK mBFKyITBW0TaepSvFyqtcY0XANdU9obtqh+7qH0ySNGjZKIqELPFsFz0bt7A6bjF33I= X-Google-Smtp-Source: AGHT+IE+65XyCIHt0mMmNZ9x/WwtrgdOw2UmcMAB1mrk69YadyhIoyQ74Jz4sZDUtqmP6YZOIZNBbg== X-Received: by 2002:a05:6214:ca9:b0:6fd:d91:ba28 with SMTP id 6a1803df08f44-702c8cd99bdmr252089966d6.41.1752002356234; Tue, 08 Jul 2025 12:19:16 -0700 (PDT) From: Gustavo Romero To: qemu-arm@nongnu.org, richard.henderson@linaro.org, alex.bennee@linaro.org Cc: qemu-devel@nongnu.org, gustavo.romero@linaro.org Subject: [RFC PATCH-for-10.1 v3 2/5] target/arm: Add FEAT_MEC registers Date: Tue, 8 Jul 2025 19:17:01 +0000 Message-Id: <20250708191704.1068604-3-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250708191704.1068604-1-gustavo.romero@linaro.org> References: <20250708191704.1068604-1-gustavo.romero@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::f2c; envelope-from=gustavo.romero@linaro.org; helo=mail-qv1-xf2c.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: 1752008059952116600 Content-Type: text/plain; charset="utf-8" Add all FEAT_MEC registers. To work properly, FEAT_MEC also depends on FEAT_SCTLR2 and FEAT_TCR2, which are not implemented in this commit. The bits in SCTLR2 and TCR2 control which translation regimes use MECIDs, and determine which MECID is selected. FEAT_MEC also requires two new cache management instructions, not included in this commit, that will be implemented in subsequent commits. Signed-off-by: Gustavo Romero --- target/arm/cpu-features.h | 5 +++ target/arm/cpu.h | 11 ++++++ target/arm/helper.c | 70 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h index 5876162428..552d8757b7 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -594,6 +594,11 @@ static inline bool isar_feature_aa64_hbc(const ARMISAR= egisters *id) return FIELD_EX64_IDREG(id, ID_AA64ISAR2, BC) !=3D 0; } =20 +static inline bool isar_feature_aa64_mec(const ARMISARegisters *id) +{ + return FIELD_EX64_IDREG(id, ID_AA64MMFR3, MEC) !=3D 0; +} + static inline bool isar_feature_aa64_mops(const ARMISARegisters *id) { return FIELD_EX64_IDREG(id, ID_AA64ISAR2, MOPS); diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 0f64c7b163..a93eebe077 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -576,6 +576,15 @@ typedef struct CPUArchState { =20 /* NV2 register */ uint64_t vncr_el2; + + /* MEC registers */ + uint64_t mecid_p0_el2; + uint64_t mecid_a0_el2; + uint64_t mecid_p1_el2; + uint64_t mecid_a1_el2; + uint64_t mecid_rl_a_el3; + uint64_t vmecid_p_el2; + uint64_t vmecid_a_el2; } cp15; =20 struct { @@ -2424,6 +2433,8 @@ FIELD(MFAR, FPA, 12, 40) FIELD(MFAR, NSE, 62, 1) FIELD(MFAR, NS, 63, 1) =20 +#define MECID_WIDTH 16 + QEMU_BUILD_BUG_ON(ARRAY_SIZE(((ARMCPU *)0)->ccsidr) <=3D R_V7M_CSSELR_INDE= X_MASK); =20 /* If adding a feature bit which corresponds to a Linux ELF diff --git a/target/arm/helper.c b/target/arm/helper.c index b3f0d6f17a..984406c945 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6827,6 +6827,72 @@ static const ARMCPRegInfo nmi_reginfo[] =3D { .resetfn =3D arm_cp_reset_ignore }, }; =20 +static CPAccessResult mecid_access(CPUARMState *env, + const ARMCPRegInfo *ri, bool isread) +{ + int el =3D arm_current_el(env); + + if (el =3D=3D 2) { + if (arm_security_space(env) !=3D ARMSS_Realm) { + return CP_ACCESS_UNDEFINED; + } + + if (!(env->cp15.scr_el3 & SCR_MECEN)) { + return CP_ACCESS_TRAP_EL3; + } + } + + return CP_ACCESS_OK; +} + +static void mecid_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + value =3D extract64(value, 0, MECID_WIDTH); + raw_write(env, ri, value); +} + +static const ARMCPRegInfo mec_reginfo[] =3D { + { .name =3D "MECIDR_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .opc2 =3D 7, .crn =3D 10, .crm =3D 8, + .access =3D PL2_R, .type =3D ARM_CP_CONST, .resetvalue =3D MECID_WID= TH - 1 }, + { .name =3D "MECID_P0_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .opc2 =3D 0, .crn =3D 10, .crm =3D 8, + .access =3D PL2_RW, .accessfn =3D mecid_access, + .writefn =3D mecid_write, + .fieldoffset =3D offsetof(CPUARMState, cp15.mecid_p0_el2) }, + { .name =3D "MECID_A0_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .opc2 =3D 1, .crn =3D 10, .crm =3D 8, + .access =3D PL2_RW, .accessfn =3D mecid_access, + .writefn =3D mecid_write, + .fieldoffset =3D offsetof(CPUARMState, cp15.mecid_a0_el2) }, + { .name =3D "MECID_P1_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .opc2 =3D 2, .crn =3D 10, .crm =3D 8, + .access =3D PL2_RW, .accessfn =3D mecid_access, + .writefn =3D mecid_write, + .fieldoffset =3D offsetof(CPUARMState, cp15.mecid_p1_el2) }, + { .name =3D "MECID_A1_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .opc2 =3D 3, .crn =3D 10, .crm =3D 8, + .access =3D PL2_RW, .accessfn =3D mecid_access, + .writefn =3D mecid_write, + .fieldoffset =3D offsetof(CPUARMState, cp15.mecid_a1_el2) }, + { .name =3D "MECID_RL_A_EL3", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 6, .opc2 =3D 1, .crn =3D 10, .crm =3D 10, + .access =3D PL3_RW, .accessfn =3D mecid_access, + .writefn =3D mecid_write, + .fieldoffset =3D offsetof(CPUARMState, cp15.mecid_rl_a_el3) }, + { .name =3D "VMECID_P_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .opc2 =3D 0, .crn =3D 10, .crm =3D 9, + .access =3D PL2_RW, .accessfn =3D mecid_access, + .writefn =3D mecid_write, + .fieldoffset =3D offsetof(CPUARMState, cp15.vmecid_p_el2) }, + { .name =3D "VMECID_A_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .opc2 =3D 1, .crn =3D 10, .crm =3D 9, + .access =3D PL2_RW, .accessfn =3D mecid_access, + .writefn =3D mecid_write, + .fieldoffset =3D offsetof(CPUARMState, cp15.vmecid_a_el2) }, +}; + static void define_pmu_regs(ARMCPU *cpu) { /* @@ -9014,6 +9080,10 @@ void register_cp_regs_for_features(ARMCPU *cpu) define_arm_cp_regs(cpu, nmi_reginfo); } =20 + if (cpu_isar_feature(aa64_mec, cpu)) { + define_arm_cp_regs(cpu, mec_reginfo); + } + if (cpu_isar_feature(any_predinv, cpu)) { define_arm_cp_regs(cpu, predinv_reginfo); } --=20 2.34.1 From nobody Sat Nov 15 12:44:15 2025 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=1752010045; cv=none; d=zohomail.com; s=zohoarc; b=kTauepxtRTXg/ry3g+AtcEGH1ZyEgly2bO6cp9/BrkkbAiKHFkOlKb47y4X1vM8YMvuBkMQFj9M3gU3tn159gBD2bUaV359gw+/wrAYa+UaSKc8LvDkOBoAYRVvdGOI+V4cyFH/jrj3ptJrAc/jNALcUYoWRMMSRf6Ll5q/2sxE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752010045; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NTe7bOal0YIiyl9TytWq98KqOfA68utBrp7VdHEme/0=; b=Do3YQyzUC+hEG+jHQdBqHt7/YX1UY+YIhBJib14wY9wlPqx/ioYt+xa4cv6Nvd3vPadVBxeEhAceqtNSqbt8VbCWE8wDAZFKwoX5gAdVHqKg8dPcV/05/so9s1GLA5SNghM6OUaVktgsnjMicLRmQD2nQAaPbV+jeR7u+Q6TiLE= 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 1752010045687562.62081415516; Tue, 8 Jul 2025 14:27:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uZFFH-0002Uk-92; Tue, 08 Jul 2025 16:48:55 -0400 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 1uZDrd-0008VQ-9o for qemu-devel@nongnu.org; Tue, 08 Jul 2025 15:20:30 -0400 Received: from mail-qk1-x72a.google.com ([2607:f8b0:4864:20::72a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uZDrW-00088C-Kl for qemu-devel@nongnu.org; Tue, 08 Jul 2025 15:20:24 -0400 Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-7d7f2600c17so409792485a.0 for ; Tue, 08 Jul 2025 12:19:19 -0700 (PDT) Received: from gromero0.. ([189.110.24.38]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-702d638846asm56289096d6.22.2025.07.08.12.19.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jul 2025 12:19:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1752002359; x=1752607159; darn=nongnu.org; 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=NTe7bOal0YIiyl9TytWq98KqOfA68utBrp7VdHEme/0=; b=psk10WlOpB/JEUHlaJQC4s2xbu+96kGD2i3Jfwuge1MCyPErG1bhj/5BbjLrTxATmV hHmaiuGmIYmDIQeUI3dFpkO0aK2rd4aD/beidBvXothT3ii8TJm2EqTcb5JdExlp0D5q FDJfiJngSbleaT+L6RRywyK6ItC+qnE5UlQREG0mTHfi0fnmp+hwUIhcrACrIb0acfKd vA15g8wIzo1qIjtmuXgiJchFjFOaO+UxDav1hVoyYJQ9m/L7ImLlbPIruD+Sh6YWmEf0 ABVX8tlit1wi257Fu/fOClxJKDogjlGt6TVyNa29v6ycwxXp6wm9llzAF+d4sc212RTM Ktdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752002359; x=1752607159; 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=NTe7bOal0YIiyl9TytWq98KqOfA68utBrp7VdHEme/0=; b=Xfb9pGQyU3Lef57dig+N7Ek7gOUFQCyJEUhROOxvnugSTH4U7hcaBtb5GItXyUI2yL xXDvsC0Wvx+S14a/0bdsXxqVem8THtygnepM9g+I1mpj+x39HTBiLWkpTVd/V8eVlKIb tEeB8jqjESxDgw3Pz3jm3wD6QgWCdZIU6LwMRjv/31Yww2JyyM/cdJDJDrMQo+nL84Xa Oswgw/Ca1jY35nTEddcASj3yXqCUDQK2hf6dlXMYjN4GYWMARe9vjkCBBWeRCExijdEW /D8jo4pHTKXUmmbc/Pav7I13nOTUPimpMAxyf7InSISGEvIyznLl5ncyNAmwZh5MVPk2 T+bQ== X-Gm-Message-State: AOJu0YwWgPSmR5fJ8ni+gKvQ7s89ujGQ4S/UCZq5xe/YkjebRF+oElJE vAbPwb6tgZmM7O1UaqLdcPmO/qjTSpyAqvODqfYYw5Vl3lDdDofjkjCrH9WeXmrDM9k= X-Gm-Gg: ASbGncuycnsGamwpcVP7eGojLUyCriZmU9N3P8LixqPhMDlOyrEPZ13i709Pt2jQKhR 6FGtyYHB5vMIxncPKZJnbimifhZDuCDVGoFgQ5E+0YzxIXYYQ66LkHK5/J/tL4j2Fi3fdcI5O54 SoMUeZhtT+6GvLGSoSftD9e2sYz2/EOR98qzKABGAnWWjIPW13JdoqyQzFjqp/hWC07b0UgjSGf E4l05Dz7LdPMbXBe00OP/Z9fL2kFRjD96txVKTnCmefReDt+AnNb7W+e2gms3Xu5lkp7qDb4X4w 8BoRupWh4vipWYbMMAeQ9ry4Slu1vR/IOQ/3N+jq625vb0zRjZejVSo5Ec0VEQxE17M= X-Google-Smtp-Source: AGHT+IFRMpyHXm5RdpQsFF/XhdI+jUNVf0pRm7ThEspH19XAMlJL47LmlUknwNgV2859giwP3hu7DQ== X-Received: by 2002:a05:620a:1e:b0:7d3:c381:f653 with SMTP id af79cd13be357-7d9ecfe8ff6mr656693285a.56.1752002358619; Tue, 08 Jul 2025 12:19:18 -0700 (PDT) From: Gustavo Romero To: qemu-arm@nongnu.org, richard.henderson@linaro.org, alex.bennee@linaro.org Cc: qemu-devel@nongnu.org, gustavo.romero@linaro.org Subject: [RFC PATCH-for-10.1 v3 3/5] target/arm: Add FEAT_SCTLR2 Date: Tue, 8 Jul 2025 19:17:02 +0000 Message-Id: <20250708191704.1068604-4-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250708191704.1068604-1-gustavo.romero@linaro.org> References: <20250708191704.1068604-1-gustavo.romero@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::72a; envelope-from=gustavo.romero@linaro.org; helo=mail-qk1-x72a.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: 1752010046993116600 Content-Type: text/plain; charset="utf-8" Add FEAT_SCTLR2, which introduces the SCTLR2_EL1, SCTLR2_EL2, and SCTLR2_EL3 registers. These registers are extensions of the SCTLR_ELx ones. Because the bits in these registers depend on other CPU features, and only FEAT_MEC is supported at the moment, this commit only implements the EMEC bits in CTLR2_EL2 and SCTLR2_EL3. Signed-off-by: Gustavo Romero Reviewed-by: Richard Henderson --- docs/system/arm/emulation.rst | 1 + target/arm/cpu-features.h | 5 +++ target/arm/cpu.h | 15 +++++++ target/arm/helper.c | 78 +++++++++++++++++++++++++++++++++++ target/arm/internals.h | 1 + target/arm/tcg/cpu64.c | 1 + 6 files changed, 101 insertions(+) diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst index 890dc6fee2..66043b0747 100644 --- a/docs/system/arm/emulation.rst +++ b/docs/system/arm/emulation.rst @@ -121,6 +121,7 @@ the following architecture extensions: - FEAT_RPRES (Increased precision of FRECPE and FRSQRTE) - FEAT_S2FWB (Stage 2 forced Write-Back) - FEAT_SB (Speculation Barrier) +- FEAT_SCTLR2 (Extension to SCTLR_ELx) - FEAT_SEL2 (Secure EL2) - FEAT_SHA1 (SHA1 instructions) - FEAT_SHA256 (SHA256 instructions) diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h index 552d8757b7..44d6b655a9 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -416,6 +416,11 @@ static inline bool isar_feature_aa64_rdm(const ARMISAR= egisters *id) return FIELD_EX64_IDREG(id, ID_AA64ISAR0, RDM) !=3D 0; } =20 +static inline bool isar_feature_aa64_sctlr2(const ARMISARegisters *id) +{ + return FIELD_EX64_IDREG(id, ID_AA64MMFR3, SCTLRX) !=3D 0; +} + static inline bool isar_feature_aa64_sha3(const ARMISARegisters *id) { return FIELD_EX64_IDREG(id, ID_AA64ISAR0, SHA3) !=3D 0; diff --git a/target/arm/cpu.h b/target/arm/cpu.h index a93eebe077..32d30b7bb9 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -337,6 +337,7 @@ typedef struct CPUArchState { }; uint64_t sctlr_el[4]; }; + uint64_t sctlr2_el[4]; /* Extension to System control register. */ uint64_t vsctlr; /* Virtualization System control register. */ uint64_t cpacr_el1; /* Architectural feature access control regist= er */ uint64_t cptr_el[4]; /* ARMv8 feature trap registers */ @@ -1433,6 +1434,19 @@ void pmu_init(ARMCPU *cpu); #define SCTLR_SPINTMASK (1ULL << 62) /* FEAT_NMI */ #define SCTLR_TIDCP (1ULL << 63) /* FEAT_TIDCP1 */ =20 +#define SCTLR2_EMEC (1ULL << 1) /* FEAT_MEC */ +#define SCTLR2_NMEA (1ULL << 2) /* FEAT_DoubleFault2 */ +#define SCTLR2_ENADERR (1ULL << 3) /* FEAT_ADERR */ +#define SCTLR2_ENANERR (1ULL << 4) /* FEAT_ANERR */ +#define SCTLR2_EASE (1ULL << 5) /* FEAT_DoubleFault2 */ +#define SCTLR2_ENIDCP128 (1ULL << 6) /* FEAT_SYSREG128 */ +#define SCTLR2_ENPACM (1ULL << 7) /* FEAT_PAuth_LR */ +#define SCTLR2_ENPACM0 (1ULL << 8 /* FEAT_PAuth_LR */ +#define SCTLR2_CPTA (1ULL << 9) /* FEAT_CPA2 */ +#define SCTLR2_CPTA0 (1ULL << 10) /* FEAT_CPA2 */ +#define SCTLR2_CPTM (1ULL << 11) /* FEAT_CPA2 */ +#define SCTLR2_CPTM0 (1ULL << 12) /* FEAT_CAP2 */ + #define CPSR_M (0x1fU) #define CPSR_T (1U << 5) #define CPSR_F (1U << 6) @@ -1725,6 +1739,7 @@ static inline void xpsr_write(CPUARMState *env, uint3= 2_t val, uint32_t mask) #define SCR_HXEN (1ULL << 38) #define SCR_TRNDR (1ULL << 40) #define SCR_ENTP2 (1ULL << 41) +#define SCR_SCTLR2EN (1ULL << 44) #define SCR_GPF (1ULL << 48) #define SCR_MECEN (1ULL << 49) #define SCR_NSE (1ULL << 62) diff --git a/target/arm/helper.c b/target/arm/helper.c index 984406c945..5707eea822 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6144,6 +6144,8 @@ static void define_arm_vh_e2h_redirects_aliases(ARMCP= U *cpu) static const struct E2HAlias aliases[] =3D { { K(3, 0, 1, 0, 0), K(3, 4, 1, 0, 0), K(3, 5, 1, 0, 0), "SCTLR", "SCTLR_EL2", "SCTLR_EL12" }, + { K(3, 0, 1, 0, 3), K(3, 4, 1, 0, 3), K(3, 5, 1, 0, 3), + "SCTLR2_EL1", "SCTLR2_EL2", "SCTLR2_EL12" }, { K(3, 0, 1, 0, 2), K(3, 4, 1, 1, 2), K(3, 5, 1, 0, 2), "CPACR", "CPTR_EL2", "CPACR_EL12" }, { K(3, 0, 2, 0, 0), K(3, 4, 2, 0, 0), K(3, 5, 2, 0, 0), @@ -7816,6 +7818,78 @@ static const ARMCPRegInfo actlr2_hactlr2_reginfo[] = =3D { .resetvalue =3D 0 }, }; =20 +static CPAccessResult sctlr2_el2_access(CPUARMState *env, + const ARMCPRegInfo *ri, + bool isread) +{ + if (arm_current_el(env) < 3 && !(env->cp15.scr_el3 & SCR_SCTLR2EN)) { + return CP_ACCESS_TRAP_EL3; + } + return CP_ACCESS_OK; +}; + +static CPAccessResult sctlr2_el1_access(CPUARMState *env, + const ARMCPRegInfo *ri, + bool isread) +{ + CPAccessResult ret =3D access_tvm_trvm(env, ri, isread); + if (ret !=3D CP_ACCESS_OK) { + return ret; + } + if (arm_current_el(env) < 2 && !(arm_hcrx_el2_eff(env) & HCRX_SCTLR2EN= )) { + return CP_ACCESS_TRAP_EL2; + } + return sctlr2_el2_access(env, ri, isread); +}; + +static void sctlr2_el1_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + /* This register does not control any feature yet. */ +}; + +static void sctlr2_el2_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + uint64_t valid_mask =3D 0; + + if (cpu_isar_feature(aa64_mec, env_archcpu(env))) { + valid_mask |=3D SCTLR2_EMEC; + } + value &=3D valid_mask; + raw_write(env, ri, value); +}; + +static void sctlr2_el3_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + uint64_t valid_mask =3D 0; + + if (cpu_isar_feature(aa64_mec, env_archcpu(env))) { + valid_mask |=3D SCTLR2_EMEC; + } + value &=3D valid_mask; + raw_write(env, ri, value); +}; + +static const ARMCPRegInfo sctlr2_reginfo[] =3D { + { .name =3D "SCTLR2_EL1", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 0, .opc2 =3D 3, .crn =3D 1, .crm =3D 0, + .access =3D PL1_RW, .accessfn =3D sctlr2_el1_access, + .writefn =3D sctlr2_el1_write, .fgt =3D FGT_SCTLR_EL1, + .nv2_redirect_offset =3D 0x278 | NV2_REDIR_NV1, + .fieldoffset =3D offsetof(CPUARMState, cp15.sctlr2_el[1]) }, + { .name =3D "SCTLR2_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .opc2 =3D 3, .crn =3D 1, .crm =3D 0, + .access =3D PL2_RW, .accessfn =3D sctlr2_el2_access, + .writefn =3D sctlr2_el2_write, + .fieldoffset =3D offsetof(CPUARMState, cp15.sctlr2_el[2]) }, + { .name =3D "SCTLR2_EL3", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 6, .opc2 =3D 3, .crn =3D 1, .crm =3D 0, + .access =3D PL3_RW, .writefn =3D sctlr2_el3_write, + .fieldoffset =3D offsetof(CPUARMState, cp15.sctlr2_el[3]) }, +}; + void register_cp_regs_for_features(ARMCPU *cpu) { /* Register all the coprocessor registers based on feature bits */ @@ -9084,6 +9158,10 @@ void register_cp_regs_for_features(ARMCPU *cpu) define_arm_cp_regs(cpu, mec_reginfo); } =20 + if (cpu_isar_feature(aa64_sctlr2, cpu)) { + define_arm_cp_regs(cpu, sctlr2_reginfo); + } + if (cpu_isar_feature(any_predinv, cpu)) { define_arm_cp_regs(cpu, predinv_reginfo); } diff --git a/target/arm/internals.h b/target/arm/internals.h index 21a8d67edd..398e0b4a7d 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -232,6 +232,7 @@ FIELD(VTCR, SL2, 33, 1) #define HCRX_CMOW (1ULL << 9) #define HCRX_MCE2 (1ULL << 10) #define HCRX_MSCEN (1ULL << 11) +#define HCRX_SCTLR2EN (1ULL << 15) =20 #define HPFAR_NS (1ULL << 63) =20 diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c index d0df50a2f3..bdd2fe7f5b 100644 --- a/target/arm/tcg/cpu64.c +++ b/target/arm/tcg/cpu64.c @@ -1247,6 +1247,7 @@ void aarch64_max_tcg_initfn(Object *obj) t =3D FIELD_DP64(t, ID_AA64MMFR2, E0PD, 1); /* FEAT_E0PD */ SET_IDREG(isar, ID_AA64MMFR2, t); =20 + FIELD_DP64_IDREG(isar, ID_AA64MMFR3, SCTLRX, 1); /* FEAT_SCTLR2 */ FIELD_DP64_IDREG(isar, ID_AA64MMFR3, SPEC_FPACC, 1); /* FEAT_FPACC_SPE= C */ =20 t =3D GET_IDREG(isar, ID_AA64ZFR0); --=20 2.34.1 From nobody Sat Nov 15 12:44:15 2025 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=1752009617; cv=none; d=zohomail.com; s=zohoarc; b=P+C3KECOuy9KhOMNXBSHzHgygZGiEJXLnClgD6xAvXQ/6kaBobobVa0ext/niCFcuQrgXEW83xMQ6ClsZaeopw62q35IVB+4UAx5Pe54zSZAre/wpe+uZdqRoHqv+g0alAXyH0CipqUP+4EpZNohObGzpckmgm9DSLXIYq3TKL4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752009617; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=4llhfjCo4niQ3JvItczArHlabZV5Ziu1f63HFSylXpQ=; b=Yw0JSqPh1pklXLrKll1/4F4bYS9elvedEJrQKYNaSyNKY0UPIpypF6eDg0dCm2LuzgVd4Mked2XIeg31XB/4SBEdmhjuKsBwMiiVWHvskXSaR2X0eyMoFdQmxLz4038EscAXqTprDAgCbvZT8A81ic7e97JIOmafg6K7DfbUHno= 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 1752009617200956.5090081066813; Tue, 8 Jul 2025 14:20:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uZFEu-0007rZ-Nj; Tue, 08 Jul 2025 16:48:32 -0400 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 1uZDr8-0007hK-JW for qemu-devel@nongnu.org; Tue, 08 Jul 2025 15:20:00 -0400 Received: from mail-qv1-xf30.google.com ([2607:f8b0:4864:20::f30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uZDr0-00089w-E5 for qemu-devel@nongnu.org; Tue, 08 Jul 2025 15:19:49 -0400 Received: by mail-qv1-xf30.google.com with SMTP id 6a1803df08f44-702cbfe860cso44364426d6.1 for ; Tue, 08 Jul 2025 12:19:22 -0700 (PDT) Received: from gromero0.. ([189.110.24.38]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-702d638846asm56289096d6.22.2025.07.08.12.19.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jul 2025 12:19:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1752002361; x=1752607161; darn=nongnu.org; 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=4llhfjCo4niQ3JvItczArHlabZV5Ziu1f63HFSylXpQ=; b=rVomrU7oxAKN/3/+V3yPsNL6FSG59MuHP8aPKc+Y1gkiDBz746FkT6UIVqLQULcMhY oLbItcS/D2jdDE8ESwBDk8WgMoOsth6muQbimhPVW7PFBvFC/cQpDHMYMAXOx3txDFOV Yk6RqSb9nMTOXVJXonhtvZvQGPRP3zyXlqUwQ7MLmy8TLMGqRpJVt9f0uheJGGuheusD lzKXdqNEZLJwM1yXWRRIi0W2bMrR8ux1YuBhG3oymdQVxPiC3mZmP7T6hx8AxR5pUwuD R7p2jALU1ojJ/nkb7oV/wCNkruutC8bjGMXE2SX9Dlls3tqSUgDuArDrazWWhEl7AikX BTrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752002361; x=1752607161; 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=4llhfjCo4niQ3JvItczArHlabZV5Ziu1f63HFSylXpQ=; b=q8+Iw3tDk6BmTxrUfDmWsl8qQjHjjcKHmraroE8NFtQ1OkHLuAf+NZ0gyAPWaTPO/d Ti/yJfo8Edo0UZArrdP7PRcD6MWAgk3gygTOF7T9ZFXKMx4Y/NsCngfkpNArm7vrN23n f4niifRvB3VKgsaDzQWkiOWGEuBFfgbkcsrVgfrYsHp1VU+R56vMVdDVAFqDAFCHyF2P Zo+R9ukeRJaKFmcB6Zt8RzXrGfCssklaqMlHPVki3l0nDmEBiu+ttA7xDfDo2f4heYaY Zbm8u2HQ1sOWaOih6+O4M0n6s5rQjlEnrcUIhnHFBeTEqZErA8GKWh7mjl7FXoFbCMKF Wbcw== X-Gm-Message-State: AOJu0Yws5I3dy9KKhSxnQh5VLVvp9OWSKHIXi3wwGobSWOBzu4vbNUus 6dfkTZnSu8ayvRBGSzlBn5DzarWfPyFekV+jxHqJ9RO40UwTbllolTsRXEoZVX2ATWo= X-Gm-Gg: ASbGncvw8hQ3c/d4QKCDMX3vlw2sfq3BaIY9CVQ8n5rt+2TrWuGaH1fZ6AXiTRZ6E// +HszdvwgOSqDHfH2jY4pJu+Bs2s0M3On8eIkPzdmPB4+B846O2aKROmJeJc90m6yA0BQyO2t4WY t3FYgd24ieugoQ5SLoYyE2SOSX/dkJwJGwyavrtxTtk19/JEizN1QXsKHqWaWEYUfLtxCDqqN3h LtxPXhgBKYTZNPejjCF6Ohy08nHT22MnwTQSBfb/w5SWtIOb60vVL3mxz+3e13qQLpRb0fhYqN4 lhBL7T1poOjZ64MZURiPug3Frr76Y/F+0rUy/wo+W8+5WnV8BOyBeqgR1jYfYkbABEQ= X-Google-Smtp-Source: AGHT+IG3M5ZvJmu9Yg60Qcstv00Jikbk6t3DEz/Y1ZZ0G2PkCv3ffJ45GOUn9h966Qfy25wL/tko2g== X-Received: by 2002:a05:6214:29cd:b0:6fd:5d38:b07d with SMTP id 6a1803df08f44-7047db196f3mr61258076d6.41.1752002361177; Tue, 08 Jul 2025 12:19:21 -0700 (PDT) From: Gustavo Romero To: qemu-arm@nongnu.org, richard.henderson@linaro.org, alex.bennee@linaro.org Cc: qemu-devel@nongnu.org, gustavo.romero@linaro.org Subject: [RFC PATCH-for-10.1 v3 4/5] target/arm: Add FEAT_TCR2 Date: Tue, 8 Jul 2025 19:17:03 +0000 Message-Id: <20250708191704.1068604-5-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250708191704.1068604-1-gustavo.romero@linaro.org> References: <20250708191704.1068604-1-gustavo.romero@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::f30; envelope-from=gustavo.romero@linaro.org; helo=mail-qv1-xf30.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: 1752009618133116600 Content-Type: text/plain; charset="utf-8" Add FEAT_TCR2, which introduces the TCR2_EL1 and TCR2_EL2 registers. These registers are extensions of the TCR_ELx registers and provide top-level control of the EL10 and EL20 translation regimes. Since the bits in these registers depend on other CPU features, and only FEAT_MEC is supported at the moment, the FEAT_TCR2 only implements the AMEC bits for now. Signed-off-by: Gustavo Romero --- docs/system/arm/emulation.rst | 1 + target/arm/cpu-features.h | 5 +++ target/arm/cpu.h | 2 ++ target/arm/helper.c | 60 +++++++++++++++++++++++++++++++++++ target/arm/internals.h | 19 +++++++++++ target/arm/tcg/cpu64.c | 1 + 6 files changed, 88 insertions(+) diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst index 66043b0747..1c597d8673 100644 --- a/docs/system/arm/emulation.rst +++ b/docs/system/arm/emulation.rst @@ -149,6 +149,7 @@ the following architecture extensions: - FEAT_SPECRES (Speculation restriction instructions) - FEAT_SSBS (Speculative Store Bypass Safe) - FEAT_SSBS2 (MRS and MSR instructions for SSBS version 2) +- FEAT_TCR2 (Support for TCR2_ELx) - FEAT_TGran16K (Support for 16KB memory translation granule size at stage= 1) - FEAT_TGran4K (Support for 4KB memory translation granule size at stage 1) - FEAT_TGran64K (Support for 64KB memory translation granule size at stage= 1) diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h index 44d6b655a9..3878aed589 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -486,6 +486,11 @@ static inline bool isar_feature_aa64_xs(const ARMISARe= gisters *id) return FIELD_EX64_IDREG(id, ID_AA64ISAR1, XS) !=3D 0; } =20 +static inline bool isar_feature_aa64_tcr2(const ARMISARegisters *id) +{ + return FIELD_EX64_IDREG(id, ID_AA64MMFR3, TCRX) !=3D 0; +} + /* * These are the values from APA/API/APA3. * In general these must be compared '>=3D', per the normal Arm ARM diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 32d30b7bb9..5c13f89b29 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -366,6 +366,7 @@ typedef struct CPUArchState { uint64_t vsttbr_el2; /* Secure Virtualization Translation Table. */ /* MMU translation table base control. */ uint64_t tcr_el[4]; + uint64_t tcr2_el[3]; uint64_t vtcr_el2; /* Virtualization Translation Control. */ uint64_t vstcr_el2; /* Secure Virtualization Translation Control. = */ uint32_t c2_data; /* MPU data cacheable bits. */ @@ -1739,6 +1740,7 @@ static inline void xpsr_write(CPUARMState *env, uint3= 2_t val, uint32_t mask) #define SCR_HXEN (1ULL << 38) #define SCR_TRNDR (1ULL << 40) #define SCR_ENTP2 (1ULL << 41) +#define SCR_TCR2EN (1ULL << 43) #define SCR_SCTLR2EN (1ULL << 44) #define SCR_GPF (1ULL << 48) #define SCR_MECEN (1ULL << 49) diff --git a/target/arm/helper.c b/target/arm/helper.c index 5707eea822..34e12bde90 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -6154,6 +6154,8 @@ static void define_arm_vh_e2h_redirects_aliases(ARMCP= U *cpu) "TTBR1_EL1", "TTBR1_EL2", "TTBR1_EL12" }, { K(3, 0, 2, 0, 2), K(3, 4, 2, 0, 2), K(3, 5, 2, 0, 2), "TCR_EL1", "TCR_EL2", "TCR_EL12" }, + { K(3, 0, 2, 0, 3), K(3, 4, 2, 0, 3), K(3, 5, 2, 0, 3), + "TCR2_EL1", "TCR2_EL2", "TCR2_EL12" }, { K(3, 0, 4, 0, 0), K(3, 4, 4, 0, 0), K(3, 5, 4, 0, 0), "SPSR_EL1", "SPSR_EL2", "SPSR_EL12" }, { K(3, 0, 4, 0, 1), K(3, 4, 4, 0, 1), K(3, 5, 4, 0, 1), @@ -7890,6 +7892,60 @@ static const ARMCPRegInfo sctlr2_reginfo[] =3D { .fieldoffset =3D offsetof(CPUARMState, cp15.sctlr2_el[3]) }, }; =20 +static CPAccessResult tcr2_el2_access(CPUARMState *env, const ARMCPRegInfo= *ri, + bool isread) +{ + if (arm_current_el(env) < 3 && !(env->cp15.scr_el3 & SCR_TCR2EN)) { + return CP_ACCESS_TRAP_EL3; + } + return CP_ACCESS_OK; +}; + +static CPAccessResult tcr2_el1_access(CPUARMState *env, const ARMCPRegInfo= *ri, + bool isread) +{ + CPAccessResult ret =3D access_tvm_trvm(env, ri, isread); + if (ret !=3D CP_ACCESS_OK) { + return ret; + } + if (arm_current_el(env) < 2 && !(arm_hcrx_el2_eff(env) & HCRX_TCR2EN))= { + return CP_ACCESS_TRAP_EL2; + } + return tcr2_el2_access(env, ri, isread); +} + +static void tcr2_el1_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + /* This register does not control any feature yet. */ +} + +static void tcr2_el2_write(CPUARMState *env, const ARMCPRegInfo *ri, + uint64_t value) +{ + uint64_t valid_mask =3D 0; + + if (cpu_isar_feature(aa64_mec, env_archcpu(env))) { + valid_mask |=3D TCR2_AMEC0 | TCR2_AMEC1; + } + value &=3D valid_mask; + raw_write(env, ri, value); +} + +static const ARMCPRegInfo tcr2_reginfo[] =3D { + { .name =3D "TCR2_EL1", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 0, .opc2 =3D 3, .crn =3D 2, .crm =3D 0, + .access =3D PL1_RW, .accessfn =3D tcr2_el1_access, + .writefn =3D tcr2_el1_write, .fgt =3D FGT_TCR_EL1, + .nv2_redirect_offset =3D 0x270 | NV2_REDIR_NV1, + .fieldoffset =3D offsetof(CPUARMState, cp15.tcr2_el[1]) }, + { .name =3D "TCR2_EL2", .state =3D ARM_CP_STATE_AA64, + .opc0 =3D 3, .opc1 =3D 4, .opc2 =3D 3, .crn =3D 2, .crm =3D 0, + .access =3D PL2_RW, .accessfn =3D tcr2_el2_access, + .writefn =3D tcr2_el2_write, + .fieldoffset =3D offsetof(CPUARMState, cp15.tcr2_el[2]) }, +}; + void register_cp_regs_for_features(ARMCPU *cpu) { /* Register all the coprocessor registers based on feature bits */ @@ -9162,6 +9218,10 @@ void register_cp_regs_for_features(ARMCPU *cpu) define_arm_cp_regs(cpu, sctlr2_reginfo); } =20 + if (cpu_isar_feature(aa64_tcr2, cpu)) { + define_arm_cp_regs(cpu, tcr2_reginfo); + } + if (cpu_isar_feature(any_predinv, cpu)) { define_arm_cp_regs(cpu, predinv_reginfo); } diff --git a/target/arm/internals.h b/target/arm/internals.h index 398e0b4a7d..4b3dde82c6 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -201,6 +201,24 @@ FIELD(CPTR_EL3, TCPAC, 31, 1) #define TTBCR_SH1 (1U << 28) #define TTBCR_EAE (1U << 31) =20 +#define TCR2_PNCH (1ULL << 0) +#define TCR2_PIE (1ULL << 1) +#define TCR2_E0POE (1ULL << 2) +#define TCR2_POE (1ULL << 3) +#define TCR2_AIE (1ULL << 4) +#define TCR2_D128 (1ULL << 5) +#define TCR2_PTTWI (1ULL << 10) +#define TCR2_HAFT (1ULL << 11) +#define TCR2_AMEC0 (1ULL << 12) +#define TCR2_AMEC1 (1ULL << 13) +#define TCR2_DISCH0 (1ULL << 14) +#define TCR2_DISCH1 (1ULL << 15) +#define TCR2_A2 (1ULL << 16) +#define TCR2_FNG0 (1ULL << 17) +#define TCR2_FNG1 (1ULL << 18) +#define TCR2_FNGNA0 (1ULL << 20) +#define TCR2_FNGNA1 (1ULL << 21) + FIELD(VTCR, T0SZ, 0, 6) FIELD(VTCR, SL0, 6, 2) FIELD(VTCR, IRGN0, 8, 2) @@ -232,6 +250,7 @@ FIELD(VTCR, SL2, 33, 1) #define HCRX_CMOW (1ULL << 9) #define HCRX_MCE2 (1ULL << 10) #define HCRX_MSCEN (1ULL << 11) +#define HCRX_TCR2EN (1ULL << 14) #define HCRX_SCTLR2EN (1ULL << 15) =20 #define HPFAR_NS (1ULL << 63) diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c index bdd2fe7f5b..173528175a 100644 --- a/target/arm/tcg/cpu64.c +++ b/target/arm/tcg/cpu64.c @@ -1247,6 +1247,7 @@ void aarch64_max_tcg_initfn(Object *obj) t =3D FIELD_DP64(t, ID_AA64MMFR2, E0PD, 1); /* FEAT_E0PD */ SET_IDREG(isar, ID_AA64MMFR2, t); =20 + FIELD_DP64_IDREG(isar, ID_AA64MMFR3, TCRX, 1); /* FEAT_TCR2 */ FIELD_DP64_IDREG(isar, ID_AA64MMFR3, SCTLRX, 1); /* FEAT_SCTLR2 */ FIELD_DP64_IDREG(isar, ID_AA64MMFR3, SPEC_FPACC, 1); /* FEAT_FPACC_SPE= C */ =20 --=20 2.34.1 From nobody Sat Nov 15 12:44:15 2025 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=1752009645; cv=none; d=zohomail.com; s=zohoarc; b=l+MHofv/jS35cXhJ9bq1b33TtSq5HXreS1QPlyHK9+KqiLJZE6KqgtM/F4NWGWUx6OySHR0dLgxQeEDm9dpytrXG365pJnoEyhTlgi/gjvN73YyO0rQJ0FoNIxMs2UjBwvGZaiUeTjLtlCv5Z8SFL+8oaNxV0yADuhLbqvYozy4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752009645; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=5B4J7cwfIkU9OopnPqIRveaXurIgb8F7x1j5VTGinLY=; b=Uljx3nlhbJ2Cz7XV20LDJ4Z19ZrgfCgJKeyf6ws1euUskJeni6Fr8usZph/2MmVwps4/lJlpohPU+U0LFMR30bi7E7Gz/A/Md1uKTjFseRRhMz1nsgoPLrvrtqIE1zAroZGXj4gUsA7ddeYaVRraPKgFvLejRaFGarJ+d9YXgcA= 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 1752009645495187.5470827232699; Tue, 8 Jul 2025 14:20:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uZFDu-0005Rm-7l; Tue, 08 Jul 2025 16:47:30 -0400 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 1uZDqm-000764-Tr for qemu-devel@nongnu.org; Tue, 08 Jul 2025 15:19:38 -0400 Received: from mail-qv1-xf29.google.com ([2607:f8b0:4864:20::f29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1uZDqi-0008AW-Jl for qemu-devel@nongnu.org; Tue, 08 Jul 2025 15:19:30 -0400 Received: by mail-qv1-xf29.google.com with SMTP id 6a1803df08f44-6facba680a1so65832506d6.3 for ; Tue, 08 Jul 2025 12:19:25 -0700 (PDT) Received: from gromero0.. ([189.110.24.38]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-702d638846asm56289096d6.22.2025.07.08.12.19.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Jul 2025 12:19:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1752002365; x=1752607165; darn=nongnu.org; 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=5B4J7cwfIkU9OopnPqIRveaXurIgb8F7x1j5VTGinLY=; b=W5G2pyveSbDQXh6H2bKHZxp4ysIs5gWYCPGcgYanAeaZYXWZeDFKHqiUvOUQtc5NuS rIwolvS+kooSkCdWIPWSIybsP3691j2oUl9PQutVOPplQIrMbTeZZnBivDMkYMRQ/hp9 0lqeFJVMP2yp+Y29pOetW3buSxSWpPhG0JjvBpzjkUNV2ephcGltpJwtyiXY6Z6lyiSg FR2xRu5XBUq2FqXeEJO0NTltTeZmhprI1r5sHadYRDYnuK7FgTQ0JKJsxhXXArGBE88O xdjJrVxdctHjeJJoXju7uMzH+hwssu/cW06iVU0x+/3u7UaXSv5xiV3d41XLDBux4Zsg YtiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752002365; x=1752607165; 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=5B4J7cwfIkU9OopnPqIRveaXurIgb8F7x1j5VTGinLY=; b=wUHhl7aZ7Y8EkXt/6/XMawGxOl3Ddr8JRSMUWULk3R15nxXnSpoq7vV6yJpXwOdFEg zmGcAMTPvuvJF9pNxHrYQLgyieZMSRtnH4gWPqhntbeLom63YPTsb2U3RTknJ0nC+0qj j9FAgvXwqfpgb3VKvQPWkEMCAgcjLm3StnsCm+6PBXcWcnQRs8CVTLCRiOOSyCv+xEwo SJq0SKVMvSVhjXbvmyGux1pHg/xE93qXqfH0I06vVrBPCbktwDCC5zkE7epbRAgcpxYg J+FB72I0kKDZy69QR2IyP8ax0IMzs9gh49oEEdX8xj75U1wG5ijmC9ZD09RCwE+8sYJM MSlQ== X-Gm-Message-State: AOJu0Yw/FJh+wtrkrxkFla+PhKMDdPpmIpBesNVmc4m+ovyz9195ad/i y+ACmrICYlRHBLiK+/9L0gjs5muhSIGT8mn/Fb5vEtjtQwIXHVG1eFoJdDRjIZxpd60= X-Gm-Gg: ASbGncuZcRPJ8C47+VFzih4dR5mkKIg4GF4XOA8nuFu+9CIXkMrIEmlbKgdZjD/AXG4 VQEH9c1EaX3804E9Jog0JefexLnvEGrsU1QQ+FqTKbNAsVGc0SM8BQCPuajftKZrth6nsmoh/Z5 CpldwKygglV6453iDxjqRXPQjsXMGFSvxthHHLbDQkFtZlnPpQrSPNQKUDYimZu/J3NHvrX5lZe Om9kmrujvGk3JAfvfbdfGYWkiHRf+OKIMKczirohMpPQ3M/frFYxmk4jcHr2TRrXb01y/iGdnYB hEjIZB2nypUkv8/oUF70eofCwUVbnJFRBebA2LZCiYtS0kCt7HHpMeJ7QUpqgUpsnrQ= X-Google-Smtp-Source: AGHT+IFIxemT5zTXsvX807OPlqqSJw+6IW0L98Yt7/taekt84gzT9ouA5Ea8ZCgScRnlKT2w5xinJg== X-Received: by 2002:a05:6214:5016:b0:701:a5d:7e37 with SMTP id 6a1803df08f44-702c8b7e6a2mr249166666d6.13.1752002363630; Tue, 08 Jul 2025 12:19:23 -0700 (PDT) From: Gustavo Romero To: qemu-arm@nongnu.org, richard.henderson@linaro.org, alex.bennee@linaro.org Cc: qemu-devel@nongnu.org, gustavo.romero@linaro.org Subject: [RFC PATCH-for-10.1 v3 5/5] target/arm: Advertise FEAT_MEC in cpu max Date: Tue, 8 Jul 2025 19:17:04 +0000 Message-Id: <20250708191704.1068604-6-gustavo.romero@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250708191704.1068604-1-gustavo.romero@linaro.org> References: <20250708191704.1068604-1-gustavo.romero@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::f29; envelope-from=gustavo.romero@linaro.org; helo=mail-qv1-xf29.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: 1752009646314116600 Content-Type: text/plain; charset="utf-8" Advertise FEAT_MEC in AA64MMFR3 ID register for the Arm64 cpu max as a first step to fully support FEAT_MEC. The FEAT_MEC is an extension to FEAT_RME that implements multiple Memory Encryption Contexts (MEC) so the memory in a realm can be encrypted and accessing it from the wrong encryption context is not possible. An encryption context allow the selection of a memory encryption engine. At this point, no real memory encryption or obfuscation is supported, but software stacks that rely on FEAT_MEC to run should work properly, except if they use the new cache management instructions, which will be implement in a subsequent commit. Signed-off-by: Gustavo Romero --- docs/system/arm/emulation.rst | 1 + target/arm/tcg/cpu64.c | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst index 1c597d8673..1b47246d2a 100644 --- a/docs/system/arm/emulation.rst +++ b/docs/system/arm/emulation.rst @@ -89,6 +89,7 @@ the following architecture extensions: - FEAT_LSE (Large System Extensions) - FEAT_LSE2 (Large System Extensions v2) - FEAT_LVA (Large Virtual Address space) +- FEAT_MEC (Memory Encryption Contexts) - FEAT_MixedEnd (Mixed-endian support) - FEAT_MixedEndEL0 (Mixed-endian support at EL0) - FEAT_MOPS (Standardization of memory operations) diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c index 173528175a..2c63940878 100644 --- a/target/arm/tcg/cpu64.c +++ b/target/arm/tcg/cpu64.c @@ -1249,6 +1249,7 @@ void aarch64_max_tcg_initfn(Object *obj) =20 FIELD_DP64_IDREG(isar, ID_AA64MMFR3, TCRX, 1); /* FEAT_TCR2 */ FIELD_DP64_IDREG(isar, ID_AA64MMFR3, SCTLRX, 1); /* FEAT_SCTLR2 */ + FIELD_DP64_IDREG(isar, ID_AA64MMFR3, MEC, 1); /* FEAT_MEC */ FIELD_DP64_IDREG(isar, ID_AA64MMFR3, SPEC_FPACC, 1); /* FEAT_FPACC_SPE= C */ =20 t =3D GET_IDREG(isar, ID_AA64ZFR0); --=20 2.34.1