[PULL 14/36] target/arm: Don't clobber ID_PFR1.Security on M-profile cores

Maintainers: Jason Wang <jasowang@redhat.com>, Peter Maydell <peter.maydell@linaro.org>, Radoslaw Biernacki <rad@semihalf.com>, Vikram Garhwal <fnu.vikram@xilinx.com>, Jean-Christophe Dubois <jcd@tribudubois.net>, Laurent Vivier <lvivier@redhat.com>, Leif Lindholm <leif@nuviainc.com>, Thomas Huth <thuth@redhat.com>, Eric Auger <eric.auger@redhat.com>, Tyrone Ting <kfting@nuvoton.com>, Peter Chubb <peter.chubb@nicta.com.au>, "Edgar E. Iglesias" <edgar.iglesias@gmail.com>, Alistair Francis <alistair@alistair23.me>, Pavel Pisa <pisa@cmp.felk.cvut.cz>, Havard Skinnemoen <hskinnemoen@google.com>, Paolo Bonzini <pbonzini@redhat.com>
There is a newer version of this series
[PULL 14/36] target/arm: Don't clobber ID_PFR1.Security on M-profile cores
Posted by Peter Maydell 4 years, 3 months ago
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>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20201119215617.29887-4-peter.maydell@linaro.org
---
 target/arm/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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.
          */
-- 
2.20.1