Skip to contentSkip to conversation

target/arm: properly document FEAT_CRC32

RFC PATCH Superseded Alex Bennée 4 participants 12 messages Feb 22, 2023 – Aug 24, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 target/arm: properly document FEAT_CRC32

This is a mandatory feature for Armv8.1 architectures but we don't state the feature clearly in our emulation list. While checking verify our cortex-a76 model matches up with the current TRM by breaking out the long form isar into a more modern readable FIELD_DP code.

---
 docs/system/arm/emulation.rst |  1 +
 target/arm/cpu64.c            | 29 ++++++++++++++++++++++++++---
 target/arm/cpu_tcg.c          |  2 +-
 3 files changed, 28 insertions(+), 4 deletions(-)
docs/system/arm/emulation.rst +1 -0
index 2062d71261..2c4fde5eef 100644
@@ -14,6 +14,7 @@ the following architecture extensions:
 - FEAT_BBM at level 2 (Translation table break-before-make levels)
 - FEAT_BF16 (AArch64 BFloat16 instructions)
 - FEAT_BTI (Branch Target Identification)
+- FEAT_CRC32 (CRC32 instruction)
 - FEAT_CSV2 (Cache speculation variant 2)
 - FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1)
 - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2)
target/arm/cpu64.c +26 -3
index 4066950da1..12e1a532ab 100644
@@ -912,6 +912,8 @@ static void aarch64_a72_initfn(Object *obj)
 static void aarch64_a76_initfn(Object *obj)
 {
     ARMCPU *cpu = ARM_CPU(obj);
+    uint64_t t;
+    uint32_t u;
 
     cpu->dtb_compatible = "arm,cortex-a76";
     set_feature(&cpu->env, ARM_FEATURE_V8);
@@ -928,7 +930,18 @@ static void aarch64_a76_initfn(Object *obj)
     cpu->ctr = 0x8444C004;
     cpu->dcz_blocksize = 4;
     cpu->isar.id_aa64dfr0  = 0x0000000010305408ull;
-    cpu->isar.id_aa64isar0 = 0x0000100010211120ull;
+
+    /* per r4p1 of the Cryptographic Extension TRM */
+    t = cpu->isar.id_aa64isar0;
+    t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2);      /* FEAT_PMULL */
+    t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1);     /* FEAT_SHA1 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 1);     /* FEAT_SHA512 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1);    /* FEAT_CRC32 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2);   /* FEAT_LSE */
+    t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1);      /* FEAT_RDM */
+    t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1);       /* FEAT_DotProd */
+    cpu->isar.id_aa64isar0 = t;
+
     cpu->isar.id_aa64isar1 = 0x0000000000100001ull;
     cpu->isar.id_aa64mmfr0 = 0x0000000000101122ull;
     cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull;
@@ -942,7 +955,17 @@ static void aarch64_a76_initfn(Object *obj)
     cpu->isar.id_isar2 = 0x21232042;
     cpu->isar.id_isar3 = 0x01112131;
     cpu->isar.id_isar4 = 0x00010142;
-    cpu->isar.id_isar5 = 0x01011121;
+
+    /* per r4p1 of the Cryptographic Extension TRM */
+    u = cpu->isar.id_isar5;
+    u = FIELD_DP32(t, ID_ISAR5, SEVL, 1);
+    u = FIELD_DP32(t, ID_ISAR5, AES, 2);          /* FEAT_PMULL */
+    u = FIELD_DP32(t, ID_ISAR5, SHA1, 1);         /* FEAT_SHA1 */
+    u = FIELD_DP32(t, ID_ISAR5, SHA2, 1);         /* FEAT_SHA256 */
+    u = FIELD_DP32(t, ID_ISAR5, CRC32, 1);        /* FEAT_CRC32 */
+    u = FIELD_DP32(t, ID_ISAR5, RDM, 1);          /* FEAT_RDM */
+    cpu->isar.id_isar5 = u;
+
     cpu->isar.id_isar6 = 0x00000010;
     cpu->isar.id_mmfr0 = 0x10201105;
     cpu->isar.id_mmfr1 = 0x40000000;
@@ -1167,7 +1190,7 @@ static void aarch64_max_initfn(Object *obj)
     t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2);      /* FEAT_PMULL */
     t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1);     /* FEAT_SHA1 */
     t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2);     /* FEAT_SHA512 */
