* [RFC PATCH 0/2] target/sh4: Disable decode_gusa when plugins enabled
@ 2023-08-24 18:12 Richard Henderson
2023-08-24 18:12 ` [PATCH 1/2] accel/tcg: Add plugin_enabled to DisasContextBase Richard Henderson
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Richard Henderson @ 2023-08-24 18:12 UTC (permalink / raw)
To: qemu-devel; +Cc: alex.bennee
Alex, perhaps this will DTRT for your plugin test case.
r~
Richard Henderson (2):
accel/tcg: Add plugin_enabled to DisasContextBase
target/sh4: Disable decode_gusa when plugins enabled
include/exec/translator.h | 2 ++
accel/tcg/translator.c | 1 +
target/sh4/translate.c | 41 +++++++++++++++++++++++++++------------
3 files changed, 32 insertions(+), 12 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] accel/tcg: Add plugin_enabled to DisasContextBase
2023-08-24 18:12 [RFC PATCH 0/2] target/sh4: Disable decode_gusa when plugins enabled Richard Henderson
@ 2023-08-24 18:12 ` Richard Henderson
2023-08-24 18:12 ` [PATCH 2/2] target/sh4: Disable decode_gusa when plugins enabled Richard Henderson
2023-08-30 18:44 ` [RFC PATCH 0/2] " Alex Bennée
2 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2023-08-24 18:12 UTC (permalink / raw)
To: qemu-devel; +Cc: alex.bennee
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
include/exec/translator.h | 2 ++
accel/tcg/translator.c | 1 +
2 files changed, 3 insertions(+)
diff --git a/include/exec/translator.h b/include/exec/translator.h
index a53d3243d4..e89c182cca 100644
--- a/include/exec/translator.h
+++ b/include/exec/translator.h
@@ -72,6 +72,7 @@ typedef enum DisasJumpType {
* @num_insns: Number of translated instructions (including current).
* @max_insns: Maximum number of instructions to be translated in this TB.
* @singlestep_enabled: "Hardware" single stepping enabled.
+ * @plugin_enabled: TCG plugin enabled in this TB.
*
* Architecture-agnostic disassembly context.
*/
@@ -83,6 +84,7 @@ typedef struct DisasContextBase {
int num_insns;
int max_insns;
bool singlestep_enabled;
+ bool plugin_enabled;
void *host_addr[2];
} DisasContextBase;
diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c
index 1a6a5448c8..37f8dadbbd 100644
--- a/accel/tcg/translator.c
+++ b/accel/tcg/translator.c
@@ -156,6 +156,7 @@ void translator_loop(CPUState *cpu, TranslationBlock *tb, int *max_insns,
tcg_debug_assert(db->is_jmp == DISAS_NEXT); /* no early exit */
plugin_enabled = plugin_gen_tb_start(cpu, db, cflags & CF_MEMI_ONLY);
+ db->plugin_enabled = plugin_enabled;
while (true) {
*max_insns = ++db->num_insns;
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] target/sh4: Disable decode_gusa when plugins enabled
2023-08-24 18:12 [RFC PATCH 0/2] target/sh4: Disable decode_gusa when plugins enabled Richard Henderson
2023-08-24 18:12 ` [PATCH 1/2] accel/tcg: Add plugin_enabled to DisasContextBase Richard Henderson
@ 2023-08-24 18:12 ` Richard Henderson
2023-08-30 18:44 ` [RFC PATCH 0/2] " Alex Bennée
2 siblings, 0 replies; 4+ messages in thread
From: Richard Henderson @ 2023-08-24 18:12 UTC (permalink / raw)
To: qemu-devel; +Cc: alex.bennee
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
target/sh4/translate.c | 41 +++++++++++++++++++++++++++++------------
1 file changed, 29 insertions(+), 12 deletions(-)
diff --git a/target/sh4/translate.c b/target/sh4/translate.c
index 49c87d7a01..f2bdd1d0fc 100644
--- a/target/sh4/translate.c
+++ b/target/sh4/translate.c
@@ -1817,6 +1817,18 @@ static void decode_opc(DisasContext * ctx)
}
#ifdef CONFIG_USER_ONLY
+/*
+ * Restart with the EXCLUSIVE bit set, within a TB run via
+ * cpu_exec_step_atomic holding the exclusive lock.
+ */
+static void gen_restart_exclusive(DisasContext *ctx)
+{
+ ctx->envflags |= TB_FLAG_GUSA_EXCLUSIVE;
+ gen_save_cpu_state(ctx, false);
+ gen_helper_exclusive(cpu_env);
+ ctx->base.is_jmp = DISAS_NORETURN;
+}
+
/* For uniprocessors, SH4 uses optimistic restartable atomic sequences.
Upon an interrupt, a real kernel would simply notice magic values in
the registers and reset the PC to the start of the sequence.
@@ -2150,12 +2162,7 @@ static void decode_gusa(DisasContext *ctx, CPUSH4State *env)
qemu_log_mask(LOG_UNIMP, "Unrecognized gUSA sequence %08x-%08x\n",
pc, pc_end);
- /* Restart with the EXCLUSIVE bit set, within a TB run via
- cpu_exec_step_atomic holding the exclusive lock. */
- ctx->envflags |= TB_FLAG_GUSA_EXCLUSIVE;
- gen_save_cpu_state(ctx, false);
- gen_helper_exclusive(cpu_env);
- ctx->base.is_jmp = DISAS_NORETURN;
+ gen_restart_exclusive(ctx);
/* We're not executing an instruction, but we must report one for the
purposes of accounting within the TB. We might as well report the
@@ -2243,12 +2250,22 @@ static void sh4_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs)
#ifdef CONFIG_USER_ONLY
if (unlikely(ctx->envflags & TB_FLAG_GUSA_MASK)
&& !(ctx->envflags & TB_FLAG_GUSA_EXCLUSIVE)) {
- /* We're in an gUSA region, and we have not already fallen
- back on using an exclusive region. Attempt to parse the
- region into a single supported atomic operation. Failure
- is handled within the parser by raising an exception to
- retry using an exclusive region. */
- decode_gusa(ctx, env);
+ /*
+ * We're in an gUSA region, and we have not already fallen
+ * back on using an exclusive region. Attempt to parse the
+ * region into a single supported atomic operation. Failure
+ * is handled within the parser by raising an exception to
+ * retry using an exclusive region.
+ *
+ * Parsing the region in one block conflicts with plugins,
+ * so always use exclusive mode if plugins enabled.
+ */
+ if (ctx->base.plugin_enabled) {
+ gen_restart_exclusive(ctx);
+ ctx->base.pc_next += 2;
+ } else {
+ decode_gusa(ctx, env);
+ }
return;
}
#endif
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [RFC PATCH 0/2] target/sh4: Disable decode_gusa when plugins enabled
2023-08-24 18:12 [RFC PATCH 0/2] target/sh4: Disable decode_gusa when plugins enabled Richard Henderson
2023-08-24 18:12 ` [PATCH 1/2] accel/tcg: Add plugin_enabled to DisasContextBase Richard Henderson
2023-08-24 18:12 ` [PATCH 2/2] target/sh4: Disable decode_gusa when plugins enabled Richard Henderson
@ 2023-08-30 18:44 ` Alex Bennée
2 siblings, 0 replies; 4+ messages in thread
From: Alex Bennée @ 2023-08-30 18:44 UTC (permalink / raw)
To: Richard Henderson; +Cc: qemu-devel
Richard Henderson <richard.henderson@linaro.org> writes:
> Alex, perhaps this will DTRT for your plugin test case.
It does thanks, queued to plugins/next.
>
> r~
>
> Richard Henderson (2):
> accel/tcg: Add plugin_enabled to DisasContextBase
> target/sh4: Disable decode_gusa when plugins enabled
>
> include/exec/translator.h | 2 ++
> accel/tcg/translator.c | 1 +
> target/sh4/translate.c | 41 +++++++++++++++++++++++++++------------
> 3 files changed, 32 insertions(+), 12 deletions(-)
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-08-30 18:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-24 18:12 [RFC PATCH 0/2] target/sh4: Disable decode_gusa when plugins enabled Richard Henderson
2023-08-24 18:12 ` [PATCH 1/2] accel/tcg: Add plugin_enabled to DisasContextBase Richard Henderson
2023-08-24 18:12 ` [PATCH 2/2] target/sh4: Disable decode_gusa when plugins enabled Richard Henderson
2023-08-30 18:44 ` [RFC PATCH 0/2] " Alex Bennée
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).