[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 05/35] target/ppc: Suppress single step interrupts on rfi-type ins
From: |
Cédric Le Goater |
Subject: |
[PULL 05/35] target/ppc: Suppress single step interrupts on rfi-type instructions |
Date: |
Mon, 4 Sep 2023 11:06:00 +0200 |
From: Nicholas Piggin <npiggin@gmail.com>
BookS does not take single step interrupts on completion of rfi and
similar (rfid, hrfid, rfscv). This is not a completely clean way to
do it, but in general non-branch instructions that change NIP on
completion are excluded.
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
---
target/ppc/translate.c | 23 +++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)
diff --git a/target/ppc/translate.c b/target/ppc/translate.c
index 505159667083..6e8f1797ac95 100644
--- a/target/ppc/translate.c
+++ b/target/ppc/translate.c
@@ -338,7 +338,7 @@ static void gen_ppc_maybe_interrupt(DisasContext *ctx)
* The exception can be either POWERPC_EXCP_TRACE (on most PowerPCs) or
* POWERPC_EXCP_DEBUG (on BookE).
*/
-static void gen_debug_exception(DisasContext *ctx)
+static void gen_debug_exception(DisasContext *ctx, bool rfi_type)
{
#if !defined(CONFIG_USER_ONLY)
if (ctx->flags & POWERPC_FLAG_DE) {
@@ -357,10 +357,12 @@ static void gen_debug_exception(DisasContext *ctx)
tcg_constant_i32(POWERPC_EXCP_DEBUG));
ctx->base.is_jmp = DISAS_NORETURN;
} else {
- TCGv t0 = tcg_temp_new();
- tcg_gen_movi_tl(t0, ctx->cia);
- gen_helper_book3s_trace(cpu_env, t0);
- ctx->base.is_jmp = DISAS_NORETURN;
+ if (!rfi_type) { /* BookS does not single step rfi type instructions */
+ TCGv t0 = tcg_temp_new();
+ tcg_gen_movi_tl(t0, ctx->cia);
+ gen_helper_book3s_trace(cpu_env, t0);
+ ctx->base.is_jmp = DISAS_NORETURN;
+ }
}
#endif
}
@@ -7412,6 +7414,8 @@ static void ppc_tr_tb_stop(DisasContextBase *dcbase,
CPUState *cs)
/* Honor single stepping. */
if (unlikely(ctx->singlestep_enabled & CPU_SINGLE_STEP)) {
+ bool rfi_type = false;
+
switch (is_jmp) {
case DISAS_TOO_MANY:
case DISAS_EXIT_UPDATE:
@@ -7420,12 +7424,19 @@ static void ppc_tr_tb_stop(DisasContextBase *dcbase,
CPUState *cs)
break;
case DISAS_EXIT:
case DISAS_CHAIN:
+ /*
+ * This is a heuristic, to put it kindly. The rfi class of
+ * instructions are among the few outside branches that change
+ * NIP without taking an interrupt. Single step trace interrupts
+ * do not fire on completion of these instructions.
+ */
+ rfi_type = true;
break;
default:
g_assert_not_reached();
}
- gen_debug_exception(ctx);
+ gen_debug_exception(ctx, rfi_type);
return;
}
--
2.41.0
- [PULL 00/35] ppc queue, Cédric Le Goater, 2023/09/04
- [PULL 02/35] ppc: Add stub implementation of TRIG SPRs, Cédric Le Goater, 2023/09/04
- [PULL 03/35] target/ppc: Remove single-step suppression inside 0x100-0xf00, Cédric Le Goater, 2023/09/04
- [PULL 06/35] target/ppc: Implement breakpoint debug facility for v2.07S, Cédric Le Goater, 2023/09/04
- [PULL 01/35] target/ppc: Generate storage interrupts for radix RC changes, Cédric Le Goater, 2023/09/04
- [PULL 05/35] target/ppc: Suppress single step interrupts on rfi-type instructions,
Cédric Le Goater <=
- [PULL 04/35] target/ppc: Improve book3s branch trace interrupt for v2.07S, Cédric Le Goater, 2023/09/04
- [PULL 07/35] target/ppc: Implement watchpoint debug facility for v2.07S, Cédric Le Goater, 2023/09/04
- [PULL 08/35] spapr: implement H_SET_MODE debug facilities, Cédric Le Goater, 2023/09/04
- [PULL 09/35] ppc/vhyp: reset exception state when handling vhyp hcall, Cédric Le Goater, 2023/09/04
- [PULL 10/35] ppc/vof: Fix missed fields in VOF cleanup, Cédric Le Goater, 2023/09/04
- [PULL 11/35] hw/ppc/ppc.c: Tidy over-long lines, Cédric Le Goater, 2023/09/04
- [PULL 12/35] hw/ppc: Introduce functions for conversion between timebase and nanoseconds, Cédric Le Goater, 2023/09/04
- [PULL 13/35] host-utils: Add muldiv64_round_up, Cédric Le Goater, 2023/09/04
- [PULL 14/35] hw/ppc: Round up the decrementer interval when converting to ns, Cédric Le Goater, 2023/09/04
- [PULL 15/35] hw/ppc: Avoid decrementer rounding errors, Cédric Le Goater, 2023/09/04