Skip to contentSkip to conversation

target/arm: More trivial features, A76, N1

PATCH In review Richard Henderson 2 participants 17 messages Apr 10, 2022 – Apr 11, 2022

lore
Share & tools
lore
#0 lore raw

cover target/arm: More trivial features, A76, N1

Based-on: [email protected] ("target/arm: Implement features Debugv8p4, RAS, IESB")

3 more completely trivial features, and a 4th that merely needs to add some state words.

Add definitions for cortex-a76 (also requires gicv4) and neoverse-n1 (also requires gicv4.1), but we now have all of the in-cpu features implemented.

r~

Richard Henderson (7):
target/arm: Enable FEAT_CSV2 for -cpu max target/arm: Update ISAR fields for ARMv8.8 target/arm: Enable FEAT_CSV2_2 for -cpu max target/arm: Enable FEAT_CSV3 for -cpu max target/arm: Enable FEAT_DGH for -cpu max target/arm: Define cortex-a76
target/arm: Define neoverse-n1

 target/arm/cpu.h           |  39 +++++++++++
 hw/arm/sbsa-ref.c          |   2 +
 hw/arm/virt.c              |   2 +
 target/arm/cpu64.c         | 131 +++++++++++++++++++++++++++++++++++++
 target/arm/cpu_tcg.c       |   2 +
 target/arm/helper.c        |  70 +++++++++++++++++++-
 target/arm/translate-a64.c |   1 +
 7 files changed, 246 insertions(+), 1 deletion(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/7 target/arm: Enable FEAT_CSV2 for -cpu max

This extension concerns branch speculation, which TCG does not implement. Thus we can trivially enable this feature.

---
 target/arm/cpu64.c   | 1 +
 target/arm/cpu_tcg.c | 1 +
 2 files changed, 2 insertions(+)
target/arm/cpu64.c +1 -0
index def0f1fdcb..c1006a067c 100644
@@ -805,6 +805,7 @@ static void aarch64_max_initfn(Object *obj)
     t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1);
     t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1);      /* FEAT_SEL2 */
     t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1);       /* FEAT_DIT */
+    t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 1);      /* FEAT_CSV2 */
     cpu->isar.id_aa64pfr0 = t;
 
     t = cpu->isar.id_aa64pfr1;
target/arm/cpu_tcg.c +1 -0
index 5cce9116d0..2750cbebec 100644
@@ -71,6 +71,7 @@ void arm32_max_features(ARMCPU *cpu)
     cpu->isar.id_mmfr4 = t;
 
     t = cpu->isar.id_pfr0;
+    t = FIELD_DP32(t, ID_PFR0, CSV2, 2);          /* FEAT_CVS2 */
     t = FIELD_DP32(t, ID_PFR0, DIT, 1);           /* FEAT_DIT */
     t = FIELD_DP32(t, ID_PFR0, RAS, 1);           /* FEAT_RAS */
     cpu->isar.id_pfr0 = t;
Signature · 1 line
2.25.1
#3 lore raw

PATCH 2/7 target/arm: Update ISAR fields for ARMv8.8

In reply to Richard Henderson

Update isar fields per ARM DDI0487 H.a.

---
 target/arm/cpu.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
target/arm/cpu.h +23 -0
index eb8cb738b5..c6c6d89a69 100644
@@ -1941,6 +1941,7 @@ FIELD(ID_MMFR4, CCIDX, 24, 4)
 FIELD(ID_MMFR4, EVT, 28, 4)
 
 FIELD(ID_MMFR5, ETS, 0, 4)
+FIELD(ID_MMFR5, NTLBPA, 4, 4)
 
 FIELD(ID_PFR0, STATE0, 0, 4)
 FIELD(ID_PFR0, STATE1, 4, 4)
@@ -1993,6 +1994,16 @@ FIELD(ID_AA64ISAR1, SPECRES, 40, 4)
 FIELD(ID_AA64ISAR1, BF16, 44, 4)
 FIELD(ID_AA64ISAR1, DGH, 48, 4)
 FIELD(ID_AA64ISAR1, I8MM, 52, 4)
+FIELD(ID_AA64ISAR1, XS, 56, 4)
+FIELD(ID_AA64ISAR1, LS64, 60, 4)
+
+FIELD(ID_AA64ISAR2, WFXT, 0, 4)
+FIELD(ID_AA64ISAR2, RPRES, 4, 4)
+FIELD(ID_AA64ISAR2, GPA3, 8, 4)
+FIELD(ID_AA64ISAR2, APA3, 12, 4)
+FIELD(ID_AA64ISAR2, MOPS, 16, 4)
+FIELD(ID_AA64ISAR2, BC, 20, 4)
+FIELD(ID_AA64ISAR2, PAC_FRAC, 24, 4)
 
 FIELD(ID_AA64PFR0, EL0, 0, 4)
 FIELD(ID_AA64PFR0, EL1, 4, 4)
