target-arm: Store SPSR_EL1 state in banked_spsr[1] (SPSR_svc)
PATCH v2 1/1 target-arm: Store SPSR_EL1 state in banked_spsr[1] (SPSR_svc)
The AArch64 SPSR_EL1 register is architecturally mandated to be mapped to the AArch32 SPSR_svc register. This means its state should live in QEMU's env->banked_spsr[1] field. Correct the various places in the code that incorrectly put it in banked_spsr[0].
---v1->v2: fix all the places which were using [0], not just one...
target-arm/helper-a64.c | 2 +- target-arm/helper.c | 2 +- target-arm/internals.h | 5 ++++- 3 files changed, 6 insertions(+), 3 deletions(-)
target-arm/helper-a64.c +1 -1
@@ -523,7 +523,7 @@ void aarch64_cpu_do_interrupt(CPUState *cs)aarch64_save_sp (env,arm_current_el (env)); env->elr_el[new_el] = env->pc; }else { - env->banked_spsr[0 ] =cpsr_read (env); + env->banked_spsr[aarch64_banked_spsr_index (new_el)] =cpsr_read (env);if (!env->thumb) { env->cp15.esr_el[new_el] |=1 <<25 ; }
target-arm/helper.c +1 -1
@@ -2438,7 +2438,7 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { { .name = "SPSR_EL1", .state = ARM_CP_STATE_AA64, .type = ARM_CP_ALIAS, .opc0 = 3, .opc1 = 0, .crn = 4, .crm = 0, .opc2 = 0, - .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[0]) }, + .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[1]) },/* We rely on the access checks not allowing the guest to write to the * state field when SPSel indicates that it's being used as the stack * pointer.
target-arm/internals.h +4 -1
@@ -82,11 +82,14 @@ static inline void arm_log_exception(int idx)/* * For AArch64, map a given EL to an index in the banked_spsr array. +* Note that this mapping and the AArch32 mapping defined in bank_number() +* must agree such that the AArch64<->AArch32 SPSRs have the architecturally +* mandated mapping between each other. */ static inline unsigned int aarch64_banked_spsr_index (unsigned int el) {static const unsigned int map[4 ] = { - [1 ] =0 ,/* EL1. */ + [1 ] =1 ,/* EL1. */ [2 ] =6 ,/* EL2. */ [3 ] =7 ,/* EL3. */ };
Signature · 1 line
1.9.1
Quoted 7 lines · Peter Maydell
The AArch64
SPSR_EL1register is architecturally mandated to be mapped to the AArch32SPSR_svcregister. This means its state should live in QEMU's env->banked_spsr[1] field. Correct the various places in the code that incorrectly put it in banked_spsr[0].Signed-off-by Peter Maydell <[email protected]>
Alex, will you respin the SPSR patch based on this one then? You can change the authorship on the SPSR patch to yourself if you prefer.
Thanks,
-Christoffer
Quoted 10 lines · Christoffer Dall
Quoted 7 lines · Peter Maydell
The AArch64
SPSR_EL1register is architecturally mandated to be mapped to the AArch32SPSR_svcregister. This means its state should live in QEMU's env->banked_spsr[1] field. Correct the various places in the code that incorrectly put it in banked_spsr[0].Signed-off-by Peter Maydell <[email protected]>Reviewed-by Christoffer Dall <[email protected]>
Thanks. It also occurs to me that we could avoid some of these magic 1/6/7 numbers by defining some constants BANK_USR, BANK_SVC, BANK_ABT, etc for the return values from bank_number (ie the indexes into env->banked_* arrays),
and then using them where we need to refer to particular banked_* entries elsewhere. Then for instance this array in aarch64_banked_spsr_index() looks like
[1] = BANK_SVC, /* EL1. */
[2] = BANK_HYP, /* EL2. */
[3] = BANK_MON, /* EL3. */and the mapping between the AArch32 and AArch64 SPSRs is suddenly much more obvious and easy to check.
-- PMM
Quoted 7 lines · Christoffer Dall
Quoted 6 lines · Peter Maydell
The AArch64
SPSR_EL1register is architecturally mandated to be mapped to the AArch32SPSR_svcregister. This means its state should live in QEMU's env->banked_spsr[1] field. Correct the various places in the code that incorrectly put it in banked_spsr[0].
Quoted 7 lines
Quoted 1 line
Signed-off-by Peter Maydell <[email protected]>Reviewed-by Christoffer Dall <[email protected]>Alex, will you respin the SPSR patch based on this one then? You can change the authorship on the SPSR patch to yourself if you prefer.
Yeah I'll re-spin the series hopefully by the end of this week or early next.
Quoted 3 lines
Thanks,
-Christoffer
Signature · 5 lines
Alex Bennée _______________________________________________ kvmarm mailing list [email protected] https://lists.cs.columbia.edu/mailman/listinfo/kvmarm