[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/26] target/arm: Unify checking for M Main Extension in MRS/MSR
From: |
Peter Maydell |
Subject: |
[PULL 02/26] target/arm: Unify checking for M Main Extension in MRS/MSR |
Date: |
Mon, 23 Jan 2023 13:35:29 +0000 |
From: David Reiss <dreiss@meta.com>
BASEPRI, FAULTMASK, and their _NS equivalents only exist on devices with
the Main Extension. However, the MRS instruction did not check this,
and the MSR instruction handled it inconsistently (warning BASEPRI, but
silently ignoring writes to BASEPRI_NS). Unify this behavior and always
warn when reading or writing any of these registers if the extension is
not present.
Signed-off-by: David Reiss <dreiss@meta.com>
Message-id: 167330628518.10497.13100425787268927786-0@git.sr.ht
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
target/arm/m_helper.c | 22 ++++++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/target/arm/m_helper.c b/target/arm/m_helper.c
index 033a4d92614..d87b9ecd123 100644
--- a/target/arm/m_helper.c
+++ b/target/arm/m_helper.c
@@ -2465,11 +2465,17 @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
}
return env->v7m.primask[M_REG_NS];
case 0x91: /* BASEPRI_NS */
+ if (!arm_feature(env, ARM_FEATURE_M_MAIN)) {
+ goto bad_reg;
+ }
if (!env->v7m.secure) {
return 0;
}
return env->v7m.basepri[M_REG_NS];
case 0x93: /* FAULTMASK_NS */
+ if (!arm_feature(env, ARM_FEATURE_M_MAIN)) {
+ goto bad_reg;
+ }
if (!env->v7m.secure) {
return 0;
}
@@ -2515,8 +2521,14 @@ uint32_t HELPER(v7m_mrs)(CPUARMState *env, uint32_t reg)
return env->v7m.primask[env->v7m.secure];
case 17: /* BASEPRI */
case 18: /* BASEPRI_MAX */
+ if (!arm_feature(env, ARM_FEATURE_M_MAIN)) {
+ goto bad_reg;
+ }
return env->v7m.basepri[env->v7m.secure];
case 19: /* FAULTMASK */
+ if (!arm_feature(env, ARM_FEATURE_M_MAIN)) {
+ goto bad_reg;
+ }
return env->v7m.faultmask[env->v7m.secure];
default:
bad_reg:
@@ -2581,13 +2593,19 @@ void HELPER(v7m_msr)(CPUARMState *env, uint32_t
maskreg, uint32_t val)
env->v7m.primask[M_REG_NS] = val & 1;
return;
case 0x91: /* BASEPRI_NS */
- if (!env->v7m.secure || !arm_feature(env, ARM_FEATURE_M_MAIN)) {
+ if (!arm_feature(env, ARM_FEATURE_M_MAIN)) {
+ goto bad_reg;
+ }
+ if (!env->v7m.secure) {
return;
}
env->v7m.basepri[M_REG_NS] = val & 0xff;
return;
case 0x93: /* FAULTMASK_NS */
- if (!env->v7m.secure || !arm_feature(env, ARM_FEATURE_M_MAIN)) {
+ if (!arm_feature(env, ARM_FEATURE_M_MAIN)) {
+ goto bad_reg;
+ }
+ if (!env->v7m.secure) {
return;
}
env->v7m.faultmask[M_REG_NS] = val & 1;
--
2.34.1
- [PULL 01/26] target/arm: Widen cnthctl_el2 to uint64_t, (continued)
- [PULL 01/26] target/arm: Widen cnthctl_el2 to uint64_t, Peter Maydell, 2023/01/23
- [PULL 07/26] hw/i2c/bitbang_i2c: Convert DPRINTF() to trace events, Peter Maydell, 2023/01/23
- [PULL 09/26] hw/i2c/versatile_i2c: Replace VersatileI2CState -> ArmSbconI2CState, Peter Maydell, 2023/01/23
- [PULL 15/26] target/arm/sme: Introduce aarch64_set_svcr(), Peter Maydell, 2023/01/23
- [PULL 11/26] hw/i2c/versatile_i2c: Use ARM_SBCON_I2C() macro, Peter Maydell, 2023/01/23
- [PULL 19/26] target/arm/sme: Unify set_pstate() SM/ZA helpers as set_svcr(), Peter Maydell, 2023/01/23
- [PULL 22/26] target/arm: Don't set EXC_RETURN.ES if Security Extension not present, Peter Maydell, 2023/01/23
- [PULL 16/26] target/arm/sme: Reset SVE state in aarch64_set_svcr(), Peter Maydell, 2023/01/23
- [PULL 21/26] target/arm: Fix in_debug path in S1_ptw_translate, Peter Maydell, 2023/01/23
- [PULL 18/26] target/arm/sme: Rebuild hflags in aarch64_set_svcr(), Peter Maydell, 2023/01/23
- [PULL 02/26] target/arm: Unify checking for M Main Extension in MRS/MSR,
Peter Maydell <=
- [PULL 03/26] hw/i2c/bitbang_i2c: Define TYPE_GPIO_I2C in public header, Peter Maydell, 2023/01/23
- [PULL 04/26] hw/i2c/bitbang_i2c: Remove unused dummy MemoryRegion, Peter Maydell, 2023/01/23
- [PULL 08/26] hw/i2c/versatile_i2c: Drop useless casts from void * to pointer, Peter Maydell, 2023/01/23
- [PULL 06/26] hw/i2c/bitbang_i2c: Trace state changes, Peter Maydell, 2023/01/23
- [PULL 10/26] hw/i2c/versatile_i2c: Replace TYPE_VERSATILE_I2C -> TYPE_ARM_SBCON_I2C, Peter Maydell, 2023/01/23
- [PULL 05/26] hw/i2c/bitbang_i2c: Change state calling bitbang_i2c_set_state() helper, Peter Maydell, 2023/01/23
- [PULL 12/26] hw/i2c/versatile_i2c: Rename versatile_i2c -> arm_sbcon_i2c, Peter Maydell, 2023/01/23
- [PULL 17/26] target/arm/sme: Reset ZA state in aarch64_set_svcr(), Peter Maydell, 2023/01/23
- [PULL 23/26] target/arm: implement DBGCLAIM registers, Peter Maydell, 2023/01/23
- [PULL 20/26] target/arm: Fix physical address resolution for MTE, Peter Maydell, 2023/01/23