All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: Peter Maydell <peter.maydell@linaro.org>,
	qemu-arm@nongnu.org, qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org, "Alex Bennée" <alex.bennee@linaro.org>,
	"Laurent Vivier" <laurent@vivier.eu>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
	"Aleksandar Rikalo" <aleksandar.rikalo@syrmia.com>,
	"Stefan Pejic" <stefan.pejic@syrmia.com>,
	"Chris Wulff" <crwulff@gmail.com>, "Marek Vasut" <marex@denx.de>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Alistair Francis" <alistair.francis@wdc.com>,
	"Bin Meng" <bin.meng@windriver.com>,
	"Max Filippov" <jcmvbkbc@gmail.com>,
	"Furquan Shaikh" <furquan@rivosinc.com>
Subject: Re: [PATCH 7/7] target/riscv: Honour -semihosting-config userspace=on and enable=on
Date: Mon, 15 Aug 2022 15:26:55 -0500	[thread overview]
Message-ID: <08d41c28-728a-0ef2-c528-b55c4984ca2b@linaro.org> (raw)
In-Reply-To: <20220815190303.2061559-8-peter.maydell@linaro.org>

On 8/15/22 14:03, Peter Maydell wrote:
> The riscv target incorrectly enabled semihosting always, whether the
> user asked for it or not.  Call semihosting_enabled() passing the
> correct value to the is_userspace argument, which fixes this and also
> handles the userspace=on argument.
> 
> Note that this is a behaviour change: we used to default to
> semihosting being enabled, and now the user must pass
> "-semihosting-config enable=on" if they want it.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   target/riscv/cpu_helper.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/target/riscv/cpu_helper.c b/target/riscv/cpu_helper.c
> index 59b3680b1b2..49c4ea98ac9 100644
> --- a/target/riscv/cpu_helper.c
> +++ b/target/riscv/cpu_helper.c
> @@ -24,6 +24,7 @@
>   #include "exec/exec-all.h"
>   #include "tcg/tcg-op.h"
>   #include "trace.h"
> +#include "semihosting/semihost.h"
>   #include "semihosting/common-semi.h"
>   
>   int riscv_cpu_mmu_index(CPURISCVState *env, bool ifetch)
> @@ -1342,7 +1343,7 @@ void riscv_cpu_do_interrupt(CPUState *cs)
>       target_ulong mtval2 = 0;
>   
>       if  (cause == RISCV_EXCP_SEMIHOST) {
> -        if (env->priv >= PRV_S) {
> +        if (semihosting_enabled(env->priv < PRV_S)) {
>               do_common_semihosting(cs);
>               env->pc += 4;
>               return;

I think this should be done in translate.  We should not have the overhead of checking the 
three insn sequence around ebreak unless semihosting is enabled.  Note that ctx->mem_idx 
== env->priv, per cpu_mem_index().


r~



  reply	other threads:[~2022-08-15 20:28 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-15 19:02 [PATCH 0/7] Allow semihosting from user mode Peter Maydell
2022-08-15 19:02 ` [PATCH 1/7] semihosting: Allow optional use of semihosting from userspace Peter Maydell
2022-08-16  0:27   ` Philippe Mathieu-Daudé via
2022-08-16  0:27     ` Philippe Mathieu-Daudé
2022-08-16  8:50   ` Alex Bennée
2022-08-18  4:17   ` Alistair Francis
2022-08-15 19:02 ` [PATCH 2/7] target/arm: Honour -semihosting-config userspace=on Peter Maydell
2022-08-15 19:02 ` [PATCH 3/7] target/m68k: " Peter Maydell
2022-08-16 10:55   ` Laurent Vivier
2022-08-15 19:03 ` [PATCH 4/7] target/mips: " Peter Maydell
2022-08-16  0:33   ` Philippe Mathieu-Daudé via
2022-08-16  0:33     ` Philippe Mathieu-Daudé
2022-08-15 19:03 ` [PATCH 5/7] target/nios2: " Peter Maydell
2022-08-15 19:03 ` [PATCH 6/7] target/xtensa: " Peter Maydell
2022-08-15 23:15   ` Max Filippov
2022-08-16  0:35   ` Philippe Mathieu-Daudé via
2022-08-16  0:35     ` Philippe Mathieu-Daudé
2022-08-15 19:03 ` [PATCH 7/7] target/riscv: Honour -semihosting-config userspace=on and enable=on Peter Maydell
2022-08-15 20:26   ` Richard Henderson [this message]
2022-08-16  5:39     ` Furquan Shaikh
2022-08-18  4:19   ` Alistair Francis
2022-08-18 13:57     ` Peter Maydell
2022-08-19  0:55       ` Alistair Francis
2022-08-19  9:09         ` Peter Maydell
2022-08-15 20:27 ` [PATCH 0/7] Allow semihosting from user mode Richard Henderson

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=08d41c28-728a-0ef2-c528-b55c4984ca2b@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=aleksandar.rikalo@syrmia.com \
    --cc=alex.bennee@linaro.org \
    --cc=alistair.francis@wdc.com \
    --cc=bin.meng@windriver.com \
    --cc=crwulff@gmail.com \
    --cc=f4bug@amsat.org \
    --cc=furquan@rivosinc.com \
    --cc=jcmvbkbc@gmail.com \
    --cc=jiaxun.yang@flygoat.com \
    --cc=laurent@vivier.eu \
    --cc=marex@denx.de \
    --cc=palmer@dabbelt.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=stefan.pejic@syrmia.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 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.