@@ -2015,6 +2026,10 @@ FIELD(ID_AA64PFR1, SSBS, 4, 4)
 FIELD(ID_AA64PFR1, MTE, 8, 4)
 FIELD(ID_AA64PFR1, RAS_FRAC, 12, 4)
 FIELD(ID_AA64PFR1, MPAM_FRAC, 16, 4)
+FIELD(ID_AA64PFR1, SME, 24, 4)
+FIELD(ID_AA64PFR1, RNDR_TRAP, 28, 4)
+FIELD(ID_AA64PFR1, CSV2_FRAC, 32, 4)
+FIELD(ID_AA64PFR1, NMI, 36, 4)
 
 FIELD(ID_AA64MMFR0, PARANGE, 0, 4)
 FIELD(ID_AA64MMFR0, ASIDBITS, 4, 4)
@@ -2041,6 +2056,11 @@ FIELD(ID_AA64MMFR1, SPECSEI, 24, 4)
 FIELD(ID_AA64MMFR1, XNX, 28, 4)
 FIELD(ID_AA64MMFR1, TWED, 32, 4)
 FIELD(ID_AA64MMFR1, ETS, 36, 4)
+FIELD(ID_AA64MMFR1, HCX, 40, 4)
+FIELD(ID_AA64MMFR1, AFP, 44, 4)
+FIELD(ID_AA64MMFR1, NTLBPA, 48, 4)
+FIELD(ID_AA64MMFR1, TIDCP1, 52, 4)
+FIELD(ID_AA64MMFR1, CMOW, 56, 4)
 
 FIELD(ID_AA64MMFR2, CNP, 0, 4)
 FIELD(ID_AA64MMFR2, UAO, 4, 4)
@@ -2067,7 +2087,9 @@ FIELD(ID_AA64DFR0, CTX_CMPS, 28, 4)
 FIELD(ID_AA64DFR0, PMSVER, 32, 4)
 FIELD(ID_AA64DFR0, DOUBLELOCK, 36, 4)
 FIELD(ID_AA64DFR0, TRACEFILT, 40, 4)
+FIELD(ID_AA64DFR0, TRACEBUFFER, 44, 4)
 FIELD(ID_AA64DFR0, MTPMU, 48, 4)
+FIELD(ID_AA64DFR0, BRBE, 52, 4)
 
 FIELD(ID_AA64ZFR0, SVEVER, 0, 4)
 FIELD(ID_AA64ZFR0, AES, 4, 4)
@@ -2089,6 +2111,7 @@ FIELD(ID_DFR0, PERFMON, 24, 4)
 FIELD(ID_DFR0, TRACEFILT, 28, 4)
 
 FIELD(ID_DFR1, MTPMU, 0, 4)
+FIELD(ID_DFR1, HPMN0, 4, 4)
 
 FIELD(DBGDIDR, SE_IMP, 12, 1)
 FIELD(DBGDIDR, NSUHD_IMP, 14, 1)
Signature · 1 line
2.25.1
Reviewed-by on v1 2/7
#4 lore raw

Re: [PATCH 2/7] target/arm: Update ISAR fields for ARMv8.8

Quoted 9 lines · Richard Henderson

Update isar fields per ARM DDI0487 H.a.

---
 target/arm/cpu.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

target/arm/cpu.h FIELD(ID_AA64DFR0, CTX_CMPS, 28, 4) · line 2092

Quoted 6 lines
target/arm/cpu.h +2 -0
@@ -2067,7 +2087,9 @@ FIELD(ID_AA64DFR0, CTX_CMPS, 28, 4)
 FIELD(ID_AA64DFR0, PMSVER, 32, 4)
 FIELD(ID_AA64DFR0, DOUBLELOCK, 36, 4)
 FIELD(ID_AA64DFR0, TRACEFILT, 40, 4)
+FIELD(ID_AA64DFR0, TRACEBUFFER, 44, 4)
 FIELD(ID_AA64DFR0, MTPMU, 48, 4)
+FIELD(ID_AA64DFR0, BRBE, 52, 4)

Also
FIELD(ID_AA64DFR0, HPMN0, 60, 4)

Otherwise

thanks
-- PMM

#5 lore raw

PATCH 3/7 target/arm: Enable FEAT_CSV2_2 for -cpu max

In reply to Richard Henderson

There is no branch prediction in TCG, therefore there is no need to actually include the context number into the predictor. Therefore all we need to do is add the state for SCXTNUM_ELx.

---
 target/arm/cpu.h    | 16 +++++++++++
 target/arm/cpu64.c  |  2 +-
 target/arm/helper.c | 70 ++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 86 insertions(+), 2 deletions(-)