-    t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1);
+    t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1);    /* FEAT_CRC32 */
     t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2);   /* FEAT_LSE */
     t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1);      /* FEAT_RDM */
     t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 1);     /* FEAT_SHA3 */
target/arm/cpu_tcg.c +1 -1
index df0c45e523..961d2fd9ba 100644
@@ -34,7 +34,7 @@ void aa32_max_features(ARMCPU *cpu)
     t = FIELD_DP32(t, ID_ISAR5, AES, 2);          /* FEAT_PMULL */
     t = FIELD_DP32(t, ID_ISAR5, SHA1, 1);         /* FEAT_SHA1 */
     t = FIELD_DP32(t, ID_ISAR5, SHA2, 1);         /* FEAT_SHA256 */
-    t = FIELD_DP32(t, ID_ISAR5, CRC32, 1);
+    t = FIELD_DP32(t, ID_ISAR5, CRC32, 1);        /* FEAT_CRC32 */
     t = FIELD_DP32(t, ID_ISAR5, RDM, 1);          /* FEAT_RDM */
     t = FIELD_DP32(t, ID_ISAR5, VCMA, 1);         /* FEAT_FCMA */
     cpu->isar.id_isar5 = t;
Signature · 1 line
2.39.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Alex Bennée

This is a mandatory feature for Armv8.1 architectures but we don't state the feature clearly in our emulation list.

Split in 2 patches?

Quoted 10 lines

While checking verify
our cortex-a76 model matches up with the current TRM by breaking out the long form isar into a more modern readable FIELD_DP code.

---
  docs/system/arm/emulation.rst |  1 +
  target/arm/cpu64.c            | 29 ++++++++++++++++++++++++++---
  target/arm/cpu_tcg.c          |  2 +-
  3 files changed, 28 insertions(+), 4 deletions(-)
#2 lore raw
Quoted 5 lines · Philippe Mathieu-Daudé
Quoted 2 lines · Alex Bennée

This is a mandatory feature for Armv8.1 architectures but we don't state the feature clearly in our emulation list.

Split in 2 patches?

Its all pretty much a NOP aside from the comments. I split the isar code just to check my working.

Quoted 13 lines
Quoted 10 lines

While checking verify
our cortex-a76 model matches up with the current TRM by breaking out the long form isar into a more modern readable FIELD_DP code.

---
  docs/system/arm/emulation.rst |  1 +
  target/arm/cpu64.c            | 29 ++++++++++++++++++++++++++---
  target/arm/cpu_tcg.c          |  2 +-
  3 files changed, 28 insertions(+), 4 deletions(-)
Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#3 lore raw
In reply to Alex Bennée
Quoted 43 lines · Alex Bennée

This is a mandatory feature for Armv8.1 architectures but we don't state the feature clearly in our emulation list. While checking verify our cortex-a76 model matches up with the current TRM by breaking out the long form isar into a more modern readable FIELD_DP code.

---
  docs/system/arm/emulation.rst |  1 +
  target/arm/cpu64.c            | 29 ++++++++++++++++++++++++++---
  target/arm/cpu_tcg.c          |  2 +-
  3 files changed, 28 insertions(+), 4 deletions(-)
docs/system/arm/emulation.rst +1 -0
index 2062d71261..2c4fde5eef 100644
@@ -14,6 +14,7 @@ the following architecture extensions:
  - FEAT_BBM at level 2 (Translation table break-before-make levels)
  - FEAT_BF16 (AArch64 BFloat16 instructions)
  - FEAT_BTI (Branch Target Identification)
+- FEAT_CRC32 (CRC32 instruction)
  - FEAT_CSV2 (Cache speculation variant 2)
  - FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1)
  - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2)
