From patchwork Thu Dec 15 12:49:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 634191 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp130728pvb; Thu, 15 Dec 2022 04:58:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf5FCCm/+y5/YqJtiirAg4yczGwafuPVQ8LerD8Avzk7DGk7I88mxhWg5FV8wEQdlJdBFirQ X-Received: by 2002:ad4:4d49:0:b0:4d7:45fb:f5ac with SMTP id m9-20020ad44d49000000b004d745fbf5acmr29639985qvm.23.1671109113859; Thu, 15 Dec 2022 04:58:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671109113; cv=none; d=google.com; s=arc-20160816; b=Ko858RKv2DPXowezBNNx+UUo5/YBicDyqnE7evrIDMNzCUjSBlXpcohHFEWiXCcE1C 0HVda0Z5C7Y1z1IDtgHKiWEVYZTza2StX4MqhWRtNH5OUhO8FvO0pBEbx8+ER9UbUrSn 1lbLw8TDvDURK+hvF47UYoggcIE9RQXdGqpvfXWSCyWfNpTayX3WwoIiHWThwZbd6Zq8 vhuDGqwlZZmO4DOhBsPamCihRRqFouMvySpomWbSmksJc5qLcdy6UtxFZDaoRIZtv6DZ UuBrZ5LsLioazMvObvUTuc77aPpv8F03VweZm3gc9SYLZod+cuIuFGC7G2YAZ0EWKqeE djig== 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:to:from :dkim-signature; bh=uupKhb0u/oKN7bGek/c6f+4vzO/X9cJUo24FKyvg7uE=; b=wkZVyl3Jg5PMIMAUULph3CqZ9EJAOZb0irbyCFqRw3kAbEhjWEN3kC8kZNvilIDjJq OrTicczogxZm7PbagMwp56OehvNkXdM3KTF+rXN9x6jrX6xvsP3mqeIAz0k+PpyEYPSN Su+MSH30J/c9ZZ5BKpF93udHjGYkBBVu2WUVh3SsLhKU3BwPrUXxNyuNwjewyIEm+Aek bCOOzthkmiaJHDsbS5BroShCGHbK/05zQLumzrjr5wT/3BSjsUYjBbEurFm+FvcuyPoJ KrXiH1smm1hGs5n3DFfuz+TvpjDOL2nyz0dKmQlMpnAFRha301jztpUCqNNeOa52+Z+m OLWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GafXR0H6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gv9-20020a056214262900b004c75e51845fsi1964603qvb.292.2022.12.15.04.58.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Dec 2022 04:58:33 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GafXR0H6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5ngx-0006nz-Oe; Thu, 15 Dec 2022 07:50:27 -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 1p5ngv-0006jn-Cx for qemu-devel@nongnu.org; Thu, 15 Dec 2022 07:50:25 -0500 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5ngt-00047M-DA for qemu-devel@nongnu.org; Thu, 15 Dec 2022 07:50:25 -0500 Received: by mail-wm1-x32d.google.com with SMTP id c65-20020a1c3544000000b003cfffd00fc0so1632598wma.1 for ; Thu, 15 Dec 2022 04:50:22 -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:to:from:from:to:cc:subject:date:message-id :reply-to; bh=uupKhb0u/oKN7bGek/c6f+4vzO/X9cJUo24FKyvg7uE=; b=GafXR0H62DHoizKAMC6X6O5jzyBN5SU1Xt+wW1YuMwA+Vo3LsoRKWXuTUIrScP2o9s F164/qg2JBiIm10NI9zw28kW5bC/AX3mqgJI+IImUio6+wxT8bP9VUXYePOYPVyvWZPn WjgvR7t8J10zYPKa14cnubKAmSoi1EY9xETTS3Z48JxLY/qQF41cDg2cZNZ0Z4Pse+hw PEHePgCVpXrbweHU4Bdgu4NRJxfuJ7e8Oz16+qj74Qu6Y7zbbTTzWwy8IVrxBS1OON1v njZ/9jxgiMw3qL0SFpZevIP+qAEy3bmF1Zv+5wVjYVfAu6Xhvz3SVSy5xJRD0p0W7H3x cmLQ== 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:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uupKhb0u/oKN7bGek/c6f+4vzO/X9cJUo24FKyvg7uE=; b=R4UcOwbtcrNZl73gbhVKhtEuJqu69ex6ZugdMrqAcrpAGFFMd2jJQ3PKetxNt4UdnG JqhvEu8E76RGNPWnAen8gmZ7KlYNKANtDkP68aiKQF/JTiKlLS5wqTFPTJgQvUeMGPWV tursAHGdDuO5Y9MIi7GVN9sS5P98js6uLOf786Bqu4swEs3jxkSRVVkv0k4YgbEIrnyC u24soAO59cg1mPWLCpOLjY8c84KIJJj5hvIa1aodFvcMMdJUgL9nC3uYV1UrvtxppOGs M4M2+HcB1Qub++s3kGrEjQwp8ROgNgDJ6Lo3n3QpARy/ijs+hX5Syuq1cCVsesXN/3sW ExCw== X-Gm-Message-State: ANoB5pmqHrCmAurDR/xZpntu0qAi4pPBrF/Bn+7OMSFPFQSiI6Z4/iSH F1l4mpXDZoMQgzzkalIVKe2fnQIxUPoCOpa4 X-Received: by 2002:a05:600c:1e86:b0:3cf:81af:8b73 with SMTP id be6-20020a05600c1e8600b003cf81af8b73mr21821896wmb.23.1671108622170; Thu, 15 Dec 2022 04:50:22 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id i12-20020a05600c354c00b003cfd64b6be1sm8388787wmq.27.2022.12.15.04.50.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Dec 2022 04:50:21 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 11/29] target/arm: Allow relevant HCR bits to be written for FEAT_EVT Date: Thu, 15 Dec 2022 12:49:51 +0000 Message-Id: <20221215125009.980128-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221215125009.980128-1-peter.maydell@linaro.org> References: <20221215125009.980128-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32d.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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org FEAT_EVT adds five new bits to the HCR_EL2 register: TTLBIS, TTLBOS, TICAB, TOCU and TID4. These allow the guest to enable trapping of various EL1 instructions to EL2. In this commit, add the necessary code to allow the guest to set these bits if the feature is present; because the bit is always zero when the feature isn't present we won't need to use explicit feature checks in the "trap on condition" tests in the following commits. Note that although full implementation of the feature (mandatory from Armv8.5 onward) requires all five trap bits, the ID registers permit a value indicating that only TICAB, TOCU and TID4 are implemented, which might be the case for CPUs between Armv8.2 and Armv8.5. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/cpu.h | 30 ++++++++++++++++++++++++++++++ target/arm/helper.c | 6 ++++++ 2 files changed, 36 insertions(+) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 9aeed3c8481..2b4bd20f9d0 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3757,6 +3757,16 @@ static inline bool isar_feature_aa32_tts2uxn(const ARMISARegisters *id) return FIELD_EX32(id->id_mmfr4, ID_MMFR4, XNX) != 0; } +static inline bool isar_feature_aa32_half_evt(const ARMISARegisters *id) +{ + return FIELD_EX32(id->id_mmfr4, ID_MMFR4, EVT) >= 1; +} + +static inline bool isar_feature_aa32_evt(const ARMISARegisters *id) +{ + return FIELD_EX32(id->id_mmfr4, ID_MMFR4, EVT) >= 2; +} + static inline bool isar_feature_aa32_dit(const ARMISARegisters *id) { return FIELD_EX32(id->id_pfr0, ID_PFR0, DIT) != 0; @@ -4029,6 +4039,16 @@ static inline bool isar_feature_aa64_ids(const ARMISARegisters *id) return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, IDS) != 0; } +static inline bool isar_feature_aa64_half_evt(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, EVT) >= 1; +} + +static inline bool isar_feature_aa64_evt(const ARMISARegisters *id) +{ + return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, EVT) >= 2; +} + static inline bool isar_feature_aa64_bti(const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, BT) != 0; @@ -4313,6 +4333,16 @@ static inline bool isar_feature_any_ras(const ARMISARegisters *id) return isar_feature_aa64_ras(id) || isar_feature_aa32_ras(id); } +static inline bool isar_feature_any_half_evt(const ARMISARegisters *id) +{ + return isar_feature_aa64_half_evt(id) || isar_feature_aa32_half_evt(id); +} + +static inline bool isar_feature_any_evt(const ARMISARegisters *id) +{ + return isar_feature_aa64_evt(id) || isar_feature_aa32_evt(id); +} + /* * Forward to the above feature tests given an ARMCPU pointer. */ diff --git a/target/arm/helper.c b/target/arm/helper.c index d8c8223ec38..751c360ce45 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -5267,6 +5267,12 @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask) } } + if (cpu_isar_feature(any_evt, cpu)) { + valid_mask |= HCR_TTLBIS | HCR_TTLBOS | HCR_TICAB | HCR_TOCU | HCR_TID4; + } else if (cpu_isar_feature(any_half_evt, cpu)) { + valid_mask |= HCR_TICAB | HCR_TOCU | HCR_TID4; + } + /* Clear RES0 bits. */ value &= valid_mask;