diff mbox series

target/arm: Implement ARMv8.3-CCIDX

Message ID 20200224182626.29252-1-peter.maydell@linaro.org
State New
Headers show
Series target/arm: Implement ARMv8.3-CCIDX | expand

Commit Message

Peter Maydell Feb. 24, 2020, 6:26 p.m. UTC
The ARMv8.3-CCIDX extension makes the CCSIDR_EL1 system ID registers
have a format that uses the full 64 bit width of the register, and
adds a new CCSIDR2 register so AArch32 can get at the high 32 bits.

QEMU doesn't implement caches, so we just treat these ID registers as
opaque values that are set to the correct constant values for each
CPU.  The only thing we need to do is allow 64-bit values in our
cssidr[] array and provide the CCSIDR2 accessors.

We don't set the CCIDX field in our 'max' CPU because the CCSIDR
constant values we use are the same as the ones used by the
Cortex-A57 and they are in the old 32-bit format. This means
that the extra regdef added here is unused currently, but it
means that whenever in the future we add a CPU that does need
the new 64-bit format it will just work when we set the cssidr
values and the ID registers for it.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
This is to some extent just ticking off the architecture
feature from our todo list, but it does avoid an unexpected
surprise for whoever is the first to need to implement a
core with ARMv8.3-CCIDX...

Based-on: 20200224172846.13053-1-peter.maydell@linaro.org
("target/arm: Implement v8.3-RCPC and v8.4-RCPC")
but only to avoid a textual conflict in cpu.h

 target/arm/cpu.h    | 17 ++++++++++++++++-
 target/arm/helper.c | 19 +++++++++++++++++++
 2 files changed, 35 insertions(+), 1 deletion(-)

Comments

Richard Henderson Feb. 24, 2020, 11:07 p.m. UTC | #1
On 2/24/20 10:26 AM, Peter Maydell wrote:
> The ARMv8.3-CCIDX extension makes the CCSIDR_EL1 system ID registers
> have a format that uses the full 64 bit width of the register, and
> adds a new CCSIDR2 register so AArch32 can get at the high 32 bits.
> 
> QEMU doesn't implement caches, so we just treat these ID registers as
> opaque values that are set to the correct constant values for each
> CPU.  The only thing we need to do is allow 64-bit values in our
> cssidr[] array and provide the CCSIDR2 accessors.
> 
> We don't set the CCIDX field in our 'max' CPU because the CCSIDR
> constant values we use are the same as the ones used by the
> Cortex-A57 and they are in the old 32-bit format. This means
> that the extra regdef added here is unused currently, but it
> means that whenever in the future we add a CPU that does need
> the new 64-bit format it will just work when we set the cssidr
> values and the ID registers for it.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> This is to some extent just ticking off the architecture
> feature from our todo list, but it does avoid an unexpected
> surprise for whoever is the first to need to implement a
> core with ARMv8.3-CCIDX...
> 
> Based-on: 20200224172846.13053-1-peter.maydell@linaro.org
> ("target/arm: Implement v8.3-RCPC and v8.4-RCPC")
> but only to avoid a textual conflict in cpu.h

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


r~
diff mbox series

Patch

diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 3ce453f1e01..7c860ca39ca 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -904,7 +904,7 @@  struct ARMCPU {
     /* The elements of this array are the CCSIDR values for each cache,
      * in the order L1DCache, L1ICache, L2DCache, L2ICache, etc.
      */
-    uint32_t ccsidr[16];
+    uint64_t ccsidr[16];
     uint64_t reset_cbar;
     uint32_t reset_auxcr;
     bool reset_hivecs;
@@ -3536,6 +3536,11 @@  static inline bool isar_feature_aa32_ac2(const ARMISARegisters *id)
     return FIELD_EX32(id->id_mmfr4, ID_MMFR4, AC2) != 0;
 }
 
+static inline bool isar_feature_aa32_ccidx(const ARMISARegisters *id)
+{
+    return FIELD_EX32(id->id_mmfr4, ID_MMFR4, CCIDX) != 0;
+}
+
 /*
  * 64-bit feature tests via id registers.
  */
@@ -3737,6 +3742,11 @@  static inline bool isar_feature_aa64_rcpc_8_4(const ARMISARegisters *id)
     return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, LRCPC) >= 2;
 }
 
+static inline bool isar_feature_aa64_ccidx(const ARMISARegisters *id)
+{
+    return FIELD_EX64(id->id_aa64mmfr2, ID_AA64MMFR2, CCIDX) != 0;
+}
+
 /*
  * Feature tests for "does this exist in either 32-bit or 64-bit?"
  */
@@ -3760,6 +3770,11 @@  static inline bool isar_feature_any_pmu_8_4(const ARMISARegisters *id)
     return isar_feature_aa64_pmu_8_4(id) || isar_feature_aa32_pmu_8_4(id);
 }
 
+static inline bool isar_feature_any_ccidx(const ARMISARegisters *id)
+{
+    return isar_feature_aa64_ccidx(id) || isar_feature_aa32_ccidx(id);
+}
+
 /*
  * Forward to the above feature tests given an ARMCPU pointer.
  */
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 79db169e046..045f1b680a4 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -6726,6 +6726,21 @@  static const ARMCPRegInfo predinv_reginfo[] = {
     REGINFO_SENTINEL
 };
 
+static uint64_t ccsidr2_read(CPUARMState *env, const ARMCPRegInfo *ri)
+{
+    /* Read the high 32 bits of the current CCSIDR */
+    return extract64(ccsidr_read(env, ri), 32, 32);
+}
+
+static const ARMCPRegInfo ccsidr2_reginfo[] = {
+    { .name = "CCSIDR2", .state = ARM_CP_STATE_BOTH,
+      .opc0 = 3, .opc1 = 1, .crn = 0, .crm = 0, .opc2 = 2,
+      .access = PL1_R,
+      .accessfn = access_aa64_tid2,
+      .readfn = ccsidr2_read, .type = ARM_CP_NO_RAW },
+    REGINFO_SENTINEL
+};
+
 static CPAccessResult access_aa64_tid3(CPUARMState *env, const ARMCPRegInfo *ri,
                                        bool isread)
 {
@@ -7788,6 +7803,10 @@  void register_cp_regs_for_features(ARMCPU *cpu)
         define_arm_cp_regs(cpu, predinv_reginfo);
     }
 
+    if (cpu_isar_feature(any_ccidx, cpu)) {
+        define_arm_cp_regs(cpu, ccsidr2_reginfo);
+    }
+
 #ifndef CONFIG_USER_ONLY
     /*
      * Register redirections and aliases must be done last,