target/arm/cpu.h +16 -0
index c6c6d89a69..0b89620662 100644
@@ -688,6 +688,8 @@ typedef struct CPUArchState {
         ARMPACKey apdb;
         ARMPACKey apga;
     } keys;
+
+    uint64_t scxtnum_el[4];
 #endif
 
 #if defined(CONFIG_USER_ONLY)
@@ -1211,6 +1213,7 @@ void pmu_init(ARMCPU *cpu);
 #define SCTLR_WXN     (1U << 19)
 #define SCTLR_ST      (1U << 20) /* up to ??, RAZ in v6 */
 #define SCTLR_UWXN    (1U << 20) /* v7 onward, AArch32 only */
+#define SCTLR_TSCXT   (1U << 20) /* FEAT_CSV2_1p2, AArch64 only */
 #define SCTLR_FI      (1U << 21) /* up to v7, v8 RES0 */
 #define SCTLR_IESB    (1U << 21) /* v8.2-IESB, AArch64 only */
 #define SCTLR_U       (1U << 22) /* up to v6, RAO in v7 */
@@ -4368,6 +4371,19 @@ static inline bool isar_feature_aa64_dit(const ARMISARegisters *id)
     return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, DIT) != 0;
 }
 
+static inline bool isar_feature_aa64_scxtnum(const ARMISARegisters *id)
+{
+    int key = FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, CSV2);
+    if (key >= 2) {
+        return true;      /* FEAT_CSV2_2 */
+    }
+    if (key == 1) {
+        key = FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, CSV2_FRAC);
+        return key >= 2;  /* FEAT_CSV2_1p2 */
+    }
+    return false;
+}
+
 static inline bool isar_feature_aa64_ssbs(const ARMISARegisters *id)
 {
     return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SSBS) != 0;
target/arm/cpu64.c +1 -1
index c1006a067c..9ff08bd995 100644
@@ -805,7 +805,7 @@ static void aarch64_max_initfn(Object *obj)
     t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1);
     t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1);      /* FEAT_SEL2 */
     t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1);       /* FEAT_DIT */
-    t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 1);      /* FEAT_CSV2 */
+    t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 2);      /* FEAT_CSV2_2 */
     cpu->isar.id_aa64pfr0 = t;
 
     t = cpu->isar.id_aa64pfr1;
target/arm/helper.c +69 -1

100 lines not on this page · raw message

Signature · 1 line
2.25.1
#6 lore raw

Re: [PATCH 3/7] target/arm: Enable FEAT_CSV2_2 for -cpu max

Quoted 58 lines · Richard Henderson

There is no branch prediction in TCG, therefore there is no need to actually include the context number into the predictor. Therefore all we need to do is add the state for SCXTNUM_ELx.

---
 target/arm/cpu.h    | 16 +++++++++++
 target/arm/cpu64.c  |  2 +-
 target/arm/helper.c | 70 ++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 86 insertions(+), 2 deletions(-)
target/arm/cpu.h +16 -0
index c6c6d89a69..0b89620662 100644
@@ -688,6 +688,8 @@ typedef struct CPUArchState {
         ARMPACKey apdb;
         ARMPACKey apga;
     } keys;
+
+    uint64_t scxtnum_el[4];
 #endif
 
 #if defined(CONFIG_USER_ONLY)
@@ -1211,6 +1213,7 @@ void pmu_init(ARMCPU *cpu);
 #define SCTLR_WXN     (1U << 19)
 #define SCTLR_ST      (1U << 20) /* up to ??, RAZ in v6 */
 #define SCTLR_UWXN    (1U << 20) /* v7 onward, AArch32 only */
+#define SCTLR_TSCXT   (1U << 20) /* FEAT_CSV2_1p2, AArch64 only */
 #define SCTLR_FI      (1U << 21) /* up to v7, v8 RES0 */
 #define SCTLR_IESB    (1U << 21) /* v8.2-IESB, AArch64 only */
 #define SCTLR_U       (1U << 22) /* up to v6, RAO in v7 */
@@ -4368,6 +4371,19 @@ static inline bool isar_feature_aa64_dit(const ARMISARegisters *id)
     return FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, DIT) != 0;
 }
 
+static inline bool isar_feature_aa64_scxtnum(const ARMISARegisters *id)
+{
+    int key = FIELD_EX64(id->id_aa64pfr0, ID_AA64PFR0, CSV2);
+    if (key >= 2) {
+        return true;      /* FEAT_CSV2_2 */
+    }
+    if (key == 1) {
+        key = FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, CSV2_FRAC);
+        return key >= 2;  /* FEAT_CSV2_1p2 */
+    }
+    return false;
+}
+
 static inline bool isar_feature_aa64_ssbs(const ARMISARegisters *id)
 {
     return FIELD_EX64(id->id_aa64pfr1, ID_AA64PFR1, SSBS) != 0;
target/arm/cpu64.c +0 -0
index c1006a067c..9ff08bd995 100644

target/arm/cpu64.c static void aarch64_max_initfn(Object *obj) · line 808

Quoted 5 lines
target/arm/cpu64.c +1 -1
@@ -805,7 +805,7 @@ static void aarch64_max_initfn(Object *obj)
     t = FIELD_DP64(t, ID_AA64PFR0, SVE, 1);
     t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1);      /* FEAT_SEL2 */
     t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1);       /* FEAT_DIT */
