[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 04/14] target/arm: Don't allow RES0 CNTHCTL_EL2 bits to be written
From: |
Peter Maydell |
Subject: |
[PULL 04/14] target/arm: Don't allow RES0 CNTHCTL_EL2 bits to be written |
Date: |
Fri, 8 Mar 2024 15:50:05 +0000 |
Don't allow the guest to write CNTHCTL_EL2 bits which don't exist.
This is not strictly architecturally required, but it is how we've
tended to implement registers more recently.
In particular, bits [19:18] are only present with FEAT_RME,
and bits [17:12] will only be present with FEAT_ECV.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20240301183219.2424889-5-peter.maydell@linaro.org
---
target/arm/helper.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 1c82d12a883..37845218527 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -2968,6 +2968,24 @@ static void gt_cnthctl_write(CPUARMState *env, const
ARMCPRegInfo *ri,
{
ARMCPU *cpu = env_archcpu(env);
uint32_t oldval = env->cp15.cnthctl_el2;
+ uint32_t valid_mask =
+ R_CNTHCTL_EL0PCTEN_E2H1_MASK |
+ R_CNTHCTL_EL0VCTEN_E2H1_MASK |
+ R_CNTHCTL_EVNTEN_MASK |
+ R_CNTHCTL_EVNTDIR_MASK |
+ R_CNTHCTL_EVNTI_MASK |
+ R_CNTHCTL_EL0VTEN_MASK |
+ R_CNTHCTL_EL0PTEN_MASK |
+ R_CNTHCTL_EL1PCTEN_E2H1_MASK |
+ R_CNTHCTL_EL1PTEN_MASK;
+
+ if (cpu_isar_feature(aa64_rme, cpu)) {
+ valid_mask |= R_CNTHCTL_CNTVMASK_MASK | R_CNTHCTL_CNTPMASK_MASK;
+ }
+
+ /* Clear RES0 bits */
+ value &= valid_mask;
+
raw_write(env, ri, value);
if ((oldval ^ value) & R_CNTHCTL_CNTVMASK_MASK) {
--
2.34.1
- [PULL 00/14] target-arm queue, Peter Maydell, 2024/03/08
- [PULL 02/14] target/arm: Timer _EL02 registers UNDEF for E2H == 0, Peter Maydell, 2024/03/08
- [PULL 01/14] target/arm: Move some register related defines to internals.h, Peter Maydell, 2024/03/08
- [PULL 06/14] target/arm: Define CNTPCTSS_EL0 and CNTVCTSS_EL0, Peter Maydell, 2024/03/08
- [PULL 07/14] target/arm: Implement FEAT_ECV CNTPOFF_EL2 handling, Peter Maydell, 2024/03/08
- [PULL 05/14] target/arm: Implement new FEAT_ECV trap bits, Peter Maydell, 2024/03/08
- [PULL 08/14] target/arm: Enable FEAT_ECV for 'max' CPU, Peter Maydell, 2024/03/08
- [PULL 04/14] target/arm: Don't allow RES0 CNTHCTL_EL2 bits to be written,
Peter Maydell <=
- [PULL 11/14] tests/qtest: Add STM32L4x5 GPIO QTest testcase, Peter Maydell, 2024/03/08
- [PULL 13/14] hw/rtc/sun4v-rtc: Relicense to GPLv2-or-later, Peter Maydell, 2024/03/08
- [PULL 12/14] target/arm: Fix 32-bit SMOPA, Peter Maydell, 2024/03/08
- [PULL 03/14] target/arm: use FIELD macro for CNTHCTL bit definitions, Peter Maydell, 2024/03/08
- [PULL 10/14] hw/arm: Connect STM32L4x5 GPIO to STM32L4x5 SoC, Peter Maydell, 2024/03/08
- [PULL 14/14] target/arm: Move v7m-related code from cpu32.c into a separate file, Peter Maydell, 2024/03/08
- [PULL 09/14] hw/gpio: Implement STM32L4x5 GPIO, Peter Maydell, 2024/03/08
- Re: [PULL 00/14] target-arm queue, Peter Maydell, 2024/03/09