Skip to contentSkip to conversation

target/ppc: Fix icount access for some hypervisor instructions

PATCH Applied Nicholas Piggin 4 participants 6 messages Jun 25, 2023 – Jun 30, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 target/ppc: Fix icount access for some hypervisor instructions

Several instructions and register access require icount reads and are missing translator_io_start().

---
 target/ppc/translate.c | 7 +++++++
 1 file changed, 7 insertions(+)
target/ppc/translate.c +7 -0
index eb278c2683..c1c3cd8767 100644
@@ -1177,6 +1177,7 @@ void spr_write_hmer(DisasContext *ctx, int sprn, int gprn)
 
 void spr_write_lpcr(DisasContext *ctx, int sprn, int gprn)
 {
+    translator_io_start(&ctx->base);
     gen_helper_store_lpcr(cpu_env, cpu_gpr[gprn]);
 }
 #endif /* !defined(CONFIG_USER_ONLY) */
@@ -4002,6 +4003,7 @@ static void gen_doze(DisasContext *ctx)
     TCGv_i32 t;
 
     CHK_HV(ctx);
+    translator_io_start(&ctx->base);
     t = tcg_constant_i32(PPC_PM_DOZE);
     gen_helper_pminsn(cpu_env, t);
     /* Stop translation, as the CPU is supposed to sleep from now */
@@ -4017,6 +4019,7 @@ static void gen_nap(DisasContext *ctx)
     TCGv_i32 t;
 
     CHK_HV(ctx);
+    translator_io_start(&ctx->base);
     t = tcg_constant_i32(PPC_PM_NAP);
     gen_helper_pminsn(cpu_env, t);
     /* Stop translation, as the CPU is supposed to sleep from now */
@@ -4032,6 +4035,7 @@ static void gen_stop(DisasContext *ctx)
     TCGv_i32 t;
 
     CHK_HV(ctx);
+    translator_io_start(&ctx->base);
     t = tcg_constant_i32(PPC_PM_STOP);
     gen_helper_pminsn(cpu_env, t);
     /* Stop translation, as the CPU is supposed to sleep from now */
@@ -4047,6 +4051,7 @@ static void gen_sleep(DisasContext *ctx)
     TCGv_i32 t;
 
     CHK_HV(ctx);
+    translator_io_start(&ctx->base);
     t = tcg_constant_i32(PPC_PM_SLEEP);
     gen_helper_pminsn(cpu_env, t);
     /* Stop translation, as the CPU is supposed to sleep from now */
@@ -4062,6 +4067,7 @@ static void gen_rvwinkle(DisasContext *ctx)
     TCGv_i32 t;
 
     CHK_HV(ctx);
+    translator_io_start(&ctx->base);
     t = tcg_constant_i32(PPC_PM_RVWINKLE);
     gen_helper_pminsn(cpu_env, t);
     /* Stop translation, as the CPU is supposed to sleep from now */
@@ -4458,6 +4464,7 @@ static void gen_hrfid(DisasContext *ctx)
 #else
     /* Restore CPU state */
     CHK_HV(ctx);
+    translator_io_start(&ctx->base);
     gen_helper_hrfid(cpu_env);
     ctx->base.is_jmp = DISAS_EXIT;
 #endif
Signature · 1 line
2.40.1
#1 lore raw

PATCH 2/2 tests/avocado: record_replay test for ppc powernv machine

The powernv machine can boot Linux to VFS mount with icount enabled. Add a test case for it.

---
 tests/avocado/replay_kernel.py | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
tests/avocado/replay_kernel.py +16 -0
index a4dc8c0d6c..dc350fd781 100644
@@ -258,6 +258,22 @@ def test_ppc64_pseries(self):
         console_pattern = 'VFS: Cannot open root device'
         self.run_rr(kernel_path, kernel_command_line, console_pattern)
 
+    def test_ppc64_powernv(self):
+        """
+        :avocado: tags=arch:ppc64
+        :avocado: tags=machine:powernv
+        :avocado: tags=accel:tcg
+        """
+        kernel_url = ('https://archives.fedoraproject.org/pub/archive'
+                      '/fedora-secondary/releases/29/Everything/ppc64le/os'
+                      '/ppc/ppc64/vmlinuz')
+        kernel_hash = '3fe04abfc852b66653b8c3c897a59a689270bc77'
+        kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
+
+        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=tty0 console=hvc0'
+        console_pattern = 'VFS: Cannot open root device'
+        self.run_rr(kernel_path, kernel_command_line, console_pattern)
+
     def test_m68k_q800(self):
         """
         :avocado: tags=arch:m68k
Signature · 1 line
2.40.1
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] tests/avocado: record_replay test for ppc powernv machine

Quoted 4 lines · Nicholas Piggin

The powernv machine can boot Linux to VFS mount with icount enabled. Add a test case for it.

Thanks,

C.

Quoted 31 lines
---
  tests/avocado/replay_kernel.py | 16 ++++++++++++++++
  1 file changed, 16 insertions(+)
tests/avocado/replay_kernel.py +16 -0
index a4dc8c0d6c..dc350fd781 100644
@@ -258,6 +258,22 @@ def test_ppc64_pseries(self):
          console_pattern = 'VFS: Cannot open root device'
          self.run_rr(kernel_path, kernel_command_line, console_pattern)
 
+    def test_ppc64_powernv(self):
+        """
+        :avocado: tags=arch:ppc64
+        :avocado: tags=machine:powernv
+        :avocado: tags=accel:tcg
+        """
+        kernel_url = ('https://archives.fedoraproject.org/pub/archive'
+                      '/fedora-secondary/releases/29/Everything/ppc64le/os'
+                      '/ppc/ppc64/vmlinuz')
+        kernel_hash = '3fe04abfc852b66653b8c3c897a59a689270bc77'
+        kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
+
+        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=tty0 console=hvc0'
+        console_pattern = 'VFS: Cannot open root device'
+        self.run_rr(kernel_path, kernel_command_line, console_pattern)
+
      def test_m68k_q800(self):
          """
          :avocado: tags=arch:m68k
