target/nios2: add DISAS_NORETURN case for nothing more to generate
PATCH v2 1/4 target/nios2: add DISAS_NORETURN case for nothing more to generate
Add DISAS_NORETURN case for nothing more to generate because at runtime execution will never return from some helper call. And at the same time replace DISAS_UPDATE in t_gen_helper_raise_exception and gen_exception with the newly added DISAS_NORETURN.
--- target/nios2/translate.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
target/nios2/translate.c +3 -2
@@ -149,7 +149,7 @@ static void t_gen_helper_raise_exception(DisasContext *dc,tcg_gen_movi_tl (dc->cpu_R[R_PC ], dc->pc);gen_helper_raise_exception (dc->cpu_env, tmp);tcg_temp_free_i32 (tmp); - dc->is_jmp =DISAS_UPDATE ; + dc->is_jmp =DISAS_NORETURN ; }static bool use_goto_tb (DisasContext *dc,uint32_t dest)
@@ -802,7 +802,7 @@ static void gen_exception(DisasContext *dc, uint32_t excp)tcg_gen_movi_tl (cpu_R[R_PC ], dc->pc);gen_helper_raise_exception (cpu_env, tmp);tcg_temp_free_i32 (tmp); - dc->is_jmp =DISAS_UPDATE ; + dc->is_jmp =DISAS_NORETURN ; }/* generate intermediate code for basic block 'tb'. */
@@ -877,6 +877,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)tcg_gen_exit_tb (NULL ,0 );break ; +case DISAS_NORETURN :case DISAS_TB_JUMP :/* nothing more to generate */ break ;
Signature · 1 line
2.21.3
PATCH v2 2/4 target/nios2: in line the semantics of DISAS_UPDATE with other targets
In line the semantics of DISAS_UPDATE on nios2 target with other targets which is to explicitly write the PC back into the cpu state before doing a tcg_gen_exit_tb().
--- target/nios2/translate.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
target/nios2/translate.c +1 -1
@@ -865,6 +865,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)/* Indicate where the next block should start */ switch (dc->is_jmp) {case DISAS_NEXT : +case DISAS_UPDATE :/* Save the current PC back into the CPU register */ tcg_gen_movi_tl (cpu_R[R_PC ], dc->pc);tcg_gen_exit_tb (NULL ,0 );
@@ -872,7 +873,6 @@ void gen_intermediate_code(CPUState *cs, TranslationBlock *tb, int max_insns)default :case DISAS_JUMP : -case DISAS_UPDATE :/* The jump will already have updated the PC register */ tcg_gen_exit_tb (NULL ,0 );break ;
Signature · 1 line
2.21.3
PATCH v2 3/4 target/nios2: Use gen_io_start around wrctl instruction
In reply to Wentong Wuwrctl instruction on nios2 target will cause checking cpu interrupt but tcg_handle_interrupt() will call cpu_abort() if the CPU gets an interrupt while it's not in 'can do IO' state, so add gen_io_start around wrctl instruction. Also at the same time, end the onging TB with DISAS_UPDATE.
--- target/nios2/translate.c | 5 +++++ 1 file changed, 5 insertions(+)
target/nios2/translate.c +5 -0
@@ -32,6 +32,7 @@#include "exec/cpu_ldst.h" #include "exec/translator.h" #include "qemu/qemu-print.h" +#include "exec/gen-icount.h" /* is_jmp field values */ #define DISAS_JUMP DISAS_TARGET_0/* only pc was modified dynamically */
@@ -518,7 +519,11 @@ static void wrctl(DisasContext *dc, uint32_t code, uint32_t flags)/* If interrupts were enabled using WRCTL, trigger them. */ #if !defined(CONFIG_USER_ONLY )if ((instr.imm5 +CR_BASE ) ==CR_STATUS ) { +if (tb_cflags (dc->tb) &CF_USE_ICOUNT ) { +gen_io_start (); + }gen_helper_check_interrupts (dc->cpu_env); + dc->is_jmp =DISAS_UPDATE ; }#endif }
Signature · 1 line
2.21.3
PATCH v2 4/4 hw/nios2: exit to main CPU loop only when unmasking interrupts
In reply to Wentong WuOnly when guest code is unmasking interrupts, terminate the excution of translated code and exit to the main CPU loop to handle previous pended interrupts because of the interrupts mask by guest code.
--- hw/nios2/cpu_pic.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
hw/nios2/cpu_pic.c +2 -1
@@ -54,7 +54,8 @@ static void nios2_pic_cpu_handler(void *opaque, int irq, int level)void nios2_check_interrupts (CPUNios2State *env) { -if (env->irq_pending) { +if (env->irq_pending && + (env->regs[CR_STATUS ] &CR_STATUS_PIE )) { env->irq_pending =0 ;cpu_interrupt (env_cpu (env),CPU_INTERRUPT_HARD ); }
Signature · 1 line
2.21.3
Quoted 7 lines · Wentong Wu
Add
DISAS_NORETURNcase for nothing more to generate because at runtime execution will never return from some helper call. And at the same time replaceDISAS_UPDATEint_gen_helper_raise_exceptionandgen_exceptionwith the newly addedDISAS_NORETURN.Signed-off-by Wentong Wu <[email protected]>
Hi; I'm going to pick these up and get them into master.
A couple of notes below for if you plan to submit more patches to QEMU in future: these are really just minor workflow things, but they do help make our lives easier in getting code submissions into the tree.
If people provide you with a Reviewed-by: tag for a patch, and you don't change it when you send out an updated version, it's helpful if you include that tag in the commit message of the revised version you send out. This saves people having to remember whether they'd reviewed something or not, and means that when applying I don't have to go back and look at old versions to see who reviewed what.
Patch series are much easier for our tooling to deal with if you send them out with a cover letter email (a 0/n email which all the other emails are followups to; git format-patch has a '--cover-letter' option which will do the right thing here).
We document this kind of workflow stuff here:
https://wiki.qemu.org/Contribute/SubmitAPatch
thanks
-- PMM
Quoted 14 lines
-----Original Message-----
From: Peter Maydell <[email protected]>
Sent: Sunday, July 12, 2020 2:50 AM
To: Wu, Wentong <[email protected]>
Cc: QEMU Developers <[email protected]>; QEMU Trivial <[email protected]>; Chris Wulff <[email protected]>; Marek Vasut <[email protected]>
Subject: Re: [PATCH v2 1/4] target/nios2: addDISAS_NORETURNcase for nothing more to generateQuoted 6 lines · Wentong Wu
Add
DISAS_NORETURNcase for nothing more to generate because at runtime execution will never return from some helper call. And at the same time replaceDISAS_UPDATEint_gen_helper_raise_exceptionandgen_exceptionwith the newly addedDISAS_NORETURN.
Quoted 5 lines
Quoted 1 line
Signed-off-by Wentong Wu <[email protected]>Hi; I'm going to pick these up and get them into master.
A couple of notes below for if you plan to submit more patches to QEMU in future: these are really just minor workflow things, but they do help make our lives easier in getting code submissions into the tree.
Thanks Peter, I will follow the process to submit more patches to QEMU project, and I really learn a lot! Thanks
Quoted 9 lines
If people provide you with a Reviewed-by: tag for a patch, and you don't change it when you send out an updated version, it's helpful if you include that tag in the commit message of the revised version you send out. This saves people having to remember whether they'd reviewed something or not, and means that when applying I don't have to go back and look at old versions to see who reviewed what.
Patch series are much easier for our tooling to deal with if you send them out with a cover letter email (a 0/n email which all the other emails are followups to; git format-patch has a '--cover-letter' option which will do the right thing here).
We document this kind of workflow stuff here:
https://wiki.qemu.org/Contribute/SubmitAPatchthanks
-- PMM