[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 02/10] target/arm: Correct value returned by pmu_counter_mask()
From: |
Peter Maydell |
Subject: |
[PATCH 02/10] target/arm: Correct value returned by pmu_counter_mask() |
Date: |
Thu, 11 Aug 2022 18:16:11 +0100 |
pmu_counter_mask() accidentally returns a value with bits [63:32]
set, because the expression it returns is evaluated as a signed value
that gets sign-extended to 64 bits. Force the whole expression to be
evaluated with 64-bit arithmetic with ULL suffixes.
The main effect of this bug was that a guest could write to the bits
in the high half of registers like PMCNTENSET_EL0 that are supposed
to be RES0.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/arm/internals.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/arm/internals.h b/target/arm/internals.h
index b8fefdff675..83526166de0 100644
--- a/target/arm/internals.h
+++ b/target/arm/internals.h
@@ -1296,7 +1296,7 @@ static inline uint32_t pmu_num_counters(CPUARMState *env)
/* Bits allowed to be set/cleared for PMCNTEN* and PMINTEN* */
static inline uint64_t pmu_counter_mask(CPUARMState *env)
{
- return (1 << 31) | ((1 << pmu_num_counters(env)) - 1);
+ return (1ULL << 31) | ((1ULL << pmu_num_counters(env)) - 1);
}
#ifdef TARGET_AARCH64
--
2.25.1
- [PATCH 00/10] target/arm: Implement FEAT_PMUv3p5, Peter Maydell, 2022/08/11
- [PATCH 01/10] target/arm: Don't corrupt high half of PMOVSR when cycle counter overflows, Peter Maydell, 2022/08/11
- [PATCH 02/10] target/arm: Correct value returned by pmu_counter_mask(),
Peter Maydell <=
- [PATCH 06/10] target/arm: Detect overflow when calculating next PMU interrupt, Peter Maydell, 2022/08/11
- [PATCH 03/10] target/arm: Don't mishandle count when enabling or disabling PMU counters, Peter Maydell, 2022/08/11
- [PATCH 08/10] target/arm: Implement FEAT_PMUv3p5 cycle counter disable bits, Peter Maydell, 2022/08/11
- [PATCH 05/10] target/arm: Honour MDCR_EL2.HPMD in Secure EL2, Peter Maydell, 2022/08/11