target/arm/cpu64.c +3 -1
index 4066950da1..12e1a532ab 100644
@@ -912,6 +912,8 @@ static void aarch64_a72_initfn(Object *obj)
  static void aarch64_a76_initfn(Object *obj)
  {
      ARMCPU *cpu = ARM_CPU(obj);
+    uint64_t t;
+    uint32_t u;
 
      cpu->dtb_compatible = "arm,cortex-a76";
      set_feature(&cpu->env, ARM_FEATURE_V8);
@@ -928,7 +930,18 @@ static void aarch64_a76_initfn(Object *obj)
      cpu->ctr = 0x8444C004;
      cpu->dcz_blocksize = 4;
      cpu->isar.id_aa64dfr0  = 0x0000000010305408ull;
-    cpu->isar.id_aa64isar0 = 0x0000100010211120ull;
+

target/arm/cpu64.c static void aarch64_a76_initfn(Object *obj) · line 943

Quoted 10 lines
target/arm/cpu64.c +10 -0
+    /* per r4p1 of the Cryptographic Extension TRM */
+    t = cpu->isar.id_aa64isar0;
+    t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2);      /* FEAT_PMULL */
+    t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1);     /* FEAT_SHA1 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 1);     /* FEAT_SHA512 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1);    /* FEAT_CRC32 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2);   /* FEAT_LSE */
+    t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1);      /* FEAT_RDM */
+    t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1);       /* FEAT_DotProd */
+    cpu->isar.id_aa64isar0 = t;

Ok, so, this might be helpful for grepping, but it's not helpful for reading the documentation, which on page B2-137 uses hex.

r~

#4 lore raw
Quoted 44 lines · Richard Henderson
Quoted 43 lines · Alex Bennée

This is a mandatory feature for Armv8.1 architectures but we don't state the feature clearly in our emulation list. While checking verify our cortex-a76 model matches up with the current TRM by breaking out the long form isar into a more modern readable FIELD_DP code.

---
  docs/system/arm/emulation.rst |  1 + target/arm/cpu64.c            | 29 ++++++++++++++++++++++++++--- target/arm/cpu_tcg.c          |  2 +-

  3 files changed, 28 insertions(+), 4 deletions(-)
docs/system/arm/emulation.rst +1 -0
index 2062d71261..2c4fde5eef 100644
@@ -14,6 +14,7 @@ the following architecture extensions:
   - FEAT_BBM at level 2 (Translation table break-before-make levels)
   - FEAT_BF16 (AArch64 BFloat16 instructions)
   - FEAT_BTI (Branch Target Identification)
+- FEAT_CRC32 (CRC32 instruction)
   - FEAT_CSV2 (Cache speculation variant 2)
   - FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1)
   - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2)
target/arm/cpu64.c +4 -1
index 4066950da1..12e1a532ab 100644
@@ -912,6 +912,8 @@ static void aarch64_a72_initfn(Object *obj)
   static void aarch64_a76_initfn(Object *obj)
   {
       ARMCPU *cpu = ARM_CPU(obj);
+    uint64_t t;
+    uint32_t u;
       cpu->dtb_compatible = "arm,cortex-a76";
       set_feature(&cpu->env, ARM_FEATURE_V8);
@@ -928,7 +930,18 @@ static void aarch64_a76_initfn(Object *obj)
       cpu->ctr = 0x8444C004;
       cpu->dcz_blocksize = 4;
       cpu->isar.id_aa64dfr0  = 0x0000000010305408ull;
-    cpu->isar.id_aa64isar0 = 0x0000100010211120ull;
+
+    /* per r4p1 of the Cryptographic Extension TRM */
Quoted 8 lines

target/arm/cpu64.c static void aarch64_a76_initfn(Object *obj) · line 942

Quoted 8 lines
target/arm/cpu64.c +8 -0
+    t = cpu->isar.id_aa64isar0;
+    t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2);      /* FEAT_PMULL */
+    t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1);     /* FEAT_SHA1 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 1);     /* FEAT_SHA512 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1);    /* FEAT_CRC32 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2);   /* FEAT_LSE */
+    t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1);      /* FEAT_RDM */
+    t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1);       /* FEAT_DotProd */

Maybe:

        assert(t == 0x0000100010211120ull);
Quoted 7 lines

target/arm/cpu64.c static void aarch64_a76_initfn(Object *obj) · line 943

Quoted 1 line
target/arm/cpu64.c +1 -0
+    cpu->isar.id_aa64isar0 = t;

Ok, so, this might be helpful for grepping, but it's not helpful for reading the documentation, which on page B2-137 uses hex.

r~

#5 lore raw
Quoted 56 lines · Philippe Mathieu-Daudé
Quoted 44 lines · Richard Henderson
Quoted 43 lines · Alex Bennée

This is a mandatory feature for Armv8.1 architectures but we don't state the feature clearly in our emulation list. While checking verify our cortex-a76 model matches up with the current TRM by breaking out the long form isar into a more modern readable FIELD_DP code.

