All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/4] target/nios2: add DISAS_NORETURN case for nothing more to generate
@ 2020-07-10 23:34 Wentong Wu
  2020-07-10 23:34 ` [PATCH v2 2/4] target/nios2: in line the semantics of DISAS_UPDATE with other targets Wentong Wu
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Wentong Wu @ 2020-07-10 23:34 UTC (permalink / raw)
  To: qemu-devel, peter.maydell; +Cc: qemu-trivial, marex, crwulff, Wentong Wu

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.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
---
 target/nios2/translate.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/target/nios2/translate.c b/target/nios2/translate.c
index e17656e6..b052be85 100644
--- a/target/nios2/translate.c
+++ b/target/nios2/translate.c
@@ -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;
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/4] target/nios2: in line the semantics of DISAS_UPDATE with other targets
  2020-07-10 23:34 [PATCH v2 1/4] target/nios2: add DISAS_NORETURN case for nothing more to generate Wentong Wu
@ 2020-07-10 23:34 ` Wentong Wu
  2020-07-10 23:34 ` [PATCH v2 3/4] target/nios2: Use gen_io_start around wrctl instruction Wentong Wu
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Wentong Wu @ 2020-07-10 23:34 UTC (permalink / raw)
  To: qemu-devel, peter.maydell; +Cc: qemu-trivial, marex, crwulff, Wentong Wu

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().

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
---
 target/nios2/translate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/nios2/translate.c b/target/nios2/translate.c
index b052be85..83c10eb2 100644
--- a/target/nios2/translate.c
+++ b/target/nios2/translate.c
@@ -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;
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 3/4] target/nios2: Use gen_io_start around wrctl instruction
  2020-07-10 23:34 [PATCH v2 1/4] target/nios2: add DISAS_NORETURN case for nothing more to generate Wentong Wu
  2020-07-10 23:34 ` [PATCH v2 2/4] target/nios2: in line the semantics of DISAS_UPDATE with other targets Wentong Wu
@ 2020-07-10 23:34 ` Wentong Wu
  2020-07-10 23:34 ` [PATCH v2 4/4] hw/nios2: exit to main CPU loop only when unmasking interrupts Wentong Wu
  2020-07-11 18:49 ` [PATCH v2 1/4] target/nios2: add DISAS_NORETURN case for nothing more to generate Peter Maydell
  3 siblings, 0 replies; 6+ messages in thread
From: Wentong Wu @ 2020-07-10 23:34 UTC (permalink / raw)
  To: qemu-devel, peter.maydell; +Cc: qemu-trivial, marex, crwulff, Wentong Wu

wrctl 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.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
---
 target/nios2/translate.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/target/nios2/translate.c b/target/nios2/translate.c
index 83c10eb2..51347ada 100644
--- a/target/nios2/translate.c
+++ b/target/nios2/translate.c
@@ -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
 }
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 4/4] hw/nios2: exit to main CPU loop only when unmasking interrupts
  2020-07-10 23:34 [PATCH v2 1/4] target/nios2: add DISAS_NORETURN case for nothing more to generate Wentong Wu
  2020-07-10 23:34 ` [PATCH v2 2/4] target/nios2: in line the semantics of DISAS_UPDATE with other targets Wentong Wu
  2020-07-10 23:34 ` [PATCH v2 3/4] target/nios2: Use gen_io_start around wrctl instruction Wentong Wu
@ 2020-07-10 23:34 ` Wentong Wu
  2020-07-11 18:49 ` [PATCH v2 1/4] target/nios2: add DISAS_NORETURN case for nothing more to generate Peter Maydell
  3 siblings, 0 replies; 6+ messages in thread
From: Wentong Wu @ 2020-07-10 23:34 UTC (permalink / raw)
  To: qemu-devel, peter.maydell; +Cc: qemu-trivial, marex, crwulff, Wentong Wu

Only 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.

Signed-off-by: Wentong Wu <wentong.wu@intel.com>
---
 hw/nios2/cpu_pic.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/nios2/cpu_pic.c b/hw/nios2/cpu_pic.c
index 1c1989d5..5ea7e52a 100644
--- a/hw/nios2/cpu_pic.c
+++ b/hw/nios2/cpu_pic.c
@@ -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);
     }
-- 
2.21.3



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/4] target/nios2: add DISAS_NORETURN case for nothing more to generate
  2020-07-10 23:34 [PATCH v2 1/4] target/nios2: add DISAS_NORETURN case for nothing more to generate Wentong Wu
                   ` (2 preceding siblings ...)
  2020-07-10 23:34 ` [PATCH v2 4/4] hw/nios2: exit to main CPU loop only when unmasking interrupts Wentong Wu
@ 2020-07-11 18:49 ` Peter Maydell
  2020-07-12 15:18   ` Wu, Wentong
  3 siblings, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2020-07-11 18:49 UTC (permalink / raw)
  To: Wentong Wu; +Cc: QEMU Trivial, Marek Vasut, Chris Wulff, QEMU Developers

On Fri, 10 Jul 2020 at 16:46, Wentong Wu <wentong.wu@intel.com> wrote:
>
> 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.
>
> Signed-off-by: Wentong Wu <wentong.wu@intel.com>

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [PATCH v2 1/4] target/nios2: add DISAS_NORETURN case for nothing more to generate
  2020-07-11 18:49 ` [PATCH v2 1/4] target/nios2: add DISAS_NORETURN case for nothing more to generate Peter Maydell
@ 2020-07-12 15:18   ` Wu, Wentong
  0 siblings, 0 replies; 6+ messages in thread
From: Wu, Wentong @ 2020-07-12 15:18 UTC (permalink / raw)
  To: Peter Maydell; +Cc: QEMU Trivial, Marek Vasut, Chris Wulff, QEMU Developers

> -----Original Message-----
> From: Peter Maydell <peter.maydell@linaro.org> 
> Sent: Sunday, July 12, 2020 2:50 AM
> To: Wu, Wentong <wentong.wu@intel.com>
> Cc: QEMU Developers <qemu-devel@nongnu.org>; QEMU Trivial <qemu-trivial@nongnu.org>; Chris Wulff <crwulff@gmail.com>; Marek Vasut <marex@denx.de>
> Subject: Re: [PATCH v2 1/4] target/nios2: add DISAS_NORETURN case for nothing more to generate
> 
> On Fri, 10 Jul 2020 at 16:46, Wentong Wu <wentong.wu@intel.com> wrote:
> >
> > 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.
> >
> > Signed-off-by: Wentong Wu <wentong.wu@intel.com>
> 
> 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

> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-07-12 15:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-10 23:34 [PATCH v2 1/4] target/nios2: add DISAS_NORETURN case for nothing more to generate Wentong Wu
2020-07-10 23:34 ` [PATCH v2 2/4] target/nios2: in line the semantics of DISAS_UPDATE with other targets Wentong Wu
2020-07-10 23:34 ` [PATCH v2 3/4] target/nios2: Use gen_io_start around wrctl instruction Wentong Wu
2020-07-10 23:34 ` [PATCH v2 4/4] hw/nios2: exit to main CPU loop only when unmasking interrupts Wentong Wu
2020-07-11 18:49 ` [PATCH v2 1/4] target/nios2: add DISAS_NORETURN case for nothing more to generate Peter Maydell
2020-07-12 15:18   ` Wu, Wentong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.