-    t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 1);      /* FEAT_CSV2 */
+    t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 2);      /* FEAT_CSV2_2 */

I think we should probably explicitly zero ID_AA64PFR1.CSV2_frac. Doesn't matter now, but might if in future we move 'max' from "a57 with extras" to "some CPU with CSV2_1p1 plus extras".

Quoted 28 lines
target/arm/cpu64.c +0 -0
     cpu->isar.id_aa64pfr0 = t;
 
     t = cpu->isar.id_aa64pfr1;
target/arm/helper.c +6 -0
index bd1c8e01cb..66af3397ee 100644
@@ -1780,6 +1780,9 @@ static void scr_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
         if (cpu_isar_feature(aa64_mte, cpu)) {
             valid_mask |= SCR_ATA;
         }
+        if (cpu_isar_feature(aa64_scxtnum, cpu)) {
+            valid_mask |= SCR_ENSCXT;
+        }
     } else {
         valid_mask &= ~(SCR_RW | SCR_ST);
         if (cpu_isar_feature(aa32_ras, cpu)) {
@@ -5312,6 +5315,9 @@ static void do_hcr_write(CPUARMState *env, uint64_t value, uint64_t valid_mask)
         if (cpu_isar_feature(aa64_mte, cpu)) {
             valid_mask |= HCR_ATA | HCR_DCT | HCR_TID5;
         }
+        if (cpu_isar_feature(aa64_scxtnum, cpu)) {
+            valid_mask |= HCR_ENSCXT;
+        }
     }
 
     /* Clear RES0 bits.  */

target/arm/helper.c static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu) · line 5974

Quoted 4 lines
target/arm/helper.c +1 -0
@@ -5965,6 +5971,10 @@ static void define_arm_vh_e2h_redirects_aliases(ARMCPU *cpu)
         { K(3, 0,  5, 6, 0), K(3, 4,  5, 6, 0), K(3, 5, 5, 6, 0),
           "TFSR_EL1", "TFSR_EL2", "TFSR_EL12", isar_feature_aa64_mte },
 
+        { K(3, 0, 0xd, 0, 7), K(3, 4, 0xd, 0, 7), K(3, 5, 0xd, 0, 7),

Use decimal to follow the style of the rest of this table, please.

Quoted 22 lines
target/arm/helper.c +14 -1
+          "SCXTNUM_EL1", "SCXTNUM_EL2", "SCXTNUM_EL12",
+          isar_feature_aa64_scxtnum },
+
         /* TODO: ARMv8.2-SPE -- PMSCR_EL2 */
         /* TODO: ARMv8.4-Trace -- TRFCR_EL2 */
     };
@@ -7434,7 +7444,61 @@ static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = {
     REGINFO_SENTINEL
 };
 