---
  docs/system/arm/emulation.rst |  1 + target/arm/cpu64.c            | 29 ++++++++++++++++++++++++++--- target/arm/cpu_tcg.c          |  2 +-

  3 files changed, 28 insertions(+), 4 deletions(-)
docs/system/arm/emulation.rst +1 -0
index 2062d71261..2c4fde5eef 100644
@@ -14,6 +14,7 @@ the following architecture extensions:
   - FEAT_BBM at level 2 (Translation table break-before-make levels)
   - FEAT_BF16 (AArch64 BFloat16 instructions)
   - FEAT_BTI (Branch Target Identification)
+- FEAT_CRC32 (CRC32 instruction)
   - FEAT_CSV2 (Cache speculation variant 2)
   - FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1)
   - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2)
target/arm/cpu64.c +4 -1
index 4066950da1..12e1a532ab 100644
@@ -912,6 +912,8 @@ static void aarch64_a72_initfn(Object *obj)
   static void aarch64_a76_initfn(Object *obj)
   {
       ARMCPU *cpu = ARM_CPU(obj);
+    uint64_t t;
+    uint32_t u;
       cpu->dtb_compatible = "arm,cortex-a76";
       set_feature(&cpu->env, ARM_FEATURE_V8);
@@ -928,7 +930,18 @@ static void aarch64_a76_initfn(Object *obj)
       cpu->ctr = 0x8444C004;
       cpu->dcz_blocksize = 4;
       cpu->isar.id_aa64dfr0  = 0x0000000010305408ull;
-    cpu->isar.id_aa64isar0 = 0x0000100010211120ull;
+
+    /* per r4p1 of the Cryptographic Extension TRM */
Quoted 8 lines

target/arm/cpu64.c static void aarch64_a76_initfn(Object *obj) · line 942

Quoted 8 lines
target/arm/cpu64.c +8 -0
+    t = cpu->isar.id_aa64isar0;
+    t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2);      /* FEAT_PMULL */
+    t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1);     /* FEAT_SHA1 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 1);     /* FEAT_SHA512 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1);    /* FEAT_CRC32 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2);   /* FEAT_LSE */
+    t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1);      /* FEAT_RDM */
+    t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1);       /* FEAT_DotProd */

Maybe:

Quoted 1 line

        assert(t == 0x0000100010211120ull);

But why bother to break it out then?

r~

#6 lore raw
Quoted 57 lines · Richard Henderson
Quoted 56 lines · Philippe Mathieu-Daudé
Quoted 44 lines · Richard Henderson
Quoted 43 lines · Alex Bennée

This is a mandatory feature for Armv8.1 architectures but we don't state the feature clearly in our emulation list. While checking verify our cortex-a76 model matches up with the current TRM by breaking out the long form isar into a more modern readable FIELD_DP code.

---
  docs/system/arm/emulation.rst |  1 + target/arm/cpu64.c            | 29 ++++++++++++++++++++++++++--- target/arm/cpu_tcg.c          |  2 +-

  3 files changed, 28 insertions(+), 4 deletions(-)
docs/system/arm/emulation.rst +1 -0
index 2062d71261..2c4fde5eef 100644
@@ -14,6 +14,7 @@ the following architecture extensions:
   - FEAT_BBM at level 2 (Translation table break-before-make levels)
   - FEAT_BF16 (AArch64 BFloat16 instructions)
   - FEAT_BTI (Branch Target Identification)
+- FEAT_CRC32 (CRC32 instruction)
   - FEAT_CSV2 (Cache speculation variant 2)
   - FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1)
   - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2)
target/arm/cpu64.c +4 -1
index 4066950da1..12e1a532ab 100644
@@ -912,6 +912,8 @@ static void aarch64_a72_initfn(Object *obj)
   static void aarch64_a76_initfn(Object *obj)
   {
       ARMCPU *cpu = ARM_CPU(obj);
+    uint64_t t;
+    uint32_t u;
       cpu->dtb_compatible = "arm,cortex-a76";
       set_feature(&cpu->env, ARM_FEATURE_V8);
@@ -928,7 +930,18 @@ static void aarch64_a76_initfn(Object *obj)
       cpu->ctr = 0x8444C004;
       cpu->dcz_blocksize = 4;
       cpu->isar.id_aa64dfr0  = 0x0000000010305408ull;
-    cpu->isar.id_aa64isar0 = 0x0000100010211120ull;
+
+    /* per r4p1 of the Cryptographic Extension TRM */
Quoted 8 lines

target/arm/cpu64.c static void aarch64_a76_initfn(Object *obj) · line 942

Quoted 8 lines
target/arm/cpu64.c +8 -0
+    t = cpu->isar.id_aa64isar0;
+    t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2);      /* FEAT_PMULL */
+    t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1);     /* FEAT_SHA1 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 1);     /* FEAT_SHA512 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1);    /* FEAT_CRC32 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2);   /* FEAT_LSE */
+    t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1);      /* FEAT_RDM */
+    t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1);       /* FEAT_DotProd */

