[PATCH 05/10] accel/tcg: Move cpu_unwind_state_data() declaration

Philippe Mathieu-Daudé posted 10 patches 1 week, 1 day ago
[PATCH 05/10] accel/tcg: Move cpu_unwind_state_data() declaration
Posted by Philippe Mathieu-Daudé 1 week, 1 day ago
cpu_unwind_state_data() is specific to TCG accelerator,
move it to "exec/translate-all.h".

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/exec/cpu-common.h    | 13 -------------
 include/exec/translate-all.h | 12 ++++++++++++
 2 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index 638dc806a5..b36fbf2a39 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -193,19 +193,6 @@ void tcg_cflags_set(CPUState *cpu, uint32_t flags);
 /* current cflags for hashing/comparison */
 uint32_t curr_cflags(CPUState *cpu);
 
-/**
- * cpu_unwind_state_data:
- * @cpu: the cpu context
- * @host_pc: the host pc within the translation
- * @data: output data
- *
- * Attempt to load the the unwind state for a host pc occurring in
- * translated code.  If @host_pc is not in translated code, the
- * function returns false; otherwise @data is loaded.
- * This is the same unwind info as given to restore_state_to_opc.
- */
-bool cpu_unwind_state_data(CPUState *cpu, uintptr_t host_pc, uint64_t *data);
-
 /**
  * cpu_restore_state:
  * @cpu: the cpu context
diff --git a/include/exec/translate-all.h b/include/exec/translate-all.h
index 85c9460c7c..f06cfedd52 100644
--- a/include/exec/translate-all.h
+++ b/include/exec/translate-all.h
@@ -21,6 +21,18 @@
 
 #include "exec/exec-all.h"
 
+/**
+ * cpu_unwind_state_data:
+ * @cpu: the cpu context
+ * @host_pc: the host pc within the translation
+ * @data: output data
+ *
+ * Attempt to load the the unwind state for a host pc occurring in
+ * translated code.  If @host_pc is not in translated code, the
+ * function returns false; otherwise @data is loaded.
+ * This is the same unwind info as given to restore_state_to_opc.
+ */
+bool cpu_unwind_state_data(CPUState *cpu, uintptr_t host_pc, uint64_t *data);
 
 /* translate-all.c */
 void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr);
-- 
2.45.2


Re: [PATCH 05/10] accel/tcg: Move cpu_unwind_state_data() declaration
Posted by Peter Maydell 1 week, 1 day ago
On Fri, 15 Nov 2024 at 15:21, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>
> cpu_unwind_state_data() is specific to TCG accelerator,
> move it to "exec/translate-all.h".
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>  include/exec/cpu-common.h    | 13 -------------
>  include/exec/translate-all.h | 12 ++++++++++++
>  2 files changed, 12 insertions(+), 13 deletions(-)
>
> diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
> index 638dc806a5..b36fbf2a39 100644
> --- a/include/exec/cpu-common.h
> +++ b/include/exec/cpu-common.h
> @@ -193,19 +193,6 @@ void tcg_cflags_set(CPUState *cpu, uint32_t flags);
>  /* current cflags for hashing/comparison */
>  uint32_t curr_cflags(CPUState *cpu);
>
> -/**
> - * cpu_unwind_state_data:
> - * @cpu: the cpu context
> - * @host_pc: the host pc within the translation
> - * @data: output data
> - *
> - * Attempt to load the the unwind state for a host pc occurring in
> - * translated code.  If @host_pc is not in translated code, the
> - * function returns false; otherwise @data is loaded.
> - * This is the same unwind info as given to restore_state_to_opc.
> - */
> -bool cpu_unwind_state_data(CPUState *cpu, uintptr_t host_pc, uint64_t *data);
> -
>  /**
>   * cpu_restore_state:
>   * @cpu: the cpu context
> diff --git a/include/exec/translate-all.h b/include/exec/translate-all.h
> index 85c9460c7c..f06cfedd52 100644
> --- a/include/exec/translate-all.h
> +++ b/include/exec/translate-all.h
> @@ -21,6 +21,18 @@
>
>  #include "exec/exec-all.h"
>
> +/**
> + * cpu_unwind_state_data:
> + * @cpu: the cpu context
> + * @host_pc: the host pc within the translation
> + * @data: output data
> + *
> + * Attempt to load the the unwind state for a host pc occurring in
> + * translated code.  If @host_pc is not in translated code, the
> + * function returns false; otherwise @data is loaded.
> + * This is the same unwind info as given to restore_state_to_opc.
> + */
> +bool cpu_unwind_state_data(CPUState *cpu, uintptr_t host_pc, uint64_t *data);
>
>  /* translate-all.c */
>  void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr);

