[PATCH 3/3] target/ppc: Re-use gen_pause() in gen_wait()

Philippe Mathieu-Daudé posted 3 patches 3 days, 21 hours ago
Maintainers: Bernhard Beschow <shentey@gmail.com>, Nicholas Piggin <npiggin@gmail.com>, Chinmay Rath <rathc@linux.ibm.com>
[PATCH 3/3] target/ppc: Re-use gen_pause() in gen_wait()
Posted by Philippe Mathieu-Daudé 3 days, 21 hours ago
Avoid open-coding gen_pause() in gen_wait().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/ppc/translate.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/target/ppc/translate.c b/target/ppc/translate.c
index a1a97e0fd2e..1b5d2521deb 100644
--- a/target/ppc/translate.c
+++ b/target/ppc/translate.c
@@ -1982,17 +1982,18 @@ static inline void gen_op_arith_subf(DisasContext *ctx, TCGv ret, TCGv arg1,
 
 /***                            Integer logical                            ***/
 
-#if defined(TARGET_PPC64) && !defined(CONFIG_USER_ONLY)
 static void gen_pause(DisasContext *ctx)
 {
     TCGv_i32 t0 = tcg_constant_i32(1);
     tcg_gen_st_i32(t0, tcg_env,
                    -offsetof(PowerPCCPU, env) + offsetof(CPUState, halted));
 
-    /* Stop translation, this gives other CPUs a chance to run */
+    /*
+     * Stop translation, as the CPU is supposed to sleep from now,
+     * giving other CPUs a chance to run
+     */
     gen_exception_nip(ctx, EXCP_HLT, ctx->base.pc_next);
 }
-#endif /* defined(TARGET_PPC64) */
 
 /***                             Integer rotate                            ***/
 
@@ -3368,11 +3369,7 @@ static void gen_wait(DisasContext *ctx)
      * to occur.
      */
     if (wc == 0) {
-        TCGv_i32 t0 = tcg_constant_i32(1);
-        tcg_gen_st_i32(t0, tcg_env,
-                       -offsetof(PowerPCCPU, env) + offsetof(CPUState, halted));
-        /* Stop translation, as the CPU is supposed to sleep from now */
-        gen_exception_nip(ctx, EXCP_HLT, ctx->base.pc_next);
+        gen_pause(ctx);
     }
 
     /*
-- 
2.51.0


Re: [PATCH 3/3] target/ppc: Re-use gen_pause() in gen_wait()
Posted by Richard Henderson 3 days, 21 hours ago
On 9/24/25 10:30, Philippe Mathieu-Daudé wrote:
> Avoid open-coding gen_pause() in gen_wait().
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   target/ppc/translate.c | 13 +++++--------
>   1 file changed, 5 insertions(+), 8 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>


r~