Maybe:

Quoted 3 lines
Quoted 1 line

         assert(t == 0x0000100010211120ull);

But why bother to break it out then?

To keep everybody happy :) For example Alex can grep which cores implement FEAT_CRC32...

#7 lore raw
In reply to Richard Henderson
Quoted 50 lines · Richard Henderson
Quoted 48 lines · Alex Bennée

This is a mandatory feature for Armv8.1 architectures but we don't state the feature clearly in our emulation list. While checking verify our cortex-a76 model matches up with the current TRM by breaking out the long form isar into a more modern readable FIELD_DP code.

---
  docs/system/arm/emulation.rst |  1 +
  target/arm/cpu64.c            | 29 ++++++++++++++++++++++++++---
  target/arm/cpu_tcg.c          |  2 +-
  3 files changed, 28 insertions(+), 4 deletions(-)
docs/system/arm/emulation.rst +1 -0
index 2062d71261..2c4fde5eef 100644
@@ -14,6 +14,7 @@ the following architecture extensions:
  - FEAT_BBM at level 2 (Translation table break-before-make levels)
  - FEAT_BF16 (AArch64 BFloat16 instructions)
  - FEAT_BTI (Branch Target Identification)
+- FEAT_CRC32 (CRC32 instruction)
  - FEAT_CSV2 (Cache speculation variant 2)
  - FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1)
  - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2)
target/arm/cpu64.c +8 -1
index 4066950da1..12e1a532ab 100644
@@ -912,6 +912,8 @@ static void aarch64_a72_initfn(Object *obj)
  static void aarch64_a76_initfn(Object *obj)
  {
      ARMCPU *cpu = ARM_CPU(obj);
+    uint64_t t;
+    uint32_t u;
 
      cpu->dtb_compatible = "arm,cortex-a76";
      set_feature(&cpu->env, ARM_FEATURE_V8);
@@ -928,7 +930,18 @@ static void aarch64_a76_initfn(Object *obj)
      cpu->ctr = 0x8444C004;
      cpu->dcz_blocksize = 4;
      cpu->isar.id_aa64dfr0  = 0x0000000010305408ull;
-    cpu->isar.id_aa64isar0 = 0x0000100010211120ull;
+
+    /* per r4p1 of the Cryptographic Extension TRM */
+    t = cpu->isar.id_aa64isar0;
+    t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2);      /* FEAT_PMULL */
+    t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1);     /* FEAT_SHA1 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 1);     /* FEAT_SHA512 */
Quoted 8 lines

target/arm/cpu64.c static void aarch64_a76_initfn(Object *obj) · line 943

Quoted 5 lines
target/arm/cpu64.c +5 -0
+    t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1);    /* FEAT_CRC32 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2);   /* FEAT_LSE */
+    t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1);      /* FEAT_RDM */
+    t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1);       /* FEAT_DotProd */
+    cpu->isar.id_aa64isar0 = t;

Ok, so, this might be helpful for grepping, but it's not helpful for reading the documentation, which on page B2-137 uses hex.

Agreed -- we write these functions and review them by looking at the TRMs, and the TRMs specify the values of the ID registers as straight hex values.

thanks
-- PMM

#8 lore raw
Quoted 61 lines · Peter Maydell
Quoted 50 lines · Richard Henderson
Quoted 48 lines · Alex Bennée

This is a mandatory feature for Armv8.1 architectures but we don't state the feature clearly in our emulation list. While checking verify our cortex-a76 model matches up with the current TRM by breaking out the long form isar into a more modern readable FIELD_DP code.

---
  docs/system/arm/emulation.rst |  1 +
  target/arm/cpu64.c            | 29 ++++++++++++++++++++++++++---
  target/arm/cpu_tcg.c          |  2 +-
  3 files changed, 28 insertions(+), 4 deletions(-)
