target-arm: Preparations for A64 EL2 and 3
cover target-arm: Preparations for A64 EL2 and 3
From: "Edgar E. Iglesias" <[email protected]>
Hi,
I've been doing some work on modeling parts of EL2 and 3 + some of the system-wide virtualization features for ARMv8. A lot is missing but I've got a series with enough to for example run KVM A64 guests on top of EL3 firmware inside emulated QEMU A64 VMs.
I'm working on cleaning things up and plan to send patches and publish things as I go.
This series does a first round of preparations. Most of it has little or no user visible impact as the EL2 and 3 features remain disabled.
For the arrayification of the various EL regs that do not exist for EL0, I've used index macros. I don't really have a preference here, so if you have better/less ugly ideas or preferences I'm happy to change the pattern (getters/setters or whatever).
Happy to address any comments people may have.
Cheers,
Edgar
Edgar E. Iglesias (22):
target-arm: A64: Add friendly logging of PSTATE A and I flags
target-arm: Make elr_el1 an array
target-arm: Make esr_el1 an array
target-arm: c12_vbar -> vbar_el[]
target-arm: Add arm_el_to_mmu_idx()
target-arm: Move get_mem_index to translate.h
target-arm: A64: Add SP entries for EL2 and 3
target-arm: A64: Add ELR entries for EL2 and 3
target-arm: Add SPSR entries for EL2/HYP and EL3/MON
target-arm: A64: Introduce arm64_banked_spsr_index()
target-arm: Add a feature flag for EL2
target-arm: Add a feature flag for EL3
target-arm: Register EL2 versions of ELR and SPSR
target-arm: Register EL3 versions of ELR and SPSR
target-arm: A64: Forbid ERET to increase the EL
target-arm: A64: Forbid ERET to unimplemented ELs
target-arm: A64: Generalize ERET to various ELs
target-arm: A64: Generalize update_spsel for the various ELs
target-arm: Add storage for VBAR_EL2 and 3
target-arm: Make vbar_write writeback to any CPREG
target-arm: A64: Register VBAR_EL2
target-arm: A64: Register VBAR_EL3
target-arm/cpu.h | 38 +++++++++++++++++++++----- target-arm/helper-a64.c | 15 ++++++----- target-arm/helper.c | 67 +++++++++++++++++++++++++++++++++++++++------- target-arm/internals.h | 25 ++++++++++++----- target-arm/kvm64.c | 4 +-- target-arm/machine.c | 12 ++++----- target-arm/op_helper.c | 19 ++++++++----- target-arm/translate-a64.c | 13 +++------ target-arm/translate.h | 5 ++++ 9 files changed, 145 insertions(+), 53 deletions(-)
Signature · 1 line
1.8.3.2
PATCH 1/22 target-arm: A64: Add friendly logging of PSTATE A and I flags
From: "Edgar E. Iglesias" <[email protected]>
--- target-arm/translate-a64.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
target-arm/translate-a64.c +3 -1
@@ -137,8 +137,10 @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f,cpu_fprintf (f," " ); } } - cpu_fprintf(f, "PSTATE=%08x (flags %c%c%c%c)\n", + cpu_fprintf(f, "PSTATE=%08x (flags %c%c%c%c%c%c)\n", psr, + psr & PSTATE_A ? 'A' : '-', + psr & PSTATE_I ? 'I' : '-', psr & PSTATE_N ? 'N' : '-', psr & PSTATE_Z ? 'Z' : '-', psr & PSTATE_C ? 'C' : '-',
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH v1 01/22] target-arm: A64: Add friendly logging of PSTATE A and I flags
Quoted 12 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/translate-a64.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)target-arm/translate-a64.c +0
-0
target-arm/translate-a64.c void aarch64_cpu_dump_state(CPUState *cs, FILE *f, · line 140
Quoted 5 lines
target-arm/translate-a64.c +1
-1@@ -137,8 +137,10 @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f,cpu_fprintf (f," " ); } } - cpu_fprintf(f, "PSTATE=%08x (flags %c%c%c%c)\n", + cpu_fprintf(f, "PSTATE=%08x (flags %c%c%c%c%c%c)\n",
Should delimit (just a space I think) between DAIF and NZCV components. ARM ARM repeatedly refers to these two groups of four as single item suggesting they are two logical groupings of 4 bits each.
target-arm/translate-a64.c void aarch64_cpu_dump_state(CPUState *cs, FILE *f, · line 143
Quoted 3 lines
target-arm/translate-a64.c +2
-0psr, + psr &PSTATE_A ?'A' :'-' , + psr & PSTATE_I ? 'I' : '-',
And should the full DAIF be added for completeness?
Regards,
Peter
Quoted 7 lines
target-arm/translate-a64.c +0
-1psr &PSTATE_N ?'N' :'-' , psr &PSTATE_Z ?'Z' :'-' , psr & PSTATE_C ? 'C' : '-', --1.8.3.2
Re: [Qemu-devel] [PATCH v1 01/22] target-arm: A64: Add friendly logging of PSTATE A and I flags
In reply to Edgar E. IglesiasQuoted 13 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/translate-a64.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)target-arm/translate-a64.c +0
-0@@ -137,8 +137,10 @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f,cpu_fprintf (f," " );
target-arm/translate-a64.c void aarch64_cpu_dump_state(CPUState *cs, FILE *f, · line 146
Quoted 10 lines
target-arm/translate-a64.c +3
-1} } - cpu_fprintf(f, "PSTATE=%08x (flags %c%c%c%c)\n", + cpu_fprintf(f, "PSTATE=%08x (flags %c%c%c%c%c%c)\n", psr, + psr & PSTATE_A ? 'A' : '-', + psr & PSTATE_I ? 'I' : '-', psr & PSTATE_N ? 'N' : '-', psr & PSTATE_Z ? 'Z' : '-', psr & PSTATE_C ? 'C' : '-',
Why A and I ? In particular in QEMU the A bit is always zero because we don't do System Errors (aka asynchronous external aborts), and it's weird to show I but not F. The idea of splitting out NZCV is really that (as with the A32/T32 state dump) they're the most useful bits for immediately figuring out code flow); anything else you can fish out of the hex value by hand if you really need it. I think you can make a case for "decode only a small set of key bits" or for "completely decode the whole register", but I'm not sure adding only two more bits makes sense.
thanks
-- PMM
Re: [Qemu-devel] [PATCH v1 01/22] target-arm: A64: Add friendly logging of PSTATE A and I flags
Quoted 27 lines · Peter Maydell
Quoted 13 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/translate-a64.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)target-arm/translate-a64.c +0
-0@@ -137,8 +137,10 @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f,cpu_fprintf (f," " );target-arm/translate-a64.c void aarch64_cpu_dump_state(CPUState *cs, FILE *f, · line 146
Quoted 10 lines
target-arm/translate-a64.c +3
-1} } - cpu_fprintf(f, "PSTATE=%08x (flags %c%c%c%c)\n", + cpu_fprintf(f, "PSTATE=%08x (flags %c%c%c%c%c%c)\n", psr, + psr & PSTATE_A ? 'A' : '-', + psr & PSTATE_I ? 'I' : '-', psr & PSTATE_N ? 'N' : '-', psr & PSTATE_Z ? 'Z' : '-', psr & PSTATE_C ? 'C' : '-',Why A and I ? In particular in QEMU the A bit is always zero because we don't do System Errors (aka asynchronous
Quoted 8 lines
external aborts), and it's weird to show I but not F. The idea of splitting out NZCV is really that (as with the A32/T32 state dump) they're the most useful bits for immediately figuring out code flow); anything else you can fish out of the hex value by hand if you really need it. I think you can make a case for "decode only a small set of key bits" or for "completely decode the whole register", but I'm not sure adding only two more bits makes sense.
Hi,
TBH I didn't give this much thought. I used the I flag while debugging some virq stuff and probably added A while stumbling in the dark at some point..
For v2 I've added the DAIF flags with delimiter if thats not good enough I suggest removing the patch, it's not very important.
Cheers,
Edgar
PATCH 2/22 target-arm: Make elr_el1 an array
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
No functional change.
Prepares for future additions of the EL2 and 3 versions of this reg.
--- target-arm/cpu.h | 3 ++- target-arm/helper-a64.c | 4 ++-- target-arm/helper.c | 3 ++- target-arm/kvm64.c | 4 ++-- target-arm/machine.c | 2 +- target-arm/op_helper.c | 6 +++--- 6 files changed, 12 insertions(+), 10 deletions(-)
target-arm/cpu.h +2 -1
@@ -162,7 +162,8 @@ typedef struct CPUARMState {uint32_t condexec_bits;/* IT bits. cpsr[15:10,26:25]. */ uint64_t daif;/* exception masks, in the bits they are in in PSTATE */ -uint64_t elr_el1;/* AArch64 ELR_EL1 */ +#define ELR_EL_IDX (x) (x - 1) +uint64_t elr_el[1 ];/* AArch64 exception link regs */ uint64_t sp_el[2 ];/* AArch64 banked stack pointers */ /* System control coprocessor (cp15) */
target-arm/helper-a64.c +2 -2
@@ -491,13 +491,13 @@ void aarch64_cpu_do_interrupt(CPUState *cs) env->banked_spsr[0 ] =pstate_read (env); env->sp_el[arm_current_pl (env)] = env->xregs[31 ]; env->xregs[31 ] = env->sp_el[1 ]; - env->elr_el1 = env->pc; + env->elr_el[ELR_EL_IDX (1 )] = env->pc; }else { env->banked_spsr[0 ] =cpsr_read (env);if (!env->thumb) { env->cp15.esr_el1 |=1 <<25 ; } - env->elr_el1 = env->regs[15 ]; + env->elr_el[ELR_EL_IDX (1 )] = env->regs[15 ];for (i =0 ; i <15 ; i++) { env->xregs[i] = env->regs[i];
target-arm/helper.c +2 -1
@@ -2055,7 +2055,8 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { { .name = "ELR_EL1", .state = ARM_CP_STATE_AA64, .type = ARM_CP_NO_MIGRATE, .opc0 = 3, .opc1 = 0, .crn = 4, .crm = 0, .opc2 = 1, - .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, elr_el1) }, + .access = PL1_RW, + .fieldoffset = offsetof(CPUARMState, elr_el[ELR_EL_IDX(1)]) }, { .name = "SPSR_EL1", .state = ARM_CP_STATE_AA64, .type = ARM_CP_NO_MIGRATE, .opc0 = 3, .opc1 = 0, .crn = 4, .crm = 0, .opc2 = 0,
target-arm/kvm64.c +2 -2
@@ -161,7 +161,7 @@ int kvm_arch_put_registers(CPUState *cs, int level) } reg.id =AARCH64_CORE_REG (elr_el1); - reg.addr = (uintptr_t ) &env->elr_el1; + reg.addr = (uintptr_t ) &env->elr_el[ELR_EL_IDX (1 )]; ret =kvm_vcpu_ioctl (cs,KVM_SET_ONE_REG , ®);if (ret) {return ret;
@@ -241,7 +241,7 @@ int kvm_arch_get_registers(CPUState *cs) } reg.id =AARCH64_CORE_REG (elr_el1); - reg.addr = (uintptr_t ) &env->elr_el1; + reg.addr = (uintptr_t ) &env->elr_el[ELR_EL_IDX (1 )]; ret =kvm_vcpu_ioctl (cs,KVM_GET_ONE_REG , ®);if (ret) {return ret;
target-arm/machine.c +1 -1
@@ -243,7 +243,7 @@ const VMStateDescription vmstate_arm_cpu = {VMSTATE_UINT32_ARRAY (env.banked_r14,ARMCPU ,6 ),VMSTATE_UINT32_ARRAY (env.usr_regs,ARMCPU ,5 ),VMSTATE_UINT32_ARRAY (env.fiq_regs,ARMCPU ,5 ), -VMSTATE_UINT64 (env.elr_el1,ARMCPU ), +VMSTATE_UINT64 (env.elr_el[ELR_EL_IDX (1 )],ARMCPU ),VMSTATE_UINT64_ARRAY (env.sp_el,ARMCPU ,2 ),/* The length-check must come before the arrays to avoid * incoming data possibly overflowing the array.
target-arm/op_helper.c +3 -3
@@ -406,7 +406,7 @@ void HELPER(exception_return)(CPUARMState *env) env->regs[i] = env->xregs[i]; } - env->regs[15 ] = env->elr_el1 & ~0x1 ; + env->regs[15 ] = env->elr_el[ELR_EL_IDX (1 )] & ~0x1 ; }else { new_el =extract32 (spsr,2 ,2 );if (new_el >1 ) {
@@ -424,7 +424,7 @@ void HELPER(exception_return)(CPUARMState *env) env->aarch64 =1 ;pstate_write (env, spsr); env->xregs[31 ] = env->sp_el[new_el]; - env->pc = env->elr_el1; + env->pc = env->elr_el[ELR_EL_IDX (1 )]; }return ;
@@ -438,7 +438,7 @@ illegal_return:* no change to exception level, execution state or stack pointer */ env->pstate |=PSTATE_IL ; - env->pc = env->elr_el1; + env->pc = env->elr_el[ELR_EL_IDX (1 )]; spsr &=PSTATE_NZCV |PSTATE_DAIF ; spsr |=pstate_read (env) & ~(PSTATE_NZCV |PSTATE_DAIF );pstate_write (env, spsr);
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH v1 02/22] target-arm: Make elr_el1 an array
Quoted 20 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
No functional change.
Prepares for future additions of the EL2 and 3 versions of this reg.Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/cpu.h | 3 ++- target-arm/helper-a64.c | 4 ++-- target-arm/helper.c | 3 ++- target-arm/kvm64.c | 4 ++-- target-arm/machine.c | 2 +- target-arm/op_helper.c | 6 +++--- 6 files changed, 12 insertions(+), 10 deletions(-)target-arm/cpu.h +0
-0
target-arm/cpu.h typedef struct CPUARMState { · line 166
Quoted 6 lines
target-arm/cpu.h +2
-1@@ -162,7 +162,8 @@ typedef struct CPUARMState {uint32_t condexec_bits;/* IT bits. cpsr[15:10,26:25]. */ uint64_t daif;/* exception masks, in the bits they are in in PSTATE */ -uint64_t elr_el1;/* AArch64 ELR_EL1 */ +#define ELR_EL_IDX (x) (x - 1) +uint64_t elr_el[1 ];/* AArch64 exception link regs */
Is it perhaps just easier to waste the space and always pad these EL-banked CP arrays out to length 4 you can just use literal numbers in the code? Probably make life easier when introspecting the CPU state in GDB too.
Regards,
Peter
Quoted 107 lines
target-arm/cpu.h +0
-0uint64_t sp_el[2 ];/* AArch64 banked stack pointers */ /* System control coprocessor (cp15) */ target-arm/helper-a64.c +2
-2@@ -491,13 +491,13 @@ void aarch64_cpu_do_interrupt(CPUState *cs) env->banked_spsr[0 ] =pstate_read (env); env->sp_el[arm_current_pl (env)] = env->xregs[31 ]; env->xregs[31 ] = env->sp_el[1 ]; - env->elr_el1 = env->pc; + env->elr_el[ELR_EL_IDX (1 )] = env->pc; }else { env->banked_spsr[0 ] =cpsr_read (env);if (!env->thumb) { env->cp15.esr_el1 |=1 <<25 ; } - env->elr_el1 = env->regs[15 ]; + env->elr_el[ELR_EL_IDX (1 )] = env->regs[15 ];for (i =0 ; i <15 ; i++) { env->xregs[i] = env->regs[i];target-arm/helper.c +2
-1@@ -2055,7 +2055,8 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { { .name = "ELR_EL1", .state = ARM_CP_STATE_AA64, .type = ARM_CP_NO_MIGRATE, .opc0 = 3, .opc1 = 0, .crn = 4, .crm = 0, .opc2 = 1, - .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, elr_el1) }, + .access = PL1_RW, + .fieldoffset = offsetof(CPUARMState, elr_el[ELR_EL_IDX(1)]) }, { .name = "SPSR_EL1", .state = ARM_CP_STATE_AA64, .type = ARM_CP_NO_MIGRATE, .opc0 = 3, .opc1 = 0, .crn = 4, .crm = 0, .opc2 = 0,target-arm/kvm64.c +2
-2@@ -161,7 +161,7 @@ int kvm_arch_put_registers(CPUState *cs, int level) } reg.id =AARCH64_CORE_REG (elr_el1); - reg.addr = (uintptr_t ) &env->elr_el1; + reg.addr = (uintptr_t ) &env->elr_el[ELR_EL_IDX (1 )]; ret =kvm_vcpu_ioctl (cs,KVM_SET_ONE_REG , ®);if (ret) {return ret;@@ -241,7 +241,7 @@ int kvm_arch_get_registers(CPUState *cs) } reg.id =AARCH64_CORE_REG (elr_el1); - reg.addr = (uintptr_t ) &env->elr_el1; + reg.addr = (uintptr_t ) &env->elr_el[ELR_EL_IDX (1 )]; ret =kvm_vcpu_ioctl (cs,KVM_GET_ONE_REG , ®);if (ret) {return ret;target-arm/machine.c +1
-1@@ -243,7 +243,7 @@ const VMStateDescription vmstate_arm_cpu = {VMSTATE_UINT32_ARRAY (env.banked_r14,ARMCPU ,6 ),VMSTATE_UINT32_ARRAY (env.usr_regs,ARMCPU ,5 ),VMSTATE_UINT32_ARRAY (env.fiq_regs,ARMCPU ,5 ), -VMSTATE_UINT64 (env.elr_el1,ARMCPU ), +VMSTATE_UINT64 (env.elr_el[ELR_EL_IDX (1 )],ARMCPU ),VMSTATE_UINT64_ARRAY (env.sp_el,ARMCPU ,2 ),/* The length-check must come before the arrays to avoid * incoming data possibly overflowing the array. target-arm/op_helper.c +3
-4@@ -406,7 +406,7 @@ void HELPER(exception_return)(CPUARMState *env) env->regs[i] = env->xregs[i]; } - env->regs[15 ] = env->elr_el1 & ~0x1 ; + env->regs[15 ] = env->elr_el[ELR_EL_IDX (1 )] & ~0x1 ; }else { new_el =extract32 (spsr,2 ,2 );if (new_el >1 ) {@@ -424,7 +424,7 @@ void HELPER(exception_return)(CPUARMState *env) env->aarch64 =1 ;pstate_write (env, spsr); env->xregs[31 ] = env->sp_el[new_el]; - env->pc = env->elr_el1; + env->pc = env->elr_el[ELR_EL_IDX (1 )]; }return ;@@ -438,7 +438,7 @@ illegal_return:* no change to exception level, execution state or stack pointer */ env->pstate |=PSTATE_IL ; - env->pc = env->elr_el1; + env->pc = env->elr_el[ELR_EL_IDX (1 )]; spsr &=PSTATE_NZCV |PSTATE_DAIF ; spsr |=pstate_read (env) & ~(PSTATE_NZCV |PSTATE_DAIF );pstate_write (env, spsr); --1.8.3.2
Re: [Qemu-devel] [PATCH v1 02/22] target-arm: Make elr_el1 an array
Quoted 25 lines · Peter Crosthwaite
Quoted 23 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
No functional change.
Prepares for future additions of the EL2 and 3 versions of this reg.Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/cpu.h | 3 ++- target-arm/helper-a64.c | 4 ++-- target-arm/helper.c | 3 ++- target-arm/kvm64.c | 4 ++-- target-arm/machine.c | 2 +- target-arm/op_helper.c | 6 +++--- 6 files changed, 12 insertions(+), 10 deletions(-)target-arm/cpu.h +0
-0@@ -162,7 +162,8 @@ typedef struct CPUARMState {uint32_t condexec_bits;/* IT bits. cpsr[15:10,26:25]. */ uint64_t daif;/* exception masks, in the bits they are in in PSTATE */
Quoted 8 lines
target-arm/cpu.h typedef struct CPUARMState { · line 166
Quoted 3 lines
target-arm/cpu.h +2
-1-uint64_t elr_el1;/* AArch64 ELR_EL1 */ +#define ELR_EL_IDX (x) (x - 1) +uint64_t elr_el[1 ];/* AArch64 exception link regs */ Is it perhaps just easier to waste the space and always pad these EL-banked CP arrays out to length 4 you can just use literal numbers in the code? Probably make life easier when introspecting the CPU state in GDB too.
Thanks Peter,
I've fixed all your comments except this one. I considered this pattern but avoided it due to the bloating of CPUARMState. Anyway, I'm happy to change to this full array allocation if others agree.
PMM, what is your preference on this?
Best regards,
Edgar
Quoted 111 lines
Regards,
PeterQuoted 107 lines
target-arm/cpu.h +0
-0uint64_t sp_el[2 ];/* AArch64 banked stack pointers */ /* System control coprocessor (cp15) */ target-arm/helper-a64.c +2
-2@@ -491,13 +491,13 @@ void aarch64_cpu_do_interrupt(CPUState *cs) env->banked_spsr[0 ] =pstate_read (env); env->sp_el[arm_current_pl (env)] = env->xregs[31 ]; env->xregs[31 ] = env->sp_el[1 ]; - env->elr_el1 = env->pc; + env->elr_el[ELR_EL_IDX (1 )] = env->pc; }else { env->banked_spsr[0 ] =cpsr_read (env);if (!env->thumb) { env->cp15.esr_el1 |=1 <<25 ; } - env->elr_el1 = env->regs[15 ]; + env->elr_el[ELR_EL_IDX (1 )] = env->regs[15 ];for (i =0 ; i <15 ; i++) { env->xregs[i] = env->regs[i];target-arm/helper.c +2
-1@@ -2055,7 +2055,8 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { { .name = "ELR_EL1", .state = ARM_CP_STATE_AA64, .type = ARM_CP_NO_MIGRATE, .opc0 = 3, .opc1 = 0, .crn = 4, .crm = 0, .opc2 = 1, - .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, elr_el1) }, + .access = PL1_RW, + .fieldoffset = offsetof(CPUARMState, elr_el[ELR_EL_IDX(1)]) }, { .name = "SPSR_EL1", .state = ARM_CP_STATE_AA64, .type = ARM_CP_NO_MIGRATE, .opc0 = 3, .opc1 = 0, .crn = 4, .crm = 0, .opc2 = 0,target-arm/kvm64.c +2
-2@@ -161,7 +161,7 @@ int kvm_arch_put_registers(CPUState *cs, int level) } reg.id =AARCH64_CORE_REG (elr_el1); - reg.addr = (uintptr_t ) &env->elr_el1; + reg.addr = (uintptr_t ) &env->elr_el[ELR_EL_IDX (1 )]; ret =kvm_vcpu_ioctl (cs,KVM_SET_ONE_REG , ®);if (ret) {return ret;@@ -241,7 +241,7 @@ int kvm_arch_get_registers(CPUState *cs) } reg.id =AARCH64_CORE_REG (elr_el1); - reg.addr = (uintptr_t ) &env->elr_el1; + reg.addr = (uintptr_t ) &env->elr_el[ELR_EL_IDX (1 )]; ret =kvm_vcpu_ioctl (cs,KVM_GET_ONE_REG , ®);if (ret) {return ret;target-arm/machine.c +1
-1@@ -243,7 +243,7 @@ const VMStateDescription vmstate_arm_cpu = {VMSTATE_UINT32_ARRAY (env.banked_r14,ARMCPU ,6 ),VMSTATE_UINT32_ARRAY (env.usr_regs,ARMCPU ,5 ),VMSTATE_UINT32_ARRAY (env.fiq_regs,ARMCPU ,5 ), -VMSTATE_UINT64 (env.elr_el1,ARMCPU ), +VMSTATE_UINT64 (env.elr_el[ELR_EL_IDX (1 )],ARMCPU ),VMSTATE_UINT64_ARRAY (env.sp_el,ARMCPU ,2 ),/* The length-check must come before the arrays to avoid * incoming data possibly overflowing the array. target-arm/op_helper.c +3
-4@@ -406,7 +406,7 @@ void HELPER(exception_return)(CPUARMState *env) env->regs[i] = env->xregs[i]; } - env->regs[15 ] = env->elr_el1 & ~0x1 ; + env->regs[15 ] = env->elr_el[ELR_EL_IDX (1 )] & ~0x1 ; }else { new_el =extract32 (spsr,2 ,2 );if (new_el >1 ) {@@ -424,7 +424,7 @@ void HELPER(exception_return)(CPUARMState *env) env->aarch64 =1 ;pstate_write (env, spsr); env->xregs[31 ] = env->sp_el[new_el]; - env->pc = env->elr_el1; + env->pc = env->elr_el[ELR_EL_IDX (1 )]; }return ;@@ -438,7 +438,7 @@ illegal_return:* no change to exception level, execution state or stack pointer */ env->pstate |=PSTATE_IL ; - env->pc = env->elr_el1; + env->pc = env->elr_el[ELR_EL_IDX (1 )]; spsr &=PSTATE_NZCV |PSTATE_DAIF ; spsr |=pstate_read (env) & ~(PSTATE_NZCV |PSTATE_DAIF );pstate_write (env, spsr); --1.8.3.2
Re: [Qemu-devel] [PATCH v1 02/22] target-arm: Make elr_el1 an array
Quoted 35 lines · Edgar E. Iglesias
Quoted 25 lines · Peter Crosthwaite
Quoted 23 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
No functional change.
Prepares for future additions of the EL2 and 3 versions of this reg.Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/cpu.h | 3 ++- target-arm/helper-a64.c | 4 ++-- target-arm/helper.c | 3 ++- target-arm/kvm64.c | 4 ++-- target-arm/machine.c | 2 +- target-arm/op_helper.c | 6 +++--- 6 files changed, 12 insertions(+), 10 deletions(-)target-arm/cpu.h +0
-0@@ -162,7 +162,8 @@ typedef struct CPUARMState {uint32_t condexec_bits;/* IT bits. cpsr[15:10,26:25]. */ uint64_t daif;/* exception masks, in the bits they are in in PSTATE */ Quoted 8 lines
target-arm/cpu.h typedef struct CPUARMState { · line 166
Quoted 3 lines
target-arm/cpu.h +2
-1-uint64_t elr_el1;/* AArch64 ELR_EL1 */ +#define ELR_EL_IDX (x) (x - 1) +uint64_t elr_el[1 ];/* AArch64 exception link regs */ Is it perhaps just easier to waste the space and always pad these EL-banked CP arrays out to length 4 you can just use literal numbers in the code? Probably make life easier when introspecting the CPU state in GDB too.
Quoted 7 lines
Thanks Peter,
I've fixed all your comments except this one. I considered this pattern but avoided it due to the bloating of CPUARMState. Anyway, I'm happy to change to this full array allocation if others agree.
PMM, what is your preference on this?
I think I'd rather we just padded the array to length 4.
thanks
-- PMM
Re: [Qemu-devel] [PATCH v1 02/22] target-arm: Make elr_el1 an array
Quoted 38 lines · Peter Maydell
Quoted 37 lines · Edgar E. Iglesias
Quoted 25 lines · Peter Crosthwaite
Quoted 23 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
No functional change.
Prepares for future additions of the EL2 and 3 versions of this reg.Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/cpu.h | 3 ++- target-arm/helper-a64.c | 4 ++-- target-arm/helper.c | 3 ++- target-arm/kvm64.c | 4 ++-- target-arm/machine.c | 2 +- target-arm/op_helper.c | 6 +++--- 6 files changed, 12 insertions(+), 10 deletions(-)target-arm/cpu.h +0
-0@@ -162,7 +162,8 @@ typedef struct CPUARMState {uint32_t condexec_bits;/* IT bits. cpsr[15:10,26:25]. */ uint64_t daif;/* exception masks, in the bits they are in in PSTATE */ Quoted 8 lines
target-arm/cpu.h typedef struct CPUARMState { · line 166
Quoted 3 lines
target-arm/cpu.h +2
-1-uint64_t elr_el1;/* AArch64 ELR_EL1 */ +#define ELR_EL_IDX (x) (x - 1) +uint64_t elr_el[1 ];/* AArch64 exception link regs */ Is it perhaps just easier to waste the space and always pad these EL-banked CP arrays out to length 4 you can just use literal numbers in the code? Probably make life easier when introspecting the CPU state in GDB too.
Thanks Peter,
Quoted 7 lines
Quoted 5 lines
I've fixed all your comments except this one. I considered this pattern but avoided it due to the bloating of CPUARMState. Anyway, I'm happy to change to this full array allocation if others agree.
PMM, what is your preference on this?
I think I'd rather we just padded the array to length 4.
Sounds good, I'll change the pattern.
Cheers,
Edgar
Re: [Qemu-devel] [PATCH v1 02/22] target-arm: Make elr_el1 an array
In reply to Edgar E. IglesiasQuoted 8 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
No functional change.
Prepares for future additions of the EL2 and 3 versions of this reg.
target-arm/machine.c const VMStateDescription vmstate_arm_cpu = { · line 249
Quoted 8 lines
target-arm/machine.c +1
-1@@ -243,7 +243,7 @@ const VMStateDescription vmstate_arm_cpu = {VMSTATE_UINT32_ARRAY (env.banked_r14,ARMCPU ,6 ),VMSTATE_UINT32_ARRAY (env.usr_regs,ARMCPU ,5 ),VMSTATE_UINT32_ARRAY (env.fiq_regs,ARMCPU ,5 ), -VMSTATE_UINT64 (env.elr_el1,ARMCPU ), +VMSTATE_UINT64 (env.elr_el[ELR_EL_IDX (1 )],ARMCPU ),VMSTATE_UINT64_ARRAY (env.sp_el,ARMCPU ,2 ),/* The length-check must come before the arrays to avoid * incoming data possibly overflowing the array.
Do we add the rest of the elr_el[] array to the vmstate in a later patch?
thanks
-- PMM
Re: [Qemu-devel] [PATCH v1 02/22] target-arm: Make elr_el1 an array
Quoted 6 lines · Peter Maydell
Quoted 4 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
No functional change.
Prepares for future additions of the EL2 and 3 versions of this reg.
Quoted 14 lines
target-arm/machine.c const VMStateDescription vmstate_arm_cpu = { · line 249
Quoted 11 lines
target-arm/machine.c +1
-1@@ -243,7 +243,7 @@ const VMStateDescription vmstate_arm_cpu = {VMSTATE_UINT32_ARRAY (env.banked_r14,ARMCPU ,6 ),VMSTATE_UINT32_ARRAY (env.usr_regs,ARMCPU ,5 ),VMSTATE_UINT32_ARRAY (env.fiq_regs,ARMCPU ,5 ), -VMSTATE_UINT64 (env.elr_el1,ARMCPU ), +VMSTATE_UINT64 (env.elr_el[ELR_EL_IDX (1 )],ARMCPU ),VMSTATE_UINT64_ARRAY (env.sp_el,ARMCPU ,2 ),/* The length-check must come before the arrays to avoid * incoming data possibly overflowing the array. Do we add the rest of the elr_el[] array to the vmstate in a later patch?
Yes. I can squash the patches if you prefer but I did find it useful to do some of these changes in steps of non-functional change followed by the actual usage/addition of EL2/3 while developing.
Cheers,
Edgar
PATCH 3/22 target-arm: Make esr_el1 an array
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
No functional change.
Prepares for future addtion of EL2 and 3 versions of this reg.
--- target-arm/cpu.h | 3 ++- target-arm/helper-a64.c | 4 ++-- target-arm/helper.c | 11 ++++++----- 3 files changed, 10 insertions(+), 8 deletions(-)
target-arm/cpu.h +2 -1
@@ -186,7 +186,8 @@ typedef struct CPUARMState {uint32_t pmsav5_data_ap;/* PMSAv5 MPU data access permissions */ uint32_t pmsav5_insn_ap;/* PMSAv5 MPU insn access permissions */ uint32_t ifsr_el2;/* Fault status registers. */ -uint64_t esr_el1; +#define ESR_EL_IDX (x) (x - 1) +uint64_t esr_el[1 ];uint32_t c6_region[8 ];/* MPU base/size registers. */ uint64_t far_el1;/* Fault address registers. */ uint64_t par_el1;/* Translation result. */
target-arm/helper-a64.c +2 -2
@@ -464,7 +464,7 @@ void aarch64_cpu_do_interrupt(CPUState *cs) env->exception.syndrome); } - env->cp15.esr_el1 = env->exception.syndrome; + env->cp15.esr_el[ESR_EL_IDX (1 )] = env->exception.syndrome; env->cp15.far_el1 = env->exception.vaddress;switch (cs->exception_index) {
@@ -495,7 +495,7 @@ void aarch64_cpu_do_interrupt(CPUState *cs) }else { env->banked_spsr[0 ] =cpsr_read (env);if (!env->thumb) { - env->cp15.esr_el1 |=1 <<25 ; + env->cp15.esr_el[ESR_EL_IDX (1 )] |=1 <<25 ; } env->elr_el[ELR_EL_IDX (1 )] = env->regs[15 ];
target-arm/helper.c +6 -5
@@ -1452,7 +1452,7 @@ static void vmsa_ttbr_write(CPUARMState *env, const ARMCPRegInfo *ri,static const ARMCPRegInfo vmsa_cp_reginfo[] = { { .name ="DFSR" , .cp =15 , .crn =5 , .crm =0 , .opc1 =0 , .opc2 =0 , .access =PL1_RW , .type =ARM_CP_NO_MIGRATE , - .fieldoffset =offsetoflow32 (CPUARMState, cp15.esr_el1), + .fieldoffset =offsetoflow32 (CPUARMState, cp15.esr_el[ESR_EL_IDX (1 )]), .resetfn = arm_cp_reset_ignore, }, { .name ="IFSR" , .cp =15 , .crn =5 , .crm =0 , .opc1 =0 , .opc2 =1 , .access =PL1_RW ,
@@ -1460,7 +1460,8 @@ static const ARMCPRegInfo vmsa_cp_reginfo[] = { { .name = "ESR_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .crn = 5, .crm = 2, .opc1 = 0, .opc2 = 0, .access = PL1_RW, - .fieldoffset = offsetof(CPUARMState, cp15.esr_el1), .resetvalue = 0, }, + .fieldoffset = offsetof(CPUARMState, cp15.esr_el[ESR_EL_IDX(1)]), + .resetvalue = 0, }, { .name = "TTBR0_EL1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .crn = 2, .crm = 0, .opc1 = 0, .opc2 = 0, .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.ttbr0_el1),
@@ -1521,7 +1522,7 @@ static void omap_cachemaint_write(CPUARMState *env, const ARMCPRegInfo *ri,static const ARMCPRegInfo omap_cp_reginfo[] = { { .name ="DFSR" , .cp =15 , .crn =5 , .crm =CP_ANY , .opc1 =CP_ANY , .opc2 =CP_ANY , .access =PL1_RW , .type =ARM_CP_OVERRIDE , - .fieldoffset =offsetoflow32 (CPUARMState, cp15.esr_el1), + .fieldoffset =offsetoflow32 (CPUARMState, cp15.esr_el[ESR_EL_IDX (1 )]), .resetvalue =0 , }, { .name ="" , .cp =15 , .crn =15 , .crm =0 , .opc1 =0 , .opc2 =0 , .access =PL1_RW , .type =ARM_CP_NOP },
@@ -3331,11 +3332,11 @@ void arm_cpu_do_interrupt(CPUState *cs) offset =4 ;break ;case EXCP_DATA_ABORT : - env->cp15.esr_el1 = env->exception.fsr; + env->cp15.esr_el[ESR_EL_IDX (1 )] = env->exception.fsr; env->cp15.far_el1 =deposit64 (env->cp15.far_el1,0 ,32 , env->exception.vaddress);qemu_log_mask (CPU_LOG_INT ,"...with DFSR 0x%x DFAR 0x%x\n" , - (uint32_t )env->cp15.esr_el1, + (uint32_t )env->cp15.esr_el[ESR_EL_IDX (1 )], (uint32_t )env->exception.vaddress); new_mode =ARM_CPU_MODE_ABT ; addr =0x10 ;
Signature · 1 line
1.8.3.2
PATCH 4/22 target-arm: c12_vbar -> vbar_el[]
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
No functional change.
Preparation for adding EL2 and 3 versions of this reg.
--- target-arm/cpu.h | 3 ++- target-arm/helper-a64.c | 2 +- target-arm/helper.c | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-)
target-arm/cpu.h +2 -1
@@ -200,7 +200,8 @@ typedef struct CPUARMState {uint32_t c9_pmuserenr;/* perf monitor user enable */ uint32_t c9_pminten;/* perf monitor interrupt enables */ uint64_t mair_el1; -uint64_t c12_vbar;/* vector base address register */ +#define VBAR_EL_IDX (x) (x - 1) +uint64_t vbar_el[1 ];/* vector base address register */ uint32_t c13_fcse;/* FCSE PID. */ uint64_t contextidr_el1;/* Context ID. */ uint64_t tpidr_el0;/* User RW Thread register. */
target-arm/helper-a64.c +1 -1
@@ -443,7 +443,7 @@ void aarch64_cpu_do_interrupt(CPUState *cs) {ARMCPU *cpu =ARM_CPU (cs);CPUARMState *env = &cpu->env; -target_ulong addr = env->cp15.c12_vbar; +target_ulong addr = env->cp15.vbar_el[VBAR_EL_IDX (1 )];int i;if (arm_current_pl (env) ==0 ) {
target-arm/helper.c +3 -3
@@ -657,7 +657,7 @@ static void vbar_write(CPUARMState *env, const ARMCPRegInfo *ri,* contexts. (ARMv8 would permit us to do no masking at all, but ARMv7 * requires the bottom five bits to be RAZ/WI because they're UNK/SBZP.) */ - env->cp15.c12_vbar = value & ~0x1FULL ; + env->cp15.vbar_el[VBAR_EL_IDX (1 )] = value & ~0x1FULL ; }static uint64_t ccsidr_read (CPUARMState *env,const ARMCPRegInfo *ri)
@@ -766,7 +766,7 @@ static const ARMCPRegInfo v7_cp_reginfo[] = { { .name = "VBAR", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .crn = 12, .crm = 0, .opc1 = 0, .opc2 = 0, .access = PL1_RW, .writefn = vbar_write, - .fieldoffset = offsetof(CPUARMState, cp15.c12_vbar), + .fieldoffset = offsetof(CPUARMState, cp15.vbar_el[VBAR_EL_IDX(1)]), .resetvalue = 0 }, { .name = "SCR", .cp = 15, .crn = 1, .crm = 1, .opc1 = 0, .opc2 = 0, .access = PL1_RW, .fieldoffset = offsetof(CPUARMState, cp15.c1_scr),
@@ -3373,7 +3373,7 @@ void arm_cpu_do_interrupt(CPUState *cs)* and is never in monitor mode this feature is always active. * Note: only bits 31:5 are valid. */ - addr += env->cp15.c12_vbar; + addr += env->cp15.vbar_el[VBAR_EL_IDX (1 )]; }switch_mode (env, new_mode); env->spsr =cpsr_read (env);
Signature · 1 line
1.8.3.2
PATCH 5/22 target-arm: Add arm_el_to_mmu_idx()
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Maps a given EL to the corresponding MMU index.
--- target-arm/cpu.h | 21 ++++++++++++++++++++- target-arm/translate-a64.c | 8 ++------ 2 files changed, 22 insertions(+), 7 deletions(-)
target-arm/cpu.h +20 -1
@@ -1086,9 +1086,28 @@ static inline CPUARMState *cpu_init(const char *cpu_model)#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 +static inline int arm_el_to_mmu_idx (int current_el) +{ +#ifdef CONFIG_USER_ONLY +return MMU_USER_IDX ; +#else +switch (current_el) { +case 0 : +return MMU_USER_IDX ; +case 1 : +return 0 ; +default : +/* Unsupported EL. */ +assert (0 ); +return 0 ; + } +#endif +} +static inline int cpu_mmu_index (CPUARMState *env) { -return arm_current_pl (env) ?0 :1 ; +int cur_el =arm_current_pl (env); +return arm_el_to_mmu_idx (cur_el); }#include "exec/cpu-all.h"
target-arm/translate-a64.c +2 -6
@@ -164,13 +164,9 @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f, } } -static int get_mem_index (DisasContext *s) +static inline int get_mem_index (DisasContext *s) { -#ifdef CONFIG_USER_ONLY -return 1 ; -#else -return s->user; -#endif +return arm_el_to_mmu_idx (s->current_pl); }void gen_a64_set_pc_im (uint64_t val)
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH v1 05/22] target-arm: Add arm_el_to_mmu_idx()
Quoted 15 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Maps a given EL to the corresponding MMU index.
Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/cpu.h | 21 ++++++++++++++++++++- target-arm/translate-a64.c | 8 ++------ 2 files changed, 22 insertions(+), 7 deletions(-)target-arm/cpu.h +0
-0
target-arm/cpu.h static inline CPUARMState *cpu_init(const char *cpu_model) · line 1088
Quoted 3 lines
target-arm/cpu.h +0
-0@@ -1086,9 +1086,28 @@ static inline CPUARMState *cpu_init(const char *cpu_model)#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1
Blank line here.
Otherwise:
Quoted 50 lines
target-arm/cpu.h +20
-1+static inline int arm_el_to_mmu_idx (int current_el) +{ +#ifdef CONFIG_USER_ONLY +return MMU_USER_IDX ; +#else +switch (current_el) { +case 0 : +return MMU_USER_IDX ; +case 1 : +return 0 ; +default : +/* Unsupported EL. */ +assert (0 ); +return 0 ; + } +#endif +} +static inline int cpu_mmu_index (CPUARMState *env) { -return arm_current_pl (env) ?0 :1 ; +int cur_el =arm_current_pl (env); +return arm_el_to_mmu_idx (cur_el); }#include "exec/cpu-all.h" target-arm/translate-a64.c +2
-7@@ -164,13 +164,9 @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f, } } -static int get_mem_index (DisasContext *s) +static inline int get_mem_index (DisasContext *s) { -#ifdef CONFIG_USER_ONLY -return 1 ; -#else -return s->user; -#endif +return arm_el_to_mmu_idx (s->current_pl); }void gen_a64_set_pc_im (uint64_t val) --1.8.3.2
Re: [Qemu-devel] [PATCH v1 05/22] target-arm: Add arm_el_to_mmu_idx()
In reply to Edgar E. IglesiasQuoted 24 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Maps a given EL to the corresponding MMU index.
Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/cpu.h | 21 ++++++++++++++++++++- target-arm/translate-a64.c | 8 ++------ 2 files changed, 22 insertions(+), 7 deletions(-)target-arm/cpu.h +6
-0@@ -1086,9 +1086,28 @@ static inline CPUARMState *cpu_init(const char *cpu_model)#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 +static inline int arm_el_to_mmu_idx (int current_el) +{ +#ifdef CONFIG_USER_ONLY +return MMU_USER_IDX ; +#else +switch (current_el) {
target-arm/cpu.h static inline CPUARMState *cpu_init(const char *cpu_model) · line 1104
Quoted 10 lines
target-arm/cpu.h +10
-0+case 0 : +return MMU_USER_IDX ; +case 1 : +return 0 ; +default : +/* Unsupported EL. */ +assert (0 ); + return 0; + } +#endif
Can we just make the EL and the MMU index the same thing, or is secure-vs-nonsecure going to need its own MMU indexes anyway?
thanks
-- PMM
Re: [Qemu-devel] [PATCH v1 05/22] target-arm: Add arm_el_to_mmu_idx()
Quoted 31 lines · Peter Maydell
Quoted 30 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Maps a given EL to the corresponding MMU index.
Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/cpu.h | 21 ++++++++++++++++++++- target-arm/translate-a64.c | 8 ++------ 2 files changed, 22 insertions(+), 7 deletions(-)target-arm/cpu.h +12
-0@@ -1086,9 +1086,28 @@ static inline CPUARMState *cpu_init(const char *cpu_model)#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 +static inline int arm_el_to_mmu_idx (int current_el) +{ +#ifdef CONFIG_USER_ONLY +return MMU_USER_IDX ; +#else +switch (current_el) { +case 0 : +return MMU_USER_IDX ; +case 1 : +return 0 ; +default : +/* Unsupported EL. */
Quoted 8 lines
target-arm/cpu.h static inline CPUARMState *cpu_init(const char *cpu_model) · line 1104
Quoted 4 lines
target-arm/cpu.h +4
-0+assert (0 ); + return 0; + } +#endif Can we just make the EL and the MMU index the same thing, or is secure-vs-nonsecure going to need its own MMU indexes anyway?
Right, I did the conversion to 1:1 mapping at an early stage but avoided it as we will need an indirect mapping for Secure EL0/1 anyway.
I still have the patches around but they will conflict with the other trustzone patches on the list so I'd rather avoid them for now.
Thanks,
Edgar
Re: [Qemu-devel] [PATCH v1 05/22] target-arm: Add arm_el_to_mmu_idx()
Quoted 39 lines · Edgar E. Iglesias
Quoted 30 lines · Peter Maydell
Quoted 29 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Maps a given EL to the corresponding MMU index.
Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/cpu.h | 21 ++++++++++++++++++++- target-arm/translate-a64.c | 8 ++------ 2 files changed, 22 insertions(+), 7 deletions(-)target-arm/cpu.h +11
-0@@ -1086,9 +1086,28 @@ static inline CPUARMState *cpu_init(const char *cpu_model)#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 +static inline int arm_el_to_mmu_idx (int current_el) +{ +#ifdef CONFIG_USER_ONLY +return MMU_USER_IDX ; +#else +switch (current_el) { +case 0 : +return MMU_USER_IDX ; +case 1 : +return 0 ; +default :Quoted 8 lines
target-arm/cpu.h static inline CPUARMState *cpu_init(const char *cpu_model) · line 1104
Quoted 5 lines
target-arm/cpu.h +5
-0+/* Unsupported EL. */ +assert (0 ); + return 0; + } +#endif Can we just make the EL and the MMU index the same thing, or is secure-vs-nonsecure going to need its own MMU indexes anyway?
Quoted 3 lines
Right, I did the conversion to 1:1 mapping at an early stage but avoided it as we will need an indirect mapping for Secure EL0/1 anyway.
How often do we switch between secure and non-secure? If it doesn't happen all that often, we could just flush the TLB on every transition.
Alex
Re: [Qemu-devel] [PATCH v1 05/22] target-arm: Add arm_el_to_mmu_idx()
Quoted 41 lines · Alexander Graf
Quoted 39 lines · Edgar E. Iglesias
Quoted 38 lines · Peter Maydell
Quoted 24 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Maps a given EL to the corresponding MMU index.
Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/cpu.h | 21 ++++++++++++++++++++- target-arm/translate-a64.c | 8 ++------ 2 files changed, 22 insertions(+), 7 deletions(-)target-arm/cpu.h +6
-0@@ -1086,9 +1086,28 @@ static inline CPUARMState *cpu_init(const char *cpu_model)#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 +static inline int arm_el_to_mmu_idx (int current_el) +{ +#ifdef CONFIG_USER_ONLY +return MMU_USER_IDX ; +#else +switch (current_el) {target-arm/cpu.h static inline CPUARMState *cpu_init(const char *cpu_model) · line 1104
Quoted 10 lines
target-arm/cpu.h +10
-0+case 0 : +return MMU_USER_IDX ; +case 1 : +return 0 ; +default : +/* Unsupported EL. */ +assert (0 ); + return 0; + } +#endif Can we just make the EL and the MMU index the same thing, or is secure-vs-nonsecure going to need its own MMU indexes anyway?
Quoted 6 lines
Quoted 3 lines
Right, I did the conversion to 1:1 mapping at an early stage but avoided it as we will need an indirect mapping for Secure EL0/1 anyway.
How often do we switch between secure and non-secure? If it doesn't happen all that often, we could just flush the TLB on every transition.
That's an option. I think this mostly affects aarch32 as that is where the TTBR regs are banked. For aarch64 I think the world switching FW has to rewrite the TTBR regs leading to TLB flushes anyway with current code. IIUC..
I can include a switch over to 1:1 mapping between EL and MMU-idx if preferd. I already have the patches but they will make this series conflict alot more with the TZ patches on list.
Thanks,
Edgar
PATCH 6/22 target-arm: Move get_mem_index to translate.h
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
So that it can be shared with the A32 code in the future.
--- target-arm/translate-a64.c | 5 ----- target-arm/translate.h | 5 +++++ 2 files changed, 5 insertions(+), 5 deletions(-)
target-arm/translate-a64.c +0 -5
@@ -164,11 +164,6 @@ void aarch64_cpu_dump_state(CPUState *cs, FILE *f, } } -static inline int get_mem_index (DisasContext *s) -{ -return arm_el_to_mmu_idx (s->current_pl); -} -void gen_a64_set_pc_im (uint64_t val) {tcg_gen_movi_i64 (cpu_pc, val);
target-arm/translate.h +5 -0
@@ -52,6 +52,11 @@ static inline int arm_dc_feature(DisasContext *dc, int feature)return (dc->features & (1ULL << feature)) !=0 ; } +static inline int get_mem_index (DisasContext *s) +{ +return arm_el_to_mmu_idx (s->current_pl); +} +/* target-specific extra values for is_jmp */ /* These instructions trap after executing, so the A32/T32 decoder must * defer them until after the conditional execution state has been updated.
Signature · 1 line
1.8.3.2
PATCH 7/22 target-arm: A64: Add SP entries for EL2 and 3
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
--- target-arm/cpu.h | 2 +- target-arm/machine.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
target-arm/cpu.h +1 -1
@@ -164,7 +164,7 @@ typedef struct CPUARMState {#define ELR_EL_IDX (x) (x - 1)uint64_t elr_el[1 ];/* AArch64 exception link regs */ -uint64_t sp_el[2 ];/* AArch64 banked stack pointers */ +uint64_t sp_el[4 ];/* AArch64 banked stack pointers */ /* System control coprocessor (cp15) */ struct {
target-arm/machine.c +4 -4
@@ -222,9 +222,9 @@ static int cpu_post_load(void *opaque, int version_id)const VMStateDescription vmstate_arm_cpu = { .name ="cpu" , - .version_id =17 , - .minimum_version_id =17 , - .minimum_version_id_old =17 , + .version_id =18 , + .minimum_version_id =18 , + .minimum_version_id_old =18 , .pre_save = cpu_pre_save, .post_load = cpu_post_load, .fields = (VMStateField []) {
@@ -244,7 +244,7 @@ const VMStateDescription vmstate_arm_cpu = {VMSTATE_UINT32_ARRAY (env.usr_regs,ARMCPU ,5 ),VMSTATE_UINT32_ARRAY (env.fiq_regs,ARMCPU ,5 ),VMSTATE_UINT64 (env.elr_el[ELR_EL_IDX (1 )],ARMCPU ), -VMSTATE_UINT64_ARRAY (env.sp_el,ARMCPU ,2 ), +VMSTATE_UINT64_ARRAY (env.sp_el,ARMCPU ,4 ),/* The length-check must come before the arrays to avoid * incoming data possibly overflowing the array. */
Signature · 1 line
1.8.3.2
PATCH 8/22 target-arm: A64: Add ELR entries for EL2 and 3
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
--- target-arm/cpu.h | 2 +- target-arm/machine.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-)
target-arm/cpu.h +1 -1
@@ -163,7 +163,7 @@ typedef struct CPUARMState {uint64_t daif;/* exception masks, in the bits they are in in PSTATE */ #define ELR_EL_IDX (x) (x - 1) -uint64_t elr_el[1 ];/* AArch64 exception link regs */ +uint64_t elr_el[3 ];/* AArch64 exception link regs */ uint64_t sp_el[4 ];/* AArch64 banked stack pointers */ /* System control coprocessor (cp15) */
target-arm/machine.c +4 -4
@@ -222,9 +222,9 @@ static int cpu_post_load(void *opaque, int version_id)const VMStateDescription vmstate_arm_cpu = { .name ="cpu" , - .version_id =18 , - .minimum_version_id =18 , - .minimum_version_id_old =18 , + .version_id =19 , + .minimum_version_id =19 , + .minimum_version_id_old =19 , .pre_save = cpu_pre_save, .post_load = cpu_post_load, .fields = (VMStateField []) {
@@ -243,7 +243,7 @@ const VMStateDescription vmstate_arm_cpu = {VMSTATE_UINT32_ARRAY (env.banked_r14,ARMCPU ,6 ),VMSTATE_UINT32_ARRAY (env.usr_regs,ARMCPU ,5 ),VMSTATE_UINT32_ARRAY (env.fiq_regs,ARMCPU ,5 ), -VMSTATE_UINT64 (env.elr_el[ELR_EL_IDX (1 )],ARMCPU ), +VMSTATE_UINT64_ARRAY (env.elr_el,ARMCPU ,3 ),VMSTATE_UINT64_ARRAY (env.sp_el,ARMCPU ,4 ),/* The length-check must come before the arrays to avoid * incoming data possibly overflowing the array.
Signature · 1 line
1.8.3.2
PATCH 9/22 target-arm: Add SPSR entries for EL2/HYP and EL3/MON
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
--- target-arm/cpu.h | 4 +++- target-arm/helper.c | 4 ++++ target-arm/machine.c | 8 ++++---- 3 files changed, 11 insertions(+), 5 deletions(-)
target-arm/cpu.h +3 -1
@@ -143,7 +143,7 @@ typedef struct CPUARMState {uint32_t spsr;/* Banked registers. */ -uint64_t banked_spsr[6 ]; +uint64_t banked_spsr[8 ];uint32_t banked_r13[6 ];uint32_t banked_r14[6 ];
@@ -566,7 +566,9 @@ enum arm_cpu_mode {ARM_CPU_MODE_FIQ =0x11 ,ARM_CPU_MODE_IRQ =0x12 ,ARM_CPU_MODE_SVC =0x13 , +ARM_CPU_MODE_MON =0x16 ,ARM_CPU_MODE_ABT =0x17 , +ARM_CPU_MODE_HYP =0x1a ,ARM_CPU_MODE_UND =0x1b , ARM_CPU_MODE_SYS = 0x1f };
target-arm/helper.c +4 -0
@@ -3078,6 +3078,10 @@ int bank_number(int mode)return 4 ;case ARM_CPU_MODE_FIQ :return 5 ; +case ARM_CPU_MODE_HYP : +return 6 ; +case ARM_CPU_MODE_MON : +return 7 ; }hw_error ("bank number requested for bad CPSR mode value 0x%x\n" , mode); }
target-arm/machine.c +4 -4
@@ -222,9 +222,9 @@ static int cpu_post_load(void *opaque, int version_id)const VMStateDescription vmstate_arm_cpu = { .name ="cpu" , - .version_id =19 , - .minimum_version_id =19 , - .minimum_version_id_old =19 , + .version_id =20 , + .minimum_version_id =20 , + .minimum_version_id_old =20 , .pre_save = cpu_pre_save, .post_load = cpu_post_load, .fields = (VMStateField []) {
@@ -238,7 +238,7 @@ const VMStateDescription vmstate_arm_cpu = { .offset = 0, },VMSTATE_UINT32 (env.spsr,ARMCPU ), -VMSTATE_UINT64_ARRAY (env.banked_spsr,ARMCPU ,6 ), +VMSTATE_UINT64_ARRAY (env.banked_spsr,ARMCPU ,8 ),VMSTATE_UINT32_ARRAY (env.banked_r13,ARMCPU ,6 ),VMSTATE_UINT32_ARRAY (env.banked_r14,ARMCPU ,6 ), VMSTATE_UINT32_ARRAY(env.usr_regs, ARMCPU, 5),
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH v1 09/22] target-arm: Add SPSR entries for EL2/HYP and EL3/MON
Quoted 1 line · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Noticed I missed updating cpu_mode_names[]
Queued an update to translate.c for v2.
Cheers,
Edgar
Quoted 75 lines
Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/cpu.h | 4 +++- target-arm/helper.c | 4 ++++ target-arm/machine.c | 8 ++++---- 3 files changed, 11 insertions(+), 5 deletions(-)target-arm/cpu.h +3
-1@@ -143,7 +143,7 @@ typedef struct CPUARMState {uint32_t spsr;/* Banked registers. */ -uint64_t banked_spsr[6 ]; +uint64_t banked_spsr[8 ];uint32_t banked_r13[6 ];uint32_t banked_r14[6 ];@@ -566,7 +566,9 @@ enum arm_cpu_mode {ARM_CPU_MODE_FIQ =0x11 ,ARM_CPU_MODE_IRQ =0x12 ,ARM_CPU_MODE_SVC =0x13 , +ARM_CPU_MODE_MON =0x16 ,ARM_CPU_MODE_ABT =0x17 , +ARM_CPU_MODE_HYP =0x1a ,ARM_CPU_MODE_UND =0x1b , ARM_CPU_MODE_SYS = 0x1f };target-arm/helper.c +4
-0@@ -3078,6 +3078,10 @@ int bank_number(int mode)return 4 ;case ARM_CPU_MODE_FIQ :return 5 ; +case ARM_CPU_MODE_HYP : +return 6 ; +case ARM_CPU_MODE_MON : +return 7 ; }hw_error ("bank number requested for bad CPSR mode value 0x%x\n" , mode); }target-arm/machine.c +4
-4@@ -222,9 +222,9 @@ static int cpu_post_load(void *opaque, int version_id)const VMStateDescription vmstate_arm_cpu = { .name ="cpu" , - .version_id =19 , - .minimum_version_id =19 , - .minimum_version_id_old =19 , + .version_id =20 , + .minimum_version_id =20 , + .minimum_version_id_old =20 , .pre_save = cpu_pre_save, .post_load = cpu_post_load, .fields = (VMStateField []) {@@ -238,7 +238,7 @@ const VMStateDescription vmstate_arm_cpu = { .offset = 0, },VMSTATE_UINT32 (env.spsr,ARMCPU ), -VMSTATE_UINT64_ARRAY (env.banked_spsr,ARMCPU ,6 ), +VMSTATE_UINT64_ARRAY (env.banked_spsr,ARMCPU ,8 ),VMSTATE_UINT32_ARRAY (env.banked_r13,ARMCPU ,6 ),VMSTATE_UINT32_ARRAY (env.banked_r14,ARMCPU ,6 ), VMSTATE_UINT32_ARRAY(env.usr_regs, ARMCPU, 5),Signature · 1 line
1.8.3.2
PATCH 10/22 target-arm: A64: Introduce arm64_banked_spsr_index()
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Add arm64_banked_spsr_index(), used to map an Exception Level to an index in the baked_spsr array.
--- target-arm/helper-a64.c | 5 +++-- target-arm/internals.h | 14 ++++++++++++++ target-arm/op_helper.c | 3 ++- 3 files changed, 19 insertions(+), 3 deletions(-)
target-arm/helper-a64.c +3 -2
@@ -444,6 +444,7 @@ void aarch64_cpu_do_interrupt(CPUState *cs)ARMCPU *cpu =ARM_CPU (cs);CPUARMState *env = &cpu->env;target_ulong addr = env->cp15.vbar_el[VBAR_EL_IDX (1 )]; +unsigned int spsr_idx =arm64_banked_spsr_index (1 );int i;if (arm_current_pl (env) ==0 ) {
@@ -488,12 +489,12 @@ void aarch64_cpu_do_interrupt(CPUState *cs) }if (is_a64 (env)) { - env->banked_spsr[0 ] =pstate_read (env); + env->banked_spsr[spsr_idx] =pstate_read (env); env->sp_el[arm_current_pl (env)] = env->xregs[31 ]; env->xregs[31 ] = env->sp_el[1 ]; env->elr_el[ELR_EL_IDX (1 )] = env->pc; }else { - env->banked_spsr[0 ] =cpsr_read (env); + env->banked_spsr[spsr_idx] =cpsr_read (env);if (!env->thumb) { env->cp15.esr_el[ESR_EL_IDX (1 )] |=1 <<25 ; }
target-arm/internals.h +14 -0
@@ -75,6 +75,20 @@ static inline void arm_log_exception(int idx)*/ #define GTIMER_SCALE 16 +/* +* For aarch64, map a given EL to an index in the banked_spsr array. +*/ +static inline unsigned int arm64_banked_spsr_index (unsigned int el) +{ +static const unsigned int map[3 ] = { + [0 ] =0 ,/* EL1. */ + [1 ] =6 ,/* EL2. */ + [2 ] =7 ,/* EL3. */ + }; +assert (el >=1 && el <=3 ); +return map[el -1 ]; +} +int bank_number (int mode);void switch_mode (CPUARMState *,int );void arm_cpu_register_gdb_regs_for_features (ARMCPU *cpu);
target-arm/op_helper.c +2 -1
@@ -386,7 +386,8 @@ void HELPER(msr_i_pstate)(CPUARMState *env, uint32_t op, uint32_t imm)void HELPER (exception_return )(CPUARMState *env) { -uint32_t spsr = env->banked_spsr[0 ]; +unsigned int spsr_idx =arm64_banked_spsr_index (1 ); +uint32_t spsr = env->banked_spsr[spsr_idx];int new_el, i;if (env->pstate &PSTATE_SP ) {
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH v1 10/22] target-arm: A64: Introduce arm64_banked_spsr_index()
Quoted 46 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Add
arm64_banked_spsr_index(), used to map an Exception Level to an index in thebaked_spsrarray.Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/helper-a64.c | 5 +++-- target-arm/internals.h | 14 ++++++++++++++ target-arm/op_helper.c | 3 ++- 3 files changed, 19 insertions(+), 3 deletions(-)target-arm/helper-a64.c +3
-2@@ -444,6 +444,7 @@ void aarch64_cpu_do_interrupt(CPUState *cs)ARMCPU *cpu =ARM_CPU (cs);CPUARMState *env = &cpu->env;target_ulong addr = env->cp15.vbar_el[VBAR_EL_IDX (1 )]; +unsigned int spsr_idx =arm64_banked_spsr_index (1 );int i;if (arm_current_pl (env) ==0 ) {@@ -488,12 +489,12 @@ void aarch64_cpu_do_interrupt(CPUState *cs) }if (is_a64 (env)) { - env->banked_spsr[0 ] =pstate_read (env); + env->banked_spsr[spsr_idx] =pstate_read (env); env->sp_el[arm_current_pl (env)] = env->xregs[31 ]; env->xregs[31 ] = env->sp_el[1 ]; env->elr_el[ELR_EL_IDX (1 )] = env->pc; }else { - env->banked_spsr[0 ] =cpsr_read (env); + env->banked_spsr[spsr_idx] =cpsr_read (env);if (!env->thumb) { env->cp15.esr_el[ESR_EL_IDX (1 )] |=1 <<25 ; }target-arm/internals.h +0
-0@@ -75,6 +75,20 @@ static inline void arm_log_exception(int idx)*/ #define GTIMER_SCALE 16
target-arm/internals.h static inline void arm_log_exception(int idx) · line 86
Quoted 10 lines
target-arm/internals.h +9
-0+/* +* For aarch64, map a given EL to an index in the banked_spsr array. +*/ +static inline unsigned int arm64_banked_spsr_index (unsigned int el) +{ +static const unsigned int map[3 ] = { + [0 ] =0 ,/* EL1. */ + [1 ] =6 ,/* EL2. */ + [2 ] =7 ,/* EL3. */
You could just change the [] indicies to [1], [2], [3]
target-arm/internals.h static inline void arm_log_exception(int idx) · line 89
Quoted 3 lines
target-arm/internals.h +3
-0+ }; +assert (el >=1 && el <=3 ); +return map[el -1 ];
And drop this subtraction.
Regards,
Peter
Quoted 23 lines
target-arm/internals.h +2
-0+} +int bank_number (int mode);void switch_mode (CPUARMState *,int );void arm_cpu_register_gdb_regs_for_features (ARMCPU *cpu);target-arm/op_helper.c +2
-2@@ -386,7 +386,8 @@ void HELPER(msr_i_pstate)(CPUARMState *env, uint32_t op, uint32_t imm)void HELPER (exception_return )(CPUARMState *env) { -uint32_t spsr = env->banked_spsr[0 ]; +unsigned int spsr_idx =arm64_banked_spsr_index (1 ); +uint32_t spsr = env->banked_spsr[spsr_idx];int new_el, i;if (env->pstate &PSTATE_SP ) { --1.8.3.2
Re: [Qemu-devel] [PATCH v1 10/22] target-arm: A64: Introduce arm64_banked_spsr_index()
In reply to Edgar E. IglesiasQuoted 29 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Add
arm64_banked_spsr_index(), used to map an Exception Level to an index in thebaked_spsrarray.Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/helper-a64.c | 5 +++-- target-arm/internals.h | 14 ++++++++++++++ target-arm/op_helper.c | 3 ++- 3 files changed, 19 insertions(+), 3 deletions(-)target-arm/helper-a64.c +1
-1@@ -444,6 +444,7 @@ void aarch64_cpu_do_interrupt(CPUState *cs)ARMCPU *cpu =ARM_CPU (cs);CPUARMState *env = &cpu->env;target_ulong addr = env->cp15.vbar_el[VBAR_EL_IDX (1 )]; +unsigned int spsr_idx =arm64_banked_spsr_index (1 );int i;if (arm_current_pl (env) ==0 ) {@@ -488,12 +489,12 @@ void aarch64_cpu_do_interrupt(CPUState *cs) }if (is_a64 (env)) { - env->banked_spsr[0 ] =pstate_read (env);
target-arm/helper-a64.c void aarch64_cpu_do_interrupt(CPUState *cs) · line 500
Quoted 10 lines
target-arm/helper-a64.c +2
-1+ env->banked_spsr[spsr_idx] =pstate_read (env); env->sp_el[arm_current_pl (env)] = env->xregs[31 ]; env->xregs[31 ] = env->sp_el[1 ]; env->elr_el[ELR_EL_IDX (1 )] = env->pc; }else { - env->banked_spsr[0 ] =cpsr_read (env); + env->banked_spsr[spsr_idx] =cpsr_read (env);if (!env->thumb) { env->cp15.esr_el[ESR_EL_IDX (1 )] |=1 <<25 ; }
This looks bogus -- the function you've added is only valid if we are taking the exception from AArch64, but we use the spsr_idx in the from-AArch32 case as well.
target-arm/internals.h static inline void arm_log_exception(int idx) · line 79
Quoted 10 lines
target-arm/internals.h +2
-0@@ -75,6 +75,20 @@ static inline void arm_log_exception(int idx)*/ #define GTIMER_SCALE 16 +/* +* For aarch64, map a given EL to an index in the banked_spsr array.
In comments, "AArch64", please.
target-arm/internals.h static inline void arm_log_exception(int idx) · line 81
Quoted 2 lines
target-arm/internals.h +2
-0+*/ +static inline unsigned int arm64_banked_spsr_index (unsigned int el)
"aarch64", not "arm64", please.
target-arm/internals.h static inline void arm_log_exception(int idx) · line 91
Quoted 10 lines
target-arm/internals.h +10
-0+{ +static const unsigned int map[3 ] = { + [0 ] =0 ,/* EL1. */ + [1 ] =6 ,/* EL2. */ + [2 ] =7 ,/* EL3. */ + }; +assert (el >=1 && el <=3 ); +return map[el -1 ]; +} +
thanks
-- PMM
Re: [Qemu-devel] [PATCH v1 10/22] target-arm: A64: Introduce arm64_banked_spsr_index()
Quoted 28 lines · Peter Maydell
Quoted 27 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Add
arm64_banked_spsr_index(), used to map an Exception Level to an index in thebaked_spsrarray.Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/helper-a64.c | 5 +++-- target-arm/internals.h | 14 ++++++++++++++ target-arm/op_helper.c | 3 ++- 3 files changed, 19 insertions(+), 3 deletions(-)target-arm/helper-a64.c +1
-0@@ -444,6 +444,7 @@ void aarch64_cpu_do_interrupt(CPUState *cs)ARMCPU *cpu =ARM_CPU (cs);CPUARMState *env = &cpu->env;target_ulong addr = env->cp15.vbar_el[VBAR_EL_IDX (1 )]; +unsigned int spsr_idx =arm64_banked_spsr_index (1 );int i;if (arm_current_pl (env) ==0 ) {@@ -488,12 +489,12 @@ void aarch64_cpu_do_interrupt(CPUState *cs) }
Quoted 16 lines
target-arm/helper-a64.c void aarch64_cpu_do_interrupt(CPUState *cs) · line 500
Quoted 12 lines
target-arm/helper-a64.c +2
-2if (is_a64 (env)) { - env->banked_spsr[0 ] =pstate_read (env); + env->banked_spsr[spsr_idx] =pstate_read (env); env->sp_el[arm_current_pl (env)] = env->xregs[31 ]; env->xregs[31 ] = env->sp_el[1 ]; env->elr_el[ELR_EL_IDX (1 )] = env->pc; }else { - env->banked_spsr[0 ] =cpsr_read (env); + env->banked_spsr[spsr_idx] =cpsr_read (env);if (!env->thumb) { env->cp15.esr_el[ESR_EL_IDX (1 )] |=1 <<25 ; }This looks bogus -- the function you've added is only valid if we are taking the exception from AArch64, but we use the
spsr_idxin the from-AArch32 case as well.
Good catch, thanks!
Quoted 14 lines
target-arm/internals.h static inline void arm_log_exception(int idx) · line 79
Quoted 11 lines
target-arm/internals.h +2
-0@@ -75,6 +75,20 @@ static inline void arm_log_exception(int idx)*/ #define GTIMER_SCALE 16 +/* +* For aarch64, map a given EL to an index in the banked_spsr array. In comments, "AArch64", please.
Quoted 4 lines
target-arm/internals.h static inline void arm_log_exception(int idx) · line 81
Quoted 2 lines
target-arm/internals.h +2
-0+*/ +static inline unsigned int arm64_banked_spsr_index (unsigned int el)"aarch64", not "arm64", please.
Will fix
Cheers,
Edgar
PATCH 11/22 target-arm: Add a feature flag for EL2
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
--- target-arm/cpu.h | 1 + 1 file changed, 1 insertion(+)
target-arm/cpu.h +1 -0
@@ -636,6 +636,7 @@ enum arm_features {ARM_FEATURE_CBAR ,/* has cp15 CBAR */ ARM_FEATURE_CRC ,/* ARMv8 CRC instructions */ ARM_FEATURE_CBAR_RO ,/* has cp15 CBAR and it is read-only */ + ARM_FEATURE_EL2, /* has EL2 Virtualization support */ };static inline int arm_feature (CPUARMState *env,int feature)
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH v1 11/22] target-arm: Add a feature flag for EL2
Quoted 3 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>
Quoted 20 lines
--- target-arm/cpu.h | 1 + 1 file changed, 1 insertion(+)target-arm/cpu.h +1
-1@@ -636,6 +636,7 @@ enum arm_features {ARM_FEATURE_CBAR ,/* has cp15 CBAR */ ARM_FEATURE_CRC ,/* ARMv8 CRC instructions */ ARM_FEATURE_CBAR_RO ,/* has cp15 CBAR and it is read-only */ + ARM_FEATURE_EL2, /* has EL2 Virtualization support */ };static inline int arm_feature (CPUARMState *env,int feature) --1.8.3.2
PATCH 12/22 target-arm: Add a feature flag for EL3
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
--- target-arm/cpu.h | 1 + 1 file changed, 1 insertion(+)
target-arm/cpu.h +1 -0
@@ -637,6 +637,7 @@ enum arm_features {ARM_FEATURE_CRC ,/* ARMv8 CRC instructions */ ARM_FEATURE_CBAR_RO ,/* has cp15 CBAR and it is read-only */ ARM_FEATURE_EL2 ,/* has EL2 Virtualization support */ + ARM_FEATURE_EL3, /* has EL3 Secure monitor support */ };static inline int arm_feature (CPUARMState *env,int feature)
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH v1 12/22] target-arm: Add a feature flag for EL3
Quoted 3 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>
Quoted 20 lines
--- target-arm/cpu.h | 1 + 1 file changed, 1 insertion(+)target-arm/cpu.h +1
-1@@ -637,6 +637,7 @@ enum arm_features {ARM_FEATURE_CRC ,/* ARMv8 CRC instructions */ ARM_FEATURE_CBAR_RO ,/* has cp15 CBAR and it is read-only */ ARM_FEATURE_EL2 ,/* has EL2 Virtualization support */ + ARM_FEATURE_EL3, /* has EL3 Secure monitor support */ };static inline int arm_feature (CPUARMState *env,int feature) --1.8.3.2
PATCH 13/22 target-arm: Register EL2 versions of ELR and SPSR
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
--- target-arm/helper.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)
target-arm/helper.c +17 -0
@@ -2078,6 +2078,19 @@ static const ARMCPRegInfo v8_cp_reginfo[] = {REGINFO_SENTINEL }; +static const ARMCPRegInfo v8_el2_cp_reginfo[] = { + { .name ="ELR_EL2" , .state =ARM_CP_STATE_AA64 , + .type =ARM_CP_NO_MIGRATE , + .opc0 =3 , .opc1 =4 , .crn =4 , .crm =0 , .opc2 =1 , + .access =PL2_RW , + .fieldoffset = offsetof(CPUARMState, elr_el[ELR_EL_IDX(2)]) }, + { .name ="SPSR_EL2" , .state =ARM_CP_STATE_AA64 , + .type =ARM_CP_NO_MIGRATE , + .opc0 =3 , .opc1 =4 , .crn =4 , .crm =0 , .opc2 =0 , + .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[6]) }, +REGINFO_SENTINEL +}; +static void sctlr_write (CPUARMState *env,const ARMCPRegInfo *ri,uint64_t value) {
@@ -2321,6 +2334,10 @@ void register_cp_regs_for_features(ARMCPU *cpu)define_arm_cp_regs (cpu, v8_idregs);define_arm_cp_regs (cpu, v8_cp_reginfo);define_aarch64_debug_regs (cpu); + +if (arm_feature (env,ARM_FEATURE_EL2 )) { +define_arm_cp_regs (cpu, v8_el2_cp_reginfo); + } }if (arm_feature (env,ARM_FEATURE_MPU )) {/* These are the MPU registers prior to PMSAv6. Any new
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH v1 13/22] target-arm: Register EL2 versions of ELR and SPSR
Quoted 32 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/helper.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)target-arm/helper.c +13
-0@@ -2078,6 +2078,19 @@ static const ARMCPRegInfo v8_cp_reginfo[] = {REGINFO_SENTINEL }; +static const ARMCPRegInfo v8_el2_cp_reginfo[] = { + { .name ="ELR_EL2" , .state =ARM_CP_STATE_AA64 , + .type =ARM_CP_NO_MIGRATE , + .opc0 =3 , .opc1 =4 , .crn =4 , .crm =0 , .opc2 =1 , + .access =PL2_RW , + .fieldoffset = offsetof(CPUARMState, elr_el[ELR_EL_IDX(2)]) }, + { .name ="SPSR_EL2" , .state =ARM_CP_STATE_AA64 , + .type =ARM_CP_NO_MIGRATE , + .opc0 =3 , .opc1 =4 , .crn =4 , .crm =0 , .opc2 =0 , + .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[6]) }, +REGINFO_SENTINEL +}; +static void sctlr_write (CPUARMState *env,const ARMCPRegInfo *ri,uint64_t value) {
target-arm/helper.c void register_cp_regs_for_features(ARMCPU *cpu) · line 2340
Quoted 7 lines
target-arm/helper.c +4
-0@@ -2321,6 +2334,10 @@ void register_cp_regs_for_features(ARMCPU *cpu)define_arm_cp_regs (cpu, v8_idregs);define_arm_cp_regs (cpu, v8_cp_reginfo);define_aarch64_debug_regs (cpu); + +if (arm_feature (env,ARM_FEATURE_EL2 )) { +define_arm_cp_regs (cpu, v8_el2_cp_reginfo); + }
I think this should be outside the if ARM_FEATURE_V8 for consistency. None of the other per-feature CP register defs are nested within the ifferry for their ARM version. Detecting the invalid combination of ARM_FEATURE_EL2 and pre V8 should probably be an assertion done in arm_cpu_realizefn().
Otherwise:
Quoted 7 lines
target-arm/helper.c +0
-1}if (arm_feature (env,ARM_FEATURE_MPU )) {/* These are the MPU registers prior to PMSAv6. Any new -- 1.8.3.2
Re: [Qemu-devel] [PATCH v1 13/22] target-arm: Register EL2 versions of ELR and SPSR
Quoted 39 lines · Peter Crosthwaite
Quoted 37 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/helper.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+)target-arm/helper.c +15
-0@@ -2078,6 +2078,19 @@ static const ARMCPRegInfo v8_cp_reginfo[] = {REGINFO_SENTINEL }; +static const ARMCPRegInfo v8_el2_cp_reginfo[] = { + { .name ="ELR_EL2" , .state =ARM_CP_STATE_AA64 , + .type =ARM_CP_NO_MIGRATE , + .opc0 =3 , .opc1 =4 , .crn =4 , .crm =0 , .opc2 =1 , + .access =PL2_RW , + .fieldoffset = offsetof(CPUARMState, elr_el[ELR_EL_IDX(2)]) }, + { .name ="SPSR_EL2" , .state =ARM_CP_STATE_AA64 , + .type =ARM_CP_NO_MIGRATE , + .opc0 =3 , .opc1 =4 , .crn =4 , .crm =0 , .opc2 =0 , + .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[6]) }, +REGINFO_SENTINEL +}; +static void sctlr_write (CPUARMState *env,const ARMCPRegInfo *ri,uint64_t value) {@@ -2321,6 +2334,10 @@ void register_cp_regs_for_features(ARMCPU *cpu)define_arm_cp_regs (cpu, v8_idregs);define_arm_cp_regs (cpu, v8_cp_reginfo);define_aarch64_debug_regs (cpu); + +if (arm_feature (env,ARM_FEATURE_EL2 )) {
Quoted 8 lines
target-arm/helper.c void register_cp_regs_for_features(ARMCPU *cpu) · line 2340
Quoted 2 lines
target-arm/helper.c +2
-0+define_arm_cp_regs (cpu, v8_el2_cp_reginfo); + }I think this should be outside the if
ARM_FEATURE_V8for consistency. None of the other per-feature CP register defs are nested within the ifferry for their ARM version. Detecting the invalid combination ofARM_FEATURE_EL2and pre V8 should probably be an assertion done inarm_cpu_realizefn().
ARM_FEATURE_EL2 + pre-V8 should be valid, that seems the obvious way to indicate "v7 CPU with virt extensions".
As it happens registering these reginfo on a pre-v8 CPU is harmless -- they'll just never be accessible.
thanks
-- PMM
PATCH 14/22 target-arm: Register EL3 versions of ELR and SPSR
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
--- target-arm/helper.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
target-arm/helper.c +16 -0
@@ -2091,6 +2091,19 @@ static const ARMCPRegInfo v8_el2_cp_reginfo[] = {REGINFO_SENTINEL }; +static const ARMCPRegInfo v8_el3_cp_reginfo[] = { + { .name ="ELR_EL3" , .state =ARM_CP_STATE_AA64 , + .type =ARM_CP_NO_MIGRATE , + .opc0 =3 , .opc1 =6 , .crn =4 , .crm =0 , .opc2 =1 , + .access =PL3_RW , + .fieldoffset = offsetof(CPUARMState, elr_el[ELR_EL_IDX(3)]) }, + { .name ="SPSR_EL3" , .state =ARM_CP_STATE_AA64 , + .type =ARM_CP_NO_MIGRATE , + .opc0 =3 , .opc1 =6 , .crn =4 , .crm =0 , .opc2 =0 , + .access = PL3_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[7]) }, +REGINFO_SENTINEL +}; +static void sctlr_write (CPUARMState *env,const ARMCPRegInfo *ri,uint64_t value) {
@@ -2338,6 +2351,9 @@ void register_cp_regs_for_features(ARMCPU *cpu)if (arm_feature (env,ARM_FEATURE_EL2 )) {define_arm_cp_regs (cpu, v8_el2_cp_reginfo); } +if (arm_feature (env,ARM_FEATURE_EL3 )) { +define_arm_cp_regs (cpu, v8_el3_cp_reginfo); + } }if (arm_feature (env,ARM_FEATURE_MPU )) {/* These are the MPU registers prior to PMSAv6. Any new
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH v1 14/22] target-arm: Register EL3 versions of ELR and SPSR
Quoted 3 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>
Same as last patch,
Otherwise:
Quoted 42 lines
--- target-arm/helper.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)target-arm/helper.c +16
-1@@ -2091,6 +2091,19 @@ static const ARMCPRegInfo v8_el2_cp_reginfo[] = {REGINFO_SENTINEL }; +static const ARMCPRegInfo v8_el3_cp_reginfo[] = { + { .name ="ELR_EL3" , .state =ARM_CP_STATE_AA64 , + .type =ARM_CP_NO_MIGRATE , + .opc0 =3 , .opc1 =6 , .crn =4 , .crm =0 , .opc2 =1 , + .access =PL3_RW , + .fieldoffset = offsetof(CPUARMState, elr_el[ELR_EL_IDX(3)]) }, + { .name ="SPSR_EL3" , .state =ARM_CP_STATE_AA64 , + .type =ARM_CP_NO_MIGRATE , + .opc0 =3 , .opc1 =6 , .crn =4 , .crm =0 , .opc2 =0 , + .access = PL3_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[7]) }, +REGINFO_SENTINEL +}; +static void sctlr_write (CPUARMState *env,const ARMCPRegInfo *ri,uint64_t value) {@@ -2338,6 +2351,9 @@ void register_cp_regs_for_features(ARMCPU *cpu)if (arm_feature (env,ARM_FEATURE_EL2 )) {define_arm_cp_regs (cpu, v8_el2_cp_reginfo); } +if (arm_feature (env,ARM_FEATURE_EL3 )) { +define_arm_cp_regs (cpu, v8_el3_cp_reginfo); + } }if (arm_feature (env,ARM_FEATURE_MPU )) {/* These are the MPU registers prior to PMSAv6. Any new -- 1.8.3.2
PATCH 15/22 target-arm: A64: Forbid ERET to increase the EL
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
--- target-arm/op_helper.c | 5 +++++ 1 file changed, 5 insertions(+)
target-arm/op_helper.c +5 -0
@@ -389,6 +389,7 @@ void HELPER(exception_return)(CPUARMState *env)unsigned int spsr_idx =arm64_banked_spsr_index (1 );uint32_t spsr = env->banked_spsr[spsr_idx];int new_el, i; +int cur_el =arm_current_pl (env);if (env->pstate &PSTATE_SP ) { env->sp_el[1 ] = env->xregs[31 ];
@@ -410,6 +411,10 @@ void HELPER(exception_return)(CPUARMState *env) env->regs[15 ] = env->elr_el[ELR_EL_IDX (1 )] & ~0x1 ; }else { new_el =extract32 (spsr,2 ,2 ); +if (new_el > cur_el) { +/* Disallow returns to higher ELs than the current one. */ + goto illegal_return; + }if (new_el >1 ) {/* Return to unimplemented EL */ goto illegal_return;
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH v1 15/22] target-arm: A64: Forbid ERET to increase the EL
Quoted 3 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>
Quoted 31 lines
--- target-arm/op_helper.c | 5 +++++ 1 file changed, 5 insertions(+)target-arm/op_helper.c +5
-1@@ -389,6 +389,7 @@ void HELPER(exception_return)(CPUARMState *env)unsigned int spsr_idx =arm64_banked_spsr_index (1 );uint32_t spsr = env->banked_spsr[spsr_idx];int new_el, i; +int cur_el =arm_current_pl (env);if (env->pstate &PSTATE_SP ) { env->sp_el[1 ] = env->xregs[31 ];@@ -410,6 +411,10 @@ void HELPER(exception_return)(CPUARMState *env) env->regs[15 ] = env->elr_el[ELR_EL_IDX (1 )] & ~0x1 ; }else { new_el =extract32 (spsr,2 ,2 ); +if (new_el > cur_el) { +/* Disallow returns to higher ELs than the current one. */ + goto illegal_return; + }if (new_el >1 ) {/* Return to unimplemented EL */ goto illegal_return; --1.8.3.2
PATCH 16/22 target-arm: A64: Forbid ERET to unimplemented ELs
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Check for EL2 support before returning to it.
--- target-arm/op_helper.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
target-arm/op_helper.c +3 -5
@@ -411,12 +411,10 @@ void HELPER(exception_return)(CPUARMState *env) env->regs[15 ] = env->elr_el[ELR_EL_IDX (1 )] & ~0x1 ; }else { new_el =extract32 (spsr,2 ,2 ); -if (new_el > cur_el) { +if (new_el > cur_el + || (new_el ==2 && !arm_feature (env,ARM_FEATURE_EL2 ))) {/* Disallow returns to higher ELs than the current one. */ - goto illegal_return; - } -if (new_el >1 ) { -/* Return to unimplemented EL */ +/* Disallow returns to unimplemented ELs. */ goto illegal_return; }if (extract32 (spsr,1 ,1 )) {
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH v1 16/22] target-arm: A64: Forbid ERET to unimplemented ELs
Quoted 5 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Check for EL2 support before returning to it.
Signed-off-by Edgar E. Iglesias <[email protected]>
Quoted 28 lines
--- target-arm/op_helper.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)target-arm/op_helper.c +3
-6@@ -411,12 +411,10 @@ void HELPER(exception_return)(CPUARMState *env) env->regs[15 ] = env->elr_el[ELR_EL_IDX (1 )] & ~0x1 ; }else { new_el =extract32 (spsr,2 ,2 ); -if (new_el > cur_el) { +if (new_el > cur_el + || (new_el ==2 && !arm_feature (env,ARM_FEATURE_EL2 ))) {/* Disallow returns to higher ELs than the current one. */ - goto illegal_return; - } -if (new_el >1 ) { -/* Return to unimplemented EL */ +/* Disallow returns to unimplemented ELs. */ goto illegal_return; }if (extract32 (spsr,1 ,1 )) { --1.8.3.2
Re: [Qemu-devel] [PATCH v1 16/22] target-arm: A64: Forbid ERET to unimplemented ELs
In reply to Edgar E. IglesiasQuoted 16 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Check for EL2 support before returning to it.
Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/op_helper.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)target-arm/op_helper.c +0
-0@@ -411,12 +411,10 @@ void HELPER(exception_return)(CPUARMState *env) env->regs[15 ] = env->elr_el[ELR_EL_IDX (1 )] & ~0x1 ; }else {
target-arm/op_helper.c void HELPER(exception_return)(CPUARMState *env) · line 417
Quoted 10 lines
target-arm/op_helper.c +3
-5new_el =extract32 (spsr,2 ,2 ); -if (new_el > cur_el) { +if (new_el > cur_el + || (new_el ==2 && !arm_feature (env,ARM_FEATURE_EL2 ))) {/* Disallow returns to higher ELs than the current one. */ - goto illegal_return; - } -if (new_el >1 ) { -/* Return to unimplemented EL */ +/* Disallow returns to unimplemented ELs. */
Merge the comments rather than having two one-liners one after the other, please.
/* Disallow return to an EL which is unimplemented or higher
* than the current one.
*/
thanks
-- PMM
Re: [Qemu-devel] [PATCH v1 16/22] target-arm: A64: Forbid ERET to unimplemented ELs
Quoted 25 lines · Peter Maydell
Quoted 24 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Check for EL2 support before returning to it.
Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/op_helper.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)target-arm/op_helper.c +2
-4@@ -411,12 +411,10 @@ void HELPER(exception_return)(CPUARMState *env) env->regs[15 ] = env->elr_el[ELR_EL_IDX (1 )] & ~0x1 ; }else { new_el =extract32 (spsr,2 ,2 ); -if (new_el > cur_el) { +if (new_el > cur_el + || (new_el ==2 && !arm_feature (env,ARM_FEATURE_EL2 ))) {/* Disallow returns to higher ELs than the current one. */ - goto illegal_return; - } -if (new_el >1 ) {
Quoted 8 lines
target-arm/op_helper.c void HELPER(exception_return)(CPUARMState *env) · line 417
Quoted 2 lines
target-arm/op_helper.c +1
-1-/* Return to unimplemented EL */ +/* Disallow returns to unimplemented ELs. */ Merge the comments rather than having two one-liners one after the other, please.
/* Disallow return to an EL which is unimplemented or higher
* than the current one.
*/
Fixed for v2, thanks.
Cheers,
Edgar
PATCH 17/22 target-arm: A64: Generalize ERET to various ELs
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Adds support for ERET to Aarch64 EL2 and 3.
--- target-arm/op_helper.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
target-arm/op_helper.c +7 -6
@@ -386,13 +386,14 @@ void HELPER(msr_i_pstate)(CPUARMState *env, uint32_t op, uint32_t imm)void HELPER (exception_return )(CPUARMState *env) { -unsigned int spsr_idx =arm64_banked_spsr_index (1 ); -uint32_t spsr = env->banked_spsr[spsr_idx]; -int new_el, i;int cur_el =arm_current_pl (env); +unsigned int spsr_idx =arm64_banked_spsr_index (cur_el); +uint32_t spsr; +int new_el, i; + spsr = env->banked_spsr[spsr_idx];if (env->pstate &PSTATE_SP ) { - env->sp_el[1 ] = env->xregs[31 ]; + env->sp_el[cur_el] = env->xregs[31 ]; }else { env->sp_el[0 ] = env->xregs[31 ]; }
@@ -428,7 +429,7 @@ void HELPER(exception_return)(CPUARMState *env) env->aarch64 =1 ;pstate_write (env, spsr); env->xregs[31 ] = env->sp_el[new_el]; - env->pc = env->elr_el[ELR_EL_IDX (1 )]; + env->pc = env->elr_el[ELR_EL_IDX (cur_el)]; }return ;
@@ -442,7 +443,7 @@ illegal_return:* no change to exception level, execution state or stack pointer */ env->pstate |=PSTATE_IL ; - env->pc = env->elr_el[ELR_EL_IDX (1 )]; + env->pc = env->elr_el[ELR_EL_IDX (cur_el)]; spsr &=PSTATE_NZCV |PSTATE_DAIF ; spsr |=pstate_read (env) & ~(PSTATE_NZCV |PSTATE_DAIF );pstate_write (env, spsr);
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH v1 17/22] target-arm: A64: Generalize ERET to various ELs
Quoted 16 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Adds support for ERET to Aarch64 EL2 and 3.
Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/op_helper.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)target-arm/op_helper.c +0
-0@@ -386,13 +386,14 @@ void HELPER(msr_i_pstate)(CPUARMState *env, uint32_t op, uint32_t imm)void HELPER (exception_return )(CPUARMState *env)
target-arm/op_helper.c void HELPER(msr_i_pstate)(CPUARMState *env, uint32_t op, uint32_t imm) · line 394
Quoted 10 lines
target-arm/op_helper.c +4
-3{ -unsigned int spsr_idx =arm64_banked_spsr_index (1 ); -uint32_t spsr = env->banked_spsr[spsr_idx]; -int new_el, i;int cur_el =arm_current_pl (env); +unsigned int spsr_idx =arm64_banked_spsr_index (cur_el); +uint32_t spsr; +int new_el, i; + spsr = env->banked_spsr[spsr_idx];
Why change to split declaration and assignment (amongst the other all-in-one's above)?
Otherwise:
Quoted 28 lines
target-arm/op_helper.c +3
-4if (env->pstate &PSTATE_SP ) { - env->sp_el[1 ] = env->xregs[31 ]; + env->sp_el[cur_el] = env->xregs[31 ]; }else { env->sp_el[0 ] = env->xregs[31 ]; }@@ -428,7 +429,7 @@ void HELPER(exception_return)(CPUARMState *env) env->aarch64 =1 ;pstate_write (env, spsr); env->xregs[31 ] = env->sp_el[new_el]; - env->pc = env->elr_el[ELR_EL_IDX (1 )]; + env->pc = env->elr_el[ELR_EL_IDX (cur_el)]; }return ;@@ -442,7 +443,7 @@ illegal_return:* no change to exception level, execution state or stack pointer */ env->pstate |=PSTATE_IL ; - env->pc = env->elr_el[ELR_EL_IDX (1 )]; + env->pc = env->elr_el[ELR_EL_IDX (cur_el)]; spsr &=PSTATE_NZCV |PSTATE_DAIF ; spsr |=pstate_read (env) & ~(PSTATE_NZCV |PSTATE_DAIF );pstate_write (env, spsr); --1.8.3.2
PATCH 18/22 target-arm: A64: Generalize update_spsel for the various ELs
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
--- target-arm/internals.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
target-arm/internals.h +5 -6
@@ -107,6 +107,7 @@ int arm_rmode_to_sf(int rmode);static inline void update_spsel (CPUARMState *env,uint32_t imm) { +unsigned int cur_el =arm_current_pl (env);/* Update PSTATE SPSel bit; this requires us to update the * working stack pointer in xregs[31]. */
@@ -115,17 +116,15 @@ static inline void update_spsel(CPUARMState *env, uint32_t imm) } env->pstate =deposit32 (env->pstate,0 ,1 , imm); -/* EL0 has no access rights to update SPSel, and this code -* assumes we are updating SP for EL1 while running as EL1. -*/ -assert (arm_current_pl (env) ==1 ); +/* EL0 has no access rights to update SPSel. */ +assert (cur_el >=1 && cur_el <=3 );if (env->pstate &PSTATE_SP ) {/* Switch from using SP_EL0 to using SP_ELx */ env->sp_el[0 ] = env->xregs[31 ]; - env->xregs[31 ] = env->sp_el[1 ]; + env->xregs[31 ] = env->sp_el[cur_el]; }else {/* Switch from SP_EL0 to SP_ELx */ - env->sp_el[1 ] = env->xregs[31 ]; + env->sp_el[cur_el] = env->xregs[31 ]; env->xregs[31 ] = env->sp_el[0 ]; } }
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH v1 18/22] target-arm: A64: Generalize update_spsel for the various ELs
Quoted 3 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>
Quoted 42 lines
--- target-arm/internals.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)target-arm/internals.h +5
-7@@ -107,6 +107,7 @@ int arm_rmode_to_sf(int rmode);static inline void update_spsel (CPUARMState *env,uint32_t imm) { +unsigned int cur_el =arm_current_pl (env);/* Update PSTATE SPSel bit; this requires us to update the * working stack pointer in xregs[31]. */ @@ -115,17 +116,15 @@ static inline void update_spsel(CPUARMState *env, uint32_t imm) } env->pstate =deposit32 (env->pstate,0 ,1 , imm); -/* EL0 has no access rights to update SPSel, and this code -* assumes we are updating SP for EL1 while running as EL1. -*/ -assert (arm_current_pl (env) ==1 ); +/* EL0 has no access rights to update SPSel. */ +assert (cur_el >=1 && cur_el <=3 );if (env->pstate &PSTATE_SP ) {/* Switch from using SP_EL0 to using SP_ELx */ env->sp_el[0 ] = env->xregs[31 ]; - env->xregs[31 ] = env->sp_el[1 ]; + env->xregs[31 ] = env->sp_el[cur_el]; }else {/* Switch from SP_EL0 to SP_ELx */ - env->sp_el[1 ] = env->xregs[31 ]; + env->sp_el[cur_el] = env->xregs[31 ]; env->xregs[31 ] = env->sp_el[0 ]; } } --1.8.3.2
Re: [Qemu-devel] [PATCH v1 18/22] target-arm: A64: Generalize update_spsel for the various ELs
In reply to Edgar E. Iglesiastarget-arm/internals.h static inline void update_spsel(CPUARMState *env, uint32_t imm) · line 120
Quoted 6 lines · Edgar E. Iglesias
target-arm/internals.h +2
-4-/* EL0 has no access rights to update SPSel, and this code -* assumes we are updating SP for EL1 while running as EL1. -*/ -assert (arm_current_pl (env) ==1 ); +/* EL0 has no access rights to update SPSel. */ +assert (cur_el >=1 && cur_el <=3 );
The old comment makes it clear that we're not supposed to get here when running as EL0. The new comment makes this look like a possible DoS attack.
r~
Re: [Qemu-devel] [PATCH v1 18/22] target-arm: A64: Generalize update_spsel for the various ELs
Quoted 10 lines · Richard Henderson
target-arm/internals.h static inline void update_spsel(CPUARMState *env, uint32_t imm) · line 120
Quoted 6 lines · Edgar E. Iglesias
target-arm/internals.h +2
-4-/* EL0 has no access rights to update SPSel, and this code -* assumes we are updating SP for EL1 while running as EL1. -*/ -assert (arm_current_pl (env) ==1 ); +/* EL0 has no access rights to update SPSel. */ +assert (cur_el >=1 && cur_el <=3 );The old comment makes it clear that we're not supposed to get here when running as EL0. The new comment makes this look like a possible DoS attack.
I've changed it to the following for next version:
/* We rely on illegal updates to SPsel from EL0 to get trapped
* at translation time.
*/If you have better suggestions I'm happy to update.
Thanks,
Edgar
Re: [Qemu-devel] [PATCH v1 18/22] target-arm: A64: Generalize update_spsel for the various ELs
Quoted 6 lines · Edgar E. Iglesias
I've changed it to the following for next version:
/* We rely on illegal updates to SPsel from EL0 to get trapped * at translation time. */If you have better suggestions I'm happy to update.
Excellent, thanks.
r~
PATCH 19/22 target-arm: Add storage for VBAR_EL2 and 3
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
--- target-arm/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-arm/cpu.h +1 -1
@@ -201,7 +201,7 @@ typedef struct CPUARMState {uint32_t c9_pminten;/* perf monitor interrupt enables */ uint64_t mair_el1;#define VBAR_EL_IDX (x) (x - 1) -uint64_t vbar_el[1 ];/* vector base address register */ +uint64_t vbar_el[3 ];/* vector base address register */ uint32_t c13_fcse;/* FCSE PID. */ uint64_t contextidr_el1;/* Context ID. */ uint64_t tpidr_el0;/* User RW Thread register. */
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH v1 19/22] target-arm: Add storage for VBAR_EL2 and 3
Quoted 21 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target-arm/cpu.h +1
-2@@ -201,7 +201,7 @@ typedef struct CPUARMState {uint32_t c9_pminten;/* perf monitor interrupt enables */ uint64_t mair_el1;#define VBAR_EL_IDX (x) (x - 1) -uint64_t vbar_el[1 ];/* vector base address register */ +uint64_t vbar_el[3 ];/* vector base address register */ uint32_t c13_fcse;/* FCSE PID. */ uint64_t contextidr_el1;/* Context ID. */ uint64_t tpidr_el0;/* User RW Thread register. */ --
Quoted 1 line
1.8.3.2
You should just fold this into whichever patch causes us to start actually accessing vbar_el[] for other ELs.
thanks
-- PMM
Re: [Qemu-devel] [PATCH v1 19/22] target-arm: Add storage for VBAR_EL2 and 3
Quoted 18 lines · Peter Maydell
Quoted 17 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/cpu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target-arm/cpu.h +1
-1@@ -201,7 +201,7 @@ typedef struct CPUARMState {uint32_t c9_pminten;/* perf monitor interrupt enables */ uint64_t mair_el1;#define VBAR_EL_IDX (x) (x - 1) -uint64_t vbar_el[1 ];/* vector base address register */ +uint64_t vbar_el[3 ];/* vector base address register */
Quoted 8 lines
Quoted 5 lines
target-arm/cpu.h +0
-1uint32_t c13_fcse;/* FCSE PID. */ uint64_t contextidr_el1;/* Context ID. */ uint64_t tpidr_el0;/* User RW Thread register. */ --1.8.3.2
You should just fold this into whichever patch causes us to start actually accessing vbar_el[] for other ELs.
Agreed, will squash them.
Thanks,
Edgar
PATCH 20/22 target-arm: Make vbar_write writeback to any CPREG
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
--- target-arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-arm/helper.c +1 -1
@@ -657,7 +657,7 @@ static void vbar_write(CPUARMState *env, const ARMCPRegInfo *ri,* contexts. (ARMv8 would permit us to do no masking at all, but ARMv7 * requires the bottom five bits to be RAZ/WI because they're UNK/SBZP.) */ - env->cp15.vbar_el[VBAR_EL_IDX (1 )] = value & ~0x1FULL ; +CPREG_FIELD64 (env, ri) = value & ~0x1FULL ; }static uint64_t ccsidr_read (CPUARMState *env,const ARMCPRegInfo *ri)
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH v1 20/22] target-arm: Make vbar_write writeback to any CPREG
Quoted 12 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target-arm/helper.c +0
-0
target-arm/helper.c static void vbar_write(CPUARMState *env, const ARMCPRegInfo *ri, · line 660
Quoted 5 lines
target-arm/helper.c +1
-1@@ -657,7 +657,7 @@ static void vbar_write(CPUARMState *env, const ARMCPRegInfo *ri,* contexts. (ARMv8 would permit us to do no masking at all, but ARMv7 * requires the bottom five bits to be RAZ/WI because they're UNK/SBZP.) */ - env->cp15.vbar_el[VBAR_EL_IDX (1 )] = value & ~0x1FULL ; +CPREG_FIELD64 (env, ri) = value & ~0x1FULL ;
Use raw_write() to implement CP register writing (check vmsa_ttbr_write for example).
Regards,
Peter
Quoted 7 lines
target-arm/helper.c +0
-1}static uint64_t ccsidr_read (CPUARMState *env,const ARMCPRegInfo *ri) --1.8.3.2
PATCH 21/22 target-arm: A64: Register VBAR_EL2
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
--- target-arm/helper.c | 5 +++++ 1 file changed, 5 insertions(+)
target-arm/helper.c +5 -0
@@ -2088,6 +2088,11 @@ static const ARMCPRegInfo v8_el2_cp_reginfo[] = { .type = ARM_CP_NO_MIGRATE, .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 0, .opc2 = 0, .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[6]) }, + { .name = "VBAR_EL2", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 0, .opc2 = 0, + .access = PL2_RW, .writefn = vbar_write, + .fieldoffset = offsetof(CPUARMState, cp15.vbar_el[1]), + .resetvalue = 0 }, REGINFO_SENTINEL };
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH v1 21/22] target-arm: A64: Register VBAR_EL2
Quoted 12 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/helper.c | 5 +++++ 1 file changed, 5 insertions(+)target-arm/helper.c +0
-0
target-arm/helper.c static const ARMCPRegInfo v8_el2_cp_reginfo[] = { · line 2094
Quoted 7 lines
target-arm/helper.c +4
-0@@ -2088,6 +2088,11 @@ static const ARMCPRegInfo v8_el2_cp_reginfo[] = { .type = ARM_CP_NO_MIGRATE, .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 0, .opc2 = 0, .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[6]) }, + { .name = "VBAR_EL2", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 0, .opc2 = 0, + .access = PL2_RW, .writefn = vbar_write, + .fieldoffset = offsetof(CPUARMState, cp15.vbar_el[1]),
This [1] is smoewhat misleading, and should either use the VBAR_EL_IDX macro or if changing over to always-four array, just [2].
Regards,
Peter
Quoted 8 lines
target-arm/helper.c +1
-1+ .resetvalue = 0 }, REGINFO_SENTINEL }; --1.8.3.2
Re: [Qemu-devel] [PATCH v1 21/22] target-arm: A64: Register VBAR_EL2
In reply to Edgar E. IglesiasQuoted 12 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/helper.c | 5 +++++ 1 file changed, 5 insertions(+)target-arm/helper.c +0
-0
target-arm/helper.c static const ARMCPRegInfo v8_el2_cp_reginfo[] = { · line 2097
Quoted 10 lines
target-arm/helper.c +5
-0@@ -2088,6 +2088,11 @@ static const ARMCPRegInfo v8_el2_cp_reginfo[] = { .type = ARM_CP_NO_MIGRATE, .opc0 = 3, .opc1 = 4, .crn = 4, .crm = 0, .opc2 = 0, .access = PL2_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[6]) }, + { .name = "VBAR_EL2", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 4, .crn = 12, .crm = 0, .opc2 = 0, + .access = PL2_RW, .writefn = vbar_write, + .fieldoffset = offsetof(CPUARMState, cp15.vbar_el[1]), + .resetvalue = 0 }, REGINFO_SENTINEL };
ARM ARM says that if EL2 isn't implemented then this register should be RES0 from EL3 (ie not UNDEF).
thanks
-- PMM
PATCH 22/22 target-arm: A64: Register VBAR_EL3
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
--- target-arm/helper.c | 5 +++++ 1 file changed, 5 insertions(+)
target-arm/helper.c +5 -0
@@ -2106,6 +2106,11 @@ static const ARMCPRegInfo v8_el3_cp_reginfo[] = { .type = ARM_CP_NO_MIGRATE, .opc0 = 3, .opc1 = 6, .crn = 4, .crm = 0, .opc2 = 0, .access = PL3_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[7]) }, + { .name = "VBAR_EL3", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 6, .crn = 12, .crm = 0, .opc2 = 0, + .access = PL3_RW, .writefn = vbar_write, + .fieldoffset = offsetof(CPUARMState, cp15.vbar_el[2]), + .resetvalue = 0 }, REGINFO_SENTINEL };
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH v1 22/22] target-arm: A64: Register VBAR_EL3
Quoted 12 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>--- target-arm/helper.c | 5 +++++ 1 file changed, 5 insertions(+)target-arm/helper.c +0
-0
target-arm/helper.c static const ARMCPRegInfo v8_el3_cp_reginfo[] = { · line 2112
Quoted 7 lines
target-arm/helper.c +4
-0@@ -2106,6 +2106,11 @@ static const ARMCPRegInfo v8_el3_cp_reginfo[] = { .type = ARM_CP_NO_MIGRATE, .opc0 = 3, .opc1 = 6, .crn = 4, .crm = 0, .opc2 = 0, .access = PL3_RW, .fieldoffset = offsetof(CPUARMState, banked_spsr[7]) }, + { .name = "VBAR_EL3", .state = ARM_CP_STATE_AA64, + .opc0 = 3, .opc1 = 6, .crn = 12, .crm = 0, .opc2 = 0, + .access = PL3_RW, .writefn = vbar_write, + .fieldoffset = offsetof(CPUARMState, cp15.vbar_el[2]),
Same comment as P21.
Regards,
Peter
Quoted 8 lines
target-arm/helper.c +1
-1+ .resetvalue = 0 }, REGINFO_SENTINEL }; --1.8.3.2
Quoted 10 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Hi,
I've been doing some work on modeling parts of EL2 and 3 + some of the system-wide virtualization features for ARMv8. A lot is missing but I've got a series with enough to for example run KVM A64 guests on top of EL3 firmware inside emulated QEMU A64 VMs.
I'm working on cleaning things up and plan to send patches and publish things as I go.
So before I start reviewing this, how does it relate to the Samsung series for AArch32 trustzone (EL3) support that was posted last year? In Linaro we've been planning to rework that and integrate it upstream...
thanks
-- PMM
Quoted 12 lines · Peter Maydell
Quoted 10 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Hi,
I've been doing some work on modeling parts of EL2 and 3 + some of the system-wide virtualization features for ARMv8. A lot is missing but I've got a series with enough to for example run KVM A64 guests on top of EL3 firmware inside emulated QEMU A64 VMs.
I'm working on cleaning things up and plan to send patches and publish things as I go.
Quoted 5 lines
So before I start reviewing this, how does it relate to the Samsung series for AArch32 trustzone (EL3) support that was posted last year? In Linaro we've been planning to rework that and integrate it upstream...
Hi Peter,
AFAICT the series have some minor overlap but mostly they complement each other. The aarch64 EL3 support I've got so far is very limited. Has mode switching, separate page tables, SMC etc and that kind of things but no S/NS state yet. The A64 security state parts can be implemented on top of the Samsung series.
Cheers,
Edgar
Hi
I’ve been reworking the Samsung patches as part of my Master thesis and I wanted to send them some time this week. I am currently rebasing them when I noticed Edgar’s patches. Is there some branch with the patches so I could rebase on them?
Thanks,
Fabian
On 07 May 2014, at 05:46, Edgar E. Iglesias <[email protected]<mailto:[email protected]>> wrote:
On Tue, May 06, 2014 at 08:58:43AM +0100, Peter Maydell wrote:
On 6 May 2014 07:08, Edgar E. Iglesias <[email protected]<mailto:[email protected]>> wrote:
From: "Edgar E. Iglesias" <[email protected]<mailto:[email protected]>>
Hi,
I've been doing some work on modeling parts of EL2 and 3 + some of the system-wide virtualization features for ARMv8. A lot is missing but I've got a series with enough to for example run KVM A64 guests on top of EL3 firmware inside emulated QEMU A64 VMs.
I'm working on cleaning things up and plan to send patches and publish things as I go.
So before I start reviewing this, how does it relate to the Samsung series for AArch32 trustzone (EL3) support that was posted last year? In Linaro we've been planning to rework that and integrate it upstream...
Hi Peter,
AFAICT the series have some minor overlap but mostly they complement each other. The aarch64 EL3 support I've got so far is very limited. Has mode switching, separate page tables, SMC etc and that kind of things but no S/NS state yet. The A64 security state parts can be implemented on top of the Samsung series.
Cheers,
Edgar
Quoted 3 lines · Aggeler Fabian
I’ve been reworking the Samsung patches as part of my Master thesis and I wanted to send them some time this week. I am currently rebasing them when I noticed Edgar’s patches. Is there some branch with the patches so I could rebase on them?
Hmm, that makes about three lots of people trying to do similar things at this point. We should try to coordinate so we don't duplicate work.
thanks
-- PMM
I see. What is Greg Bellows working on exactly? Also peripherals like TZASC, TZPC,...? My plan is to focus on them now if no one else is working on them. What do you suggest to minimize overlap?
Thanks,
Fabian
________________________________________
From: Peter Maydell [[email protected]]
Sent: Monday, May 12, 2014 10:39 PM
To: Aggeler Fabian
Cc: Edgar E. Iglesias; Rob Herring; Peter Crosthwaite; QEMU Developers; Alexander Graf; John Williams; Alex Bennée; Greg Bellows
Subject: Re: [Qemu-devel] [PATCH v1 00/22] target-arm: Preparations for A64 EL2 and 3
Quoted 3 lines · Aggeler Fabian
I’ve been reworking the Samsung patches as part of my Master thesis and I wanted to send them some time this week. I am currently rebasing them when I noticed Edgar’s patches. Is there some branch with the patches so I could rebase on them?
Hmm, that makes about three lots of people trying to do similar things at this point. We should try to coordinate so we don't duplicate work.
thanks
-- PMM
Hi Fabian,
I too had been updating the core TZ patches provided by Samsung. From looking at your changes I see a lot of similarities in our code with the exception being the mechanism for banked register support. The difference being that your approach is a bit more explicit in the declaration of the banked registers. Whereas my approach was to update the banked registers once all the other registers were registered. Both approaches I believe work.
I spoke with Peter M. and he and I are okay with your approach. I will be looking closer at your patches today and making comments.
One thing that held me up from committing sooner was testing my changes.
Do you have a good approach for testing the changes?
Regards,
Greg
Quoted 28 lines · Aggeler Fabian
I see. What is Greg Bellows working on exactly? Also peripherals like TZASC, TZPC,...? My plan is to focus on them now if no one else is working on them. What do you suggest to minimize overlap?
Thanks,
Fabian
________________________________________
From: Peter Maydell [[email protected]]
Sent: Monday, May 12, 2014 10:39 PM
To: Aggeler Fabian
Cc: Edgar E. Iglesias; Rob Herring; Peter Crosthwaite; QEMU Developers; Alexander Graf; John Williams; Alex Bennée; Greg Bellows
Subject: Re: [Qemu-devel] [PATCH v1 00/22] target-arm: Preparations for A64 EL2 and 3Quoted 1 line · Aggeler Fabian
I’ve been reworking the Samsung patches as part of my Master thesis and
I wanted to
Quoted 1 line
send them some time this week. I am currently rebasing them when I
noticed Edgar’s
Quoted 1 line
patches. Is there some branch with the patches so I could rebase on them?
Hmm, that makes about three lots of people trying to do similar things at this point. We should try to coordinate so we don't duplicate work.
thanks
-- PMM
Hi Greg
Thanks for your comments. I still have to work through them. I am using OpenVirtualization in secure world, which then switches to a Linux kernel in non-secure world to test the patches. What about you?
Best,
Fabian
On 14 May 2014, at 15:55, Greg Bellows <[email protected]<mailto:[email protected]>> wrote:
Hi Fabian,
I too had been updating the core TZ patches provided by Samsung. From looking at your changes I see a lot of similarities in our code with the exception being the mechanism for banked register support. The difference being that your approach is a bit more explicit in the declaration of the banked registers. Whereas my approach was to update the banked registers once all the other registers were registered. Both approaches I believe work.
I spoke with Peter M. and he and I are okay with your approach. I will be looking closer at your patches today and making comments.
One thing that held me up from committing sooner was testing my changes. Do you have a good approach for testing the changes?
Regards,
Greg
On 14 May 2014 03:58, Aggeler Fabian <[email protected]<mailto:[email protected]>> wrote:
I see. What is Greg Bellows working on exactly? Also peripherals like TZASC, TZPC,...? My plan is to focus on them now if no one else is working on them. What do you suggest to minimize overlap?
Thanks,
Fabian
________________________________________
From: Peter Maydell [[email protected]<mailto:[email protected]>]
Sent: Monday, May 12, 2014 10:39 PM
To: Aggeler Fabian
Cc: Edgar E. Iglesias; Rob Herring; Peter Crosthwaite; QEMU Developers; Alexander Graf; John Williams; Alex Bennée; Greg Bellows
Subject: Re: [Qemu-devel] [PATCH v1 00/22] target-arm: Preparations for A64 EL2 and 3
Quoted 3 lines · On 12 May 2014 20:13, Aggeler Fabian <[email protected]<mailto:aggelerf…
I’ve been reworking the Samsung patches as part of my Master thesis and I wanted to send them some time this week. I am currently rebasing them when I noticed Edgar’s patches. Is there some branch with the patches so I could rebase on them?
Hmm, that makes about three lots of people trying to do similar things at this point. We should try to coordinate so we don't duplicate work.
thanks
-- PMM
Quoted 6 lines · Aggeler Fabian
Hi Greg
Thanks for your comments. I still have to work through them. I am using OpenVirtualization in secure world, which then switches to a Linux kernel in non-secure world to test the patches. What about you?
Best,
Fabian
Hi, Fabian, are there some secure OS with secure user-space tasks which can be used for testing whether world switching is performed correctly?
Regards, Sergey.
Quoted 40 lines · On 14 May 2014, at 15:55, Greg Bellows <[email protected]<mailto:greg.bel…
Hi Fabian,
I too had been updating the core TZ patches provided by Samsung. From looking at your changes I see a lot of similarities in our code with the exception being the mechanism for banked register support. The difference being that your approach is a bit more explicit in the declaration of the banked registers. Whereas my approach was to update the banked registers once all the other registers were registered. Both approaches I believe work.
I spoke with Peter M. and he and I are okay with your approach. I will be looking closer at your patches today and making comments.
One thing that held me up from committing sooner was testing my changes. Do you have a good approach for testing the changes?
Regards,
Greg
On 14 May 2014 03:58, Aggeler Fabian <[email protected]<mailto:[email protected]>> wrote:
I see. What is Greg Bellows working on exactly? Also peripherals like TZASC, TZPC,...? My plan is to focus on them now if no one else is working on them. What do you suggest to minimize overlap?Thanks,
Fabian
________________________________________
From: Peter Maydell [[email protected]<mailto:[email protected]>]
Sent: Monday, May 12, 2014 10:39 PM
To: Aggeler Fabian
Cc: Edgar E. Iglesias; Rob Herring; Peter Crosthwaite; QEMU Developers; Alexander Graf; John Williams; Alex Bennée; Greg Bellows
Subject: Re: [Qemu-devel] [PATCH v1 00/22] target-arm: Preparations for A64 EL2 and 3Quoted 3 lines · On 12 May 2014 20:13, Aggeler Fabian <[email protected]<mailto:aggelerf…
I’ve been reworking the Samsung patches as part of my Master thesis and I wanted to send them some time this week. I am currently rebasing them when I noticed Edgar’s patches. Is there some branch with the patches so I could rebase on them?
Hmm, that makes about three lots of people trying to do similar things at this point. We should try to coordinate so we don't duplicate work.
thanks
-- PMM
Hi Sergey,
Quoted 10 lines · Sergey Fedorov
Quoted 6 lines · Aggeler Fabian
Hi Greg
Thanks for your comments. I still have to work through them. I am using OpenVirtualization in secure world, which then switches to a Linux kernel in non-secure world to test the patches. What about you?
Best,
FabianHi, Fabian, are there some secure OS with secure user-space tasks which can be used for testing whether world switching is performed correctly?
In my experience, A32 and A64 Linux runs fine in secure supervisor mode / EL1_S (KVM, if enabled, will fail gracefully). A32 and A64 Linux applications run fine in secure user mode / EL0_S.
For A64 EL3 there's https://github.com/ARM-software/arm-trusted-firmware,
although I've yet to use it myself. It advertises an EL1 test payload.
Christopher
Quoted 42 lines
Quoted 40 lines · On 14 May 2014, at 15:55, Greg Bellows <[email protected]<mailto:greg.bel…
Hi Fabian,
I too had been updating the core TZ patches provided by Samsung. From looking at your changes I see a lot of similarities in our code with the exception being the mechanism for banked register support. The difference being that your approach is a bit more explicit in the declaration of the banked registers. Whereas my approach was to update the banked registers once all the other registers were registered. Both approaches I believe work.
I spoke with Peter M. and he and I are okay with your approach. I will be looking closer at your patches today and making comments.
One thing that held me up from committing sooner was testing my changes. Do you have a good approach for testing the changes?
Regards,
Greg
On 14 May 2014 03:58, Aggeler Fabian <[email protected]<mailto:[email protected]>> wrote:
I see. What is Greg Bellows working on exactly? Also peripherals like TZASC, TZPC,...? My plan is to focus on them now if no one else is working on them. What do you suggest to minimize overlap?Thanks,
Fabian
________________________________________
From: Peter Maydell [[email protected]<mailto:[email protected]>]
Sent: Monday, May 12, 2014 10:39 PM
To: Aggeler Fabian
Cc: Edgar E. Iglesias; Rob Herring; Peter Crosthwaite; QEMU Developers; Alexander Graf; John Williams; Alex Bennée; Greg Bellows
Subject: Re: [Qemu-devel] [PATCH v1 00/22] target-arm: Preparations for A64 EL2 and 3Quoted 3 lines · On 12 May 2014 20:13, Aggeler Fabian <[email protected]<mailto:aggelerf…
I’ve been reworking the Samsung patches as part of my Master thesis and I wanted to send them some time this week. I am currently rebasing them when I noticed Edgar’s patches. Is there some branch with the patches so I could rebase on them?
Hmm, that makes about three lots of people trying to do similar things at this point. We should try to coordinate so we don't duplicate work.
thanks
-- PMM
Signature · 3 lines
Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation.
Quoted 1 line · Aggeler Fabian
I see. What is Greg Bellows working on exactly? Also peripherals like TZASC, TZPC,...? My plan is to focus on them now if no one else is working on them. What do you suggest to minimize overlap?
Hi,
With regards to my patches our overlap is minimal. I dont think I will have any problems rebasing on top of your stuff.
I've got aarch64 VIRQ/GICv2 virtualization support, Timer updates, MMU 2nd stage translation + a few hax here and there. Will hopefully post next week. My focus has been on getting KVM to run within emulated QEMU. Not so much on EL3 and TrustZone.
WRT coordination, I'm happy to rebase if other patches go in before mine in any area I've mentioned. IMO, the best help right now would be to actually get some of the basic and few conflicting patches reviewed & merged.
Cheers,
Edgar
Quoted 4 lines · Aggeler Fabian
Hi
I’ve been reworking the Samsung patches as part of my Master thesis and I wanted to send them some time this week. I am currently rebasing them when I noticed Edgar’s patches. Is there some branch with the patches so I could rebase on them?
The patches tool is very good for getting someones work off list as a local branch.
https://github.com/aliguori/patches
Regards,
Peter
Quoted 3 lines · Aggeler Fabian
Hi
I’ve been reworking the Samsung patches as part of my Master thesis and I wanted to send them some time this week. I am currently rebasing them when I noticed Edgar’s patches. Is there some branch with the patches so I could rebase on them?
Hi,
I've put my v2 here:git://repo.or.cz/qemu/cris-port.git edgar/a64/elx-refactor.2
I'm busy with some other things now but plan to send out more patches next week.
Best regards,
Edgar
Quoted 35 lines
Thanks,
FabianOn 07 May 2014, at 05:46, Edgar E. Iglesias <[email protected]<mailto:[email protected]>> wrote:
On Tue, May 06, 2014 at 08:58:43AM +0100, Peter Maydell wrote:
On 6 May 2014 07:08, Edgar E. Iglesias <[email protected]<mailto:[email protected]>> wrote:
From: "Edgar E. Iglesias" <[email protected]<mailto:[email protected]>>Hi,
I've been doing some work on modeling parts of EL2 and 3 + some of the system-wide virtualization features for ARMv8. A lot is missing but I've got a series with enough to for example run KVM A64 guests on top of EL3 firmware inside emulated QEMU A64 VMs.
I'm working on cleaning things up and plan to send patches and publish things as I go.So before I start reviewing this, how does it relate to the Samsung series for AArch32 trustzone (EL3) support that was posted last year? In Linaro we've been planning to rework that and integrate it upstream...
Hi Peter,
AFAICT the series have some minor overlap but mostly they complement each other. The aarch64 EL3 support I've got so far is very limited. Has mode switching, separate page tables, SMC etc and that kind of things but no S/NS state yet. The A64 security state parts can be implemented on top of the Samsung series.
Cheers,
Edgar
Quoted 14 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Hi,
I've been doing some work on modeling parts of EL2 and 3 + some of the system-wide virtualization features for ARMv8. A lot is missing but I've got a series with enough to for example run KVM A64 guests on top of EL3 firmware inside emulated QEMU A64 VMs.
I'm working on cleaning things up and plan to send patches and publish things as I go.This series does a first round of preparations. Most of it has little or no user visible impact as the EL2 and 3 features remain disabled.
Quoted 6 lines
For the arrayification of the various EL regs that do not exist for EL0, I've used index macros. I don't really have a preference here, so if you have better/less ugly ideas or preferences I'm happy to change the pattern (getters/setters or whatever).
Happy to address any comments people may have.
I've only had a rough glimpse at the patches, but so far things look pretty sane.
Alex