This function is used by some code in target/i386 and
target/openrisc, but a quick grep suggests that they don't
include translate-all.h or any other header that would pull
it in indirectly.

It also seems a bit odd to move the cpu_unwind_state_data()
prototype but not the similar cpu_restore_state() (which is
also TCG-only).

thanks
-- PMM
Re: [PATCH 05/10] accel/tcg: Move cpu_unwind_state_data() declaration
Posted by Philippe Mathieu-Daudé 1 week, 1 day ago
On 15/11/24 15:48, Peter Maydell wrote:
> On Fri, 15 Nov 2024 at 15:21, Philippe Mathieu-Daudé <philmd@linaro.org> wrote:
>>
>> cpu_unwind_state_data() is specific to TCG accelerator,
>> move it to "exec/translate-all.h".
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   include/exec/cpu-common.h    | 13 -------------
>>   include/exec/translate-all.h | 12 ++++++++++++
>>   2 files changed, 12 insertions(+), 13 deletions(-)
>>
>> diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
>> index 638dc806a5..b36fbf2a39 100644
>> --- a/include/exec/cpu-common.h
>> +++ b/include/exec/cpu-common.h
>> @@ -193,19 +193,6 @@ void tcg_cflags_set(CPUState *cpu, uint32_t flags);
>>   /* current cflags for hashing/comparison */
>>   uint32_t curr_cflags(CPUState *cpu);
>>
>> -/**
>> - * cpu_unwind_state_data:
>> - * @cpu: the cpu context
>> - * @host_pc: the host pc within the translation
>> - * @data: output data
>> - *
>> - * Attempt to load the the unwind state for a host pc occurring in
>> - * translated code.  If @host_pc is not in translated code, the
>> - * function returns false; otherwise @data is loaded.
>> - * This is the same unwind info as given to restore_state_to_opc.
>> - */
>> -bool cpu_unwind_state_data(CPUState *cpu, uintptr_t host_pc, uint64_t *data);
>> -
>>   /**
>>    * cpu_restore_state:
>>    * @cpu: the cpu context
>> diff --git a/include/exec/translate-all.h b/include/exec/translate-all.h
>> index 85c9460c7c..f06cfedd52 100644
>> --- a/include/exec/translate-all.h
>> +++ b/include/exec/translate-all.h
>> @@ -21,6 +21,18 @@
>>
>>   #include "exec/exec-all.h"
>>
>> +/**
>> + * cpu_unwind_state_data:
>> + * @cpu: the cpu context
>> + * @host_pc: the host pc within the translation
>> + * @data: output data
>> + *
>> + * Attempt to load the the unwind state for a host pc occurring in
>> + * translated code.  If @host_pc is not in translated code, the
>> + * function returns false; otherwise @data is loaded.
>> + * This is the same unwind info as given to restore_state_to_opc.
>> + */
>> +bool cpu_unwind_state_data(CPUState *cpu, uintptr_t host_pc, uint64_t *data);
>>
>>   /* translate-all.c */
>>   void tb_check_watchpoint(CPUState *cpu, uintptr_t retaddr);
> 
> This function is used by some code in target/i386 and
> target/openrisc, but a quick grep suggests that they don't
> include translate-all.h or any other header that would pull
> it in indirectly.

Oops, this slipped to the next patch.

> It also seems a bit odd to move the cpu_unwind_state_data()
> prototype but not the similar cpu_restore_state() (which is
> also TCG-only).

OK I'll move them together (clearing "exec/cpu-common.h" is
not easy...)