diff mbox series

[03/15] target/arm: Don't clobber ID_PFR1.Security on M-profile cores

Message ID 20201116160831.31000-4-peter.maydell@linaro.org
State Superseded
Headers show
Series target/arm: More v8.1M features | expand

Commit Message

Peter Maydell Nov. 16, 2020, 4:08 p.m. UTC
In arm_cpu_realizefn() we check whether the board code disabled EL3
via the has_el3 CPU object property, which we create if the CPU
starts with the ARM_FEATURE_EL3 feature bit.  If it is disabled, then
we turn off ARM_FEATURE_EL3 and also zero out the relevant fields in
the ID_PFR1 and ID_AA64PFR0 registers.

This codepath was incorrectly being taken for M-profile CPUs, which
do not have an EL3 and don't set ARM_FEATURE_EL3, but which may have
the M-profile Security extension and so should have non-zero values
in the ID_PFR1.Security field.

Restrict the handling of the feature flag to A/R-profile cores.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

---
 target/arm/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.20.1

Comments

Richard Henderson Nov. 17, 2020, 7:12 p.m. UTC | #1
On 11/16/20 8:08 AM, Peter Maydell wrote:
> In arm_cpu_realizefn() we check whether the board code disabled EL3

> via the has_el3 CPU object property, which we create if the CPU

> starts with the ARM_FEATURE_EL3 feature bit.  If it is disabled, then

> we turn off ARM_FEATURE_EL3 and also zero out the relevant fields in

> the ID_PFR1 and ID_AA64PFR0 registers.

> 

> This codepath was incorrectly being taken for M-profile CPUs, which

> do not have an EL3 and don't set ARM_FEATURE_EL3, but which may have

> the M-profile Security extension and so should have non-zero values

> in the ID_PFR1.Security field.

> 

> Restrict the handling of the feature flag to A/R-profile cores.

> 

> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

> ---

>  target/arm/cpu.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)


Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~
diff mbox series

Patch

diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index 07492e9f9a4..40f3f798b2b 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -1674,7 +1674,7 @@  static void arm_cpu_realizefn(DeviceState *dev, Error **errp)
         }
     }
 
-    if (!cpu->has_el3) {
+    if (!arm_feature(env, ARM_FEATURE_M) && !cpu->has_el3) {
         /* If the has_el3 CPU property is disabled then we need to disable the
          * feature.
          */