#3 lore raw

Re: [PATCH 2/2] tests/avocado: record_replay test for ppc powernv machine

In reply to Nicholas Piggin
Quoted 5 lines · Nicholas Piggin

The powernv machine can boot Linux to VFS mount with icount enabled. Add a test case for it.

---

Queued in gitlab.com/danielhb/qemu/tree/ppc-next. Thanks,

Daniel

Quoted 30 lines
  tests/avocado/replay_kernel.py | 16 ++++++++++++++++
  1 file changed, 16 insertions(+)
tests/avocado/replay_kernel.py +16 -0
index a4dc8c0d6c..dc350fd781 100644
@@ -258,6 +258,22 @@ def test_ppc64_pseries(self):
          console_pattern = 'VFS: Cannot open root device'
          self.run_rr(kernel_path, kernel_command_line, console_pattern)
 
+    def test_ppc64_powernv(self):
+        """
+        :avocado: tags=arch:ppc64
+        :avocado: tags=machine:powernv
+        :avocado: tags=accel:tcg
+        """
+        kernel_url = ('https://archives.fedoraproject.org/pub/archive'
+                      '/fedora-secondary/releases/29/Everything/ppc64le/os'
+                      '/ppc/ppc64/vmlinuz')
+        kernel_hash = '3fe04abfc852b66653b8c3c897a59a689270bc77'
+        kernel_path = self.fetch_asset(kernel_url, asset_hash=kernel_hash)
+
+        kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=tty0 console=hvc0'
+        console_pattern = 'VFS: Cannot open root device'
+        self.run_rr(kernel_path, kernel_command_line, console_pattern)
+
      def test_m68k_q800(self):
          """
          :avocado: tags=arch:m68k
#5 lore raw
In reply to Nicholas Piggin
Quoted 5 lines · Nicholas Piggin

Several instructions and register access require icount reads and are missing translator_io_start().

---

Queued in gitlab.com/danielhb/qemu/tree/ppc-next. Thanks,

Daniel

Quoted 63 lines
  target/ppc/translate.c | 7 +++++++
  1 file changed, 7 insertions(+)
target/ppc/translate.c +7 -0
index eb278c2683..c1c3cd8767 100644
@@ -1177,6 +1177,7 @@ void spr_write_hmer(DisasContext *ctx, int sprn, int gprn)
 
  void spr_write_lpcr(DisasContext *ctx, int sprn, int gprn)
  {
+    translator_io_start(&ctx->base);
      gen_helper_store_lpcr(cpu_env, cpu_gpr[gprn]);
  }
  #endif /* !defined(CONFIG_USER_ONLY) */
@@ -4002,6 +4003,7 @@ static void gen_doze(DisasContext *ctx)
      TCGv_i32 t;
 
      CHK_HV(ctx);
+    translator_io_start(&ctx->base);
      t = tcg_constant_i32(PPC_PM_DOZE);
      gen_helper_pminsn(cpu_env, t);
      /* Stop translation, as the CPU is supposed to sleep from now */
@@ -4017,6 +4019,7 @@ static void gen_nap(DisasContext *ctx)
      TCGv_i32 t;
 
      CHK_HV(ctx);
+    translator_io_start(&ctx->base);
      t = tcg_constant_i32(PPC_PM_NAP);
      gen_helper_pminsn(cpu_env, t);
      /* Stop translation, as the CPU is supposed to sleep from now */
@@ -4032,6 +4035,7 @@ static void gen_stop(DisasContext *ctx)
      TCGv_i32 t;
 
      CHK_HV(ctx);
+    translator_io_start(&ctx->base);
      t = tcg_constant_i32(PPC_PM_STOP);
      gen_helper_pminsn(cpu_env, t);
      /* Stop translation, as the CPU is supposed to sleep from now */
@@ -4047,6 +4051,7 @@ static void gen_sleep(DisasContext *ctx)
      TCGv_i32 t;
 
      CHK_HV(ctx);
+    translator_io_start(&ctx->base);
      t = tcg_constant_i32(PPC_PM_SLEEP);
      gen_helper_pminsn(cpu_env, t);
      /* Stop translation, as the CPU is supposed to sleep from now */
@@ -4062,6 +4067,7 @@ static void gen_rvwinkle(DisasContext *ctx)
      TCGv_i32 t;
 
      CHK_HV(ctx);
+    translator_io_start(&ctx->base);
      t = tcg_constant_i32(PPC_PM_RVWINKLE);
      gen_helper_pminsn(cpu_env, t);
      /* Stop translation, as the CPU is supposed to sleep from now */
@@ -4458,6 +4464,7 @@ static void gen_hrfid(DisasContext *ctx)
  #else
      /* Restore CPU state */
      CHK_HV(ctx);
+    translator_io_start(&ctx->base);
      gen_helper_hrfid(cpu_env);
      ctx->base.is_jmp = DISAS_EXIT;
  #endif