[RFC PATCH 16/34] exec: [CPUTLB] Move cpu_*()/cpu_env() to common header

Anton Johansson via posted 34 patches 10 months, 1 week ago
[RFC PATCH 16/34] exec: [CPUTLB] Move cpu_*()/cpu_env() to common header
Posted by Anton Johansson via 10 months, 1 week ago
Functions are target independent.

Signed-off-by: Anton Johansson <anjo@rev.ng>
---
 include/exec/cpu-all.h    | 25 -------------------------
 include/exec/cpu-common.h | 25 +++++++++++++++++++++++++
 2 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 968fbd4d16..4778976c4b 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -295,33 +295,8 @@ CPUArchState *cpu_copy(CPUArchState *env);
      | CPU_INTERRUPT_TGT_EXT_3   \
      | CPU_INTERRUPT_TGT_EXT_4)
 
-/* accel/tcg/cpu-exec.c */
-int cpu_exec(CPUState *cpu);
-
 /* Validate correct placement of CPUArchState. */
 QEMU_BUILD_BUG_ON(offsetof(ArchCPU, parent_obj) != 0);
 QEMU_BUILD_BUG_ON(offsetof(ArchCPU, env) != sizeof(CPUState));
 
-/**
- * env_archcpu(env)
- * @env: The architecture environment
- *
- * Return the ArchCPU associated with the environment.
- */
-static inline ArchCPU *env_archcpu(CPUArchState *env)
-{
-    return (void *)env - sizeof(CPUState);
-}
-
-/**
- * env_cpu(env)
- * @env: The architecture environment
- *
- * Return the CPUState associated with the environment.
- */
-static inline CPUState *env_cpu(CPUArchState *env)
-{
-    return (void *)env - sizeof(CPUState);
-}
-
 #endif /* CPU_ALL_H */
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index d3c8b2cf55..25e50aaa37 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -347,4 +347,29 @@ G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc);
  */
 #define PAGE_PASSTHROUGH 0x0800
 
+/* accel/tcg/cpu-exec.c */
+int cpu_exec(CPUState *cpu);
+
+/**
+ * env_archcpu(env)
+ * @env: The architecture environment
+ *
+ * Return the ArchCPU associated with the environment.
+ */
+static inline ArchCPU *env_archcpu(CPUArchState *env)
+{
+    return (void *)env - sizeof(CPUState);
+}
+
+/**
+ * env_cpu(env)
+ * @env: The architecture environment
+ *
+ * Return the CPUState associated with the environment.
+ */
+static inline CPUState *env_cpu(CPUArchState *env)
+{
+    return (void *)env - sizeof(CPUState);
+}
+
 #endif /* CPU_COMMON_H */
-- 
2.43.0
Re: [RFC PATCH 16/34] exec: [CPUTLB] Move cpu_*()/cpu_env() to common header
Posted by Richard Henderson 10 months ago
On 1/20/24 00:40, Anton Johansson wrote:
> --- a/include/exec/cpu-common.h
> +++ b/include/exec/cpu-common.h
> @@ -347,4 +347,29 @@ G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc);
>    */
>   #define PAGE_PASSTHROUGH 0x0800
>   
> +/* accel/tcg/cpu-exec.c */
> +int cpu_exec(CPUState *cpu);
> +
> +/**
> + * env_archcpu(env)
> + * @env: The architecture environment
> + *
> + * Return the ArchCPU associated with the environment.
> + */
> +static inline ArchCPU *env_archcpu(CPUArchState *env)
> +{
> +    return (void *)env - sizeof(CPUState);
> +}
> +
> +/**
> + * env_cpu(env)
> + * @env: The architecture environment
> + *
> + * Return the CPUState associated with the environment.
> + */
> +static inline CPUState *env_cpu(CPUArchState *env)
> +{
> +    return (void *)env - sizeof(CPUState);
> +}
> +
>   #endif /* CPU_COMMON_H */

Missing include of hw/core/cpu.h, as far as I can see?


r~
Re: [RFC PATCH 16/34] exec: [CPUTLB] Move cpu_*()/cpu_env() to common header
Posted by Richard Henderson 10 months ago
On 1/28/24 08:14, Richard Henderson wrote:
> On 1/20/24 00:40, Anton Johansson wrote:
>> --- a/include/exec/cpu-common.h
>> +++ b/include/exec/cpu-common.h
>> @@ -347,4 +347,29 @@ G_NORETURN void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc);
>>    */
>>   #define PAGE_PASSTHROUGH 0x0800
>> +/* accel/tcg/cpu-exec.c */
>> +int cpu_exec(CPUState *cpu);
>> +
>> +/**
>> + * env_archcpu(env)
>> + * @env: The architecture environment
>> + *
>> + * Return the ArchCPU associated with the environment.
>> + */
>> +static inline ArchCPU *env_archcpu(CPUArchState *env)
>> +{
>> +    return (void *)env - sizeof(CPUState);
>> +}
>> +
>> +/**
>> + * env_cpu(env)
>> + * @env: The architecture environment
>> + *
>> + * Return the CPUState associated with the environment.
>> + */
>> +static inline CPUState *env_cpu(CPUArchState *env)
>> +{
>> +    return (void *)env - sizeof(CPUState);
>> +}
>> +
>>   #endif /* CPU_COMMON_H */
> 
> Missing include of hw/core/cpu.h, as far as I can see?

Queued, with this fix.

r~


Re: [RFC PATCH 16/34] exec: [CPUTLB] Move cpu_*()/cpu_env() to common header
Posted by Richard Henderson 10 months, 1 week ago
On 1/20/24 00:40, Anton Johansson wrote:
> Functions are target independent.
> 
> Signed-off-by: Anton Johansson<anjo@rev.ng>
> ---
>   include/exec/cpu-all.h    | 25 -------------------------
>   include/exec/cpu-common.h | 25 +++++++++++++++++++++++++
>   2 files changed, 25 insertions(+), 25 deletions(-)

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

r~