docs/system/arm/emulation.rst +1 -0
index 2062d71261..2c4fde5eef 100644
@@ -14,6 +14,7 @@ the following architecture extensions:
  - FEAT_BBM at level 2 (Translation table break-before-make levels)
  - FEAT_BF16 (AArch64 BFloat16 instructions)
  - FEAT_BTI (Branch Target Identification)
+- FEAT_CRC32 (CRC32 instruction)
  - FEAT_CSV2 (Cache speculation variant 2)
  - FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1)
  - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2)
target/arm/cpu64.c +8 -1
index 4066950da1..12e1a532ab 100644
@@ -912,6 +912,8 @@ static void aarch64_a72_initfn(Object *obj)
  static void aarch64_a76_initfn(Object *obj)
  {
      ARMCPU *cpu = ARM_CPU(obj);
+    uint64_t t;
+    uint32_t u;
 
      cpu->dtb_compatible = "arm,cortex-a76";
      set_feature(&cpu->env, ARM_FEATURE_V8);
@@ -928,7 +930,18 @@ static void aarch64_a76_initfn(Object *obj)
      cpu->ctr = 0x8444C004;
      cpu->dcz_blocksize = 4;
      cpu->isar.id_aa64dfr0  = 0x0000000010305408ull;
-    cpu->isar.id_aa64isar0 = 0x0000100010211120ull;
+
+    /* per r4p1 of the Cryptographic Extension TRM */
+    t = cpu->isar.id_aa64isar0;
+    t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2);      /* FEAT_PMULL */
+    t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1);     /* FEAT_SHA1 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 1);     /* FEAT_SHA512 */
Quoted 8 lines

target/arm/cpu64.c static void aarch64_a76_initfn(Object *obj) · line 943

Quoted 5 lines
target/arm/cpu64.c +5 -0
+    t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1);    /* FEAT_CRC32 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2);   /* FEAT_LSE */
+    t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1);      /* FEAT_RDM */
+    t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1);       /* FEAT_DotProd */
+    cpu->isar.id_aa64isar0 = t;

Ok, so, this might be helpful for grepping, but it's not helpful for reading the documentation, which on page B2-137 uses hex.

Quoted 3 lines

Agreed -- we write these functions and review them by looking at the TRMs, and the TRMs specify the values of the ID registers as straight hex values.

Ahh found it now was confusing the pages with sections: B2.4 on page B2-137.

Quoted 3 lines

thanks
-- PMM

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#9 lore raw
In reply to Richard Henderson
Quoted 47 lines · Richard Henderson
Quoted 46 lines · Alex Bennée

This is a mandatory feature for Armv8.1 architectures but we don't state the feature clearly in our emulation list. While checking verify our cortex-a76 model matches up with the current TRM by breaking out the long form isar into a more modern readable FIELD_DP code.

---
  docs/system/arm/emulation.rst |  1 +
  target/arm/cpu64.c            | 29 ++++++++++++++++++++++++++---
  target/arm/cpu_tcg.c          |  2 +-
  3 files changed, 28 insertions(+), 4 deletions(-)
docs/system/arm/emulation.rst +1 -0
index 2062d71261..2c4fde5eef 100644
@@ -14,6 +14,7 @@ the following architecture extensions:
  - FEAT_BBM at level 2 (Translation table break-before-make levels)
  - FEAT_BF16 (AArch64 BFloat16 instructions)
  - FEAT_BTI (Branch Target Identification)
+- FEAT_CRC32 (CRC32 instruction)
  - FEAT_CSV2 (Cache speculation variant 2)
  - FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1)
  - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2)
target/arm/cpu64.c +8 -1
index 4066950da1..12e1a532ab 100644
@@ -912,6 +912,8 @@ static void aarch64_a72_initfn(Object *obj)
  static void aarch64_a76_initfn(Object *obj)
  {
      ARMCPU *cpu = ARM_CPU(obj);
+    uint64_t t;
+    uint32_t u;
        cpu->dtb_compatible = "arm,cortex-a76";
      set_feature(&cpu->env, ARM_FEATURE_V8);
@@ -928,7 +930,18 @@ static void aarch64_a76_initfn(Object *obj)
      cpu->ctr = 0x8444C004;
      cpu->dcz_blocksize = 4;
      cpu->isar.id_aa64dfr0  = 0x0000000010305408ull;
-    cpu->isar.id_aa64isar0 = 0x0000100010211120ull;
+
+    /* per r4p1 of the Cryptographic Extension TRM */
+    t = cpu->isar.id_aa64isar0;
+    t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2);      /* FEAT_PMULL */
+    t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1);     /* FEAT_SHA1 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 1);     /* FEAT_SHA512 */
Quoted 8 lines

