From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>
Subject: [PULL 08/11] target/mips: Honour -semihosting-config userspace=on
Date: Wed, 14 Sep 2022 14:23:05 +0100 [thread overview]
Message-ID: <20220914132308.118495-9-richard.henderson@linaro.org> (raw)
In-Reply-To: <20220914132308.118495-1-richard.henderson@linaro.org>
From: Peter Maydell <peter.maydell@linaro.org>
Honour the commandline -semihosting-config userspace=on option,
instead of always permitting userspace semihosting calls in system
emulation mode, by passing the correct value to the is_userspace
argument of semihosting_enabled().
Note that this is a behaviour change: if the user wants to
do semihosting calls from userspace they must now specifically
enable them on the command line.
MIPS semihosting is not implemented for linux-user builds.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20220822141230.3658237-5-peter.maydell@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/mips/tcg/translate.c | 9 +++++----
target/mips/tcg/micromips_translate.c.inc | 6 +++---
target/mips/tcg/mips16e_translate.c.inc | 2 +-
target/mips/tcg/nanomips_translate.c.inc | 4 ++--
4 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/target/mips/tcg/translate.c b/target/mips/tcg/translate.c
index 0d936e2648..c3f92ea652 100644
--- a/target/mips/tcg/translate.c
+++ b/target/mips/tcg/translate.c
@@ -12082,12 +12082,13 @@ static void gen_cache_operation(DisasContext *ctx, uint32_t op, int base,
tcg_temp_free_i32(t0);
}
-static inline bool is_uhi(int sdbbp_code)
+static inline bool is_uhi(DisasContext *ctx, int sdbbp_code)
{
#ifdef CONFIG_USER_ONLY
return false;
#else
- return semihosting_enabled() && sdbbp_code == 1;
+ bool is_user = (ctx->hflags & MIPS_HFLAG_KSU) == MIPS_HFLAG_UM;
+ return semihosting_enabled(is_user) && sdbbp_code == 1;
#endif
}
@@ -13898,7 +13899,7 @@ static void decode_opc_special_r6(CPUMIPSState *env, DisasContext *ctx)
}
break;
case R6_OPC_SDBBP:
- if (is_uhi(extract32(ctx->opcode, 6, 20))) {
+ if (is_uhi(ctx, extract32(ctx->opcode, 6, 20))) {
ctx->base.is_jmp = DISAS_SEMIHOST;
} else {
if (ctx->hflags & MIPS_HFLAG_SBRI) {
@@ -14310,7 +14311,7 @@ static void decode_opc_special2_legacy(CPUMIPSState *env, DisasContext *ctx)
gen_cl(ctx, op1, rd, rs);
break;
case OPC_SDBBP:
- if (is_uhi(extract32(ctx->opcode, 6, 20))) {
+ if (is_uhi(ctx, extract32(ctx->opcode, 6, 20))) {
ctx->base.is_jmp = DISAS_SEMIHOST;
} else {
/*
diff --git a/target/mips/tcg/micromips_translate.c.inc b/target/mips/tcg/micromips_translate.c.inc
index b2c696f891..632895cc9e 100644
--- a/target/mips/tcg/micromips_translate.c.inc
+++ b/target/mips/tcg/micromips_translate.c.inc
@@ -825,7 +825,7 @@ static void gen_pool16c_insn(DisasContext *ctx)
generate_exception_break(ctx, extract32(ctx->opcode, 0, 4));
break;
case SDBBP16:
- if (is_uhi(extract32(ctx->opcode, 0, 4))) {
+ if (is_uhi(ctx, extract32(ctx->opcode, 0, 4))) {
ctx->base.is_jmp = DISAS_SEMIHOST;
} else {
/*
@@ -941,7 +941,7 @@ static void gen_pool16c_r6_insn(DisasContext *ctx)
break;
case R6_SDBBP16:
/* SDBBP16 */
- if (is_uhi(extract32(ctx->opcode, 6, 4))) {
+ if (is_uhi(ctx, extract32(ctx->opcode, 6, 4))) {
ctx->base.is_jmp = DISAS_SEMIHOST;
} else {
if (ctx->hflags & MIPS_HFLAG_SBRI) {
@@ -1310,7 +1310,7 @@ static void gen_pool32axf(CPUMIPSState *env, DisasContext *ctx, int rt, int rs)
generate_exception_end(ctx, EXCP_SYSCALL);
break;
case SDBBP:
- if (is_uhi(extract32(ctx->opcode, 16, 10))) {
+ if (is_uhi(ctx, extract32(ctx->opcode, 16, 10))) {
ctx->base.is_jmp = DISAS_SEMIHOST;
} else {
check_insn(ctx, ISA_MIPS_R1);
diff --git a/target/mips/tcg/mips16e_translate.c.inc b/target/mips/tcg/mips16e_translate.c.inc
index 7568933e23..918b15d55c 100644
--- a/target/mips/tcg/mips16e_translate.c.inc
+++ b/target/mips/tcg/mips16e_translate.c.inc
@@ -951,7 +951,7 @@ static int decode_ase_mips16e(CPUMIPSState *env, DisasContext *ctx)
}
break;
case RR_SDBBP:
- if (is_uhi(extract32(ctx->opcode, 5, 6))) {
+ if (is_uhi(ctx, extract32(ctx->opcode, 5, 6))) {
ctx->base.is_jmp = DISAS_SEMIHOST;
} else {
/*
diff --git a/target/mips/tcg/nanomips_translate.c.inc b/target/mips/tcg/nanomips_translate.c.inc
index b3aff22c18..812c111e3c 100644
--- a/target/mips/tcg/nanomips_translate.c.inc
+++ b/target/mips/tcg/nanomips_translate.c.inc
@@ -3694,7 +3694,7 @@ static int decode_nanomips_32_48_opc(CPUMIPSState *env, DisasContext *ctx)
generate_exception_end(ctx, EXCP_BREAK);
break;
case NM_SDBBP:
- if (is_uhi(extract32(ctx->opcode, 0, 19))) {
+ if (is_uhi(ctx, extract32(ctx->opcode, 0, 19))) {
ctx->base.is_jmp = DISAS_SEMIHOST;
} else {
if (ctx->hflags & MIPS_HFLAG_SBRI) {
@@ -4633,7 +4633,7 @@ static int decode_isa_nanomips(CPUMIPSState *env, DisasContext *ctx)
generate_exception_end(ctx, EXCP_BREAK);
break;
case NM_SDBBP16:
- if (is_uhi(extract32(ctx->opcode, 0, 3))) {
+ if (is_uhi(ctx, extract32(ctx->opcode, 0, 3))) {
ctx->base.is_jmp = DISAS_SEMIHOST;
} else {
if (ctx->hflags & MIPS_HFLAG_SBRI) {
--
2.34.1
next prev parent reply other threads:[~2022-09-14 13:45 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-14 13:22 [PULL 00/11] semihosting patch queue Richard Henderson
2022-09-14 13:22 ` [PULL 01/11] target/nios2: Use semihosting/syscalls.h Richard Henderson
2022-09-14 13:22 ` [PULL 02/11] target/nios2: Convert semihosting errno to gdb remote errno Richard Henderson
2022-09-14 13:23 ` [PULL 03/11] target/m68k: Use semihosting/syscalls.h Richard Henderson
2022-09-14 13:23 ` [PULL 04/11] target/m68k: Convert semihosting errno to gdb remote errno Richard Henderson
2022-09-14 13:23 ` [PULL 05/11] semihosting: Allow optional use of semihosting from userspace Richard Henderson
2022-09-14 13:23 ` [PULL 06/11] target/arm: Honour -semihosting-config userspace=on Richard Henderson
2022-09-14 13:23 ` [PULL 07/11] target/m68k: " Richard Henderson
2022-09-14 13:23 ` Richard Henderson [this message]
2022-09-14 13:23 ` [PULL 09/11] target/nios2: " Richard Henderson
2022-09-14 13:23 ` [PULL 10/11] target/xtensa: " Richard Henderson
2022-09-14 13:23 ` [PULL 11/11] target/riscv: Honour -semihosting-config userspace=on and enable=on Richard Henderson
2022-09-17 20:14 ` [PULL 00/11] semihosting patch queue Stefan Hajnoczi
2022-09-20 13:01 ` Peter Maydell
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=20220914132308.118495-9-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=f4bug@amsat.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/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).