diff mbox series

[v2,09/12] accel/tcg: Restrict cpu_loop_exit_requested() to TCG

Message ID 20240428214915.10339-10-philmd@linaro.org
State New
Headers show
Series exec: Rework around CPUState user fields | expand

Commit Message

Philippe Mathieu-Daudé April 28, 2024, 9:49 p.m. UTC
cpu_loop_exit_requested() is specific to TCG, move it
to "exec/translate-all.h".

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/exec/exec-all.h       | 17 -----------------
 include/exec/translate-all.h  | 20 ++++++++++++++++++++
 target/arm/tcg/helper-a64.c   |  1 +
 target/s390x/tcg/mem_helper.c |  1 +
 4 files changed, 22 insertions(+), 17 deletions(-)

Comments

Richard Henderson April 28, 2024, 10:08 p.m. UTC | #1
On 4/28/24 14:49, Philippe Mathieu-Daudé wrote:
> cpu_loop_exit_requested() is specific to TCG, move it
> to "exec/translate-all.h".
> 
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   include/exec/exec-all.h       | 17 -----------------
>   include/exec/translate-all.h  | 20 ++++++++++++++++++++
>   target/arm/tcg/helper-a64.c   |  1 +
>   target/s390x/tcg/mem_helper.c |  1 +
>   4 files changed, 22 insertions(+), 17 deletions(-)

I guess we could dither about whether this is the best place, but I guess it doesn't 
matter.  Do you really need the CONFIG_TCG ifdef?

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


r~
Philippe Mathieu-Daudé April 28, 2024, 10:17 p.m. UTC | #2
On 29/4/24 00:08, Richard Henderson wrote:
> On 4/28/24 14:49, Philippe Mathieu-Daudé wrote:
>> cpu_loop_exit_requested() is specific to TCG, move it
>> to "exec/translate-all.h".
>>
>> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
>> ---
>>   include/exec/exec-all.h       | 17 -----------------
>>   include/exec/translate-all.h  | 20 ++++++++++++++++++++
>>   target/arm/tcg/helper-a64.c   |  1 +
>>   target/s390x/tcg/mem_helper.c |  1 +
>>   4 files changed, 22 insertions(+), 17 deletions(-)
> 
> I guess we could dither about whether this is the best place, but I 
> guess it doesn't matter.  Do you really need the CONFIG_TCG ifdef?

Right, actually 50 patches later it ends in "exec/cpu-loop.h",
and "exec/translate-all.h" is removed. I need to check whether
or not this patch is required at this stage, maybe not. Otherwise
I'll directly introduce "exec/cpu-loop.h" I guess.

> Either way,
> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
> 
> 
> r~
Philippe Mathieu-Daudé April 29, 2024, 9:23 p.m. UTC | #3
On 29/4/24 00:17, Philippe Mathieu-Daudé wrote:
> On 29/4/24 00:08, Richard Henderson wrote:
>> On 4/28/24 14:49, Philippe Mathieu-Daudé wrote:
>>> cpu_loop_exit_requested() is specific to TCG, move it
>>> to "exec/translate-all.h".
>>>
>>> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
>>> ---
>>>   include/exec/exec-all.h       | 17 -----------------
>>>   include/exec/translate-all.h  | 20 ++++++++++++++++++++
>>>   target/arm/tcg/helper-a64.c   |  1 +
>>>   target/s390x/tcg/mem_helper.c |  1 +
>>>   4 files changed, 22 insertions(+), 17 deletions(-)
>>
>> I guess we could dither about whether this is the best place, but I 
>> guess it doesn't matter.  Do you really need the CONFIG_TCG ifdef?
> 
> Right, actually 50 patches later it ends in "exec/cpu-loop.h",
> and "exec/translate-all.h" is removed. I need to check whether
> or not this patch is required at this stage, maybe not. Otherwise
> I'll directly introduce "exec/cpu-loop.h" I guess.

So we need it at this point because cpu_loop_exit_requested()
access neg.icount_decr, which we'll restrict in few commits
(I'll mention that in the commit description).

In "exec/translate-all.h" we don't need the CONFIG_TCG #ifdef,
but we'll need it in "exec/cpu-loop.h".

>> Either way,
>> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
>>
>>
>> r~
>
diff mbox series

Patch

diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h
index 4c5e470581..2be7ef1809 100644
--- a/include/exec/exec-all.h
+++ b/include/exec/exec-all.h
@@ -29,23 +29,6 @@ 
 #include "exec/translation-block.h"
 #include "qemu/clang-tsa.h"
 
-/**
- * cpu_loop_exit_requested:
- * @cpu: The CPU state to be tested
- *
- * Indicate if somebody asked for a return of the CPU to the main loop
- * (e.g., via cpu_exit() or cpu_interrupt()).
- *
- * This is helpful for architectures that support interruptible
- * instructions. After writing back all state to registers/memory, this
- * call can be used to check if it makes sense to return to the main loop
- * or to continue executing the interruptible instruction.
- */
-static inline bool cpu_loop_exit_requested(CPUState *cpu)
-{
-    return (int32_t)qatomic_read(&cpu->neg.icount_decr.u32) < 0;
-}
-
 #if !defined(CONFIG_USER_ONLY) && defined(CONFIG_TCG)
 /* cputlb.c */
 /**
diff --git a/include/exec/translate-all.h b/include/exec/translate-all.h
index 85c9460c7c..dd26f70378 100644
--- a/include/exec/translate-all.h
+++ b/include/exec/translate-all.h
@@ -19,8 +19,28 @@ 
 #ifndef TRANSLATE_ALL_H
 #define TRANSLATE_ALL_H
 
+#include "qemu/atomic.h"
 #include "exec/exec-all.h"
+#include "hw/core/cpu.h"
 
+#ifdef CONFIG_TCG
+/**
+ * cpu_loop_exit_requested:
+ * @cpu: The CPU state to be tested
+ *
+ * Indicate if somebody asked for a return of the CPU to the main loop
+ * (e.g., via cpu_exit() or cpu_interrupt()).
+ *
+ * This is helpful for architectures that support interruptible
+ * instructions. After writing back all state to registers/memory, this
+ * call can be used to check if it makes sense to return to the main loop
+ * or to continue executing the interruptible instruction.
+ */
+static inline bool cpu_loop_exit_requested(CPUState *cpu)
+{
+    return (int32_t)qatomic_read(&cpu->neg.icount_decr.u32) < 0;
+}
+#endif
 
 /* translate-all.c */
 void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr);
diff --git a/target/arm/tcg/helper-a64.c b/target/arm/tcg/helper-a64.c
index 0ea8668ab4..f78430da0d 100644
--- a/target/arm/tcg/helper-a64.c
+++ b/target/arm/tcg/helper-a64.c
@@ -29,6 +29,7 @@ 
 #include "internals.h"
 #include "qemu/crc32c.h"
 #include "exec/exec-all.h"
+#include "exec/translate-all.h"
 #include "exec/cpu_ldst.h"
 #include "qemu/int128.h"
 #include "qemu/atomic128.h"
diff --git a/target/s390x/tcg/mem_helper.c b/target/s390x/tcg/mem_helper.c
index 6a308c5553..17fab5e8be 100644
--- a/target/s390x/tcg/mem_helper.c
+++ b/target/s390x/tcg/mem_helper.c
@@ -25,6 +25,7 @@ 
 #include "tcg_s390x.h"
 #include "exec/helper-proto.h"
 #include "exec/exec-all.h"
+#include "exec/translate-all.h"
 #include "exec/page-protection.h"
 #include "exec/cpu_ldst.h"
 #include "hw/core/tcg-cpu-ops.h"