target/arm/cpu64.c static void aarch64_a76_initfn(Object *obj) · line 943

Quoted 5 lines
target/arm/cpu64.c +5 -0
+    t = FIELD_DP64(t, ID_AA64ISAR0, CRC32, 1);    /* FEAT_CRC32 */
+    t = FIELD_DP64(t, ID_AA64ISAR0, ATOMIC, 2);   /* FEAT_LSE */
+    t = FIELD_DP64(t, ID_AA64ISAR0, RDM, 1);      /* FEAT_RDM */
+    t = FIELD_DP64(t, ID_AA64ISAR0, DP, 1);       /* FEAT_DotProd */
+    cpu->isar.id_aa64isar0 = t;

Ok, so, this might be helpful for grepping, but it's not helpful for reading the documentation, which on page B2-137 uses hex.

Well in the latest TRM is B2.62 which breaks it out to the individual bit assignments. I didn't find that first time around which is why I was reading the Cryptograhic Extension TRM which is similarly broken out.

If this is the way the documentation is going we should follow it.

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro
#10 lore raw
In reply to Alex Bennée
Quoted 18 lines · Alex Bennée

This is a mandatory feature for Armv8.1 architectures but we don't state the feature clearly in our emulation list. While checking verify our cortex-a76 model matches up with the current TRM by breaking out the long form isar into a more modern readable FIELD_DP code.

---
 docs/system/arm/emulation.rst |  1 +
 target/arm/cpu64.c            | 29 ++++++++++++++++++++++++++---
 target/arm/cpu_tcg.c          |  2 +-
 3 files changed, 28 insertions(+), 4 deletions(-)
docs/system/arm/emulation.rst +0 -0
index 2062d71261..2c4fde5eef 100644

docs/system/arm/emulation.rst the following architecture extensions: · line 20

Quoted 7 lines
docs/system/arm/emulation.rst +1 -0
@@ -14,6 +14,7 @@ the following architecture extensions:
 - FEAT_BBM at level 2 (Translation table break-before-make levels)
 - FEAT_BF16 (AArch64 BFloat16 instructions)
 - FEAT_BTI (Branch Target Identification)
+- FEAT_CRC32 (CRC32 instruction)
 - FEAT_CSV2 (Cache speculation variant 2)
 - FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1)
 - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2)

Would you mind resubmitting a version of this patch that just fixes this documentation error and doesn't also do the other stuff that caused this patch to not get through code review?

thanks
-- PMM

#11 lore raw
Quoted 14 lines · Peter Maydell
Quoted 13 lines · Alex Bennée

This is a mandatory feature for Armv8.1 architectures but we don't state the feature clearly in our emulation list. While checking verify our cortex-a76 model matches up with the current TRM by breaking out the long form isar into a more modern readable FIELD_DP code.

---
 docs/system/arm/emulation.rst |  1 +
 target/arm/cpu64.c            | 29 ++++++++++++++++++++++++++---
 target/arm/cpu_tcg.c          |  2 +-
 3 files changed, 28 insertions(+), 4 deletions(-)
Quoted 16 lines

docs/system/arm/emulation.rst the following architecture extensions: · line 20

Quoted 12 lines
docs/system/arm/emulation.rst +1 -0
index 2062d71261..2c4fde5eef 100644
@@ -14,6 +14,7 @@ the following architecture extensions:
 - FEAT_BBM at level 2 (Translation table break-before-make levels)
 - FEAT_BF16 (AArch64 BFloat16 instructions)
 - FEAT_BTI (Branch Target Identification)
+- FEAT_CRC32 (CRC32 instruction)
 - FEAT_CSV2 (Cache speculation variant 2)
 - FEAT_CSV2_1p1 (Cache speculation variant 2, version 1.1)
 - FEAT_CSV2_1p2 (Cache speculation variant 2, version 1.2)

Would you mind resubmitting a version of this patch that just fixes this documentation error and doesn't also do the other stuff that caused this patch to not get through code review?

Sent [email protected]

Signature · 2 lines
Alex Bennée
Virtualisation Tech Lead @ Linaro