target/ppc: Remove most MO_TE uses in cpu_ld/st_code/data()
v6 cover target/ppc: Remove most MO_TE uses in cpu_ld/st_code/data()
All series reviewed.
Since v5:
- Renamed mo_endian_env() -> ppc_data_endian_env()
- Renamed ppc_code_endian() -> ppc_code_endian_dc()
- Clarified expression used in ppc_code_endian_dc()
Since v4:
- Fixed incorrect rebase
Since v3 (DATA path):
- Remove MO_UNALN in do_HASH (rth)
- Complete CODE path
Philippe Mathieu-Daudé (11):
target/ppc: Inline cpu_ldl_data_ra() calls in ICBI helpers target/ppc: Inline cpu_ld/st_mmuidx_ra() calls in memory helpers target/ppc: Inline cpu_ld/st_data_ra() calls in do_hash() target/ppc: Expect page translation hash addresses to be aligned target/ppc: Introduce ppc_data_endian_env() helper target/ppc: Introduce ppc_code_endian_dc() helper target/ppc: Inline need_byteswap() and replace translator_ldl_swap() target/ppc: Check endianness via env in ppc_disas_set_info() target/ppc: Introduce ppc_env_is_little_endian() helper target/ppc: Check endianness at runtime in ppc_data_endian_env() target/ppc: Inline cpu_ldl_code() call in ppc_ldl_code()
target/ppc/internal.h | 17 ++++++++++ target/ppc/cpu_init.c | 9 ++---- target/ppc/gdbstub.c | 2 +- target/ppc/mem_helper.c | 60 ++++++++++++++++++++++++++---------- target/ppc/tcg-excp_helper.c | 27 +++++++--------- target/ppc/translate.c | 21 +++++++------ 6 files changed, 87 insertions(+), 49 deletions(-)
Signature · 1 line
2.52.0
PATCH v6 1/11 target/ppc: Inline cpu_ldl_data_ra() calls in ICBI helpers
Inline the cpu_ldl_data_ra() call in preparation of removing it. Since the returned value is discarded, don't bother to set the access endianness.
--- target/ppc/mem_helper.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
target/ppc/mem_helper.c +8 -3
@@ -320,22 +320,27 @@ void helper_dcbzl(CPUPPCState *env, target_ulong addr)void helper_icbi (CPUPPCState *env,target_ulong addr) { +unsigned mmu_idx =cpu_mmu_index (env_cpu (env), false); +MemOpIdx oi =make_memop_idx (MO_UL |MO_UNALN , mmu_idx); + addr &= ~(env->dcache_line_size -1 );/* * Invalidate one cache line : * PowerPC specification says this is to be treated like a load * (not a fetch) by the MMU. To be sure it will be so, -* do the load "by hand". +* do the load "by hand". As the returned data is not consumed, +* endianness is irrelevant. */ -cpu_ldl_data_ra (env, addr,GETPC ()); +cpu_ldl_mmu (env, addr, oi,GETPC ()); }void helper_icbiep (CPUPPCState *env,target_ulong addr) {#if !defined(CONFIG_USER_ONLY ) +MemOpIdx oi =make_memop_idx (MO_UL |MO_UNALN ,PPC_TLB_EPID_LOAD );/* See comments above */ addr &= ~(env->dcache_line_size -1 ); -cpu_ldl_mmuidx_ra (env, addr,PPC_TLB_EPID_LOAD ,GETPC ()); +cpu_ldl_mmu (env, addr, oi,GETPC ());#endif }
Signature · 1 line
2.52.0
PATCH v6 2/11 target/ppc: Inline cpu_ld/st_mmuidx_ra() calls in memory helpers
In reply to Philippe Mathieu-DaudéIn preparation of removing the cpu_ld*_mmuidx_ra() and cpu_st*_mmuidx_ra() calls, inline them.
--- target/ppc/mem_helper.c | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-)
target/ppc/mem_helper.c +32 -9
@@ -88,8 +88,11 @@ void helper_lmw(CPUPPCState *env, target_ulong addr, uint32_t reg) } }else {/* Slow path -- at least some of the operation requires i/o. */ +MemOp op =MO_TE |MO_UL |MO_UNALN ; +MemOpIdx oi =make_memop_idx (op, mmu_idx); +for (; reg <32 ; reg++) { - env->gpr[reg] =cpu_ldl_mmuidx_ra (env, addr, mmu_idx, raddr); + env->gpr[reg] =cpu_ldl_mmu (env, addr, oi, raddr); addr =addr_add (env, addr,4 ); } }
@@ -111,7 +114,10 @@ void helper_stmw(CPUPPCState *env, target_ulong addr, uint32_t reg) }else {/* Slow path -- at least some of the operation requires i/o. */ for (; reg <32 ; reg++) { -cpu_stl_mmuidx_ra (env, addr, env->gpr[reg], mmu_idx, raddr); +MemOp op =MO_TE |MO_UL |MO_UNALN ; +MemOpIdx oi =make_memop_idx (op, mmu_idx); + +cpu_stl_mmu (env, addr, env->gpr[reg], oi, raddr); addr =addr_add (env, addr,4 ); } }
@@ -152,9 +158,12 @@ static void do_lsw(CPUPPCState *env, target_ulong addr, uint32_t nb,break ; } }else { +MemOp op =MO_TE |MO_UL |MO_UNALN ; +MemOpIdx oi =make_memop_idx (op, mmu_idx); +/* Slow path -- at least some of the operation requires i/o. */ for (; nb >3 ; nb -=4 ) { - env->gpr[reg] =cpu_ldl_mmuidx_ra (env, addr, mmu_idx, raddr); + env->gpr[reg] =cpu_ldl_mmu (env, addr, oi, raddr); reg = (reg +1 ) %32 ; addr =addr_add (env, addr,4 ); }
@@ -165,10 +174,14 @@ static void do_lsw(CPUPPCState *env, target_ulong addr, uint32_t nb, val =cpu_ldub_mmuidx_ra (env, addr, mmu_idx, raddr) <<24 ;break ;case 2 : - val =cpu_lduw_mmuidx_ra (env, addr, mmu_idx, raddr) <<16 ; + op =MO_TE |MO_UW |MO_UNALN ; + oi =make_memop_idx (op, mmu_idx); + val =cpu_ldw_mmu (env, addr, oi, raddr) <<16 ;break ;case 3 : - val =cpu_lduw_mmuidx_ra (env, addr, mmu_idx, raddr) <<16 ; + op =MO_TE |MO_UW |MO_UNALN ; + oi =make_memop_idx (op, mmu_idx); + val =cpu_ldw_mmu (env, addr, oi, raddr) <<16 ; addr =addr_add (env, addr,2 ); val |=cpu_ldub_mmuidx_ra (env, addr, mmu_idx, raddr) <<8 ;break ;
@@ -241,8 +254,11 @@ void helper_stsw(CPUPPCState *env, target_ulong addr, uint32_t nb,break ; } }else { +MemOp op =MO_TE |MO_UL |MO_UNALN ; +MemOpIdx oi =make_memop_idx (op, mmu_idx); +for (; nb >3 ; nb -=4 ) { -cpu_stl_mmuidx_ra (env, addr, env->gpr[reg], mmu_idx, raddr); +cpu_stl_mmu (env, addr, env->gpr[reg], oi, raddr); reg = (reg +1 ) %32 ; addr =addr_add (env, addr,4 ); }
@@ -252,10 +268,14 @@ void helper_stsw(CPUPPCState *env, target_ulong addr, uint32_t nb,cpu_stb_mmuidx_ra (env, addr, val >>24 , mmu_idx, raddr);break ;case 2 : -cpu_stw_mmuidx_ra (env, addr, val >>16 , mmu_idx, raddr); + op =MO_TE |MO_UW |MO_UNALN ; + oi =make_memop_idx (op, mmu_idx); +cpu_stw_mmu (env, addr, val >>16 , oi, raddr);break ;case 3 : -cpu_stw_mmuidx_ra (env, addr, val >>16 , mmu_idx, raddr); + op =MO_TE |MO_UW |MO_UNALN ; + oi =make_memop_idx (op, mmu_idx); +cpu_stw_mmu (env, addr, val >>16 , oi, raddr); addr =addr_add (env, addr,2 );cpu_stb_mmuidx_ra (env, addr, val >>8 , mmu_idx, raddr);break ;
@@ -284,8 +304,11 @@ static void dcbz_common(CPUPPCState *env, target_ulong addr, haddr =probe_write (env, addr, dcbz_size, mmu_idx, retaddr);if (unlikely (!haddr)) {/* Slow path */ +MemOp op =MO_TE |MO_UQ |MO_UNALN ; +MemOpIdx oi =make_memop_idx (op, mmu_idx); +for (int i =0 ; i < dcbz_size; i +=8 ) { -cpu_stq_mmuidx_ra (env, addr + i,0 , mmu_idx, retaddr); +cpu_stq_mmu (env, addr + i,0 , oi, retaddr); }return ; }
Signature · 1 line
2.52.0
PATCH v6 3/11 target/ppc: Inline cpu_ld/st_data_ra() calls in do_hash()
In reply to Philippe Mathieu-DaudéIn preparation of removing the cpu_ld*_data_ra() and cpu_st*_data_ra() calls, inline them. No logical change intended.
We note the page translation hash address is expected to be aligned, so the MO_UNALN flag is misleading. Next commit will remove it.
--- target/ppc/tcg-excp_helper.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
target/ppc/tcg-excp_helper.c +7 -3
@@ -160,14 +160,18 @@ static void do_hash(CPUPPCState *env, target_ulong ea, target_ulong ra, target_ulong rb, uint64_t key, bool store) { uint64_t calculated_hash = hash_digest(ra, rb, key), loaded_hash; +unsigned mmu_idx =cpu_mmu_index (env_cpu (env), false); +MemOp op =MO_TE |MO_UQ |MO_UNALN ; +MemOpIdx oi =make_memop_idx (op, mmu_idx); +uintptr_t retaddr =GETPC ();if (store) { -cpu_stq_data_ra (env, ea, calculated_hash,GETPC ()); +cpu_stq_mmu (env, ea, calculated_hash, oi, retaddr); }else { - loaded_hash =cpu_ldq_data_ra (env, ea,GETPC ()); + loaded_hash =cpu_ldq_mmu (env, ea, oi, retaddr);if (loaded_hash != calculated_hash) {raise_exception_err_ra (env,POWERPC_EXCP_PROGRAM , -POWERPC_EXCP_TRAP ,GETPC ()); +POWERPC_EXCP_TRAP , retaddr); } } }
Signature · 1 line
2.52.0
PATCH v6 4/11 target/ppc: Expect page translation hash addresses to be aligned
In reply to Philippe Mathieu-DaudéThe page translation hash addresses are aligned:
remove the misleading MO_UNALN flag.
--- target/ppc/tcg-excp_helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/ppc/tcg-excp_helper.c +1 -1
@@ -161,7 +161,7 @@ static void do_hash(CPUPPCState *env, target_ulong ea, target_ulong ra, {uint64_t calculated_hash =hash_digest (ra, rb, key), loaded_hash;unsigned mmu_idx =cpu_mmu_index (env_cpu (env), false); -MemOp op =MO_TE |MO_UQ |MO_UNALN ; +MemOp op =MO_TE |MO_UQ ;MemOpIdx oi =make_memop_idx (op, mmu_idx);uintptr_t retaddr =GETPC ();
Signature · 1 line
2.52.0
PATCH v6 5/11 target/ppc: Introduce ppc_data_endian_env() helper
In reply to Philippe Mathieu-DaudéIntroduce ppc_data_endian_env() which returns the endian MemOp of the data path from the vCPU env pointer. Keep it hardcoded as MO_TE, the target built-time endianness.
--- target/ppc/internal.h | 12 ++++++++++++ target/ppc/mem_helper.c | 18 +++++++++--------- target/ppc/tcg-excp_helper.c | 2 +- 3 files changed, 22 insertions(+), 10 deletions(-)
target/ppc/internal.h +12 -0
@@ -19,10 +19,22 @@#define PPC_INTERNAL_H #include "exec/breakpoint.h" +#include "exec/memop.h" #include "hw/core/registerfields.h" #include "exec/page-protection.h" #include "accel/tcg/tb-cpu-state.h" +/** +* ppc_data_endian_env: +* @env: the cpu context +* +* Return the MemOp endianness of the DATA path. +*/ +static inline MemOp ppc_data_endian_env (const CPUPPCState *env) +{ +return MO_TE ; +} +/* PM instructions */ typedef enum { PPC_PM_DOZE,
target/ppc/mem_helper.c +9 -9
@@ -88,7 +88,7 @@ void helper_lmw(CPUPPCState *env, target_ulong addr, uint32_t reg) } }else {/* Slow path -- at least some of the operation requires i/o. */ -MemOp op =MO_TE |MO_UL |MO_UNALN ; +MemOp op =ppc_data_endian_env (env) |MO_UL |MO_UNALN ;MemOpIdx oi =make_memop_idx (op, mmu_idx);for (; reg <32 ; reg++) {
@@ -114,7 +114,7 @@ void helper_stmw(CPUPPCState *env, target_ulong addr, uint32_t reg) }else {/* Slow path -- at least some of the operation requires i/o. */ for (; reg <32 ; reg++) { -MemOp op =MO_TE |MO_UL |MO_UNALN ; +MemOp op =ppc_data_endian_env (env) |MO_UL |MO_UNALN ;MemOpIdx oi =make_memop_idx (op, mmu_idx);cpu_stl_mmu (env, addr, env->gpr[reg], oi, raddr);
@@ -158,7 +158,7 @@ static void do_lsw(CPUPPCState *env, target_ulong addr, uint32_t nb,break ; } }else { -MemOp op =MO_TE |MO_UL |MO_UNALN ; +MemOp op =ppc_data_endian_env (env) |MO_UL |MO_UNALN ;MemOpIdx oi =make_memop_idx (op, mmu_idx);/* Slow path -- at least some of the operation requires i/o. */
@@ -174,12 +174,12 @@ static void do_lsw(CPUPPCState *env, target_ulong addr, uint32_t nb, val =cpu_ldub_mmuidx_ra (env, addr, mmu_idx, raddr) <<24 ;break ;case 2 : - op =MO_TE |MO_UW |MO_UNALN ; + op =ppc_data_endian_env (env) |MO_UW |MO_UNALN ; oi =make_memop_idx (op, mmu_idx); val =cpu_ldw_mmu (env, addr, oi, raddr) <<16 ;break ;case 3 : - op =MO_TE |MO_UW |MO_UNALN ; + op =ppc_data_endian_env (env) |MO_UW |MO_UNALN ; oi =make_memop_idx (op, mmu_idx); val =cpu_ldw_mmu (env, addr, oi, raddr) <<16 ; addr =addr_add (env, addr,2 );
@@ -254,7 +254,7 @@ void helper_stsw(CPUPPCState *env, target_ulong addr, uint32_t nb,break ; } }else { -MemOp op =MO_TE |MO_UL |MO_UNALN ; +MemOp op =ppc_data_endian_env (env) |MO_UL |MO_UNALN ;MemOpIdx oi =make_memop_idx (op, mmu_idx);for (; nb >3 ; nb -=4 ) {
@@ -268,12 +268,12 @@ void helper_stsw(CPUPPCState *env, target_ulong addr, uint32_t nb,cpu_stb_mmuidx_ra (env, addr, val >>24 , mmu_idx, raddr);break ;case 2 : - op =MO_TE |MO_UW |MO_UNALN ; + op =ppc_data_endian_env (env) |MO_UW |MO_UNALN ; oi =make_memop_idx (op, mmu_idx);cpu_stw_mmu (env, addr, val >>16 , oi, raddr);break ;case 3 : - op =MO_TE |MO_UW |MO_UNALN ; + op =ppc_data_endian_env (env) |MO_UW |MO_UNALN ; oi =make_memop_idx (op, mmu_idx);cpu_stw_mmu (env, addr, val >>16 , oi, raddr); addr =addr_add (env, addr,2 );
@@ -304,7 +304,7 @@ static void dcbz_common(CPUPPCState *env, target_ulong addr, haddr =probe_write (env, addr, dcbz_size, mmu_idx, retaddr);if (unlikely (!haddr)) {/* Slow path */ -MemOp op =MO_TE |MO_UQ |MO_UNALN ; +MemOp op =ppc_data_endian_env (env) |MO_UQ |MO_UNALN ;MemOpIdx oi =make_memop_idx (op, mmu_idx);for (int i =0 ; i < dcbz_size; i +=8 ) {
target/ppc/tcg-excp_helper.c +1 -1
@@ -161,7 +161,7 @@ static void do_hash(CPUPPCState *env, target_ulong ea, target_ulong ra, {uint64_t calculated_hash =hash_digest (ra, rb, key), loaded_hash;unsigned mmu_idx =cpu_mmu_index (env_cpu (env), false); -MemOp op =MO_TE |MO_UQ ; +MemOp op =ppc_data_endian_env (env) |MO_UQ ;MemOpIdx oi =make_memop_idx (op, mmu_idx);uintptr_t retaddr =GETPC ();
Signature · 1 line
2.52.0
PATCH v6 6/11 target/ppc: Introduce ppc_code_endian_dc() helper
In reply to Philippe Mathieu-DaudéIntroduce the ppc_code_endian_dc() helper which returns the MemOp endianness for the CODE path.
Use it in need_byteswap(), removing one TARGET_BIG_ENDIAN.
Note, the target MemOp endianness can be evaluated as (see commit 5c43a750b67 "accel/tcg: Implement translator_ld*_end"):
MO_TE ^ (do_swap * MO_BSWAP)
For PPC we use the DisasContext::le_mode field to swap the default (big-endian) order, so to get the PPC MemOp endianness we can directly use:
MO_BE ^ (ctx->le_mode * MO_BSWAP)
--- target/ppc/translate.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-)
target/ppc/translate.c +12 -5
@@ -214,14 +214,21 @@ static inline bool is_ppe(const DisasContext *ctx)return !!(ctx->flags &POWERPC_FLAG_PPE42 ); } +/** +* ppc_code_endian_dc: +* @dc: the disassembly context +* +* Return the MemOp endianness of the CODE path. +*/ +static inline MemOp ppc_code_endian_dc (const DisasContext *ctx) +{ +return MO_BE ^ (ctx->le_mode *MO_BSWAP ); +} +/* Return true iff byteswap is needed in a scalar memop */ static inline bool need_byteswap (const DisasContext *ctx) { -#if TARGET_BIG_ENDIAN -return ctx->le_mode; -#else -return !ctx->le_mode; -#endif +return ppc_code_endian_dc (ctx) !=MO_TE ; }/* True when active word size < size of target_long. */
Signature · 1 line
2.52.0
PATCH v6 7/11 target/ppc: Inline need_byteswap() and replace translator_ldl_swap()
In reply to Philippe Mathieu-DaudéRather than using a boolean with translator_ldl_swap(), get the MemOp endianness with ppc_code_endian() and pass it to translator_ldl_end().
--- target/ppc/translate.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-)
target/ppc/translate.c +3 -9
@@ -225,12 +225,6 @@ static inline MemOp ppc_code_endian_dc(const DisasContext *ctx)return MO_BE ^ (ctx->le_mode *MO_BSWAP ); } -/* Return true iff byteswap is needed in a scalar memop */ -static inline bool need_byteswap (const DisasContext *ctx) -{ -return ppc_code_endian_dc (ctx) !=MO_TE ; -} -/* True when active word size < size of target_long. */ #ifdef TARGET_PPC64 # define NARROW_MODE (C ) (!(C)->sf_mode)
@@ -6595,6 +6589,7 @@ static void ppc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)DisasContext *ctx =container_of (dcbase, DisasContext, base);PowerPCCPU *cpu =POWERPC_CPU (cs);CPUPPCState *env =cpu_env (cs); +MemOp mo_endian =ppc_code_endian_dc (ctx);target_ulong pc;uint32_t insn;bool ok;
@@ -6604,7 +6599,7 @@ static void ppc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) ctx->base.pc_next, ctx->mem_idx, (int)msr_ir); ctx->cia = pc = ctx->base.pc_next; - insn =translator_ldl_swap (env, dcbase, pc,need_byteswap (ctx)); + insn =translator_ldl_end (env, dcbase, pc, mo_endian); ctx->base.pc_next = pc +=4 ;if (!is_prefix_insn (ctx, insn)) {
@@ -6620,8 +6615,7 @@ static void ppc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)gen_exception_err (ctx,POWERPC_EXCP_ALIGN ,POWERPC_EXCP_ALIGN_INSN ); ok = true; }else { -uint32_t insn2 =translator_ldl_swap (env, dcbase, pc, -need_byteswap (ctx)); +uint32_t insn2 =translator_ldl_end (env, dcbase, pc, mo_endian); ctx->base.pc_next = pc +=4 ; ok =decode_insn64 (ctx,deposit64 (insn2,32 ,32 , insn)); }
Signature · 1 line
2.52.0
PATCH v6 8/11 target/ppc: Check endianness via env in ppc_disas_set_info()
In reply to Philippe Mathieu-Daudédisas_set_info() shouldn't bother with env->hflags, access env->msr directly.
--- target/ppc/cpu_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/ppc/cpu_init.c +1 -1
@@ -7456,7 +7456,7 @@ static void ppc_disas_set_info(CPUState *cs, disassemble_info *info) {CPUPPCState *env =cpu_env (cs); -if ((env->hflags >>MSR_LE ) &1 ) { +if ((env->msr >>MSR_LE ) &1 ) { info->endian =BFD_ENDIAN_LITTLE ; }else { info->endian =BFD_ENDIAN_BIG ;
Signature · 1 line
2.52.0
PATCH v6 9/11 target/ppc: Introduce ppc_env_is_little_endian() helper
In reply to Philippe Mathieu-DaudéCentralize endianness check on MSR via a common helper.
--- target/ppc/internal.h | 5 +++++ target/ppc/cpu_init.c | 9 +++------ target/ppc/gdbstub.c | 2 +- target/ppc/mem_helper.c | 8 ++++---- 4 files changed, 13 insertions(+), 11 deletions(-)
target/ppc/internal.h +5 -0
@@ -24,6 +24,11 @@#include "exec/page-protection.h" #include "accel/tcg/tb-cpu-state.h" +static inline bool ppc_env_is_little_endian (const CPUPPCState *env) +{ +return FIELD_EX64 (env->msr,MSR ,LE ); +} +/** * ppc_data_endian_env: * @env: the cpu context
target/ppc/cpu_init.c +3 -6
@@ -7364,7 +7364,7 @@ static bool ppc_cpu_is_big_endian(CPUState *cs) {cpu_synchronize_state (cs); -return !FIELD_EX64 (cpu_env (cs)->msr,MSR ,LE ); +return !ppc_env_is_little_endian (cpu_env (cs)); } static bool ppc_get_irq_stats(InterruptStatsProvider *obj,
@@ -7456,11 +7456,8 @@ static void ppc_disas_set_info(CPUState *cs, disassemble_info *info) {CPUPPCState *env =cpu_env (cs); -if ((env->msr >>MSR_LE ) &1 ) { - info->endian =BFD_ENDIAN_LITTLE ; - }else { - info->endian =BFD_ENDIAN_BIG ; - } + info->endian =ppc_env_is_little_endian (env) ?BFD_ENDIAN_LITTLE + :BFD_ENDIAN_BIG ; info->mach = env->bfd_mach;if (!env->bfd_mach) {#ifdef TARGET_PPC64
target/ppc/gdbstub.c +1 -1
@@ -84,7 +84,7 @@ static int ppc_gdb_register_len(int n)void ppc_maybe_bswap_register (CPUPPCState *env,uint8_t *mem_buf,int len) {#ifndef CONFIG_USER_ONLY -if (!FIELD_EX64 (env->msr,MSR ,LE )) { +if (!ppc_env_is_little_endian (env)) {/* do nothing */ }else if (len ==4 ) {bswap32s ((uint32_t *)mem_buf);
target/ppc/mem_helper.c +4 -4
@@ -420,7 +420,7 @@ target_ulong helper_lscbx(CPUPPCState *env, target_ulong addr, uint32_t reg,int adjust =HI_IDX * (n_elems -1 ); \int sh =sizeof (r->element[0 ]) >>1 ; \int index = (addr &0xf ) >> sh; \ -bool byteswap =FIELD_EX64 (env->msr,MSR ,LE ); \ +bool byteswap =ppc_env_is_little_endian (env); \ \if (byteswap) { \ index = n_elems - index -1 ; \
@@ -446,7 +446,7 @@ LVE(LVEWX, cpu_ldl_be_data_ra, bswap32, u32)int adjust =HI_IDX * (n_elems -1 ); \int sh =sizeof (r->element[0 ]) >>1 ; \int index = (addr &0xf ) >> sh; \ -bool byteswap =FIELD_EX64 (env->msr,MSR ,LE ); \ +bool byteswap =ppc_env_is_little_endian (env); \ \if (byteswap) { \ index = n_elems - index -1 ; \
@@ -479,7 +479,7 @@ void helper_##name(CPUPPCState *env, target_ulong addr, \ t.s128 =int128_zero (); \if (nb) { \ nb = (nb >=16 ) ?16 : nb; \ -if (FIELD_EX64 (env->msr,MSR ,LE ) && !lj) { \ +if (ppc_env_is_little_endian (env) && !lj) { \for (i =16 ; i >16 - nb; i--) { \ t.VsrB (i -1 ) =cpu_ldub_data_ra (env, addr,GETPC ()); \ addr =addr_add (env, addr,1 ); \
@@ -510,7 +510,7 @@ void helper_##name(CPUPPCState *env, target_ulong addr, \ } \ \ nb = (nb >=16 ) ?16 : nb; \ -if (FIELD_EX64 (env->msr,MSR ,LE ) && !lj) { \ +if (ppc_env_is_little_endian (env) && !lj) { \for (i =16 ; i >16 - nb; i--) { \cpu_stb_data_ra (env, addr, xt->VsrB (i -1 ),GETPC ()); \ addr =addr_add (env, addr,1 ); \
Signature · 1 line
2.52.0
PATCH v6 10/11 target/ppc: Check endianness at runtime in ppc_data_endian_env()
In reply to Philippe Mathieu-DaudéRather a runtime endianness check via env MSR over a build-time one.
Now CPU can change endianness at runtime.
--- target/ppc/internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/ppc/internal.h +1 -1
@@ -37,7 +37,7 @@ static inline bool ppc_env_is_little_endian(const CPUPPCState *env)*/ static inline MemOp ppc_data_endian_env (const CPUPPCState *env) { -return MO_TE ; +return ppc_env_is_little_endian (env) ?MO_LE :MO_BE ; }/* PM instructions */
Signature · 1 line
2.52.0
PATCH v6 11/11 target/ppc: Inline cpu_ldl_code() call in ppc_ldl_code()
In reply to Philippe Mathieu-DaudéIn preparation of removing the cpu_ldl_code wrapper, inline it.
Get the runtime endianness with ppc_data_endian_env(), passing it to cpu_ldl_code_mmu(). No need to swap versus qemu-system binary anymore.
--- target/ppc/tcg-excp_helper.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
target/ppc/tcg-excp_helper.c +4 -13
@@ -428,22 +428,13 @@ G_NORETURN void powerpc_checkstop(CPUPPCState *env, const char *reason)cpu_loop_exit_noexc (cs); } -/* Return true iff byteswap is needed to load instruction */ -static inline bool insn_need_byteswap (CPUArchState *env) -{ -/* SYSTEM builds TARGET_BIG_ENDIAN. Need to swap when MSR[LE] is set */ -return !!(env->msr & ((target_ulong )1 <<MSR_LE )); -} -uint32_t ppc_ldl_code (CPUArchState *env,target_ulong addr) { -uint32_t insn =cpu_ldl_code (env, addr); +CPUState *cs =env_cpu (env); +MemOp op_end =ppc_data_endian_env (env); +MemOpIdx oi =make_memop_idx (MO_UL | op_end,cpu_mmu_index (cs, true)); -if (insn_need_byteswap (env)) { - insn =bswap32 (insn); - } - -return insn; +return cpu_ldl_code_mmu (env, addr, oi,0 ); }#if defined(TARGET_PPC64 )
Signature · 1 line
2.52.0