diff mbox series

[08/13] target/arm: Derive id_pfr0 from features

Message ID 20180915161738.25257-9-richard.henderson@linaro.org
State New
Headers show
Series target/arm: Derive cpu id regs from features | expand

Commit Message

Richard Henderson Sept. 15, 2018, 4:17 p.m. UTC
??? The assertion does fire for old cpus; they may be existing bugs.

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

---
 target/arm/cpu.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

-- 
2.17.1
diff mbox series

Patch

diff --git a/target/arm/cpu.c b/target/arm/cpu.c
index c227044946..0151c278e8 100644
--- a/target/arm/cpu.c
+++ b/target/arm/cpu.c
@@ -969,6 +969,29 @@  static uint32_t resolve_id_isar6(CPUARMState *env)
     return ret;
 }
 
+static uint32_t resolve_id_pfr0(CPUARMState *env)
+{
+    uint32_t ret = 0;
+
+    if (!arm_feature(env, ARM_FEATURE_M)) {
+        ret = deposit32(ret, 0, 4, 1);            /* State0 -- A32 */
+    }
+    if (arm_feature(env, ARM_FEATURE_THUMB2)) {
+        ret = deposit32(ret, 4, 4, 3);            /* State1 -- T32 */
+    } else if (arm_feature(env, ARM_FEATURE_V5)) {
+        ret = deposit32(ret, 4, 4, 1);            /* State1 -- bl/blx only */
+    }
+    if (arm_feature(env, ARM_FEATURE_JAZELLE)) {
+        ret = deposit32(ret, 8, 4, 1);            /* State2 -- Jazelle */
+    }
+    if (arm_feature(env, ARM_FEATURE_THUMB2EE)) {
+        ret = deposit32(ret, 12, 4, 1);           /* State3 -- T32EE */
+    }
+    /* RAS -- not implemented yet */
+
+    return ret;
+}
+
 static void resolve_id_regs(ARMCPU *cpu)
 {
     CPUARMState *env = &cpu->env;
@@ -997,6 +1020,10 @@  static void resolve_id_regs(ARMCPU *cpu)
 
     cpu->id_isar5 = resolve_id_isar5(env);
     cpu->id_isar6 = resolve_id_isar6(env);
+
+    orig = cpu->id_pfr0;
+    cpu->id_pfr0 = resolve_id_pfr0(env);
+    g_assert_cmphex(cpu->id_pfr0, ==, orig);
 }
 
 static void arm_cpu_realizefn(DeviceState *dev, Error **errp)