-#endif
+static CPAccessResult access_scxtnum(CPUARMState *env, const ARMCPRegInfo *ri,
+                                     bool isread)
+{
+    uint64_t hcr;
+
+    switch (arm_current_el(env)) {
+    case 0:
+        hcr = arm_hcr_el2_eff(env);
+        if ((hcr & (HCR_TGE | HCR_E2H)) != (HCR_TGE | HCR_E2H)) {
+            if (env->cp15.sctlr_el[1] & SCTLR_TSCXT) {
+                if (hcr & HCR_TGE) {

target/arm/helper.c static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = { · line 7467

Quoted 10 lines
target/arm/helper.c +10 -0
+                    return CP_ACCESS_TRAP_EL2;
+                }
+                return CP_ACCESS_TRAP;
+            }
+            if (arm_is_el2_enabled(env) && !(hcr & HCR_ENSCXT)) {
+                return CP_ACCESS_TRAP_EL2;
+            }
+        } else {
+            QEMU_FALLTHROUGH;
+    case 1:

I'm sure this is valid C, but firm 'no' to interleaving case labels and if/else statements.

Quoted 22 lines
target/arm/helper.c +22 -0
+            if (env->cp15.sctlr_el[2] & SCTLR_TSCXT) {
+                return CP_ACCESS_TRAP_EL2;
+            }
+        }
+        QEMU_FALLTHROUGH;
+    case 2:
+        if (arm_feature(env, ARM_FEATURE_EL3)
+            && !(env->cp15.scr_el3 & SCR_ENSCXT)) {
+            return CP_ACCESS_TRAP_EL3;
+        }
+    }
+    return CP_ACCESS_OK;
+}
+
+static const ARMCPRegInfo scxtnum_reginfo[] = {
+    { .name = "SCXTNUM_EL0", .state = ARM_CP_STATE_AA64,
+      .opc0 = 3, .opc1 = 3, .crn = 0xd, .crm = 0, .opc2 = 7,
+      .access = PL0_RW, .accessfn = access_scxtnum,
+      .fieldoffset = offsetof(CPUARMState, scxtnum_el[0]) },
+    { .name = "SCXTNUM_EL1", .state = ARM_CP_STATE_AA64,
+      .opc0 = 3, .opc1 = 0, .crn = 0xd, .crm = 0, .opc2 = 7,
+      .access = PL1_RW, .accessfn = access_scxtnum,

target/arm/helper.c static const ARMCPRegInfo mte_el0_cacheop_reginfo[] = { · line 7499

Quoted 10 lines
target/arm/helper.c +10 -0
+      .fieldoffset = offsetof(CPUARMState, scxtnum_el[1]) },
+    { .name = "SCXTNUM_EL2", .state = ARM_CP_STATE_AA64,
+      .opc0 = 3, .opc1 = 4, .crn = 0xd, .crm = 0, .opc2 = 7,
+      .access = PL2_RW, .accessfn = access_scxtnum,
+      .fieldoffset = offsetof(CPUARMState, scxtnum_el[2]) },
+    { .name = "SCXTNUM_EL3", .state = ARM_CP_STATE_AA64,
+      .opc0 = 3, .opc1 = 6, .crn = 0xd, .crm = 0, .opc2 = 7,
+      .access = PL3_RW,
+      .fieldoffset = offsetof(CPUARMState, scxtnum_el[3]) },
+    REGINFO_SENTINEL

Decimal not hex here too, please.

thanks
-- PMM

#7 lore raw

PATCH 4/7 target/arm: Enable FEAT_CSV3 for -cpu max

In reply to Richard Henderson

This extension concerns cache speculation, which TCG does not implement. Thus we can trivially enable this feature.

---
 target/arm/cpu64.c   | 1 +
 target/arm/cpu_tcg.c | 1 +
 2 files changed, 2 insertions(+)
target/arm/cpu64.c +1 -0
index 9ff08bd995..a0429538cc 100644
@@ -806,6 +806,7 @@ static void aarch64_max_initfn(Object *obj)
     t = FIELD_DP64(t, ID_AA64PFR0, SEL2, 1);      /* FEAT_SEL2 */
     t = FIELD_DP64(t, ID_AA64PFR0, DIT, 1);       /* FEAT_DIT */
     t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 2);      /* FEAT_CSV2_2 */
+    t = FIELD_DP64(t, ID_AA64PFR0, CSV3, 1);      /* FEAT_CSV3 */
     cpu->isar.id_aa64pfr0 = t;
 
     t = cpu->isar.id_aa64pfr1;
target/arm/cpu_tcg.c +1 -0
index 2750cbebec..31ea5a90e0 100644
@@ -77,6 +77,7 @@ void arm32_max_features(ARMCPU *cpu)
     cpu->isar.id_pfr0 = t;
 
     t = cpu->isar.id_pfr2;
+    t = FIELD_DP32(t, ID_PFR2, CSV3, 1);          /* FEAT_CSV3 */
     t = FIELD_DP32(t, ID_PFR2, SSBS, 1);          /* FEAT_SSBS */
     cpu->isar.id_pfr2 = t;
 
Signature · 1 line
2.25.1
Reviewed-by on v1 4/7
#8 lore raw

Re: [PATCH 4/7] target/arm: Enable FEAT_CSV3 for -cpu max

Quoted 9 lines · Richard Henderson

This extension concerns cache speculation, which TCG does not implement. Thus we can trivially enable this feature.

---
 target/arm/cpu64.c   | 1 +
 target/arm/cpu_tcg.c | 1 +
 2 files changed, 2 insertions(+)

thanks
-- PMM

#9 lore raw

PATCH 5/7 target/arm: Enable FEAT_DGH for -cpu max

In reply to Richard Henderson

This extension concerns not merging memory access, which TCG does not implement. Thus we can trivially enable this feature. Add a comment to handle_hint for the DGH instruction, but no code.

---
 target/arm/cpu64.c         | 1 +
 target/arm/translate-a64.c | 1 +
 2 files changed, 2 insertions(+)
target/arm/cpu64.c +1 -0
index a0429538cc..199ca437a0 100644
@@ -795,6 +795,7 @@ static void aarch64_max_initfn(Object *obj)
     t = FIELD_DP64(t, ID_AA64ISAR1, SB, 1);       /* FEAT_SB */
     t = FIELD_DP64(t, ID_AA64ISAR1, SPECRES, 1);  /* FEAT_SPECRES */
     t = FIELD_DP64(t, ID_AA64ISAR1, BF16, 1);     /* FEAT_BF16 */
+    t = FIELD_DP64(t, ID_AA64ISAR1, DGH, 1);      /* FEAT_DGH */
     t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 1);     /* FEAT_I8MM */
     cpu->isar.id_aa64isar1 = t;
 
target/arm/translate-a64.c +1 -0
index cc54dff83c..c3c1a19dea 100644
@@ -1442,6 +1442,7 @@ static void handle_hint(DisasContext *s, uint32_t insn,
         break;
     case 0b00100: /* SEV */
     case 0b00101: /* SEVL */
+    case 0b00110: /* DGH */
         /* we treat all as NOP at least for now */
         break;
     case 0b00111: /* XPACLRI */
Signature · 1 line
2.25.1
#11 lore raw

PATCH 6/7 target/arm: Define cortex-a76

In reply to Richard Henderson

Enable the a76 for virt and sbsa board use.

---
 hw/arm/sbsa-ref.c  |  1 +
 hw/arm/virt.c      |  1 +
 target/arm/cpu64.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 66 insertions(+)
hw/arm/sbsa-ref.c +1 -0
index 2387401963..2ddde88f5e 100644
@@ -145,6 +145,7 @@ static const int sbsa_ref_irqmap[] = {
 static const char * const valid_cpus[] = {
     ARM_CPU_TYPE_NAME("cortex-a57"),
     ARM_CPU_TYPE_NAME("cortex-a72"),
+    ARM_CPU_TYPE_NAME("cortex-a76"),
     ARM_CPU_TYPE_NAME("max"),
 };
 
hw/arm/virt.c +1 -0
index d2e5ecd234..ce15c36a7f 100644
@@ -202,6 +202,7 @@ static const char *valid_cpus[] = {
     ARM_CPU_TYPE_NAME("cortex-a53"),
     ARM_CPU_TYPE_NAME("cortex-a57"),
     ARM_CPU_TYPE_NAME("cortex-a72"),
+    ARM_CPU_TYPE_NAME("cortex-a76"),
     ARM_CPU_TYPE_NAME("a64fx"),
     ARM_CPU_TYPE_NAME("host"),
     ARM_CPU_TYPE_NAME("max"),
target/arm/cpu64.c +64 -0

76 lines not on this page · raw message

Signature · 1 line
2.25.1
#12 lore raw

Re: [PATCH 6/7] target/arm: Define cortex-a76

Quoted 27 lines · Richard Henderson

Enable the a76 for virt and sbsa board use.

---
 hw/arm/sbsa-ref.c  |  1 +
 hw/arm/virt.c      |  1 +
 target/arm/cpu64.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 66 insertions(+)
hw/arm/sbsa-ref.c +1 -0
index 2387401963..2ddde88f5e 100644
@@ -145,6 +145,7 @@ static const int sbsa_ref_irqmap[] = {
 static const char * const valid_cpus[] = {
     ARM_CPU_TYPE_NAME("cortex-a57"),
     ARM_CPU_TYPE_NAME("cortex-a72"),
+    ARM_CPU_TYPE_NAME("cortex-a76"),
     ARM_CPU_TYPE_NAME("max"),
 };
 
hw/arm/virt.c +0 -0
index d2e5ecd234..ce15c36a7f 100644

hw/arm/virt.c static const char *valid_cpus[] = { · line 208

Quoted 7 lines
hw/arm/virt.c +1 -0
@@ -202,6 +202,7 @@ static const char *valid_cpus[] = {
     ARM_CPU_TYPE_NAME("cortex-a53"),
     ARM_CPU_TYPE_NAME("cortex-a57"),
     ARM_CPU_TYPE_NAME("cortex-a72"),
+    ARM_CPU_TYPE_NAME("cortex-a76"),
     ARM_CPU_TYPE_NAME("a64fx"),
     ARM_CPU_TYPE_NAME("host"),
     ARM_CPU_TYPE_NAME("max"),

Need to update the list in docs/system/arm/virt.rst as well.

Quoted 23 lines
target/arm/cpu64.c +15 -0
index 199ca437a0..a00c02be2c 100644
@@ -251,6 +251,69 @@ static void aarch64_a72_initfn(Object *obj)
     define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo);
 }
 
+static void aarch64_a76_initfn(Object *obj)
+{
+    ARMCPU *cpu = ARM_CPU(obj);
+
+    cpu->dtb_compatible = "arm,cortex-a76";
+    set_feature(&cpu->env, ARM_FEATURE_V8);
+    set_feature(&cpu->env, ARM_FEATURE_NEON);
+    set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER);
+    set_feature(&cpu->env, ARM_FEATURE_AARCH64);
+    set_feature(&cpu->env, ARM_FEATURE_CBAR_RO);
+    set_feature(&cpu->env, ARM_FEATURE_EL2);
+    set_feature(&cpu->env, ARM_FEATURE_EL3);
+    set_feature(&cpu->env, ARM_FEATURE_PMU);
+
+    /* Ordered by B2.4 AArch64 registers by functional group */

target/arm/cpu64.c static void aarch64_a72_initfn(Object *obj) · line 278

Quoted 10 lines
target/arm/cpu64.c +10 -0
+    cpu->clidr = 0x82000023;
+    cpu->ctr = 0x8444C004;
+    cpu->dcz_blocksize = 4;
+    cpu->isar.id_aa64dfr0  = 0x0000000010305408ull;
+    cpu->isar.id_aa64isar0 = 0x0000100010211120ull;
+    cpu->isar.id_aa64isar1 = 0x0000000000100001ull;
+    cpu->isar.id_aa64mmfr0 = 0x0000000000101122ull;
+    cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull;
+    cpu->isar.id_aa64mmfr2 = 0x0000000000001011ull;
+    cpu->isar.id_aa64pfr0  = 0x1100000010111112ull;

This has the GIC field clear. On the one hand this is true also of all our other CPU implementations. On the other hand if we wire up a GICv3 in the board code then we will be presenting the GIC CPU interface registers, which is what this ID register field is supposed to be telling software. I guess we should handle this by having gicv3_init_cpuif() arrange for the ID field to be set. Which is mildly painful, because that will mean the value for the cpreg isn't constant.

(In real hardware the cpuif really is part of the CPU proper, so it (ie the sysregs for the GICv3) exists whether the GICv3 proper is present somewhere outside the CPU in the SoC. But our implementation doesn't put the dividing line quite where the h/w does.)

Quoted 6 lines
target/arm/cpu64.c +6 -0
+    cpu->isar.id_aa64pfr1  = 0x0000000000000010ull;
+    cpu->isar.id_dfr0  = 0x04010088;
+    cpu->isar.id_isar0 = 0x02101110;
+    cpu->isar.id_isar1 = 0x13112111;
+    cpu->isar.id_isar2 = 0x21232042;
+    cpu->isar.id_isar3 = 0x01112131;

target/arm/cpu64.c static void aarch64_a72_initfn(Object *obj) · line 294

Quoted 10 lines
target/arm/cpu64.c +10 -0
+    cpu->isar.id_isar4 = 0x00010142;
+    cpu->isar.id_isar5 = 0x01011121;
+    cpu->isar.id_isar6 = 0x00000010;
+    cpu->isar.id_mmfr0 = 0x10201105;
+    cpu->isar.id_mmfr1 = 0x40000000;
+    cpu->isar.id_mmfr2 = 0x01260000;
+    cpu->isar.id_mmfr3 = 0x02122211;
+    cpu->isar.id_mmfr4 = 0x00021110;
+    cpu->isar.id_pfr0  = 0x10010131;
+    cpu->isar.id_pfr1  = 0x10010000;

Here you have set the GIC field. We should at least be consistent :-)

target/arm/cpu64.c static void aarch64_a72_initfn(Object *obj) · line 296

Quoted 2 lines
target/arm/cpu64.c +2 -0
+    cpu->isar.id_pfr2  = 0x00000011;
+    cpu->midr = 0x413fd0b1;

This is r3p1; the r4p1 TRM is available so we might as well claim to be that.

target/arm/cpu64.c static void aarch64_a72_initfn(Object *obj) · line 309

Quoted 13 lines
target/arm/cpu64.c +13 -0
+
+    /* From B2.18 CCSIDR_EL1 */
+    cpu->ccsidr[0] = 0x701fe01a; /* 64KB L1 dcache */
+    cpu->ccsidr[1] = 0x201fe01a; /* 64KB L1 icache */
+    cpu->ccsidr[2] = 0x707fe03a; /* 512KB L2 cache */
+
+    /* From B2.93 SCTLR_EL3 */
+    cpu->reset_sctlr = 0x30c50838;
+
+    /* From B4.23 ICH_VTR_EL2 */
+    cpu->gic_num_lrs = 4;
+    cpu->gic_vpribits = 5;
+    cpu->gic_vprebits = 5;

(side note, we should really support having the non-virtual pribits/prebits for the GIC be configurable too. I have a half-written set of patches for that.)

target/arm/cpu64.c static void aarch64_a72_initfn(Object *obj) · line 314

Quoted 5 lines
target/arm/cpu64.c +5 -0
+
+    /* From B5.1 AdvSIMD AArch64 register summary */
+    cpu->isar.mvfr0 = 0x10110222;
+    cpu->isar.mvfr1 = 0x13211111;
+    cpu->isar.mvfr2 = 0x00000043;

Missing (just cross-checking what other CPUs are setting):
cpu->revidr
cpu->reset_fpsid
cpu->id_afr0
cpu->isar.dbgdidr

Quoted 6 lines
target/arm/cpu64.c +2 -0
+}
+
 void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp)
 {
     /*

target/arm/cpu64.c static const ARMCPUInfo aarch64_cpus[] = {

Quoted 8 lines
target/arm/cpu64.c +1 -1
@@ -935,6 +998,7 @@ static const ARMCPUInfo aarch64_cpus[] = {
     { .name = "cortex-a57",         .initfn = aarch64_a57_initfn },
     { .name = "cortex-a53",         .initfn = aarch64_a53_initfn },
     { .name = "cortex-a72",         .initfn = aarch64_a72_initfn },
+    { .name = "cortex-a76",         .initfn = aarch64_a76_initfn },
     { .name = "a64fx",              .initfn = aarch64_a64fx_initfn },
     { .name = "max",                .initfn = aarch64_max_initfn },
 #if defined(CONFIG_KVM) || defined(CONFIG_HVF)
--

thanks
-- PMM

#13 lore raw

Re: [PATCH 6/7] target/arm: Define cortex-a76

Quoted 10 lines · Peter Maydell
Quoted 1 line

+ cpu->isar.id_aa64pfr0 = 0x1100000010111112ull;

This has the GIC field clear. On the one hand this is true also of all our other CPU implementations. On the other hand if we wire up a GICv3 in the board code then we will be presenting the GIC CPU interface registers, which is what this ID register field is supposed to be telling software. I guess we should handle this by having gicv3_init_cpuif() arrange for the ID field to be set. Which is mildly painful, because that will mean the value for the cpreg isn't constant.

We already handle this via id_aa64pfr0_read().

Quoted 3 lines
Quoted 1 line

+ cpu->isar.id_pfr1 = 0x10010000;

Here you have set the GIC field. We should at least be consistent :-)

Oops. :-) We have id_pfr1_read() for that as well.

Quoted 4 lines
Quoted 1 line

+ cpu->midr = 0x413fd0b1;

This is r3p1; the r4p1 TRM is available so we might as well claim to be that.

Ok.

Quoted 4 lines

Missing (just cross-checking what other CPUs are setting):

   cpu->revidr
   cpu->reset_fpsid
   cpu->id_afr0

revidr and id_afr0 are 0 -- explicit zero required? We certainly assume we begin with zero for other registers for other cpus...

FPSID is deprecated, and not mentioned in the a76 or n1 specs. Presumably this is because it is not accessible at all: FPSID is not accessible from EL0 for VFPv3, and the A76 does not support aa32 at other than EL0.

Quoted 1 line
   cpu->isar.dbgdidr

"If EL1 cannot use AArch32 then the implementation of this register is OPTIONAL and deprecated."

r~

#14 lore raw

Re: [PATCH 6/7] target/arm: Define cortex-a76

Quoted 3 lines · Richard Henderson
Quoted 1 line

   cpu->isar.dbgdidr

"If EL1 cannot use AArch32 then the implementation of this register is OPTIONAL and deprecated."

Which we already handle in define_debug_regs by not defining DBGDIDR if this value is 0.

r~

#15 lore raw

PATCH 7/7 target/arm: Define neoverse-n1

In reply to Richard Henderson

Enable the n1 for virt and sbsa board use.

---
 hw/arm/sbsa-ref.c  |  1 +
 hw/arm/virt.c      |  1 +
 target/arm/cpu64.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 66 insertions(+)
hw/arm/sbsa-ref.c +1 -0
index 2ddde88f5e..dac8860f2d 100644
@@ -146,6 +146,7 @@ static const char * const valid_cpus[] = {
     ARM_CPU_TYPE_NAME("cortex-a57"),
     ARM_CPU_TYPE_NAME("cortex-a72"),
     ARM_CPU_TYPE_NAME("cortex-a76"),
+    ARM_CPU_TYPE_NAME("neoverse-n1"),
     ARM_CPU_TYPE_NAME("max"),
 };
 
hw/arm/virt.c +1 -0
index ce15c36a7f..82dd934de6 100644
@@ -204,6 +204,7 @@ static const char *valid_cpus[] = {
     ARM_CPU_TYPE_NAME("cortex-a72"),
     ARM_CPU_TYPE_NAME("cortex-a76"),
     ARM_CPU_TYPE_NAME("a64fx"),
+    ARM_CPU_TYPE_NAME("neoverse-n1"),
     ARM_CPU_TYPE_NAME("host"),
     ARM_CPU_TYPE_NAME("max"),
 };
target/arm/cpu64.c +64 -0

76 lines not on this page · raw message

Signature · 1 line
2.25.1