target/rx patch queue
The following changes since commit 401d46789410e88e9e90d76a11f46e8e9f358d55:
Merge tag 'pull-target-arm-20220421' of https://git.linaro.org/people/pmaydell/qemu-arm into staging (2022-04-21 08:04:43 -0700)
are available in the Git repository at:
https://gitlab.com/rth7680/qemu.git tags/pull-rx-20220421
for you to fetch changes up to 724eaecec6d22cf3842f896684bdc5b79492f093:
target/rx: update PC correctly in wait instruction (2022-04-21 10:09:12 -0700)
----------------------------------------------------------------
Fix usp/isp swapping upon clrpsw/setpsw.
Fix psw.i/pc upon wait.
Align dtb in ram.
----------------------------------------------------------------
Richard Henderson (4):
target/rx: Put tb_flags into DisasContext target/rx: Store PSW.U in tb->flags
target/rx: Move DISAS_UPDATE check for write to PSW target/rx: Swap stack pointers on clrpsw/setpsw instruction
Tomoaki Kawada (2):
target/rx: set PSW.I when executing wait instruction target/rx: update PC correctly in wait instruction
Yoshinori Sato (1):
hw/rx: rx-gdbsim DTB load address aligned of 16byte.
target/rx/cpu.h | 1 + hw/rx/rx-gdbsim.c | 2 +- target/rx/op_helper.c | 1 + target/rx/translate.c | 69 +++++++++++++++++++++++++++------------------------ 4 files changed, 40 insertions(+), 33 deletions(-)
[PULL 3/7] target/rx: Move DISAS_UPDATE check for write to PSW
Have one check in move_to_cr instead of one in each function that calls move_to_cr.
Message-Id: <[email protected]>
--- target/rx/translate.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
target/rx/translate.c +4 -10
@@ -368,6 +368,10 @@ static void move_to_cr(DisasContext *ctx, TCGv val, int cr)switch (cr) {case 0 :/* PSW */ gen_helper_set_psw (cpu_env, val); +if (is_privileged (ctx,0 )) { +/* PSW.{I,U} may be updated here. exit TB. */ + ctx->base.is_jmp =DISAS_UPDATE ; + }break ;/* case 1: to PC not supported */ case 2 :/* USP */
@@ -631,10 +635,6 @@ static bool trans_POPC(DisasContext *ctx, arg_POPC *a) val =tcg_temp_new ();pop (val);move_to_cr (ctx, val, a->cr); -if (a->cr ==0 &&is_privileged (ctx,0 )) { -/* PSW.I may be updated here. exit TB. */ - ctx->base.is_jmp =DISAS_UPDATE ; - }tcg_temp_free (val);return true; }
@@ -2205,9 +2205,6 @@ static bool trans_MVTC_i(DisasContext *ctx, arg_MVTC_i *a) imm =tcg_const_i32 (a->imm);move_to_cr (ctx, imm, a->cr); -if (a->cr ==0 &&is_privileged (ctx,0 )) { - ctx->base.is_jmp =DISAS_UPDATE ; - }tcg_temp_free (imm);return true; }
@@ -2216,9 +2213,6 @@ static bool trans_MVTC_i(DisasContext *ctx, arg_MVTC_i *a)static bool trans_MVTC_r (DisasContext *ctx,arg_MVTC_r *a) {move_to_cr (ctx, cpu_regs[a->rs], a->cr); -if (a->cr ==0 &&is_privileged (ctx,0 )) { - ctx->base.is_jmp =DISAS_UPDATE ; - }return true; }
Signature · 1 line
2.34.1
[PULL 1/7] target/rx: Put tb_flags into DisasContext
In reply to Richard HendersonCopy tb->flags into ctx->tb_flags; we'll want to modify this value throughout the tb in future.
Message-Id: <[email protected]>
--- target/rx/translate.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
target/rx/translate.c +3 -1
@@ -32,6 +32,7 @@ typedef struct DisasContext {DisasContextBase base;CPURXState *env;uint32_t pc; +uint32_t tb_flags; } DisasContext; typedef struct DisasCompare {
@@ -231,7 +232,7 @@ static inline TCGv rx_load_source(DisasContext *ctx, TCGv mem,/* Processor mode check */ static int is_privileged (DisasContext *ctx,int is_exception) { -if (FIELD_EX32 (ctx->base.tb->flags,PSW ,PM )) { +if (FIELD_EX32 (ctx->tb_flags,PSW ,PM )) {if (is_exception) {gen_helper_raise_privilege_violation (cpu_env); }
@@ -2292,6 +2293,7 @@ static void rx_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)CPURXState *env = cs->env_ptr;DisasContext *ctx =container_of (dcbase, DisasContext, base); ctx->env = env; + ctx->tb_flags = ctx->base.tb->flags; }static void rx_tr_tb_start (DisasContextBase *dcbase,CPUState *cs)
Signature · 1 line
2.34.1
[PULL 2/7] target/rx: Store PSW.U in tb->flags
In reply to Richard HendersonWith this, we don't need movcond to determine
which stack pointer is current.
Message-Id: <[email protected]>
--- target/rx/cpu.h | 1 + target/rx/translate.c | 42 +++++++++++++++++++++++------------------- 2 files changed, 24 insertions(+), 19 deletions(-)
target/rx/cpu.h +1 -0
@@ -149,6 +149,7 @@ static inline void cpu_get_tb_cpu_state(CPURXState *env, target_ulong *pc, *pc = env->pc; *cs_base =0 ; *flags =FIELD_DP32 (0 ,PSW ,PM , env->psw_pm); + *flags =FIELD_DP32 (*flags,PSW ,U , env->psw_u); }static inline int cpu_mmu_index (CPURXState *env,bool ifetch)
target/rx/translate.c +23 -19
107 lines not on this page · raw message
Signature · 1 line
2.34.1
[PULL 4/7] target/rx: Swap stack pointers on clrpsw/setpsw instruction
In reply to Richard HendersonWe properly perform this swap in helper_set_psw for MVTC, but we missed doing so for the CLRPSW/SETPSW of the U bit.
Message-Id: <[email protected]>
--- target/rx/translate.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
target/rx/translate.c +6 -1
@@ -2165,7 +2165,12 @@ static inline void clrsetpsw(DisasContext *ctx, int cb, int val) ctx->base.is_jmp =DISAS_UPDATE ;break ;case PSW_U : -tcg_gen_movi_i32 (cpu_psw_u, val); +if (FIELD_EX32 (ctx->tb_flags,PSW ,U ) != val) { + ctx->tb_flags =FIELD_DP32 (ctx->tb_flags,PSW ,U , val); +tcg_gen_movi_i32 (cpu_psw_u, val); +tcg_gen_mov_i32 (val ? cpu_isp : cpu_usp, cpu_sp); +tcg_gen_mov_i32 (cpu_sp, val ? cpu_usp : cpu_isp); + }break ;default :qemu_log_mask (LOG_GUEST_ERROR ,"Invalid distination %d" , cb);
Signature · 1 line
2.34.1
[PULL 5/7] hw/rx: rx-gdbsim DTB load address aligned of 16byte.
In reply to Richard HendersonFrom: Yoshinori Sato <[email protected]>
Linux kernel required alined address of DTB.
But missing align in dtb load function.
Fixed to load to the correct address.
Message-Id: <[email protected]>
--- hw/rx/rx-gdbsim.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/rx/rx-gdbsim.c +1 -1
@@ -141,7 +141,7 @@ static void rx_gdbsim_init(MachineState *machine)exit (1 ); }/* DTB is located at the end of SDRAM space. */ - dtb_offset = machine->ram_size - dtb_size; + dtb_offset =ROUND_DOWN (machine->ram_size - dtb_size,16 );rom_add_blob_fixed ("dtb" , dtb, dtb_size,SDRAM_BASE + dtb_offset);/* Set dtb address to R1 */
Signature · 1 line
2.34.1
[PULL 6/7] target/rx: set PSW.I when executing wait instruction
In reply to Richard HendersonFrom: Tomoaki Kawada <[email protected]>
This patch fixes the implementation of the wait instruction to implicitly update PSW.I as required by the ISA specification.
Message-Id: <[email protected]>
--- target/rx/op_helper.c | 1 + 1 file changed, 1 insertion(+)
target/rx/op_helper.c +1 -0
@@ -448,6 +448,7 @@ void QEMU_NORETURN helper_wait(CPURXState *env) cs->halted =1 ; env->in_sleep =1 ; + env->psw_i =1 ;raise_exception (env,EXCP_HLT ,0 ); }
Signature · 1 line
2.34.1
[PULL 7/7] target/rx: update PC correctly in wait instruction
In reply to Richard HendersonFrom: Tomoaki Kawada <[email protected]>
cpu_pc at this point does not necessary point to the current instruction (i.e., the wait instruction being translated), so it's incorrect to calculate the new value of cpu_pc based on this. It must be updated with ctx->base.pc_next, which contains the correct address of the next instruction.
This change fixes the wait instruction skipping the subsequent branch when used in an idle loop like this:
0: wait
bra.b 0b
brk // should be unreachable
Message-Id: <[email protected]>
--- target/rx/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/rx/translate.c +1 -1
@@ -2285,7 +2285,7 @@ static bool trans_INT(DisasContext *ctx, arg_INT *a)static bool trans_WAIT (DisasContext *ctx,arg_WAIT *a) {if (is_privileged (ctx,1 )) { -tcg_gen_addi_i32 (cpu_pc, cpu_pc,2 ); +tcg_gen_movi_i32 (cpu_pc, ctx->base.pc_next);gen_helper_wait (cpu_env); }return true;
Signature · 1 line
2.34.1
Richard Henderson
AppliedQuoted 8 lines · Richard Henderson
The following changes since commit
401d46789410e88e9e90d76a11f46e8e9f358d55:Merge tag 'pull-target-arm-20220421' of https://git.linaro.org/people/pmaydell/qemu-arm into staging (2022-04-21 08:04:43 -0700)are available in the Git repository at:
https://gitlab.com/rth7680/qemu.git tags/pull-rx-20220421
Quoted 8 lines
for you to fetch changes up to
724eaecec6d22cf3842f896684bdc5b79492f093:target/rx: update PC correctly in wait instruction (2022-04-21 10:09:12 -0700)
----------------------------------------------------------------
Fix usp/isp swapping upon clrpsw/setpsw.
Fix psw.i/pc upon wait.
Align dtb in ram.
Applied, thanks. Please update https://wiki.qemu.org/ChangeLog/7.1 as appropriate.
r~
Quoted 20 lines
----------------------------------------------------------------
Richard Henderson (4):
target/rx: Puttb_flagsinto DisasContext target/rx: Store PSW.U intb->flags
target/rx: MoveDISAS_UPDATEcheck for write to PSW target/rx: Swap stack pointers on clrpsw/setpsw instructionTomoaki Kawada (2):
target/rx: set PSW.I when executing wait instruction target/rx: update PC correctly in wait instructionYoshinori Sato (1):
hw/rx: rx-gdbsim DTB load address aligned of 16byte.target/rx/cpu.h | 1 + hw/rx/rx-gdbsim.c | 2 +- target/rx/op_helper.c | 1 + target/rx/translate.c | 69 +++++++++++++++++++++++++++------------------------ 4 files changed, 40 insertions(+), 33 deletions(-)