From: Richard Henderson <richard.henderson@linaro.org>
To: Wentong Wu <wentong.wu@intel.com>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, marex@denx.de, crwulff@gmail.com,
peter.maydell@linaro.org
Subject: Re: [PATCH 3/3] target/nios2: Use gen_io_start around wrctl instruction
Date: Thu, 2 Jul 2020 11:53:34 -0700 [thread overview]
Message-ID: <3260735e-05ab-2d42-f7e4-914ad804f543@linaro.org> (raw)
In-Reply-To: <20200629160535.3910-3-wentong.wu@intel.com>
On 6/29/20 9:05 AM, Wentong Wu wrote:
> 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
This isn't right. Not so much the gen_io_start portion, but the entire
existence of helper_check_interrupt.
The correct way to acknowledge interrupts after changing an interrupt mask bit
is to exit the TB back to the cpu main loop.
Which you are doing here with DISAS_UPDATE, so that part is fine. (Although
you could merge that into the switch statement above.)
Looking at nios_pic_cpu_handler, there are two other bugs:
1) Get rid of env->irq_pending and use cpu_interrupt/cpu_reset_interrupt instead.
2) Do not check env->regs[CR_STATUS] & CR_STATUS_PIE. That variable does not
belong to the pic and should not be checked there. The check belongs in
nios2_cpu_exec_interrupt, and is in fact already there.
r~
next prev parent reply other threads:[~2020-07-02 18:54 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-29 16:05 [PATCH 1/3] target/nios2: add DISAS_NORETURN case for nothing more to generate Wentong Wu
2020-06-29 16:05 ` [PATCH 2/3] target/nios2: in line the semantics of DISAS_UPDATE with other targets Wentong Wu
2020-07-02 18:14 ` Richard Henderson
2020-07-02 18:25 ` Richard Henderson
2020-06-29 16:05 ` [PATCH 3/3] target/nios2: Use gen_io_start around wrctl instruction Wentong Wu
2020-07-01 13:26 ` Wu, Wentong
2020-07-02 18:53 ` Richard Henderson [this message]
2020-07-03 13:22 ` Wu, Wentong
2020-07-05 13:22 ` Wu, Wentong
2020-07-05 13:24 ` Wu, Wentong
2020-07-05 17:08 ` Peter Maydell
2020-07-05 18:16 ` Max Filippov
2020-07-05 20:53 ` Max Filippov
2020-07-06 8:55 ` Peter Maydell
2020-07-06 0:56 ` Wu, Wentong
2020-07-03 15:14 ` Wu, Wentong
2020-07-05 17:10 ` Peter Maydell
2020-07-06 0:30 ` Wu, Wentong
2020-07-07 2:41 ` Wu, Wentong
2020-07-02 18:12 ` [PATCH 1/3] target/nios2: add DISAS_NORETURN case for nothing more to generate Richard Henderson
-- strict thread matches above, loose matches on Subject: below --
2020-07-09 11:58 [PATCH 3/3] target/nios2: Use gen_io_start around wrctl instruction Wu, Wentong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3260735e-05ab-2d42-f7e4-914ad804f543@linaro.org \
--to=richard.henderson@linaro.org \
--cc=crwulff@gmail.com \
--cc=marex@denx.de \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.org \
--cc=wentong.wu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).