From patchwork Fri Aug 9 16:04:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 818113 Delivered-To: patch@linaro.org Received: by 2002:a5d:5711:0:b0:367:895a:4699 with SMTP id a17csp370450wrv; Fri, 9 Aug 2024 09:06:33 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVRxFM8eLrkN/HrsP8nfrJAS+2SUsPsgVIf7ZJ2QR1R2uIWr/Q2PWtRmcynUWgeqUiBJw2haQQjk5Rb2fGxmtLY X-Google-Smtp-Source: AGHT+IFnG0qrnCbz60KlVB2prrQhYhmpGQgi6WcUXEvgm2nrcIcrsh8jk2WMkUsBz750ooAoshOP X-Received: by 2002:a05:6359:4c21:b0:1ac:f2c7:eab5 with SMTP id e5c5f4694b2df-1b176eeb013mr215984155d.2.1723219593175; Fri, 09 Aug 2024 09:06:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723219593; cv=none; d=google.com; s=arc-20160816; b=ZX6PSmexbo7DkGCqL/2fY3h+0YCO+grsRq6wSObdFpKwM1oZnYgoGsfOc8wcf4J1kK wsvoUwejE4sg5/+rRi1FT79b6NAo0ji8t9JwNFMzXdLjdQ6ZpqxXgk9G8WxuN2cDTZER A+IMUsvHVSYIcd4QEFXbVpz2bc2/A/8dNJYOSqN2ABjIXwwfu9SkIiVWQyG8vHPve9Rs eYllJRpGAZICn18O833gLhTaAD0orh9GTE27uefH+6VaBw11FIRiMjB5ah4zVjDgdmsT Loa6r9WIon4//Rc5c53fJFmN7kr58muNXkaUAmCNk+VscMs2v/cFIn7jmRpMBdJMLACn tPAw== 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=ICJBhRzXeSHxiQ/p/CxRsyTFTBxBWWvxj76zvD9iTsA=; fh=Xi1NxiwtsJLB4dGyGrmhtABwXUT3VFMnlAa5NC0/xDw=; b=UF59SfKnpzL3T5F4EFxpt+to/feRE8XyTHodIi2UR2MauVt30f+3CGLmQi0z0eSerA bDQFhtdj3Q7V9MNWXN/wRqYn+yLZPoO+jYBEXoJHd6RA4djRoAsqYxBCsB9G0zry/xF2 St68YO4tR6lHmaMw2h4PS9B59cmvMaY4hNXOohqjJ4o3qtD2E1Q2aZ5UUxVRxRKRjBIY HO4h/EXskaTXIPmceUE6pIyEGIVkSLq3/mJoXgilUhAIjVffRkulkwytPN0MwT8G82C4 6GeEVKQeg+umGS4hEIhn2GLwVnEWl6egZrrkE49yJtfxhmQ5m6o5vsa2XjQR4lr7L9O+ WzOA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b5Abe9i1; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ada2fe7eead31-496dd030a48si143895137.467.2024.08.09.09.06.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 09 Aug 2024 09:06:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b5Abe9i1; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1scS7B-0004VE-3p; Fri, 09 Aug 2024 12:05:17 -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 1scS6p-0004JE-9L for qemu-devel@nongnu.org; Fri, 09 Aug 2024 12:04:56 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1scS6e-0005wM-HQ for qemu-devel@nongnu.org; Fri, 09 Aug 2024 12:04:51 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-42803bbf842so21454455e9.1 for ; Fri, 09 Aug 2024 09:04:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1723219477; x=1723824277; 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=ICJBhRzXeSHxiQ/p/CxRsyTFTBxBWWvxj76zvD9iTsA=; b=b5Abe9i1vt616+EgPJfr4bTfwx8KG3TRTHTadQp6ljSdXsis+pPhd1Fe6kJ/sEzQIP QUT0EXsvuh99U7+S/kQT6gBdsXrRIc37jKRMQPlqToBB+hmQLRcvb5eH1RLbkdYqD7TO 0861UWTULG64oy8KBGI1jHByUqmi3J0Ku+iAphQuUrU3ZOctcbWhiATw0jtQqWvc7AXE 5RgYiikbnc+oKG3lMaF8FxvuyMXbhx8iOnWfhloaCxRdq3qcMB+Dht6jS6IVOmwDAE85 lu1if1B8vB6JzKr3uz8Ym45QZGL7p0nVgiWTpT6ZzLtvzYA7G6lwJ0RfN24GYuPrZdgf htwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723219477; x=1723824277; 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=ICJBhRzXeSHxiQ/p/CxRsyTFTBxBWWvxj76zvD9iTsA=; b=L9fjRV+suR/Qab7mWf87Ym+HE1pX+xBxwbI7E3Mym93POo/wdh1WrSJ1+EWkxgHfbp TyFeIkpUX6HwsfxTlfH2jM4A9ejFu2sfYaEcF7gq9AISbmFRanAMxbgfGBdsAgDLpOgM SfBxoT8234VM2pezFyyGKF7jvKF23SLQ816o1pPqyFdHxP7/h0n/gPWpdxrP+wtoFSAy is1xf4SUYipmxhdAYqLNYQFH9zALgr5zwmHbUCbf31Ik8nezY0X5r7j/EB3xH2CGreLo MRvqu2FMRDeNr2za/e0gz++Rn+LEiydw44NCY13z+d9RCOYiWWQWZg9DS7D4b9hILp1+ nZLw== X-Forwarded-Encrypted: i=1; AJvYcCUYVDoRoHfG9qvIGhgQsQfYzKm1Wk/fR1tUL1QZpu3NqBEXzxIp685b00pvrx4Os3WV4IWYdKkkRmRfiTopwwJQvZf8Lrs= X-Gm-Message-State: AOJu0Yy8miNa4pKxzzViGsCU5tY3TFKlQipEeB1MkCZgIZ8p48JLQLat d25AiQ5Wtd5W1w7OkMyvzYepxE8hKc/b7h9tQXhfBiUIl5Agz44MOKYiu63yFGQ= X-Received: by 2002:a05:6000:b89:b0:368:3b5c:7a5d with SMTP id ffacd0b85a97d-36d5e1c7656mr2289108f8f.20.1723219477084; Fri, 09 Aug 2024 09:04:37 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-429059714d5sm135171295e9.13.2024.08.09.09.04.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 09 Aug 2024 09:04:32 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Bernhard Beschow Subject: [PATCH 1/2] target/arm: Update translation regime comment for new features Date: Fri, 9 Aug 2024 17:04:29 +0100 Message-Id: <20240809160430.1144805-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240809160430.1144805-1-peter.maydell@linaro.org> References: <20240809160430.1144805-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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 We have a long comment describing the Arm architectural translation regimes and how we map them to QEMU MMU indexes. This comment has got a bit out of date: * FEAT_SEL2 allows Secure EL2 and corresponding new regimes * FEAT_RME introduces Realm state and its translation regimes * We now model the Cortex-R52 so that is no longer a hypothetical * We separated Secure Stage 2 and NonSecure Stage 2 MMU indexes * We have an MMU index per physical address spacea Add the missing pieces so that the list of architectural translation regimes matches the Arm ARM, and the list and count of QEMU MMU indexes in the comment matches the enum. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/cpu.h | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index a12859fc533..216774f5d3a 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2772,8 +2772,14 @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync); * + NonSecure EL1 & 0 stage 2 * + NonSecure EL2 * + NonSecure EL2 & 0 (ARMv8.1-VHE) - * + Secure EL1 & 0 - * + Secure EL3 + * + Secure EL1 & 0 stage 1 + * + Secure EL1 & 0 stage 2 (FEAT_SEL2) + * + Secure EL2 (FEAT_SEL2) + * + Secure EL2 & 0 (FEAT_SEL2) + * + Realm EL1 & 0 stage 1 (FEAT_RME) + * + Realm EL1 & 0 stage 2 (FEAT_RME) + * + Realm EL2 (FEAT_RME) + * + EL3 * If EL3 is 32-bit: * + NonSecure PL1 & 0 stage 1 * + NonSecure PL1 & 0 stage 2 @@ -2805,10 +2811,12 @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync); * table over and over. * 6. we need separate EL1/EL2 mmu_idx for handling the Privileged Access * Never (PAN) bit within PSTATE. - * 7. we fold together the secure and non-secure regimes for A-profile, + * 7. we fold together most secure and non-secure regimes for A-profile, * because there are no banked system registers for aarch64, so the * process of switching between secure and non-secure is * already heavyweight. + * 8. we cannot fold together Stage 2 Secure and Stage 2 NonSecure, + * because both are in use simultaneously for Secure EL2. * * This gives us the following list of cases: * @@ -2820,14 +2828,15 @@ bool write_cpustate_to_list(ARMCPU *cpu, bool kvm_sync); * EL2 EL2&0 +PAN * EL2 (aka NS PL2) * EL3 (aka S PL1) - * Physical (NS & S) - * Stage2 (NS & S) + * Stage2 Secure + * Stage2 NonSecure + * plus one TLB per Physical address space: S, NS, Realm, Root * - * for a total of 12 different mmu_idx. + * for a total of 14 different mmu_idx. * * R profile CPUs have an MPU, but can use the same set of MMU indexes * as A profile. They only need to distinguish EL0 and EL1 (and - * EL2 if we ever model a Cortex-R52). + * EL2 for cores like the Cortex-R52). * * M profile CPUs are rather different as they do not have a true MMU. * They have the following different MMU indexes: