Skip to contentSkip to conversation

target-arm: Add MDCR_EL2

PATCH Applied Sergey Fedorov 2 participants 7 messages Oct 9, 2015 – Oct 16, 2015

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 target-arm: Add MDCR_EL2

---

Changes in v2:
* Reset value is simply made zero

 target-arm/cpu.h    |  1 +
 target-arm/helper.c | 11 +++++++++++
 2 files changed, 12 insertions(+)
target-arm/cpu.h +1 -0
index cc1578c..51d8ed1 100644
@@ -378,6 +378,7 @@ typedef struct CPUARMState {
         uint64_t dbgwvr[16]; /* watchpoint value registers */
         uint64_t dbgwcr[16]; /* watchpoint control registers */
         uint64_t mdscr_el1;
+        uint64_t mdcr_el2;
         /* If the counter is enabled, this stores the last time the counter
          * was reset. Otherwise it stores the counter value
          */
target-arm/helper.c +11 -0
index 8367997..ec4097b 100644
@@ -3223,6 +3223,9 @@ static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = {
     { .name = "CNTHP_CTL_EL2", .state = ARM_CP_STATE_BOTH,
       .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 2, .opc2 = 1,
       .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
+    { .name = "MDCR_EL2", .state = ARM_CP_STATE_BOTH,
+      .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 1,
+      .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
     REGINFO_SENTINEL
 };
 
@@ -3576,6 +3579,14 @@ static const ARMCPRegInfo debug_cp_reginfo[] = {
     { .name = "MDRAR_EL1", .state = ARM_CP_STATE_AA64,
       .opc0 = 2, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 0,
       .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
+    /* The only field of MDCR_EL2 that has a defined architectural reset value
+     * is MDCR_EL2.HPMN which should reset to the value of PMCR_EL0.N; but we
+     * don't impelment any PMU event counters, so using zero as a reset
+     * value for MDCR_EL2 is okay */
+    { .name = "MDCR_EL2", .state = ARM_CP_STATE_BOTH,
+      .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 1,
+      .access = PL2_RW, .resetvalue = 0,
+      .fieldoffset = offsetof(CPUARMState, cp15.mdcr_el2), },
     { .name = "DBGDSAR", .cp = 14, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 0,
       .access = PL0_R, .type = ARM_CP_CONST, .resetvalue = 0 },
     /* Monitor debug system control register; the 32-bit alias is DBGDSCRext. */
Signature · 1 line
1.9.1
#1 lore raw
Quoted 10 lines · Sergey Fedorov

---

Changes in v2:
* Reset value is simply made zero

 target-arm/cpu.h    |  1 +
 target-arm/helper.c | 11 +++++++++++
 2 files changed, 12 insertions(+)

Applied to target-arm.next, thanks (I expanded the commit message a little).

-- PMM

#2 lore raw
Quoted 7 lines · Peter Maydell
Quoted 6 lines · Sergey Fedorov

---

Changes in v2:
* Reset value is simply made zero

Quoted 6 lines
Quoted 4 lines
 target-arm/cpu.h    |  1 +
 target-arm/helper.c | 11 +++++++++++
 2 files changed, 12 insertions(+)

Applied to target-arm.next, thanks (I expanded the commit message a little).

Thanks! So now you are going to re-apply
https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg04862.html again?

Best regards,
Sergey

#3 lore raw
Quoted 12 lines · Sergey Fedorov
Quoted 11 lines · Peter Maydell
Quoted 10 lines · Sergey Fedorov

---

Changes in v2:
* Reset value is simply made zero

 target-arm/cpu.h    |  1 +
 target-arm/helper.c | 11 +++++++++++
 2 files changed, 12 insertions(+)
Quoted 5 lines
Quoted 2 lines

Applied to target-arm.next, thanks (I expanded the commit message a little).

Thanks! So now you are going to re-apply
https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg04862.html again?

I was expecting a resend, but if it applies without changes I'll put it back on my list.

thanks
-- PMM

#4 lore raw
Quoted 13 lines · Peter Maydell
Quoted 12 lines · Sergey Fedorov
Quoted 11 lines · Peter Maydell
Quoted 10 lines · Sergey Fedorov

---

Changes in v2:
* Reset value is simply made zero

 target-arm/cpu.h    |  1 +
 target-arm/helper.c | 11 +++++++++++
 2 files changed, 12 insertions(+)
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

Applied to target-arm.next, thanks (I expanded the commit message a little).

Thanks! So now you are going to re-apply
https://lists.gnu.org/archive/html/qemu-devel/2015-09/msg04862.html again?

I was expecting a resend, but if it applies without changes I'll put it back on my list.

Yes, it applies without a change, so no need to resend :)

Best regards,
Sergey

#5 lore raw
In reply to Sergey Fedorov
Quoted 41 lines · Sergey Fedorov

---

Changes in v2:
* Reset value is simply made zero

 target-arm/cpu.h    |  1 +
 target-arm/helper.c | 11 +++++++++++
 2 files changed, 12 insertions(+)
target-arm/cpu.h +1 -0
index cc1578c..51d8ed1 100644
@@ -378,6 +378,7 @@ typedef struct CPUARMState {
         uint64_t dbgwvr[16]; /* watchpoint value registers */
         uint64_t dbgwcr[16]; /* watchpoint control registers */
         uint64_t mdscr_el1;
+        uint64_t mdcr_el2;
         /* If the counter is enabled, this stores the last time the counter
          * was reset. Otherwise it stores the counter value
          */
target-arm/helper.c +4 -0
index 8367997..ec4097b 100644
@@ -3223,6 +3223,9 @@ static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = {
     { .name = "CNTHP_CTL_EL2", .state = ARM_CP_STATE_BOTH,
       .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 2, .opc2 = 1,
       .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
+    { .name = "MDCR_EL2", .state = ARM_CP_STATE_BOTH,
+      .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 1,
+      .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
     REGINFO_SENTINEL
 };
 
@@ -3576,6 +3579,14 @@ static const ARMCPRegInfo debug_cp_reginfo[] = {
     { .name = "MDRAR_EL1", .state = ARM_CP_STATE_AA64,
       .opc0 = 2, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 0,
       .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
+    /* The only field of MDCR_EL2 that has a defined architectural reset value

target-arm/helper.c static const ARMCPRegInfo debug_cp_reginfo[] = { · line 3592

Quoted 10 lines
target-arm/helper.c +7 -0
+     * is MDCR_EL2.HPMN which should reset to the value of PMCR_EL0.N; but we
+     * don't impelment any PMU event counters, so using zero as a reset
+     * value for MDCR_EL2 is okay */
+    { .name = "MDCR_EL2", .state = ARM_CP_STATE_BOTH,
+      .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 1,
+      .access = PL2_RW, .resetvalue = 0,
+      .fieldoffset = offsetof(CPUARMState, cp15.mdcr_el2), },
     { .name = "DBGDSAR", .cp = 14, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 0,
       .access = PL0_R, .type = ARM_CP_CONST, .resetvalue = 0 },
     /* Monitor debug system control register; the 32-bit alias is DBGDSCRext. */

This fails 'make check':

GTESTER check-qtest-arm
Register redefined: cp=15 32 bit crn=1 crm=1 opc1=4 opc2=1, was
MDCR_EL2, now MDCR_EL2
** ERROR:/home/petmay01/linaro/qemu-from-laptop/qemu/target-arm/helper.c:4740:add_cpreg_to_hashtable:
code should not be reached

The second MDCR_EL2 definition needs to be in el2_cp_reginfo[], not debug_cp_reginfo[]; otherwise a CPU with EL2 but not EL2 will try to define both.

I will squash in the change which moves the definition.

thanks
-- PMM

#6 lore raw
Quoted 61 lines · Peter Maydell
Quoted 41 lines · Sergey Fedorov

---

Changes in v2:
* Reset value is simply made zero

 target-arm/cpu.h    |  1 +
 target-arm/helper.c | 11 +++++++++++
 2 files changed, 12 insertions(+)
target-arm/cpu.h +1 -0
index cc1578c..51d8ed1 100644
@@ -378,6 +378,7 @@ typedef struct CPUARMState {
         uint64_t dbgwvr[16]; /* watchpoint value registers */
         uint64_t dbgwcr[16]; /* watchpoint control registers */
         uint64_t mdscr_el1;
+        uint64_t mdcr_el2;
         /* If the counter is enabled, this stores the last time the counter
          * was reset. Otherwise it stores the counter value
          */
target-arm/helper.c +4 -0
index 8367997..ec4097b 100644
@@ -3223,6 +3223,9 @@ static const ARMCPRegInfo el3_no_el2_cp_reginfo[] = {
     { .name = "CNTHP_CTL_EL2", .state = ARM_CP_STATE_BOTH,
       .opc0 = 3, .opc1 = 4, .crn = 14, .crm = 2, .opc2 = 1,
       .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
+    { .name = "MDCR_EL2", .state = ARM_CP_STATE_BOTH,
+      .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 1,
+      .access = PL2_RW, .type = ARM_CP_CONST, .resetvalue = 0 },
     REGINFO_SENTINEL
 };
 
@@ -3576,6 +3579,14 @@ static const ARMCPRegInfo debug_cp_reginfo[] = {
     { .name = "MDRAR_EL1", .state = ARM_CP_STATE_AA64,
       .opc0 = 2, .opc1 = 0, .crn = 1, .crm = 0, .opc2 = 0,
       .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0 },
+    /* The only field of MDCR_EL2 that has a defined architectural reset value

target-arm/helper.c static const ARMCPRegInfo debug_cp_reginfo[] = { · line 3592

Quoted 10 lines
target-arm/helper.c +7 -0
+     * is MDCR_EL2.HPMN which should reset to the value of PMCR_EL0.N; but we
+     * don't impelment any PMU event counters, so using zero as a reset
+     * value for MDCR_EL2 is okay */
+    { .name = "MDCR_EL2", .state = ARM_CP_STATE_BOTH,
+      .opc0 = 3, .opc1 = 4, .crn = 1, .crm = 1, .opc2 = 1,
+      .access = PL2_RW, .resetvalue = 0,
+      .fieldoffset = offsetof(CPUARMState, cp15.mdcr_el2), },
     { .name = "DBGDSAR", .cp = 14, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 0,
       .access = PL0_R, .type = ARM_CP_CONST, .resetvalue = 0 },
     /* Monitor debug system control register; the 32-bit alias is DBGDSCRext. */

This fails 'make check':

GTESTER check-qtest-arm
Register redefined: cp=15 32 bit crn=1 crm=1 opc1=4 opc2=1, was
MDCR_EL2, now MDCR_EL2
** ERROR:/home/petmay01/linaro/qemu-from-laptop/qemu/target-arm/helper.c:4740:add_cpreg_to_hashtable:
code should not be reached

Quoted 5 lines

The second MDCR_EL2 definition needs to be in el2_cp_reginfo[], not debug_cp_reginfo[]; otherwise a CPU with EL2 but not EL2 will try to define both.

I will squash in the change which moves the definition.

Oops... I should make it a rule and do 'make check' before submitting changes.

Thanks,
Sergey