Mixed ARM A64 fixes
cover Mixed ARM A64 fixes
From: "Edgar E. Iglesias" <[email protected]>
Hi Peter,
This series fixes a few things I've noticed when running and looking at the aarch64 port.
Cheers,
Edgar
Edgar E. Iglesias (4):
target-arm: Make vbar_write 64bit friendly on 32bit hosts
target-arm: A64: Handle blr lr
target-arm: A64: Fix a typo when declaring TLBI ops
target-arm: Correct a comment refering to EL0
target-arm/helper.c | 26 +++++++++++++------------- target-arm/op_helper.c | 2 +- target-arm/translate-a64.c | 3 ++- 3 files changed, 16 insertions(+), 15 deletions(-)
Signature · 1 line
1.8.3.2
PATCH 1/4 target-arm: Make vbar_write 64bit friendly on 32bit hosts
From: "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.c12_vbar = value & ~0x1Ful ; + env->cp15.c12_vbar = value & ~0x1FULL ; }static uint64_t ccsidr_read (CPUARMState *env,const ARMCPRegInfo *ri)
Signature · 1 line
1.8.3.2
PATCH 2/4 target-arm: A64: Handle blr lr
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
For linked branches, updates to the link register happen conceptually after the read of the branch target register.
--- target-arm/translate-a64.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
target-arm/translate-a64.c +2 -1
@@ -1507,8 +1507,10 @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn)switch (opc) {case 0 :/* BR */ case 2 :/* RET */ +tcg_gen_mov_i64 (cpu_pc,cpu_reg (s, rn));break ;case 1 :/* BLR */ +tcg_gen_mov_i64 (cpu_pc,cpu_reg (s, rn));tcg_gen_movi_i64 (cpu_reg (s,30 ), s->pc);break ;case 4 :/* ERET */
@@ -1527,7 +1529,6 @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn)return ; } -tcg_gen_mov_i64 (cpu_pc,cpu_reg (s, rn)); s->is_jmp =DISAS_JUMP ; }
Signature · 1 line
1.8.3.2
PATCH 3/4 target-arm: A64: Fix a typo when declaring TLBI ops
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
Harmless typo as opc1 defaults to zero and opc2 gets re-declared to its correct value.
--- target-arm/helper.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
target-arm/helper.c +12 -12
@@ -1893,51 +1893,51 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { .access = PL1_W, .type = ARM_CP_NOP },/* TLBI operations */ { .name = "TLBI_VMALLE1IS", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 3, .opc2 = 0, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 0, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbiall_write }, { .name = "TLBI_VAE1IS", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 3, .opc2 = 1, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 1, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_va_write }, { .name = "TLBI_ASIDE1IS", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 3, .opc2 = 2, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 2, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_asid_write }, { .name = "TLBI_VAAE1IS", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 3, .opc2 = 3, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 3, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_vaa_write }, { .name = "TLBI_VALE1IS", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 3, .opc2 = 5, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 5, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_va_write }, { .name = "TLBI_VAALE1IS", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 3, .opc2 = 7, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 7, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_vaa_write }, { .name = "TLBI_VMALLE1", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 7, .opc2 = 0, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 0, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbiall_write }, { .name = "TLBI_VAE1", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 7, .opc2 = 1, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 1, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_va_write }, { .name = "TLBI_ASIDE1", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 7, .opc2 = 2, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 2, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_asid_write }, { .name = "TLBI_VAAE1", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 7, .opc2 = 3, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 3, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_vaa_write }, { .name = "TLBI_VALE1", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 7, .opc2 = 5, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 5, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_va_write }, { .name = "TLBI_VAALE1", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 7, .opc2 = 7, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 7, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_vaa_write }, #ifndef CONFIG_USER_ONLY
Signature · 1 line
1.8.3.2
PATCH 4/4 target-arm: Correct a comment refering to EL0
In reply to Edgar E. IglesiasFrom: "Edgar E. Iglesias" <[email protected]>
--- target-arm/op_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target-arm/op_helper.c +1 -1
@@ -418,7 +418,7 @@ void HELPER(exception_return)(CPUARMState *env) goto illegal_return; }if (new_el ==0 && (spsr &PSTATE_SP )) { -/* Return to EL1 with M[0] bit set */ +/* Return to EL0 with M[0] bit set */ goto illegal_return; } env->aarch64 =1 ;
Signature · 1 line
1.8.3.2
Re: [Qemu-devel] [PATCH v1 3/4] target-arm: A64: Fix a typo whendeclaring TLBI opss
In reply to Edgar E. IglesiasQuoted 6 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Harmless typo as opc1 defaults to zero and opc2 gets re-declared to its correct value.
Signed-off-by Edgar E. Iglesias <[email protected]>
Quoted 72 lines
--- target-arm/helper.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)target-arm/helper.c +12
-12@@ -1893,51 +1893,51 @@ static const ARMCPRegInfo v8_cp_reginfo[] = { .access = PL1_W, .type = ARM_CP_NOP },/* TLBI operations */ { .name = "TLBI_VMALLE1IS", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 3, .opc2 = 0, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 0, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbiall_write }, { .name = "TLBI_VAE1IS", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 3, .opc2 = 1, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 1, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_va_write }, { .name = "TLBI_ASIDE1IS", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 3, .opc2 = 2, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 2, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_asid_write }, { .name = "TLBI_VAAE1IS", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 3, .opc2 = 3, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 3, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_vaa_write }, { .name = "TLBI_VALE1IS", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 3, .opc2 = 5, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 5, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_va_write }, { .name = "TLBI_VAALE1IS", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 3, .opc2 = 7, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 3, .opc2 = 7, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_vaa_write }, { .name = "TLBI_VMALLE1", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 7, .opc2 = 0, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 0, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbiall_write }, { .name = "TLBI_VAE1", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 7, .opc2 = 1, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 1, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_va_write }, { .name = "TLBI_ASIDE1", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 7, .opc2 = 2, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 2, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_asid_write }, { .name = "TLBI_VAAE1", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 7, .opc2 = 3, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 3, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_vaa_write }, { .name = "TLBI_VALE1", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 7, .opc2 = 5, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 5, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_va_write }, { .name = "TLBI_VAALE1", .state = ARM_CP_STATE_AA64, - .opc0 = 1, .opc2 = 0, .crn = 8, .crm = 7, .opc2 = 7, + .opc0 = 1, .opc1 = 0, .crn = 8, .crm = 7, .opc2 = 7, .access = PL1_W, .type = ARM_CP_NO_MIGRATE, .writefn = tlbi_aa64_vaa_write }, #ifndef CONFIG_USER_ONLY
Signature · 1 line
Alex Bennée
Re: [Qemu-devel] [PATCH v1 2/4] target-arm: A64: Handle blr lr
In reply to Edgar E. IglesiasQuoted 6 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
For linked branches, updates to the link register happen conceptually after the read of the branch target register.
Signed-off-by Edgar E. Iglesias <[email protected]>
I'm trying to think of a case where this could actually cause a problem but I can't. However from a clarity/correctness point of view it's better.
Quoted 26 lines
--- target-arm/translate-a64.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)target-arm/translate-a64.c +2
-1@@ -1507,8 +1507,10 @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn)switch (opc) {case 0 :/* BR */ case 2 :/* RET */ +tcg_gen_mov_i64 (cpu_pc,cpu_reg (s, rn));break ;case 1 :/* BLR */ +tcg_gen_mov_i64 (cpu_pc,cpu_reg (s, rn));tcg_gen_movi_i64 (cpu_reg (s,30 ), s->pc);break ;case 4 :/* ERET */ @@ -1527,7 +1529,6 @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn)return ; } -tcg_gen_mov_i64 (cpu_pc,cpu_reg (s, rn)); s->is_jmp =DISAS_JUMP ; }
Signature · 1 line
Alex Bennée
Re: [Qemu-devel] [PATCH v1 1/4] target-arm: Make vbar_write 64bitfriendly on 32bit hostss
In reply to Edgar E. IglesiasQuoted 3 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>
Quoted 17 lines
--- 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.c12_vbar = value & ~0x1Ful ; + env->cp15.c12_vbar = value & ~0x1FULL ; }static uint64_t ccsidr_read (CPUARMState *env,const ARMCPRegInfo *ri)
Signature · 1 line
Alex Bennée
Re: [Qemu-devel] [PATCH v1 2/4] target-arm: A64: Handle blr lr
In reply to Alex BennéeQuoted 5 lines · Alex Bennée
Quoted 2 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Quoted 8 lines
Quoted 4 lines
For linked branches, updates to the link register happen conceptually after the read of the branch target register.
Signed-off-by Edgar E. Iglesias <[email protected]>I'm trying to think of a case where this could actually cause a problem but I can't. However from a clarity/correctness point of view it's better.
Well, we actually misexecute "BLR LR" otherwise, right? That's probably not very common but there's no reason it might not occur (eg call to a function pointer from a function where LR has been saved on entry and is free for use as a generic tempreg).
thanks
-- PMM
Re: [Qemu-devel] [PATCH v1 2/4] target-arm: A64: Handle blr lr
Quoted 15 lines · Peter Maydell
Quoted 5 lines · Alex Bennée
Quoted 2 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Quoted 8 lines
Quoted 4 lines
For linked branches, updates to the link register happen conceptually after the read of the branch target register.
Signed-off-by Edgar E. Iglesias <[email protected]>I'm trying to think of a case where this could actually cause a problem but I can't. However from a clarity/correctness point of view it's better.
Quoted 5 lines
Well, we actually misexecute "BLR LR" otherwise, right? That's probably not very common but there's no reason it might not occur (eg call to a function pointer from a function where LR has been saved on entry and is free for use as a generic tempreg).
Right. For example, the kernel/kvm actually does this inarch/arm64/kvm/hyp.S:773: blr lr
Thanks,
Edgar
Re: [Qemu-devel] [PATCH v1 1/4] target-arm: Make vbar_write 64bit friendly on 32bit hosts
In reply to Edgar E. IglesiasQuoted 3 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
Signed-off-by Edgar E. Iglesias <[email protected]>
Quoted 21 lines
--- target-arm/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target-arm/helper.c +1
-2@@ -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 & ~0x1Ful ; + env->cp15.c12_vbar = value & ~0x1FULL ; }static uint64_t ccsidr_read (CPUARMState *env,const ARMCPRegInfo *ri) --1.8.3.2
Re: [Qemu-devel] [PATCH v1 2/4] target-arm: A64: Handle blr lr
In reply to Edgar E. IglesiasQuoted 16 lines · Edgar E. Iglesias
Quoted 15 lines · Peter Maydell
Quoted 13 lines · Alex Bennée
Quoted 6 lines · Edgar E. Iglesias
From: "Edgar E. Iglesias" <[email protected]>
For linked branches, updates to the link register happen conceptually after the read of the branch target register.
Signed-off-by Edgar E. Iglesias <[email protected]>I'm trying to think of a case where this could actually cause a problem but I can't. However from a clarity/correctness point of view it's better.
Quoted 8 lines
Quoted 5 lines
Well, we actually misexecute "BLR LR" otherwise, right? That's probably not very common but there's no reason it might not occur (eg call to a function pointer from a function where LR has been saved on entry and is free for use as a generic tempreg).
Right. For example, the kernel/kvm actually does this in
arch/arm64/kvm/hyp.S:773: blr lr
Of course, I see know ;-)
Signature · 1 line
Alex Bennée