From nobody Tue Feb 10 21:40:05 2026 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=1770731629; cv=none; d=zohomail.com; s=zohoarc; b=kOP5BQZffP66Xm2jum7PD2nlb+zp5DOmbPOtrQRgLqxxBd6/l8OY/tvr9d0h5FGRO2tR3xYEy8fohgEBYa6ts0wBnZ+rcUoTZ6jxSDT4EHccPALtZtWv5p7aexGkkvvHbmjlO57i3yoY1hkuLn7Kenno8wmqmjlhd9QWqBiJZlM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1770731629; h=Content-Type:Content-Transfer-Encoding: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:Cc; bh=GgDAOb9kz7PXxXREyH/qdM2DkTVepbIG5XlZE6jyCCk=; b=c475S1b3OfOqk+JE1jxH0p6NjscjIH8c+gOByYrPGOOUBaOp0lz581YQ/m3ORQvTPg/lteVqu7qOrOSIHxaBCQnMTKmCKvUbH8BEiKnWxrk+nOHmaiwC2G1BoIUOY0ZFeOCs3YYfSREL1IXqNgTP/VrBPu6Ef7i1EH/VlXNUISc= 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 1770731629929834.12165346781; Tue, 10 Feb 2026 05:53:49 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vpoAP-0002Gd-J6; Tue, 10 Feb 2026 08:52:37 -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 1vpoAN-0002FN-Ce for qemu-devel@nongnu.org; Tue, 10 Feb 2026 08:52:35 -0500 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vpoAK-0006OY-OQ for qemu-devel@nongnu.org; Tue, 10 Feb 2026 08:52:35 -0500 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-47ee76e8656so12865285e9.0 for ; Tue, 10 Feb 2026 05:52:32 -0800 (PST) Received: from lanath.. (wildly.archaic.org.uk. [81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4834d5d77f9sm64344875e9.3.2026.02.10.05.52.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Feb 2026 05:52:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1770731551; x=1771336351; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=GgDAOb9kz7PXxXREyH/qdM2DkTVepbIG5XlZE6jyCCk=; b=vUIuzON0vegThJgtJIReirLzbG6t7jrszieT2YbLribSD8lKITi4tlfCqLX9WPKX3S 51AYX64xfsnQOaNk4D2LMrdC5J0MZqeIW1mNg88LPRXNOXtXl+RrmGLCZvQuSeNDOVd/ 4u894uPnaMqPtU/FXzM6SfeypSoGMsOVyMju4bmLZkkTM1upDQJ3YlB7nAcTLqWI15Aq HjxkmQ5S4RGU4yiVZAJCvkbLmqsB9kQlAIYuMTXMJvWdfKi81cGxMRa5kt/HOR5mLSgD +s+Fcnbs75u9Pnk4/UnVJkxLlEdKAlkGkdRc2NVf4RywibCSvcLQWPMBRQDc50cnHOKZ 4fHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770731551; x=1771336351; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=GgDAOb9kz7PXxXREyH/qdM2DkTVepbIG5XlZE6jyCCk=; b=HYbSQO/T3BRhSXzaLdByAa71NCG8VpkfkKcziogg45uBCn3/PBDIc/cYt3tqDwsG5d hbK7B6GD+s5qRE0BWR1H32Z1Xh9aXmcbNAqJdJGKyuuklr2Or7Q2IFxSorp8gQG3sPdi fOFUUYR1nlcHkDkTztyy6yxTrx3AWad2GL01qAiukP8sn+WA9ZXOqxRR+3g04nxWumCv kO2T4GZzwqa9CEdfheC8juyUz4GmQCKjlf87CZrs4ST2SENoTdJXwGMtKFl/2n83FEoG Fu04Za37D9Y1C//VPY4LRbHobfD7JFGWGqBoz6C6+Fh+8/3Nj0mBxgd7OveHe3ch+2XF mVUg== X-Gm-Message-State: AOJu0YyDg0I3AuwT7s/O2/Qreuh/wanQKorxxpk1Q54HmaqPoYj+B7vI cmVjrnfQhOLqXCZRuPX0pu3zGSFcidIa0TIiryBS7EtofftezymsPQU5in+/QItd3Tkj+D/musN LaYA2 X-Gm-Gg: AZuq6aJTU/dQ0EbTnPpkick8oiIl7K9/a+XxwkjS0oqp9OPuJwt5xKjm6c/6IHk597f dU8+mP2/PkM/7ebbPz7vLEihW9tOwjshBTpxXTBLKnU5ImQ/P5L6CmUx9Nb36XQmaxml+KrPPSJ bNmaVHbxa4QCdSNVZCQfUXNoctCcpWOi5Uqu5lq1u0I/LvkWiKpfKygL6m5egN/VqkChAzEuOe4 cyG4szB3LpEGu29PTepjB4jJyEQWARQT8jFHGdxne4PdEJQk1m9pSE4WhZxshB6I6X5iZmbpW1e 6XTqk/GTlQYBBQwOCE0gfVD2NAYUE+lacBf8VM4+rm4V/tFJIdngkw5+DUyTimGhKyq6jd+m8YG jmVPE2LxYvZI+TF8JfH43Gm0X6zYWRPuM9BYws/oKJjbz+K/uQo3K1+bumFJlLXQukkYnTalE0L vLLsg+Xj2pZaEMIJ95ucrvLNqDdTq/0ED+0uMnaNzVrss6C0Px6L0vKnG7RFlKefFU7BR/+YGWc JiVp4Vt1mJNheB5EYetDwbbWDrM0MQ= X-Received: by 2002:a05:600c:3590:b0:477:79c7:8994 with SMTP id 5b1f17b1804b1-48320236b01mr234506765e9.30.1770731551153; Tue, 10 Feb 2026 05:52:31 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 26/26] target/arm: implement FEAT_E2H0 Date: Tue, 10 Feb 2026 13:52:06 +0000 Message-ID: <20260210135206.229528-27-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260210135206.229528-1-peter.maydell@linaro.org> References: <20260210135206.229528-1-peter.maydell@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=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.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: qemu development 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: 1770731632695154100 From: Alex Benn=C3=A9e FEAT_E2H0 is a formalisation of the existing behaviour of HCR_EL2.E2H being programmable to switch between EL2 host mode and the "traditional" nVHE EL2 mode. This implies at some point we might want to model CPUs without FEAT_E2H0 which will always have EL2 host mode enabled. There are two values to represent no E2H0 systems of which 0b1110 will make HCR_EL2.NV1 RES0 for FEAT_NV systems. For FEAT_NV2 the NV1 bit is always valid. Message-ID: <20260130181648.628364-1-alex.bennee@linaro.org> Signed-off-by: Alex Benn=C3=A9e Reviewed-by: Mohamed Mediouni Message-id: 20260205210231.888199-1-alex.bennee@linaro.org Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- docs/system/arm/emulation.rst | 1 + target/arm/cpu-features.h | 15 +++++++++++++++ target/arm/helper.c | 21 +++++++++++++++------ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst index e0d5f9886e..7787691853 100644 --- a/docs/system/arm/emulation.rst +++ b/docs/system/arm/emulation.rst @@ -54,6 +54,7 @@ the following architecture extensions: - FEAT_DotProd (Advanced SIMD dot product instructions) - FEAT_DoubleFault (Double Fault Extension) - FEAT_E0PD (Preventing EL0 access to halves of address maps) +- FEAT_E2H0 (Programming of HCR_EL2.E2H) - FEAT_EBF16 (AArch64 Extended BFloat16 instructions) - FEAT_ECV (Enhanced Counter Virtualization) - FEAT_EL0 (Support for execution at EL0) diff --git a/target/arm/cpu-features.h b/target/arm/cpu-features.h index f7b1437340..49c50e850a 100644 --- a/target/arm/cpu-features.h +++ b/target/arm/cpu-features.h @@ -347,6 +347,7 @@ FIELD(ID_AA64MMFR3, ADERR, 56, 4) FIELD(ID_AA64MMFR3, SPEC_FPACC, 60, 4) =20 FIELD(ID_AA64MMFR4, ASID2, 8, 4) +FIELD(ID_AA64MMFR4, E2H0, 24, 4) =20 FIELD(ID_AA64DFR0, DEBUGVER, 0, 4) FIELD(ID_AA64DFR0, TRACEVER, 4, 4) @@ -1376,6 +1377,20 @@ static inline bool isar_feature_aa64_asid2(const ARM= ISARegisters *id) return FIELD_EX64_IDREG(id, ID_AA64MMFR4, ASID2) !=3D 0; } =20 +/* + * Note the E2H0 ID fields is signed, increasingly negative as more + * isn't implemented. + */ +static inline bool isar_feature_aa64_e2h0(const ARMISARegisters *id) +{ + return FIELD_SEX64_IDREG(id, ID_AA64MMFR4, E2H0) >=3D 0; +} + +static inline bool isar_feature_aa64_nv1_res0(const ARMISARegisters *id) +{ + return FIELD_SEX64_IDREG(id, ID_AA64MMFR4, E2H0) <=3D -2; +} + static inline bool isar_feature_aa64_mec(const ARMISARegisters *id) { return FIELD_EX64_IDREG(id, ID_AA64MMFR3, MEC) !=3D 0; diff --git a/target/arm/helper.c b/target/arm/helper.c index e86ceb130c..8c5769477c 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -3776,7 +3776,8 @@ static void do_hcr_write(CPUARMState *env, uint64_t v= alue, uint64_t valid_mask) } =20 if (arm_feature(env, ARM_FEATURE_AARCH64)) { - if (cpu_isar_feature(aa64_vh, cpu)) { + if (cpu_isar_feature(aa64_vh, cpu) && + cpu_isar_feature(aa64_e2h0, cpu)) { valid_mask |=3D HCR_E2H; } if (cpu_isar_feature(aa64_ras, cpu)) { @@ -3801,7 +3802,10 @@ static void do_hcr_write(CPUARMState *env, uint64_t = value, uint64_t valid_mask) valid_mask |=3D HCR_GPF; } if (cpu_isar_feature(aa64_nv, cpu)) { - valid_mask |=3D HCR_NV | HCR_NV1 | HCR_AT; + valid_mask |=3D HCR_NV | HCR_AT; + if (!cpu_isar_feature(aa64_nv1_res0, cpu)) { + valid_mask |=3D HCR_NV1; + } } if (cpu_isar_feature(aa64_nv2, cpu)) { valid_mask |=3D HCR_NV2; @@ -3817,10 +3821,15 @@ static void do_hcr_write(CPUARMState *env, uint64_t= value, uint64_t valid_mask) /* Clear RES0 bits. */ value &=3D valid_mask; =20 - /* RW is RAO/WI if EL1 is AArch64 only */ - if (arm_feature(env, ARM_FEATURE_AARCH64) && - !cpu_isar_feature(aa64_aa32_el1, cpu)) { - value |=3D HCR_RW; + if (arm_feature(env, ARM_FEATURE_AARCH64)) { + /* RW is RAO/WI if EL1 is AArch64 only */ + if (!cpu_isar_feature(aa64_aa32_el1, cpu)) { + value |=3D HCR_RW; + } + /* Strictly E2H is RES1 unless FEAT_E2H0 relaxes the requirement */ + if (!cpu_isar_feature(aa64_e2h0, cpu)) { + value |=3D HCR_E2H; + } } =20 /* --=20 2.43.0