Skip to contentSkip to conversation

target-arm: Add support for SPSR_(ABT|UND|IRQ|FIQ)

PATCH In review Soren Brinkmann 2 participants 2 messages Oct 15, 2015 – Oct 19, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-arm: Add support for SPSR_(ABT|UND|IRQ|FIQ)

---
Hi,

I recently came across some code that caused undefined instruction exceptions
when executing instructions 'mrs x11, spsr_abt' and the like. I'm not sure I
get the full picture, but it seems QEMU already keeps the state for those SPSR registers and all that might be missing is exposing those registers to the guest.

Thanks,
Sören

 target-arm/helper.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
target-arm/helper.c +16 -0
index 83679970b432..0c64c0588115 100644
@@ -3281,6 +3281,22 @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
       .type = ARM_CP_ALIAS,
       .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 0, .opc2 = 0,
       .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[6]) },
+    { .name = "SPSR_IRQ", .state = ARM_CP_STATE_AA64,
+      .type = ARM_CP_ALIAS,
+      .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 3, .opc2 = 0,
+      .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[4]) },
+    { .name = "SPSR_ABT", .state = ARM_CP_STATE_AA64,
+      .type = ARM_CP_ALIAS,
+      .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 3, .opc2 = 1,
+      .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[2]) },
+    { .name = "SPSR_UND", .state = ARM_CP_STATE_AA64,
+      .type = ARM_CP_ALIAS,
+      .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 3, .opc2 = 2,
+      .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[3]) },
+    { .name = "SPSR_FIQ", .state = ARM_CP_STATE_AA64,
+      .type = ARM_CP_ALIAS,
+      .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 3, .opc2 = 3,
+      .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[5]) },
     { .name = "VBAR_EL2", .state = ARM_CP_STATE_AA64,
       .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 0, .opc2 = 0,
       .access = PL2_RW, .writefn = vbar_write,
Signature · 1 line
2.6.1.3.g59394a9
Reviewed-by on v1 1/1
#1 lore raw
Quoted 9 lines · Soren Brinkmann

---
Hi,

I recently came across some code that caused undefined instruction exceptions
when executing instructions 'mrs x11, spsr_abt' and the like. I'm not sure I
get the full picture, but it seems QEMU already keeps the state for those SPSR registers and all that might be missing is exposing those registers to the guest.

Well, these are only accessible from EL2 or EL3, and we don't implement those yet for 64-bit...

Quoted 17 lines
target-arm/helper.c +9 -0
index 83679970b432..0c64c0588115 100644
@@ -3281,6 +3281,22 @@ static const ARMCPRegInfo el2_cp_reginfo[] = {
       .type = ARM_CP_ALIAS,
       .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 0, .opc2 = 0,
       .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[6]) },
+    { .name = "SPSR_IRQ", .state = ARM_CP_STATE_AA64,
+      .type = ARM_CP_ALIAS,
+      .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 3, .opc2 = 0,
+      .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[4]) },
+    { .name = "SPSR_ABT", .state = ARM_CP_STATE_AA64,
+      .type = ARM_CP_ALIAS,
+      .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 3, .opc2 = 1,
+      .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[2]) },
+    { .name = "SPSR_UND", .state = ARM_CP_STATE_AA64,

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

Quoted 10 lines
target-arm/helper.c +7 -0
+      .type = ARM_CP_ALIAS,
+      .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 3, .opc2 = 2,
+      .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[3]) },
+    { .name = "SPSR_FIQ", .state = ARM_CP_STATE_AA64,
+      .type = ARM_CP_ALIAS,
+      .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 3, .opc2 = 3,
+      .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[5]) },
     { .name = "VBAR_EL2", .state = ARM_CP_STATE_AA64,
       .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 0, .opc2 = 0,
       .access = PL2_RW, .writefn = vbar_write,

These look OK, so

I wonder if we should define some ARM_BANK_* constants for the indexes into the banked_* arrays?

Providing the 32-bit versions of these would be nice, but they aren't implemented as system registers and they're kind of complicated, so we'll leave that for now.

thanks
-- PMM