Skip to contentSkip to conversation

This patch fixes processing of rfi instructions in icount mode.

PATCH In review Pavel Dovgalyuk 3 participants 3 messages Oct 30, 2018 – Nov 8, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 This patch fixes processing of rfi instructions in icount mode.

From: Maria Klimushenkova <[email protected]>

In this mode writing to interrupt/peripheral state is controlled by can_do_io flag. This flag must be set explicitly before helper function invocation.

---
 target/ppc/translate.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
target/ppc/translate.c +12 -0
index 987ce6e..980862c 100644
@@ -3878,9 +3878,15 @@ static void gen_rfi(DisasContext *ctx)
     }
     /* Restore CPU state */
     CHK_SV;
+    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
+        gen_io_start();
+    }
     gen_update_cfar(ctx, ctx->base.pc_next - 4);
     gen_helper_rfi(cpu_env);
     gen_sync_exception(ctx);
+    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
+        gen_io_end();
+    }
 #endif
 }
 
@@ -3892,9 +3898,15 @@ static void gen_rfid(DisasContext *ctx)
 #else
     /* Restore CPU state */
     CHK_SV;
+    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
+        gen_io_start();
+    }
     gen_update_cfar(ctx, ctx->base.pc_next - 4);
     gen_helper_rfid(cpu_env);
     gen_sync_exception(ctx);
+    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
+        gen_io_end();
+    }
 #endif
 }
 
Tested-by on v1 1/1
#1 lore raw
Quoted 37 lines · Pavel Dovgalyuk

From: Maria Klimushenkova <[email protected]>

In this mode writing to interrupt/peripheral state is controlled by can_do_io flag. This flag must be set explicitly before helper function invocation.

---
 target/ppc/translate.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
target/ppc/translate.c +7 -0
index 987ce6e..980862c 100644
@@ -3878,9 +3878,15 @@ static void gen_rfi(DisasContext *ctx)
     }
     /* Restore CPU state */
     CHK_SV;
+    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
+        gen_io_start();
+    }
     gen_update_cfar(ctx, ctx->base.pc_next - 4);
     gen_helper_rfi(cpu_env);
     gen_sync_exception(ctx);
+    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
+        gen_io_end();
+    }
 #endif
 }
 
@@ -3892,9 +3898,15 @@ static void gen_rfid(DisasContext *ctx)
 #else
     /* Restore CPU state */
     CHK_SV;
+    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {

target/ppc/translate.c static void gen_rfid(DisasContext *ctx) · line 3911

Quoted 10 lines
target/ppc/translate.c +5 -0
+        gen_io_start();
+    }
     gen_update_cfar(ctx, ctx->base.pc_next - 4);
     gen_helper_rfid(cpu_env);
     gen_sync_exception(ctx);
+    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
+        gen_io_end();
+    }
 #endif
 }

I've given this patch a spin on top of ppc-for-3.1 and it allows my test images to boot with icount enabled without asserting, so:

ATB,

Mark.

#2 lore raw
Quoted 53 lines · Mark Cave-Ayland
Quoted 37 lines · Pavel Dovgalyuk

From: Maria Klimushenkova <[email protected]>

In this mode writing to interrupt/peripheral state is controlled by can_do_io flag. This flag must be set explicitly before helper function invocation.

---
 target/ppc/translate.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)
target/ppc/translate.c +7 -0
index 987ce6e..980862c 100644
@@ -3878,9 +3878,15 @@ static void gen_rfi(DisasContext *ctx)
     }
     /* Restore CPU state */
     CHK_SV;
+    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
+        gen_io_start();
+    }
     gen_update_cfar(ctx, ctx->base.pc_next - 4);
     gen_helper_rfi(cpu_env);
     gen_sync_exception(ctx);
+    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
+        gen_io_end();
+    }
 #endif
 }
 
@@ -3892,9 +3898,15 @@ static void gen_rfid(DisasContext *ctx)
 #else
     /* Restore CPU state */
     CHK_SV;
+    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {

target/ppc/translate.c static void gen_rfid(DisasContext *ctx) · line 3911

Quoted 10 lines
target/ppc/translate.c +5 -0
+        gen_io_start();
+    }
     gen_update_cfar(ctx, ctx->base.pc_next - 4);
     gen_helper_rfid(cpu_env);
     gen_sync_exception(ctx);
+    if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) {
+        gen_io_end();
+    }
 #endif
 }

I've given this patch a spin on top of ppc-for-3.1 and it allows my test images to boot with icount enabled without asserting, so:

Quoted 1 line

Good enough for me. Applied to ppc-for-3.1.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson